@suveren/gateway 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/integrations/gmail.json +13 -2
- package/content/integrations/mail.json +12 -2
- package/content/integrations/mollie.json +10 -0
- package/dist/control-plane/index.mjs +24 -6
- package/dist/mcp-server/http.mjs +656 -388
- package/dist/ui/assets/{index-C3vTF2Ye.js → index-wtX8LuiU.js} +10 -10
- package/dist/ui/index.html +1 -1
- package/node_modules/sanitize-html/index.js +47 -10
- package/node_modules/sanitize-html/package.json +2 -3
- package/package.json +1 -1
- package/node_modules/deepmerge/.editorconfig +0 -7
- package/node_modules/deepmerge/.eslintcache +0 -1
- package/node_modules/deepmerge/changelog.md +0 -167
- package/node_modules/deepmerge/dist/cjs.js +0 -133
- package/node_modules/deepmerge/dist/umd.js +0 -139
- package/node_modules/deepmerge/index.d.ts +0 -20
- package/node_modules/deepmerge/index.js +0 -106
- package/node_modules/deepmerge/license.txt +0 -21
- package/node_modules/deepmerge/package.json +0 -42
- package/node_modules/deepmerge/readme.md +0 -264
- package/node_modules/deepmerge/rollup.config.js +0 -22
|
@@ -34,10 +34,10 @@ var jg=Object.defineProperty;var Sg=(t,s,a)=>s in t?jg(t,s,{enumerable:!0,config
|
|
|
34
34
|
`+b+e}var J=!1;function W(e,n){if(!e||J)return"";J=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(U){var l=U}Reflect.construct(e,[],n)}else{try{n.call()}catch(U){l=U}e.call(n.prototype)}else{try{throw Error()}catch(U){l=U}e()}}catch(U){if(U&&l&&typeof U.stack=="string"){for(var d=U.stack.split(`
|
|
35
35
|
`),m=l.stack.split(`
|
|
36
36
|
`),x=d.length-1,k=m.length-1;1<=x&&0<=k&&d[x]!==m[k];)k--;for(;1<=x&&0<=k;x--,k--)if(d[x]!==m[k]){if(x!==1||k!==1)do if(x--,k--,0>k||d[x]!==m[k]){var I=`
|
|
37
|
-
`+d[x].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=x&&0<=k);break}}}finally{J=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ee(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=W(e.type,!1),e;case 11:return e=W(e.type.render,!1),e;case 1:return e=W(e.type,!0),e;default:return""}}function xe(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 q:return"Fragment";case G:return"Portal";case K:return"Profiler";case de:return"StrictMode";case ce:return"Suspense";case re:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case V:return(e.displayName||"Context")+".Consumer";case oe:return(e._context.displayName||"Context")+".Provider";case D:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return n=e.displayName||null,n!==null?n:xe(e.type)||"Memo";case he:n=e._payload,e=e._init;try{return xe(e(n))}catch{}}return null}function ke(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return xe(n);case 8:return n===de?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ne(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ae(e){var n=ne(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(x){l=""+x,m.call(this,x)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(x){l=""+x},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ee(e){e._valueTracker||(e._valueTracker=Ae(e))}function Le(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ne(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function fe(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 _e(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Ue(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=ve(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function se(e,n){n=n.checked,n!=null&&$(e,"checked",n,!1)}function je(e,n){se(e,n);var i=ve(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?dt(e,n.type,i):n.hasOwnProperty("defaultValue")&&dt(e,n.type,ve(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function $e(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function dt(e,n,i){(n!=="number"||fe(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var He=Array.isArray;function tt(e,n,i,l){if(e=e.options,n){n={};for(var d=0;d<i.length;d++)n["$"+i[d]]=!0;for(i=0;i<e.length;i++)d=n.hasOwnProperty("$"+e[i].value),e[i].selected!==d&&(e[i].selected=d),d&&l&&(e[i].defaultSelected=!0)}else{for(i=""+ve(i),n=null,d=0;d<e.length;d++){if(e[d].value===i){e[d].selected=!0,l&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function gt(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(a(91));return H({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ft(e,n){var i=n.value;if(i==null){if(i=n.children,n=n.defaultValue,i!=null){if(n!=null)throw Error(a(92));if(He(i)){if(1<i.length)throw Error(a(93));i=i[0]}n=i}n==null&&(n=""),i=n}e._wrapperState={initialValue:ve(i)}}function ze(e,n){var i=ve(n.value),l=ve(n.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),n.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),l!=null&&(e.defaultValue=""+l)}function P(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function ae(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function me(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?ae(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Te,ue=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,l,d){MSApp.execUnsafeLocalFunction(function(){return e(n,i,l,d)})}:e})(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Te=Te||document.createElement("div"),Te.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Te.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Oe(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var qe={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},Ye=["Webkit","ms","Moz","O"];Object.keys(qe).forEach(function(e){Ye.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),qe[n]=qe[e]})});function ht(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||qe.hasOwnProperty(e)&&qe[e]?(""+n).trim():n+"px"}function pn(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,d=ht(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,d):e[i]=d}}var jn=H({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 nt(e,n){if(n){if(jn[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(a(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(a(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(a(61))}if(n.style!=null&&typeof n.style!="object")throw Error(a(62))}}function kt(e,n){if(e.indexOf("-")===-1)return typeof n.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 Et=null;function wt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ie=null,Se=null,pe=null;function Me(e){if(e=bs(e)){if(typeof ie!="function")throw Error(a(280));var n=e.stateNode;n&&(n=ka(n),ie(e.stateNode,e.type,n))}}function Fe(e){Se?pe?pe.push(e):pe=[e]:Se=e}function Je(){if(Se){var e=Se,n=pe;if(pe=Se=null,Me(e),n)for(e=0;e<n.length;e++)Me(n[e])}}function Ut(e,n){return e(n)}function er(){}var rs=!1;function na(e,n,i){if(rs)return e(n,i);rs=!0;try{return Ut(e,n,i)}finally{rs=!1,(Se!==null||pe!==null)&&(er(),Je())}}function Sn(e,n){var i=e.stateNode;if(i===null)return null;var l=ka(i);if(l===null)return null;i=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(a(231,n,typeof i));return i}var tr=!1;if(g)try{var nr={};Object.defineProperty(nr,"passive",{get:function(){tr=!0}}),window.addEventListener("test",nr,nr),window.removeEventListener("test",nr,nr)}catch{tr=!1}function ra(e,n,i,l,d,m,x,k,I){var U=Array.prototype.slice.call(arguments,3);try{n.apply(i,U)}catch(X){this.onError(X)}}var $n=!1,rr=null,sr=!1,ss=null,Cr={onError:function(e){$n=!0,rr=e}};function bn(e,n,i,l,d,m,x,k,I){$n=!1,rr=null,ra.apply(Cr,arguments)}function Im(e,n,i,l,d,m,x,k,I){if(bn.apply(this,arguments),$n){if($n){var U=rr;$n=!1,rr=null}else throw Error(a(198));sr||(sr=!0,ss=U)}}function ar(e){var n=e,i=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(i=n.return),e=n.return;while(e)}return n.tag===3?i:null}function bc(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function kc(e){if(ar(e)!==e)throw Error(a(188))}function Am(e){var n=e.alternate;if(!n){if(n=ar(e),n===null)throw Error(a(188));return n!==e?null:e}for(var i=e,l=n;;){var d=i.return;if(d===null)break;var m=d.alternate;if(m===null){if(l=d.return,l!==null){i=l;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===i)return kc(d),e;if(m===l)return kc(d),n;m=m.sibling}throw Error(a(188))}if(i.return!==l.return)i=d,l=m;else{for(var x=!1,k=d.child;k;){if(k===i){x=!0,i=d,l=m;break}if(k===l){x=!0,l=d,i=m;break}k=k.sibling}if(!x){for(k=m.child;k;){if(k===i){x=!0,i=m,l=d;break}if(k===l){x=!0,l=m,i=d;break}k=k.sibling}if(!x)throw Error(a(189))}}if(i.alternate!==l)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?e:n}function Nc(e){return e=Am(e),e!==null?Cc(e):null}function Cc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=Cc(e);if(n!==null)return n;e=e.sibling}return null}var Ec=s.unstable_scheduleCallback,Tc=s.unstable_cancelCallback,Pm=s.unstable_shouldYield,_m=s.unstable_requestPaint,lt=s.unstable_now,$m=s.unstable_getCurrentPriorityLevel,Mi=s.unstable_ImmediatePriority,Rc=s.unstable_UserBlockingPriority,sa=s.unstable_NormalPriority,Lm=s.unstable_LowPriority,Ic=s.unstable_IdlePriority,aa=null,gn=null;function zm(e){if(gn&&typeof gn.onCommitFiberRoot=="function")try{gn.onCommitFiberRoot(aa,e,void 0,(e.current.flags&128)===128)}catch{}}var sn=Math.clz32?Math.clz32:Mm,Fm=Math.log,Om=Math.LN2;function Mm(e){return e>>>=0,e===0?32:31-(Fm(e)/Om|0)|0}var ia=64,oa=4194304;function as(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 la(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,d=e.suspendedLanes,m=e.pingedLanes,x=i&268435455;if(x!==0){var k=x&~d;k!==0?l=as(k):(m&=x,m!==0&&(l=as(m)))}else x=i&~d,x!==0?l=as(x):m!==0&&(l=as(m));if(l===0)return 0;if(n!==0&&n!==l&&(n&d)===0&&(d=l&-l,m=n&-n,d>=m||d===16&&(m&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)i=31-sn(n),d=1<<i,l|=e[i],n&=~d;return l}function Bm(e,n){switch(e){case 1:case 2:case 4:return n+250;case 8:case 16:case 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 n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dm(e,n){for(var i=e.suspendedLanes,l=e.pingedLanes,d=e.expirationTimes,m=e.pendingLanes;0<m;){var x=31-sn(m),k=1<<x,I=d[x];I===-1?((k&i)===0||(k&l)!==0)&&(d[x]=Bm(k,n)):I<=n&&(e.expiredLanes|=k),m&=~k}}function Bi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ac(){var e=ia;return ia<<=1,(ia&4194240)===0&&(ia=64),e}function Di(e){for(var n=[],i=0;31>i;i++)n.push(e);return n}function is(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-sn(n),e[n]=i}function Um(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<i;){var d=31-sn(i),m=1<<d;n[d]=0,l[d]=-1,e[d]=-1,i&=~m}}function Ui(e,n){var i=e.entangledLanes|=n;for(e=e.entanglements;i;){var l=31-sn(i),d=1<<l;d&n|e[l]&n&&(e[l]|=n),i&=~d}}var Ke=0;function Pc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var _c,Wi,$c,Lc,zc,Hi=!1,ca=[],Ln=null,zn=null,Fn=null,os=new Map,ls=new Map,On=[],Wm="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Fc(e,n){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Fn=null;break;case"pointerover":case"pointerout":os.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":ls.delete(n.pointerId)}}function cs(e,n,i,l,d,m){return e===null||e.nativeEvent!==m?(e={blockedOn:n,domEventName:i,eventSystemFlags:l,nativeEvent:m,targetContainers:[d]},n!==null&&(n=bs(n),n!==null&&Wi(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function Hm(e,n,i,l,d){switch(n){case"focusin":return Ln=cs(Ln,e,n,i,l,d),!0;case"dragenter":return zn=cs(zn,e,n,i,l,d),!0;case"mouseover":return Fn=cs(Fn,e,n,i,l,d),!0;case"pointerover":var m=d.pointerId;return os.set(m,cs(os.get(m)||null,e,n,i,l,d)),!0;case"gotpointercapture":return m=d.pointerId,ls.set(m,cs(ls.get(m)||null,e,n,i,l,d)),!0}return!1}function Oc(e){var n=ir(e.target);if(n!==null){var i=ar(n);if(i!==null){if(n=i.tag,n===13){if(n=bc(i),n!==null){e.blockedOn=n,zc(e.priority,function(){$c(i)});return}}else if(n===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ua(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var i=Gi(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var l=new i.constructor(i.type,i);Et=l,i.target.dispatchEvent(l),Et=null}else return n=bs(i),n!==null&&Wi(n),e.blockedOn=i,!1;n.shift()}return!0}function Mc(e,n,i){ua(e)&&i.delete(n)}function Vm(){Hi=!1,Ln!==null&&ua(Ln)&&(Ln=null),zn!==null&&ua(zn)&&(zn=null),Fn!==null&&ua(Fn)&&(Fn=null),os.forEach(Mc),ls.forEach(Mc)}function us(e,n){e.blockedOn===n&&(e.blockedOn=null,Hi||(Hi=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Vm)))}function ds(e){function n(d){return us(d,e)}if(0<ca.length){us(ca[0],e);for(var i=1;i<ca.length;i++){var l=ca[i];l.blockedOn===e&&(l.blockedOn=null)}}for(Ln!==null&&us(Ln,e),zn!==null&&us(zn,e),Fn!==null&&us(Fn,e),os.forEach(n),ls.forEach(n),i=0;i<On.length;i++)l=On[i],l.blockedOn===e&&(l.blockedOn=null);for(;0<On.length&&(i=On[0],i.blockedOn===null);)Oc(i),i.blockedOn===null&&On.shift()}var Er=A.ReactCurrentBatchConfig,da=!0;function Gm(e,n,i,l){var d=Ke,m=Er.transition;Er.transition=null;try{Ke=1,Vi(e,n,i,l)}finally{Ke=d,Er.transition=m}}function Km(e,n,i,l){var d=Ke,m=Er.transition;Er.transition=null;try{Ke=4,Vi(e,n,i,l)}finally{Ke=d,Er.transition=m}}function Vi(e,n,i,l){if(da){var d=Gi(e,n,i,l);if(d===null)co(e,n,l,fa,i),Fc(e,l);else if(Hm(d,e,n,i,l))l.stopPropagation();else if(Fc(e,l),n&4&&-1<Wm.indexOf(e)){for(;d!==null;){var m=bs(d);if(m!==null&&_c(m),m=Gi(e,n,i,l),m===null&&co(e,n,l,fa,i),m===d)break;d=m}d!==null&&l.stopPropagation()}else co(e,n,l,null,i)}}var fa=null;function Gi(e,n,i,l){if(fa=null,e=wt(l),e=ir(e),e!==null)if(n=ar(e),n===null)e=null;else if(i=n.tag,i===13){if(e=bc(n),e!==null)return e;e=null}else if(i===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return fa=e,null}function Bc(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($m()){case Mi:return 1;case Rc:return 4;case sa:case Lm:return 16;case Ic:return 536870912;default:return 16}default:return 16}}var Mn=null,Ki=null,ha=null;function Dc(){if(ha)return ha;var e,n=Ki,i=n.length,l,d="value"in Mn?Mn.value:Mn.textContent,m=d.length;for(e=0;e<i&&n[e]===d[e];e++);var x=i-e;for(l=1;l<=x&&n[i-l]===d[m-l];l++);return ha=d.slice(e,1<l?1-l:void 0)}function ma(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function pa(){return!0}function Uc(){return!1}function Wt(e){function n(i,l,d,m,x){this._reactName=i,this._targetInst=d,this.type=l,this.nativeEvent=m,this.target=x,this.currentTarget=null;for(var k in e)e.hasOwnProperty(k)&&(i=e[k],this[k]=i?i(m):m[k]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?pa:Uc,this.isPropagationStopped=Uc,this}return H(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=pa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=pa)},persist:function(){},isPersistent:pa}),n}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qi=Wt(Tr),fs=H({},Tr,{view:0,detail:0}),qm=Wt(fs),Yi,Ji,hs,ga=H({},fs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xi,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==hs&&(hs&&e.type==="mousemove"?(Yi=e.screenX-hs.screenX,Ji=e.screenY-hs.screenY):Ji=Yi=0,hs=e),Yi)},movementY:function(e){return"movementY"in e?e.movementY:Ji}}),Wc=Wt(ga),Ym=H({},ga,{dataTransfer:0}),Jm=Wt(Ym),Qm=H({},fs,{relatedTarget:0}),Qi=Wt(Qm),Xm=H({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),Zm=Wt(Xm),ep=H({},Tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tp=Wt(ep),np=H({},Tr,{data:0}),Hc=Wt(np),rp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sp={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ap={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ip(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ap[e])?!!n[e]:!1}function Xi(){return ip}var op=H({},fs,{key:function(e){if(e.key){var n=rp[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ma(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?sp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xi,charCode:function(e){return e.type==="keypress"?ma(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ma(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),lp=Wt(op),cp=H({},ga,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vc=Wt(cp),up=H({},fs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xi}),dp=Wt(up),fp=H({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),hp=Wt(fp),mp=H({},ga,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),pp=Wt(mp),gp=[9,13,27,32],Zi=g&&"CompositionEvent"in window,ms=null;g&&"documentMode"in document&&(ms=document.documentMode);var yp=g&&"TextEvent"in window&&!ms,Gc=g&&(!Zi||ms&&8<ms&&11>=ms),Kc=" ",qc=!1;function Yc(e,n){switch(e){case"keyup":return gp.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function vp(e,n){switch(e){case"compositionend":return Jc(n);case"keypress":return n.which!==32?null:(qc=!0,Kc);case"textInput":return e=n.data,e===Kc&&qc?null:e;default:return null}}function xp(e,n){if(Rr)return e==="compositionend"||!Zi&&Yc(e,n)?(e=Dc(),ha=Ki=Mn=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Gc&&n.locale!=="ko"?null:n.data;default:return null}}var wp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!wp[e.type]:n==="textarea"}function Xc(e,n,i,l){Fe(l),n=ja(n,"onChange"),0<n.length&&(i=new qi("onChange","change",null,i,l),e.push({event:i,listeners:n}))}var ps=null,gs=null;function jp(e){gu(e,0)}function ya(e){var n=$r(e);if(Le(n))return e}function Sp(e,n){if(e==="change")return n}var Zc=!1;if(g){var eo;if(g){var to="oninput"in document;if(!to){var eu=document.createElement("div");eu.setAttribute("oninput","return;"),to=typeof eu.oninput=="function"}eo=to}else eo=!1;Zc=eo&&(!document.documentMode||9<document.documentMode)}function tu(){ps&&(ps.detachEvent("onpropertychange",nu),gs=ps=null)}function nu(e){if(e.propertyName==="value"&&ya(gs)){var n=[];Xc(n,gs,e,wt(e)),na(jp,n)}}function bp(e,n,i){e==="focusin"?(tu(),ps=n,gs=i,ps.attachEvent("onpropertychange",nu)):e==="focusout"&&tu()}function kp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ya(gs)}function Np(e,n){if(e==="click")return ya(n)}function Cp(e,n){if(e==="input"||e==="change")return ya(n)}function Ep(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var an=typeof Object.is=="function"?Object.is:Ep;function ys(e,n){if(an(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var i=Object.keys(e),l=Object.keys(n);if(i.length!==l.length)return!1;for(l=0;l<i.length;l++){var d=i[l];if(!p.call(n,d)||!an(e[d],n[d]))return!1}return!0}function ru(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function su(e,n){var i=ru(e);e=0;for(var l;i;){if(i.nodeType===3){if(l=e+i.textContent.length,e<=n&&l>=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ru(i)}}function au(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?au(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function iu(){for(var e=window,n=fe();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=fe(e.document)}return n}function no(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function Tp(e){var n=iu(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&au(i.ownerDocument.documentElement,i)){if(l!==null&&no(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var d=i.textContent.length,m=Math.min(l.start,d);l=l.end===void 0?m:Math.min(l.end,d),!e.extend&&m>l&&(d=l,l=m,m=d),d=su(i,m);var x=su(i,l);d&&x&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),e.removeAllRanges(),m>l?(e.addRange(n),e.extend(x.node,x.offset)):(n.setEnd(x.node,x.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<n.length;i++)e=n[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Rp=g&&"documentMode"in document&&11>=document.documentMode,Ir=null,ro=null,vs=null,so=!1;function ou(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;so||Ir==null||Ir!==fe(l)||(l=Ir,"selectionStart"in l&&no(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),vs&&ys(vs,l)||(vs=l,l=ja(ro,"onSelect"),0<l.length&&(n=new qi("onSelect","select",null,n,i),e.push({event:n,listeners:l}),n.target=Ir)))}function va(e,n){var i={};return i[e.toLowerCase()]=n.toLowerCase(),i["Webkit"+e]="webkit"+n,i["Moz"+e]="moz"+n,i}var Ar={animationend:va("Animation","AnimationEnd"),animationiteration:va("Animation","AnimationIteration"),animationstart:va("Animation","AnimationStart"),transitionend:va("Transition","TransitionEnd")},ao={},lu={};g&&(lu=document.createElement("div").style,"AnimationEvent"in window||(delete Ar.animationend.animation,delete Ar.animationiteration.animation,delete Ar.animationstart.animation),"TransitionEvent"in window||delete Ar.transitionend.transition);function xa(e){if(ao[e])return ao[e];if(!Ar[e])return e;var n=Ar[e],i;for(i in n)if(n.hasOwnProperty(i)&&i in lu)return ao[e]=n[i];return e}var cu=xa("animationend"),uu=xa("animationiteration"),du=xa("animationstart"),fu=xa("transitionend"),hu=new Map,mu="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Bn(e,n){hu.set(e,n),u(n,[e])}for(var io=0;io<mu.length;io++){var oo=mu[io],Ip=oo.toLowerCase(),Ap=oo[0].toUpperCase()+oo.slice(1);Bn(Ip,"on"+Ap)}Bn(cu,"onAnimationEnd"),Bn(uu,"onAnimationIteration"),Bn(du,"onAnimationStart"),Bn("dblclick","onDoubleClick"),Bn("focusin","onFocus"),Bn("focusout","onBlur"),Bn(fu,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Pp=new Set("cancel close invalid load scroll toggle".split(" ").concat(xs));function pu(e,n,i){var l=e.type||"unknown-event";e.currentTarget=i,Im(l,n,void 0,e),e.currentTarget=null}function gu(e,n){n=(n&4)!==0;for(var i=0;i<e.length;i++){var l=e[i],d=l.event;l=l.listeners;e:{var m=void 0;if(n)for(var x=l.length-1;0<=x;x--){var k=l[x],I=k.instance,U=k.currentTarget;if(k=k.listener,I!==m&&d.isPropagationStopped())break e;pu(d,k,U),m=I}else for(x=0;x<l.length;x++){if(k=l[x],I=k.instance,U=k.currentTarget,k=k.listener,I!==m&&d.isPropagationStopped())break e;pu(d,k,U),m=I}}}if(sr)throw e=ss,sr=!1,ss=null,e}function Ze(e,n){var i=n[go];i===void 0&&(i=n[go]=new Set);var l=e+"__bubble";i.has(l)||(yu(n,e,2,!1),i.add(l))}function lo(e,n,i){var l=0;n&&(l|=4),yu(i,e,l,n)}var wa="_reactListening"+Math.random().toString(36).slice(2);function ws(e){if(!e[wa]){e[wa]=!0,o.forEach(function(i){i!=="selectionchange"&&(Pp.has(i)||lo(i,!1,e),lo(i,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[wa]||(n[wa]=!0,lo("selectionchange",!1,n))}}function yu(e,n,i,l){switch(Bc(n)){case 1:var d=Gm;break;case 4:d=Km;break;default:d=Vi}i=d.bind(null,n,i,e),d=void 0,!tr||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),l?d!==void 0?e.addEventListener(n,i,{capture:!0,passive:d}):e.addEventListener(n,i,!0):d!==void 0?e.addEventListener(n,i,{passive:d}):e.addEventListener(n,i,!1)}function co(e,n,i,l,d){var m=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var x=l.tag;if(x===3||x===4){var k=l.stateNode.containerInfo;if(k===d||k.nodeType===8&&k.parentNode===d)break;if(x===4)for(x=l.return;x!==null;){var I=x.tag;if((I===3||I===4)&&(I=x.stateNode.containerInfo,I===d||I.nodeType===8&&I.parentNode===d))return;x=x.return}for(;k!==null;){if(x=ir(k),x===null)return;if(I=x.tag,I===5||I===6){l=m=x;continue e}k=k.parentNode}}l=l.return}na(function(){var U=m,X=wt(i),te=[];e:{var Q=hu.get(e);if(Q!==void 0){var ye=qi,be=e;switch(e){case"keypress":if(ma(i)===0)break e;case"keydown":case"keyup":ye=lp;break;case"focusin":be="focus",ye=Qi;break;case"focusout":be="blur",ye=Qi;break;case"beforeblur":case"afterblur":ye=Qi;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=Wc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Jm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=dp;break;case cu:case uu:case du:ye=Zm;break;case fu:ye=hp;break;case"scroll":ye=qm;break;case"wheel":ye=pp;break;case"copy":case"cut":case"paste":ye=tp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=Vc}var Ne=(n&4)!==0,ct=!Ne&&e==="scroll",z=Ne?Q!==null?Q+"Capture":null:Q;Ne=[];for(var _=U,B;_!==null;){B=_;var le=B.stateNode;if(B.tag===5&&le!==null&&(B=le,z!==null&&(le=Sn(_,z),le!=null&&Ne.push(js(_,le,B)))),ct)break;_=_.return}0<Ne.length&&(Q=new ye(Q,be,null,i,X),te.push({event:Q,listeners:Ne}))}}if((n&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",Q&&i!==Et&&(be=i.relatedTarget||i.fromElement)&&(ir(be)||be[kn]))break e;if((ye||Q)&&(Q=X.window===X?X:(Q=X.ownerDocument)?Q.defaultView||Q.parentWindow:window,ye?(be=i.relatedTarget||i.toElement,ye=U,be=be?ir(be):null,be!==null&&(ct=ar(be),be!==ct||be.tag!==5&&be.tag!==6)&&(be=null)):(ye=null,be=U),ye!==be)){if(Ne=Wc,le="onMouseLeave",z="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(Ne=Vc,le="onPointerLeave",z="onPointerEnter",_="pointer"),ct=ye==null?Q:$r(ye),B=be==null?Q:$r(be),Q=new Ne(le,_+"leave",ye,i,X),Q.target=ct,Q.relatedTarget=B,le=null,ir(X)===U&&(Ne=new Ne(z,_+"enter",be,i,X),Ne.target=B,Ne.relatedTarget=ct,le=Ne),ct=le,ye&&be)t:{for(Ne=ye,z=be,_=0,B=Ne;B;B=Pr(B))_++;for(B=0,le=z;le;le=Pr(le))B++;for(;0<_-B;)Ne=Pr(Ne),_--;for(;0<B-_;)z=Pr(z),B--;for(;_--;){if(Ne===z||z!==null&&Ne===z.alternate)break t;Ne=Pr(Ne),z=Pr(z)}Ne=null}else Ne=null;ye!==null&&vu(te,Q,ye,Ne,!1),be!==null&&ct!==null&&vu(te,ct,be,Ne,!0)}}e:{if(Q=U?$r(U):window,ye=Q.nodeName&&Q.nodeName.toLowerCase(),ye==="select"||ye==="input"&&Q.type==="file")var Ce=Sp;else if(Qc(Q))if(Zc)Ce=Cp;else{Ce=kp;var Re=bp}else(ye=Q.nodeName)&&ye.toLowerCase()==="input"&&(Q.type==="checkbox"||Q.type==="radio")&&(Ce=Np);if(Ce&&(Ce=Ce(e,U))){Xc(te,Ce,i,X);break e}Re&&Re(e,Q,U),e==="focusout"&&(Re=Q._wrapperState)&&Re.controlled&&Q.type==="number"&&dt(Q,"number",Q.value)}switch(Re=U?$r(U):window,e){case"focusin":(Qc(Re)||Re.contentEditable==="true")&&(Ir=Re,ro=U,vs=null);break;case"focusout":vs=ro=Ir=null;break;case"mousedown":so=!0;break;case"contextmenu":case"mouseup":case"dragend":so=!1,ou(te,i,X);break;case"selectionchange":if(Rp)break;case"keydown":case"keyup":ou(te,i,X)}var Ie;if(Zi)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Rr?Yc(e,i)&&(Pe="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(Pe="onCompositionStart");Pe&&(Gc&&i.locale!=="ko"&&(Rr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Rr&&(Ie=Dc()):(Mn=X,Ki="value"in Mn?Mn.value:Mn.textContent,Rr=!0)),Re=ja(U,Pe),0<Re.length&&(Pe=new Hc(Pe,e,null,i,X),te.push({event:Pe,listeners:Re}),Ie?Pe.data=Ie:(Ie=Jc(i),Ie!==null&&(Pe.data=Ie)))),(Ie=yp?vp(e,i):xp(e,i))&&(U=ja(U,"onBeforeInput"),0<U.length&&(X=new Hc("onBeforeInput","beforeinput",null,i,X),te.push({event:X,listeners:U}),X.data=Ie))}gu(te,n)})}function js(e,n,i){return{instance:e,listener:n,currentTarget:i}}function ja(e,n){for(var i=n+"Capture",l=[];e!==null;){var d=e,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Sn(e,i),m!=null&&l.unshift(js(e,m,d)),m=Sn(e,n),m!=null&&l.push(js(e,m,d))),e=e.return}return l}function Pr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function vu(e,n,i,l,d){for(var m=n._reactName,x=[];i!==null&&i!==l;){var k=i,I=k.alternate,U=k.stateNode;if(I!==null&&I===l)break;k.tag===5&&U!==null&&(k=U,d?(I=Sn(i,m),I!=null&&x.unshift(js(i,I,k))):d||(I=Sn(i,m),I!=null&&x.push(js(i,I,k)))),i=i.return}x.length!==0&&e.push({event:n,listeners:x})}var _p=/\r\n?/g,$p=/\u0000|\uFFFD/g;function xu(e){return(typeof e=="string"?e:""+e).replace(_p,`
|
|
38
|
-
`).replace($p,"")}function Sa(e,n,i){if(n=xu(n),xu(e)!==n&&i)throw Error(a(425))}function ba(){}var uo=null,fo=null;function ho(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var mo=typeof setTimeout=="function"?setTimeout:void 0,Lp=typeof clearTimeout=="function"?clearTimeout:void 0,wu=typeof Promise=="function"?Promise:void 0,zp=typeof queueMicrotask=="function"?queueMicrotask:typeof wu<"u"?function(e){return wu.resolve(null).then(e).catch(Fp)}:mo;function Fp(e){setTimeout(function(){throw e})}function po(e,n){var i=n,l=0;do{var d=i.nextSibling;if(e.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(l===0){e.removeChild(d),ds(n);return}l--}else i!=="$"&&i!=="$?"&&i!=="$!"||l++;i=d}while(i);ds(n)}function Dn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function ju(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(n===0)return e;n--}else i==="/$"&&n++}e=e.previousSibling}return null}var _r=Math.random().toString(36).slice(2),yn="__reactFiber$"+_r,Ss="__reactProps$"+_r,kn="__reactContainer$"+_r,go="__reactEvents$"+_r,Op="__reactListeners$"+_r,Mp="__reactHandles$"+_r;function ir(e){var n=e[yn];if(n)return n;for(var i=e.parentNode;i;){if(n=i[kn]||i[yn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(e=ju(e);e!==null;){if(i=e[yn])return i;e=ju(e)}return n}e=i,i=e.parentNode}return null}function bs(e){return e=e[yn]||e[kn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function $r(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function ka(e){return e[Ss]||null}var yo=[],Lr=-1;function Un(e){return{current:e}}function et(e){0>Lr||(e.current=yo[Lr],yo[Lr]=null,Lr--)}function Qe(e,n){Lr++,yo[Lr]=e.current,e.current=n}var Wn={},Tt=Un(Wn),Lt=Un(!1),or=Wn;function zr(e,n){var i=e.type.contextTypes;if(!i)return Wn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=n[m];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=d),d}function zt(e){return e=e.childContextTypes,e!=null}function Na(){et(Lt),et(Tt)}function Su(e,n,i){if(Tt.current!==Wn)throw Error(a(168));Qe(Tt,n),Qe(Lt,i)}function bu(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var d in l)if(!(d in n))throw Error(a(108,ke(e)||"Unknown",d));return H({},i,l)}function Ca(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wn,or=Tt.current,Qe(Tt,e),Qe(Lt,Lt.current),!0}function ku(e,n,i){var l=e.stateNode;if(!l)throw Error(a(169));i?(e=bu(e,n,or),l.__reactInternalMemoizedMergedChildContext=e,et(Lt),et(Tt),Qe(Tt,e)):et(Lt),Qe(Lt,i)}var Nn=null,Ea=!1,vo=!1;function Nu(e){Nn===null?Nn=[e]:Nn.push(e)}function Bp(e){Ea=!0,Nu(e)}function Hn(){if(!vo&&Nn!==null){vo=!0;var e=0,n=Ke;try{var i=Nn;for(Ke=1;e<i.length;e++){var l=i[e];do l=l(!0);while(l!==null)}Nn=null,Ea=!1}catch(d){throw Nn!==null&&(Nn=Nn.slice(e+1)),Ec(Mi,Hn),d}finally{Ke=n,vo=!1}}return null}var Fr=[],Or=0,Ta=null,Ra=0,Yt=[],Jt=0,lr=null,Cn=1,En="";function cr(e,n){Fr[Or++]=Ra,Fr[Or++]=Ta,Ta=e,Ra=n}function Cu(e,n,i){Yt[Jt++]=Cn,Yt[Jt++]=En,Yt[Jt++]=lr,lr=e;var l=Cn;e=En;var d=32-sn(l)-1;l&=~(1<<d),i+=1;var m=32-sn(n)+d;if(30<m){var x=d-d%5;m=(l&(1<<x)-1).toString(32),l>>=x,d-=x,Cn=1<<32-sn(n)+d|i<<d|l,En=m+e}else Cn=1<<m|i<<d|l,En=e}function xo(e){e.return!==null&&(cr(e,1),Cu(e,1,0))}function wo(e){for(;e===Ta;)Ta=Fr[--Or],Fr[Or]=null,Ra=Fr[--Or],Fr[Or]=null;for(;e===lr;)lr=Yt[--Jt],Yt[Jt]=null,En=Yt[--Jt],Yt[Jt]=null,Cn=Yt[--Jt],Yt[Jt]=null}var Ht=null,Vt=null,rt=!1,on=null;function Eu(e,n){var i=en(5,null,null,0);i.elementType="DELETED",i.stateNode=n,i.return=e,n=e.deletions,n===null?(e.deletions=[i],e.flags|=16):n.push(i)}function Tu(e,n){switch(e.tag){case 5:var i=e.type;return n=n.nodeType!==1||i.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=Dn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=lr!==null?{id:Cn,overflow:En}:null,e.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=en(18,null,null,0),i.stateNode=n,i.return=e,e.child=i,Ht=e,Vt=null,!0):!1;default:return!1}}function jo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function So(e){if(rt){var n=Vt;if(n){var i=n;if(!Tu(e,n)){if(jo(e))throw Error(a(418));n=Dn(i.nextSibling);var l=Ht;n&&Tu(e,n)?Eu(l,i):(e.flags=e.flags&-4097|2,rt=!1,Ht=e)}}else{if(jo(e))throw Error(a(418));e.flags=e.flags&-4097|2,rt=!1,Ht=e}}}function Ru(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ht=e}function Ia(e){if(e!==Ht)return!1;if(!rt)return Ru(e),rt=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!ho(e.type,e.memoizedProps)),n&&(n=Vt)){if(jo(e))throw Iu(),Error(a(418));for(;n;)Eu(e,n),n=Dn(n.nextSibling)}if(Ru(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(n===0){Vt=Dn(e.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}e=e.nextSibling}Vt=null}}else Vt=Ht?Dn(e.stateNode.nextSibling):null;return!0}function Iu(){for(var e=Vt;e;)e=Dn(e.nextSibling)}function Mr(){Vt=Ht=null,rt=!1}function bo(e){on===null?on=[e]:on.push(e)}var Dp=A.ReactCurrentBatchConfig;function ks(e,n,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var l=i.stateNode}if(!l)throw Error(a(147,e));var d=l,m=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===m?n.ref:(n=function(x){var k=d.refs;x===null?delete k[m]:k[m]=x},n._stringRef=m,n)}if(typeof e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Aa(e,n){throw e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Au(e){var n=e._init;return n(e._payload)}function Pu(e){function n(z,_){if(e){var B=z.deletions;B===null?(z.deletions=[_],z.flags|=16):B.push(_)}}function i(z,_){if(!e)return null;for(;_!==null;)n(z,_),_=_.sibling;return null}function l(z,_){for(z=new Map;_!==null;)_.key!==null?z.set(_.key,_):z.set(_.index,_),_=_.sibling;return z}function d(z,_){return z=Xn(z,_),z.index=0,z.sibling=null,z}function m(z,_,B){return z.index=B,e?(B=z.alternate,B!==null?(B=B.index,B<_?(z.flags|=2,_):B):(z.flags|=2,_)):(z.flags|=1048576,_)}function x(z){return e&&z.alternate===null&&(z.flags|=2),z}function k(z,_,B,le){return _===null||_.tag!==6?(_=ml(B,z.mode,le),_.return=z,_):(_=d(_,B),_.return=z,_)}function I(z,_,B,le){var Ce=B.type;return Ce===q?X(z,_,B.props.children,le,B.key):_!==null&&(_.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===he&&Au(Ce)===_.type)?(le=d(_,B.props),le.ref=ks(z,_,B),le.return=z,le):(le=ti(B.type,B.key,B.props,null,z.mode,le),le.ref=ks(z,_,B),le.return=z,le)}function U(z,_,B,le){return _===null||_.tag!==4||_.stateNode.containerInfo!==B.containerInfo||_.stateNode.implementation!==B.implementation?(_=pl(B,z.mode,le),_.return=z,_):(_=d(_,B.children||[]),_.return=z,_)}function X(z,_,B,le,Ce){return _===null||_.tag!==7?(_=yr(B,z.mode,le,Ce),_.return=z,_):(_=d(_,B),_.return=z,_)}function te(z,_,B){if(typeof _=="string"&&_!==""||typeof _=="number")return _=ml(""+_,z.mode,B),_.return=z,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case F:return B=ti(_.type,_.key,_.props,null,z.mode,B),B.ref=ks(z,null,_),B.return=z,B;case G:return _=pl(_,z.mode,B),_.return=z,_;case he:var le=_._init;return te(z,le(_._payload),B)}if(He(_)||O(_))return _=yr(_,z.mode,B,null),_.return=z,_;Aa(z,_)}return null}function Q(z,_,B,le){var Ce=_!==null?_.key:null;if(typeof B=="string"&&B!==""||typeof B=="number")return Ce!==null?null:k(z,_,""+B,le);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case F:return B.key===Ce?I(z,_,B,le):null;case G:return B.key===Ce?U(z,_,B,le):null;case he:return Ce=B._init,Q(z,_,Ce(B._payload),le)}if(He(B)||O(B))return Ce!==null?null:X(z,_,B,le,null);Aa(z,B)}return null}function ye(z,_,B,le,Ce){if(typeof le=="string"&&le!==""||typeof le=="number")return z=z.get(B)||null,k(_,z,""+le,Ce);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case F:return z=z.get(le.key===null?B:le.key)||null,I(_,z,le,Ce);case G:return z=z.get(le.key===null?B:le.key)||null,U(_,z,le,Ce);case he:var Re=le._init;return ye(z,_,B,Re(le._payload),Ce)}if(He(le)||O(le))return z=z.get(B)||null,X(_,z,le,Ce,null);Aa(_,le)}return null}function be(z,_,B,le){for(var Ce=null,Re=null,Ie=_,Pe=_=0,bt=null;Ie!==null&&Pe<B.length;Pe++){Ie.index>Pe?(bt=Ie,Ie=null):bt=Ie.sibling;var Ve=Q(z,Ie,B[Pe],le);if(Ve===null){Ie===null&&(Ie=bt);break}e&&Ie&&Ve.alternate===null&&n(z,Ie),_=m(Ve,_,Pe),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve,Ie=bt}if(Pe===B.length)return i(z,Ie),rt&&cr(z,Pe),Ce;if(Ie===null){for(;Pe<B.length;Pe++)Ie=te(z,B[Pe],le),Ie!==null&&(_=m(Ie,_,Pe),Re===null?Ce=Ie:Re.sibling=Ie,Re=Ie);return rt&&cr(z,Pe),Ce}for(Ie=l(z,Ie);Pe<B.length;Pe++)bt=ye(Ie,z,Pe,B[Pe],le),bt!==null&&(e&&bt.alternate!==null&&Ie.delete(bt.key===null?Pe:bt.key),_=m(bt,_,Pe),Re===null?Ce=bt:Re.sibling=bt,Re=bt);return e&&Ie.forEach(function(Zn){return n(z,Zn)}),rt&&cr(z,Pe),Ce}function Ne(z,_,B,le){var Ce=O(B);if(typeof Ce!="function")throw Error(a(150));if(B=Ce.call(B),B==null)throw Error(a(151));for(var Re=Ce=null,Ie=_,Pe=_=0,bt=null,Ve=B.next();Ie!==null&&!Ve.done;Pe++,Ve=B.next()){Ie.index>Pe?(bt=Ie,Ie=null):bt=Ie.sibling;var Zn=Q(z,Ie,Ve.value,le);if(Zn===null){Ie===null&&(Ie=bt);break}e&&Ie&&Zn.alternate===null&&n(z,Ie),_=m(Zn,_,Pe),Re===null?Ce=Zn:Re.sibling=Zn,Re=Zn,Ie=bt}if(Ve.done)return i(z,Ie),rt&&cr(z,Pe),Ce;if(Ie===null){for(;!Ve.done;Pe++,Ve=B.next())Ve=te(z,Ve.value,le),Ve!==null&&(_=m(Ve,_,Pe),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve);return rt&&cr(z,Pe),Ce}for(Ie=l(z,Ie);!Ve.done;Pe++,Ve=B.next())Ve=ye(Ie,z,Pe,Ve.value,le),Ve!==null&&(e&&Ve.alternate!==null&&Ie.delete(Ve.key===null?Pe:Ve.key),_=m(Ve,_,Pe),Re===null?Ce=Ve:Re.sibling=Ve,Re=Ve);return e&&Ie.forEach(function(wg){return n(z,wg)}),rt&&cr(z,Pe),Ce}function ct(z,_,B,le){if(typeof B=="object"&&B!==null&&B.type===q&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case F:e:{for(var Ce=B.key,Re=_;Re!==null;){if(Re.key===Ce){if(Ce=B.type,Ce===q){if(Re.tag===7){i(z,Re.sibling),_=d(Re,B.props.children),_.return=z,z=_;break e}}else if(Re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===he&&Au(Ce)===Re.type){i(z,Re.sibling),_=d(Re,B.props),_.ref=ks(z,Re,B),_.return=z,z=_;break e}i(z,Re);break}else n(z,Re);Re=Re.sibling}B.type===q?(_=yr(B.props.children,z.mode,le,B.key),_.return=z,z=_):(le=ti(B.type,B.key,B.props,null,z.mode,le),le.ref=ks(z,_,B),le.return=z,z=le)}return x(z);case G:e:{for(Re=B.key;_!==null;){if(_.key===Re)if(_.tag===4&&_.stateNode.containerInfo===B.containerInfo&&_.stateNode.implementation===B.implementation){i(z,_.sibling),_=d(_,B.children||[]),_.return=z,z=_;break e}else{i(z,_);break}else n(z,_);_=_.sibling}_=pl(B,z.mode,le),_.return=z,z=_}return x(z);case he:return Re=B._init,ct(z,_,Re(B._payload),le)}if(He(B))return be(z,_,B,le);if(O(B))return Ne(z,_,B,le);Aa(z,B)}return typeof B=="string"&&B!==""||typeof B=="number"?(B=""+B,_!==null&&_.tag===6?(i(z,_.sibling),_=d(_,B),_.return=z,z=_):(i(z,_),_=ml(B,z.mode,le),_.return=z,z=_),x(z)):i(z,_)}return ct}var Br=Pu(!0),_u=Pu(!1),Pa=Un(null),_a=null,Dr=null,ko=null;function No(){ko=Dr=_a=null}function Co(e){var n=Pa.current;et(Pa),e._currentValue=n}function Eo(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Ur(e,n){_a=e,ko=Dr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Ft=!0),e.firstContext=null)}function Qt(e){var n=e._currentValue;if(ko!==e)if(e={context:e,memoizedValue:n,next:null},Dr===null){if(_a===null)throw Error(a(308));Dr=e,_a.dependencies={lanes:0,firstContext:e}}else Dr=Dr.next=e;return n}var ur=null;function To(e){ur===null?ur=[e]:ur.push(e)}function $u(e,n,i,l){var d=n.interleaved;return d===null?(i.next=i,To(n)):(i.next=d.next,d.next=i),n.interleaved=i,Tn(e,l)}function Tn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Vn=!1;function Ro(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Rn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gn(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(We&2)!==0){var d=l.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),l.pending=n,Tn(e,i)}return d=l.interleaved,d===null?(n.next=n,To(l)):(n.next=d.next,d.next=n),l.interleaved=n,Tn(e,i)}function $a(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Ui(e,i)}}function zu(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var x={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=x:m=m.next=x,i=i.next}while(i!==null);m===null?d=m=n:m=m.next=n}else d=m=n;i={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function La(e,n,i,l){var d=e.updateQueue;Vn=!1;var m=d.firstBaseUpdate,x=d.lastBaseUpdate,k=d.shared.pending;if(k!==null){d.shared.pending=null;var I=k,U=I.next;I.next=null,x===null?m=U:x.next=U,x=I;var X=e.alternate;X!==null&&(X=X.updateQueue,k=X.lastBaseUpdate,k!==x&&(k===null?X.firstBaseUpdate=U:k.next=U,X.lastBaseUpdate=I))}if(m!==null){var te=d.baseState;x=0,X=U=I=null,k=m;do{var Q=k.lane,ye=k.eventTime;if((l&Q)===Q){X!==null&&(X=X.next={eventTime:ye,lane:0,tag:k.tag,payload:k.payload,callback:k.callback,next:null});e:{var be=e,Ne=k;switch(Q=n,ye=i,Ne.tag){case 1:if(be=Ne.payload,typeof be=="function"){te=be.call(ye,te,Q);break e}te=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Ne.payload,Q=typeof be=="function"?be.call(ye,te,Q):be,Q==null)break e;te=H({},te,Q);break e;case 2:Vn=!0}}k.callback!==null&&k.lane!==0&&(e.flags|=64,Q=d.effects,Q===null?d.effects=[k]:Q.push(k))}else ye={eventTime:ye,lane:Q,tag:k.tag,payload:k.payload,callback:k.callback,next:null},X===null?(U=X=ye,I=te):X=X.next=ye,x|=Q;if(k=k.next,k===null){if(k=d.shared.pending,k===null)break;Q=k,k=Q.next,Q.next=null,d.lastBaseUpdate=Q,d.shared.pending=null}}while(!0);if(X===null&&(I=te),d.baseState=I,d.firstBaseUpdate=U,d.lastBaseUpdate=X,n=d.shared.interleaved,n!==null){d=n;do x|=d.lane,d=d.next;while(d!==n)}else m===null&&(d.shared.lanes=0);hr|=x,e.lanes=x,e.memoizedState=te}}function Fu(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],d=l.callback;if(d!==null){if(l.callback=null,l=i,typeof d!="function")throw Error(a(191,d));d.call(l)}}}var Ns={},vn=Un(Ns),Cs=Un(Ns),Es=Un(Ns);function dr(e){if(e===Ns)throw Error(a(174));return e}function Io(e,n){switch(Qe(Es,n),Qe(Cs,e),Qe(vn,Ns),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:me(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=me(n,e)}et(vn),Qe(vn,n)}function Wr(){et(vn),et(Cs),et(Es)}function Ou(e){dr(Es.current);var n=dr(vn.current),i=me(n,e.type);n!==i&&(Qe(Cs,e),Qe(vn,i))}function Ao(e){Cs.current===e&&(et(vn),et(Cs))}var at=Un(0);function za(e){for(var n=e;n!==null;){if(n.tag===13){var i=n.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Po=[];function _o(){for(var e=0;e<Po.length;e++)Po[e]._workInProgressVersionPrimary=null;Po.length=0}var Fa=A.ReactCurrentDispatcher,$o=A.ReactCurrentBatchConfig,fr=0,it=null,yt=null,jt=null,Oa=!1,Ts=!1,Rs=0,Up=0;function Rt(){throw Error(a(321))}function Lo(e,n){if(n===null)return!1;for(var i=0;i<n.length&&i<e.length;i++)if(!an(e[i],n[i]))return!1;return!0}function zo(e,n,i,l,d,m){if(fr=m,it=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,Fa.current=e===null||e.memoizedState===null?Gp:Kp,e=i(l,d),Ts){m=0;do{if(Ts=!1,Rs=0,25<=m)throw Error(a(301));m+=1,jt=yt=null,n.updateQueue=null,Fa.current=qp,e=i(l,d)}while(Ts)}if(Fa.current=Da,n=yt!==null&&yt.next!==null,fr=0,jt=yt=it=null,Oa=!1,n)throw Error(a(300));return e}function Fo(){var e=Rs!==0;return Rs=0,e}function xn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?it.memoizedState=jt=e:jt=jt.next=e,jt}function Xt(){if(yt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=yt.next;var n=jt===null?it.memoizedState:jt.next;if(n!==null)jt=n,yt=e;else{if(e===null)throw Error(a(310));yt=e,e={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},jt===null?it.memoizedState=jt=e:jt=jt.next=e}return jt}function Is(e,n){return typeof n=="function"?n(e):n}function Oo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=yt,d=l.baseQueue,m=i.pending;if(m!==null){if(d!==null){var x=d.next;d.next=m.next,m.next=x}l.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,l=l.baseState;var k=x=null,I=null,U=m;do{var X=U.lane;if((fr&X)===X)I!==null&&(I=I.next={lane:0,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null}),l=U.hasEagerState?U.eagerState:e(l,U.action);else{var te={lane:X,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null};I===null?(k=I=te,x=l):I=I.next=te,it.lanes|=X,hr|=X}U=U.next}while(U!==null&&U!==m);I===null?x=l:I.next=k,an(l,n.memoizedState)||(Ft=!0),n.memoizedState=l,n.baseState=x,n.baseQueue=I,i.lastRenderedState=l}if(e=i.interleaved,e!==null){d=e;do m=d.lane,it.lanes|=m,hr|=m,d=d.next;while(d!==e)}else d===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Mo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=i.dispatch,d=i.pending,m=n.memoizedState;if(d!==null){i.pending=null;var x=d=d.next;do m=e(m,x.action),x=x.next;while(x!==d);an(m,n.memoizedState)||(Ft=!0),n.memoizedState=m,n.baseQueue===null&&(n.baseState=m),i.lastRenderedState=m}return[m,l]}function Mu(){}function Bu(e,n){var i=it,l=Xt(),d=n(),m=!an(l.memoizedState,d);if(m&&(l.memoizedState=d,Ft=!0),l=l.queue,Bo(Wu.bind(null,i,l,e),[e]),l.getSnapshot!==n||m||jt!==null&&jt.memoizedState.tag&1){if(i.flags|=2048,As(9,Uu.bind(null,i,l,d,n),void 0,null),St===null)throw Error(a(349));(fr&30)!==0||Du(i,n,d)}return d}function Du(e,n,i){e.flags|=16384,e={getSnapshot:n,value:i},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.stores=[e]):(i=n.stores,i===null?n.stores=[e]:i.push(e))}function Uu(e,n,i,l){n.value=i,n.getSnapshot=l,Hu(n)&&Vu(e)}function Wu(e,n,i){return i(function(){Hu(n)&&Vu(e)})}function Hu(e){var n=e.getSnapshot;e=e.value;try{var i=n();return!an(e,i)}catch{return!0}}function Vu(e){var n=Tn(e,1);n!==null&&dn(n,e,1,-1)}function Gu(e){var n=xn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Is,lastRenderedState:e},n.queue=e,e=e.dispatch=Vp.bind(null,it,e),[n.memoizedState,e]}function As(e,n,i,l){return e={tag:e,create:n,destroy:i,deps:l,next:null},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.lastEffect=e.next=e):(i=n.lastEffect,i===null?n.lastEffect=e.next=e:(l=i.next,i.next=e,e.next=l,n.lastEffect=e)),e}function Ku(){return Xt().memoizedState}function Ma(e,n,i,l){var d=xn();it.flags|=e,d.memoizedState=As(1|n,i,void 0,l===void 0?null:l)}function Ba(e,n,i,l){var d=Xt();l=l===void 0?null:l;var m=void 0;if(yt!==null){var x=yt.memoizedState;if(m=x.destroy,l!==null&&Lo(l,x.deps)){d.memoizedState=As(n,i,m,l);return}}it.flags|=e,d.memoizedState=As(1|n,i,m,l)}function qu(e,n){return Ma(8390656,8,e,n)}function Bo(e,n){return Ba(2048,8,e,n)}function Yu(e,n){return Ba(4,2,e,n)}function Ju(e,n){return Ba(4,4,e,n)}function Qu(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Xu(e,n,i){return i=i!=null?i.concat([e]):null,Ba(4,4,Qu.bind(null,n,e),i)}function Do(){}function Zu(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Lo(n,l[1])?l[0]:(i.memoizedState=[e,n],e)}function ed(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Lo(n,l[1])?l[0]:(e=e(),i.memoizedState=[e,n],e)}function td(e,n,i){return(fr&21)===0?(e.baseState&&(e.baseState=!1,Ft=!0),e.memoizedState=i):(an(i,n)||(i=Ac(),it.lanes|=i,hr|=i,e.baseState=!0),n)}function Wp(e,n){var i=Ke;Ke=i!==0&&4>i?i:4,e(!0);var l=$o.transition;$o.transition={};try{e(!1),n()}finally{Ke=i,$o.transition=l}}function nd(){return Xt().memoizedState}function Hp(e,n,i){var l=Jn(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},rd(e))sd(n,i);else if(i=$u(e,n,i,l),i!==null){var d=_t();dn(i,e,l,d),ad(i,n,l)}}function Vp(e,n,i){var l=Jn(e),d={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(rd(e))sd(n,d);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var x=n.lastRenderedState,k=m(x,i);if(d.hasEagerState=!0,d.eagerState=k,an(k,x)){var I=n.interleaved;I===null?(d.next=d,To(n)):(d.next=I.next,I.next=d),n.interleaved=d;return}}catch{}finally{}i=$u(e,n,d,l),i!==null&&(d=_t(),dn(i,e,l,d),ad(i,n,l))}}function rd(e){var n=e.alternate;return e===it||n!==null&&n===it}function sd(e,n){Ts=Oa=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function ad(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Ui(e,i)}}var Da={readContext:Qt,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useInsertionEffect:Rt,useLayoutEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useMutableSource:Rt,useSyncExternalStore:Rt,useId:Rt,unstable_isNewReconciler:!1},Gp={readContext:Qt,useCallback:function(e,n){return xn().memoizedState=[e,n===void 0?null:n],e},useContext:Qt,useEffect:qu,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ma(4194308,4,Qu.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ma(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ma(4,2,e,n)},useMemo:function(e,n){var i=xn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=xn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Hp.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var n=xn();return e={current:e},n.memoizedState=e},useState:Gu,useDebugValue:Do,useDeferredValue:function(e){return xn().memoizedState=e},useTransition:function(){var e=Gu(!1),n=e[0];return e=Wp.bind(null,e[1]),xn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=it,d=xn();if(rt){if(i===void 0)throw Error(a(407));i=i()}else{if(i=n(),St===null)throw Error(a(349));(fr&30)!==0||Du(l,n,i)}d.memoizedState=i;var m={value:i,getSnapshot:n};return d.queue=m,qu(Wu.bind(null,l,m,e),[e]),l.flags|=2048,As(9,Uu.bind(null,l,m,i,n),void 0,null),i},useId:function(){var e=xn(),n=St.identifierPrefix;if(rt){var i=En,l=Cn;i=(l&~(1<<32-sn(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Rs++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=Up++,n=":"+n+"r"+i.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Kp={readContext:Qt,useCallback:Zu,useContext:Qt,useEffect:Bo,useImperativeHandle:Xu,useInsertionEffect:Yu,useLayoutEffect:Ju,useMemo:ed,useReducer:Oo,useRef:Ku,useState:function(){return Oo(Is)},useDebugValue:Do,useDeferredValue:function(e){var n=Xt();return td(n,yt.memoizedState,e)},useTransition:function(){var e=Oo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:Mu,useSyncExternalStore:Bu,useId:nd,unstable_isNewReconciler:!1},qp={readContext:Qt,useCallback:Zu,useContext:Qt,useEffect:Bo,useImperativeHandle:Xu,useInsertionEffect:Yu,useLayoutEffect:Ju,useMemo:ed,useReducer:Mo,useRef:Ku,useState:function(){return Mo(Is)},useDebugValue:Do,useDeferredValue:function(e){var n=Xt();return yt===null?n.memoizedState=e:td(n,yt.memoizedState,e)},useTransition:function(){var e=Mo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:Mu,useSyncExternalStore:Bu,useId:nd,unstable_isNewReconciler:!1};function ln(e,n){if(e&&e.defaultProps){n=H({},n),e=e.defaultProps;for(var i in e)n[i]===void 0&&(n[i]=e[i]);return n}return n}function Uo(e,n,i,l){n=e.memoizedState,i=i(l,n),i=i==null?n:H({},n,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Ua={isMounted:function(e){return(e=e._reactInternals)?ar(e)===e:!1},enqueueSetState:function(e,n,i){e=e._reactInternals;var l=_t(),d=Jn(e),m=Rn(l,d);m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,d),n!==null&&(dn(n,e,d,l),$a(n,e,d))},enqueueReplaceState:function(e,n,i){e=e._reactInternals;var l=_t(),d=Jn(e),m=Rn(l,d);m.tag=1,m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,d),n!==null&&(dn(n,e,d,l),$a(n,e,d))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var i=_t(),l=Jn(e),d=Rn(i,l);d.tag=2,n!=null&&(d.callback=n),n=Gn(e,d,l),n!==null&&(dn(n,e,l,i),$a(n,e,l))}};function id(e,n,i,l,d,m,x){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,m,x):n.prototype&&n.prototype.isPureReactComponent?!ys(i,l)||!ys(d,m):!0}function od(e,n,i){var l=!1,d=Wn,m=n.contextType;return typeof m=="object"&&m!==null?m=Qt(m):(d=zt(n)?or:Tt.current,l=n.contextTypes,m=(l=l!=null)?zr(e,d):Wn),n=new n(i,m),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Ua,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=m),n}function ld(e,n,i,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(i,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(i,l),n.state!==e&&Ua.enqueueReplaceState(n,n.state,null)}function Wo(e,n,i,l){var d=e.stateNode;d.props=i,d.state=e.memoizedState,d.refs={},Ro(e);var m=n.contextType;typeof m=="object"&&m!==null?d.context=Qt(m):(m=zt(n)?or:Tt.current,d.context=zr(e,m)),d.state=e.memoizedState,m=n.getDerivedStateFromProps,typeof m=="function"&&(Uo(e,n,m,i),d.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(n=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),n!==d.state&&Ua.enqueueReplaceState(d,d.state,null),La(e,i,d,l),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function Hr(e,n){try{var i="",l=n;do i+=ee(l),l=l.return;while(l);var d=i}catch(m){d=`
|
|
37
|
+
`+d[x].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=x&&0<=k);break}}}finally{J=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ee(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=W(e.type,!1),e;case 11:return e=W(e.type.render,!1),e;case 1:return e=W(e.type,!0),e;default:return""}}function xe(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 q:return"Fragment";case G:return"Portal";case K:return"Profiler";case de:return"StrictMode";case ce:return"Suspense";case re:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case V:return(e.displayName||"Context")+".Consumer";case oe:return(e._context.displayName||"Context")+".Provider";case D:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return n=e.displayName||null,n!==null?n:xe(e.type)||"Memo";case he:n=e._payload,e=e._init;try{return xe(e(n))}catch{}}return null}function ke(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return xe(n);case 8:return n===de?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ne(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ae(e){var n=ne(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(x){l=""+x,m.call(this,x)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(x){l=""+x},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ee(e){e._valueTracker||(e._valueTracker=Ae(e))}function Le(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ne(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function fe(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 _e(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function We(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=ve(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function se(e,n){n=n.checked,n!=null&&$(e,"checked",n,!1)}function je(e,n){se(e,n);var i=ve(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?dt(e,n.type,i):n.hasOwnProperty("defaultValue")&&dt(e,n.type,ve(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function $e(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function dt(e,n,i){(n!=="number"||fe(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Ve=Array.isArray;function tt(e,n,i,l){if(e=e.options,n){n={};for(var d=0;d<i.length;d++)n["$"+i[d]]=!0;for(i=0;i<e.length;i++)d=n.hasOwnProperty("$"+e[i].value),e[i].selected!==d&&(e[i].selected=d),d&&l&&(e[i].defaultSelected=!0)}else{for(i=""+ve(i),n=null,d=0;d<e.length;d++){if(e[d].value===i){e[d].selected=!0,l&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function gt(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(a(91));return H({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ft(e,n){var i=n.value;if(i==null){if(i=n.children,n=n.defaultValue,i!=null){if(n!=null)throw Error(a(92));if(Ve(i)){if(1<i.length)throw Error(a(93));i=i[0]}n=i}n==null&&(n=""),i=n}e._wrapperState={initialValue:ve(i)}}function ze(e,n){var i=ve(n.value),l=ve(n.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),n.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),l!=null&&(e.defaultValue=""+l)}function P(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function ae(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function me(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?ae(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Te,ue=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,l,d){MSApp.execUnsafeLocalFunction(function(){return e(n,i,l,d)})}:e})(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Te=Te||document.createElement("div"),Te.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Te.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Oe(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var qe={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},Ye=["Webkit","ms","Moz","O"];Object.keys(qe).forEach(function(e){Ye.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),qe[n]=qe[e]})});function ht(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||qe.hasOwnProperty(e)&&qe[e]?(""+n).trim():n+"px"}function pn(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,d=ht(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,d):e[i]=d}}var jn=H({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 nt(e,n){if(n){if(jn[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(a(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(a(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(a(61))}if(n.style!=null&&typeof n.style!="object")throw Error(a(62))}}function kt(e,n){if(e.indexOf("-")===-1)return typeof n.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 Et=null;function wt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ie=null,Se=null,pe=null;function Me(e){if(e=bs(e)){if(typeof ie!="function")throw Error(a(280));var n=e.stateNode;n&&(n=ka(n),ie(e.stateNode,e.type,n))}}function Fe(e){Se?pe?pe.push(e):pe=[e]:Se=e}function Je(){if(Se){var e=Se,n=pe;if(pe=Se=null,Me(e),n)for(e=0;e<n.length;e++)Me(n[e])}}function Ut(e,n){return e(n)}function er(){}var rs=!1;function na(e,n,i){if(rs)return e(n,i);rs=!0;try{return Ut(e,n,i)}finally{rs=!1,(Se!==null||pe!==null)&&(er(),Je())}}function Sn(e,n){var i=e.stateNode;if(i===null)return null;var l=ka(i);if(l===null)return null;i=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(a(231,n,typeof i));return i}var tr=!1;if(g)try{var nr={};Object.defineProperty(nr,"passive",{get:function(){tr=!0}}),window.addEventListener("test",nr,nr),window.removeEventListener("test",nr,nr)}catch{tr=!1}function ra(e,n,i,l,d,m,x,k,I){var U=Array.prototype.slice.call(arguments,3);try{n.apply(i,U)}catch(X){this.onError(X)}}var $n=!1,rr=null,sr=!1,ss=null,Cr={onError:function(e){$n=!0,rr=e}};function bn(e,n,i,l,d,m,x,k,I){$n=!1,rr=null,ra.apply(Cr,arguments)}function Im(e,n,i,l,d,m,x,k,I){if(bn.apply(this,arguments),$n){if($n){var U=rr;$n=!1,rr=null}else throw Error(a(198));sr||(sr=!0,ss=U)}}function ar(e){var n=e,i=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(i=n.return),e=n.return;while(e)}return n.tag===3?i:null}function bc(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function kc(e){if(ar(e)!==e)throw Error(a(188))}function Am(e){var n=e.alternate;if(!n){if(n=ar(e),n===null)throw Error(a(188));return n!==e?null:e}for(var i=e,l=n;;){var d=i.return;if(d===null)break;var m=d.alternate;if(m===null){if(l=d.return,l!==null){i=l;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===i)return kc(d),e;if(m===l)return kc(d),n;m=m.sibling}throw Error(a(188))}if(i.return!==l.return)i=d,l=m;else{for(var x=!1,k=d.child;k;){if(k===i){x=!0,i=d,l=m;break}if(k===l){x=!0,l=d,i=m;break}k=k.sibling}if(!x){for(k=m.child;k;){if(k===i){x=!0,i=m,l=d;break}if(k===l){x=!0,l=m,i=d;break}k=k.sibling}if(!x)throw Error(a(189))}}if(i.alternate!==l)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?e:n}function Nc(e){return e=Am(e),e!==null?Cc(e):null}function Cc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=Cc(e);if(n!==null)return n;e=e.sibling}return null}var Ec=s.unstable_scheduleCallback,Tc=s.unstable_cancelCallback,Pm=s.unstable_shouldYield,_m=s.unstable_requestPaint,lt=s.unstable_now,$m=s.unstable_getCurrentPriorityLevel,Mi=s.unstable_ImmediatePriority,Rc=s.unstable_UserBlockingPriority,sa=s.unstable_NormalPriority,Lm=s.unstable_LowPriority,Ic=s.unstable_IdlePriority,aa=null,gn=null;function zm(e){if(gn&&typeof gn.onCommitFiberRoot=="function")try{gn.onCommitFiberRoot(aa,e,void 0,(e.current.flags&128)===128)}catch{}}var sn=Math.clz32?Math.clz32:Mm,Fm=Math.log,Om=Math.LN2;function Mm(e){return e>>>=0,e===0?32:31-(Fm(e)/Om|0)|0}var ia=64,oa=4194304;function as(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 la(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,d=e.suspendedLanes,m=e.pingedLanes,x=i&268435455;if(x!==0){var k=x&~d;k!==0?l=as(k):(m&=x,m!==0&&(l=as(m)))}else x=i&~d,x!==0?l=as(x):m!==0&&(l=as(m));if(l===0)return 0;if(n!==0&&n!==l&&(n&d)===0&&(d=l&-l,m=n&-n,d>=m||d===16&&(m&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)i=31-sn(n),d=1<<i,l|=e[i],n&=~d;return l}function Bm(e,n){switch(e){case 1:case 2:case 4:return n+250;case 8:case 16:case 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 n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dm(e,n){for(var i=e.suspendedLanes,l=e.pingedLanes,d=e.expirationTimes,m=e.pendingLanes;0<m;){var x=31-sn(m),k=1<<x,I=d[x];I===-1?((k&i)===0||(k&l)!==0)&&(d[x]=Bm(k,n)):I<=n&&(e.expiredLanes|=k),m&=~k}}function Bi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ac(){var e=ia;return ia<<=1,(ia&4194240)===0&&(ia=64),e}function Di(e){for(var n=[],i=0;31>i;i++)n.push(e);return n}function is(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-sn(n),e[n]=i}function Um(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<i;){var d=31-sn(i),m=1<<d;n[d]=0,l[d]=-1,e[d]=-1,i&=~m}}function Ui(e,n){var i=e.entangledLanes|=n;for(e=e.entanglements;i;){var l=31-sn(i),d=1<<l;d&n|e[l]&n&&(e[l]|=n),i&=~d}}var Ke=0;function Pc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var _c,Wi,$c,Lc,zc,Hi=!1,ca=[],Ln=null,zn=null,Fn=null,os=new Map,ls=new Map,On=[],Wm="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Fc(e,n){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Fn=null;break;case"pointerover":case"pointerout":os.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":ls.delete(n.pointerId)}}function cs(e,n,i,l,d,m){return e===null||e.nativeEvent!==m?(e={blockedOn:n,domEventName:i,eventSystemFlags:l,nativeEvent:m,targetContainers:[d]},n!==null&&(n=bs(n),n!==null&&Wi(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function Hm(e,n,i,l,d){switch(n){case"focusin":return Ln=cs(Ln,e,n,i,l,d),!0;case"dragenter":return zn=cs(zn,e,n,i,l,d),!0;case"mouseover":return Fn=cs(Fn,e,n,i,l,d),!0;case"pointerover":var m=d.pointerId;return os.set(m,cs(os.get(m)||null,e,n,i,l,d)),!0;case"gotpointercapture":return m=d.pointerId,ls.set(m,cs(ls.get(m)||null,e,n,i,l,d)),!0}return!1}function Oc(e){var n=ir(e.target);if(n!==null){var i=ar(n);if(i!==null){if(n=i.tag,n===13){if(n=bc(i),n!==null){e.blockedOn=n,zc(e.priority,function(){$c(i)});return}}else if(n===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ua(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var i=Gi(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var l=new i.constructor(i.type,i);Et=l,i.target.dispatchEvent(l),Et=null}else return n=bs(i),n!==null&&Wi(n),e.blockedOn=i,!1;n.shift()}return!0}function Mc(e,n,i){ua(e)&&i.delete(n)}function Vm(){Hi=!1,Ln!==null&&ua(Ln)&&(Ln=null),zn!==null&&ua(zn)&&(zn=null),Fn!==null&&ua(Fn)&&(Fn=null),os.forEach(Mc),ls.forEach(Mc)}function us(e,n){e.blockedOn===n&&(e.blockedOn=null,Hi||(Hi=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Vm)))}function ds(e){function n(d){return us(d,e)}if(0<ca.length){us(ca[0],e);for(var i=1;i<ca.length;i++){var l=ca[i];l.blockedOn===e&&(l.blockedOn=null)}}for(Ln!==null&&us(Ln,e),zn!==null&&us(zn,e),Fn!==null&&us(Fn,e),os.forEach(n),ls.forEach(n),i=0;i<On.length;i++)l=On[i],l.blockedOn===e&&(l.blockedOn=null);for(;0<On.length&&(i=On[0],i.blockedOn===null);)Oc(i),i.blockedOn===null&&On.shift()}var Er=A.ReactCurrentBatchConfig,da=!0;function Gm(e,n,i,l){var d=Ke,m=Er.transition;Er.transition=null;try{Ke=1,Vi(e,n,i,l)}finally{Ke=d,Er.transition=m}}function Km(e,n,i,l){var d=Ke,m=Er.transition;Er.transition=null;try{Ke=4,Vi(e,n,i,l)}finally{Ke=d,Er.transition=m}}function Vi(e,n,i,l){if(da){var d=Gi(e,n,i,l);if(d===null)co(e,n,l,fa,i),Fc(e,l);else if(Hm(d,e,n,i,l))l.stopPropagation();else if(Fc(e,l),n&4&&-1<Wm.indexOf(e)){for(;d!==null;){var m=bs(d);if(m!==null&&_c(m),m=Gi(e,n,i,l),m===null&&co(e,n,l,fa,i),m===d)break;d=m}d!==null&&l.stopPropagation()}else co(e,n,l,null,i)}}var fa=null;function Gi(e,n,i,l){if(fa=null,e=wt(l),e=ir(e),e!==null)if(n=ar(e),n===null)e=null;else if(i=n.tag,i===13){if(e=bc(n),e!==null)return e;e=null}else if(i===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return fa=e,null}function Bc(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($m()){case Mi:return 1;case Rc:return 4;case sa:case Lm:return 16;case Ic:return 536870912;default:return 16}default:return 16}}var Mn=null,Ki=null,ha=null;function Dc(){if(ha)return ha;var e,n=Ki,i=n.length,l,d="value"in Mn?Mn.value:Mn.textContent,m=d.length;for(e=0;e<i&&n[e]===d[e];e++);var x=i-e;for(l=1;l<=x&&n[i-l]===d[m-l];l++);return ha=d.slice(e,1<l?1-l:void 0)}function ma(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function pa(){return!0}function Uc(){return!1}function Wt(e){function n(i,l,d,m,x){this._reactName=i,this._targetInst=d,this.type=l,this.nativeEvent=m,this.target=x,this.currentTarget=null;for(var k in e)e.hasOwnProperty(k)&&(i=e[k],this[k]=i?i(m):m[k]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?pa:Uc,this.isPropagationStopped=Uc,this}return H(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=pa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=pa)},persist:function(){},isPersistent:pa}),n}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qi=Wt(Tr),fs=H({},Tr,{view:0,detail:0}),qm=Wt(fs),Yi,Ji,hs,ga=H({},fs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xi,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==hs&&(hs&&e.type==="mousemove"?(Yi=e.screenX-hs.screenX,Ji=e.screenY-hs.screenY):Ji=Yi=0,hs=e),Yi)},movementY:function(e){return"movementY"in e?e.movementY:Ji}}),Wc=Wt(ga),Ym=H({},ga,{dataTransfer:0}),Jm=Wt(Ym),Qm=H({},fs,{relatedTarget:0}),Qi=Wt(Qm),Xm=H({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),Zm=Wt(Xm),ep=H({},Tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tp=Wt(ep),np=H({},Tr,{data:0}),Hc=Wt(np),rp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sp={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ap={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ip(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ap[e])?!!n[e]:!1}function Xi(){return ip}var op=H({},fs,{key:function(e){if(e.key){var n=rp[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ma(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?sp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xi,charCode:function(e){return e.type==="keypress"?ma(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ma(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),lp=Wt(op),cp=H({},ga,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vc=Wt(cp),up=H({},fs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xi}),dp=Wt(up),fp=H({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),hp=Wt(fp),mp=H({},ga,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),pp=Wt(mp),gp=[9,13,27,32],Zi=g&&"CompositionEvent"in window,ms=null;g&&"documentMode"in document&&(ms=document.documentMode);var yp=g&&"TextEvent"in window&&!ms,Gc=g&&(!Zi||ms&&8<ms&&11>=ms),Kc=" ",qc=!1;function Yc(e,n){switch(e){case"keyup":return gp.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function vp(e,n){switch(e){case"compositionend":return Jc(n);case"keypress":return n.which!==32?null:(qc=!0,Kc);case"textInput":return e=n.data,e===Kc&&qc?null:e;default:return null}}function xp(e,n){if(Rr)return e==="compositionend"||!Zi&&Yc(e,n)?(e=Dc(),ha=Ki=Mn=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Gc&&n.locale!=="ko"?null:n.data;default:return null}}var wp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!wp[e.type]:n==="textarea"}function Xc(e,n,i,l){Fe(l),n=ja(n,"onChange"),0<n.length&&(i=new qi("onChange","change",null,i,l),e.push({event:i,listeners:n}))}var ps=null,gs=null;function jp(e){gu(e,0)}function ya(e){var n=$r(e);if(Le(n))return e}function Sp(e,n){if(e==="change")return n}var Zc=!1;if(g){var eo;if(g){var to="oninput"in document;if(!to){var eu=document.createElement("div");eu.setAttribute("oninput","return;"),to=typeof eu.oninput=="function"}eo=to}else eo=!1;Zc=eo&&(!document.documentMode||9<document.documentMode)}function tu(){ps&&(ps.detachEvent("onpropertychange",nu),gs=ps=null)}function nu(e){if(e.propertyName==="value"&&ya(gs)){var n=[];Xc(n,gs,e,wt(e)),na(jp,n)}}function bp(e,n,i){e==="focusin"?(tu(),ps=n,gs=i,ps.attachEvent("onpropertychange",nu)):e==="focusout"&&tu()}function kp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ya(gs)}function Np(e,n){if(e==="click")return ya(n)}function Cp(e,n){if(e==="input"||e==="change")return ya(n)}function Ep(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var an=typeof Object.is=="function"?Object.is:Ep;function ys(e,n){if(an(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var i=Object.keys(e),l=Object.keys(n);if(i.length!==l.length)return!1;for(l=0;l<i.length;l++){var d=i[l];if(!p.call(n,d)||!an(e[d],n[d]))return!1}return!0}function ru(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function su(e,n){var i=ru(e);e=0;for(var l;i;){if(i.nodeType===3){if(l=e+i.textContent.length,e<=n&&l>=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ru(i)}}function au(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?au(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function iu(){for(var e=window,n=fe();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=fe(e.document)}return n}function no(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function Tp(e){var n=iu(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&au(i.ownerDocument.documentElement,i)){if(l!==null&&no(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var d=i.textContent.length,m=Math.min(l.start,d);l=l.end===void 0?m:Math.min(l.end,d),!e.extend&&m>l&&(d=l,l=m,m=d),d=su(i,m);var x=su(i,l);d&&x&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),e.removeAllRanges(),m>l?(e.addRange(n),e.extend(x.node,x.offset)):(n.setEnd(x.node,x.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<n.length;i++)e=n[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Rp=g&&"documentMode"in document&&11>=document.documentMode,Ir=null,ro=null,vs=null,so=!1;function ou(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;so||Ir==null||Ir!==fe(l)||(l=Ir,"selectionStart"in l&&no(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),vs&&ys(vs,l)||(vs=l,l=ja(ro,"onSelect"),0<l.length&&(n=new qi("onSelect","select",null,n,i),e.push({event:n,listeners:l}),n.target=Ir)))}function va(e,n){var i={};return i[e.toLowerCase()]=n.toLowerCase(),i["Webkit"+e]="webkit"+n,i["Moz"+e]="moz"+n,i}var Ar={animationend:va("Animation","AnimationEnd"),animationiteration:va("Animation","AnimationIteration"),animationstart:va("Animation","AnimationStart"),transitionend:va("Transition","TransitionEnd")},ao={},lu={};g&&(lu=document.createElement("div").style,"AnimationEvent"in window||(delete Ar.animationend.animation,delete Ar.animationiteration.animation,delete Ar.animationstart.animation),"TransitionEvent"in window||delete Ar.transitionend.transition);function xa(e){if(ao[e])return ao[e];if(!Ar[e])return e;var n=Ar[e],i;for(i in n)if(n.hasOwnProperty(i)&&i in lu)return ao[e]=n[i];return e}var cu=xa("animationend"),uu=xa("animationiteration"),du=xa("animationstart"),fu=xa("transitionend"),hu=new Map,mu="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Bn(e,n){hu.set(e,n),u(n,[e])}for(var io=0;io<mu.length;io++){var oo=mu[io],Ip=oo.toLowerCase(),Ap=oo[0].toUpperCase()+oo.slice(1);Bn(Ip,"on"+Ap)}Bn(cu,"onAnimationEnd"),Bn(uu,"onAnimationIteration"),Bn(du,"onAnimationStart"),Bn("dblclick","onDoubleClick"),Bn("focusin","onFocus"),Bn("focusout","onBlur"),Bn(fu,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Pp=new Set("cancel close invalid load scroll toggle".split(" ").concat(xs));function pu(e,n,i){var l=e.type||"unknown-event";e.currentTarget=i,Im(l,n,void 0,e),e.currentTarget=null}function gu(e,n){n=(n&4)!==0;for(var i=0;i<e.length;i++){var l=e[i],d=l.event;l=l.listeners;e:{var m=void 0;if(n)for(var x=l.length-1;0<=x;x--){var k=l[x],I=k.instance,U=k.currentTarget;if(k=k.listener,I!==m&&d.isPropagationStopped())break e;pu(d,k,U),m=I}else for(x=0;x<l.length;x++){if(k=l[x],I=k.instance,U=k.currentTarget,k=k.listener,I!==m&&d.isPropagationStopped())break e;pu(d,k,U),m=I}}}if(sr)throw e=ss,sr=!1,ss=null,e}function Ze(e,n){var i=n[go];i===void 0&&(i=n[go]=new Set);var l=e+"__bubble";i.has(l)||(yu(n,e,2,!1),i.add(l))}function lo(e,n,i){var l=0;n&&(l|=4),yu(i,e,l,n)}var wa="_reactListening"+Math.random().toString(36).slice(2);function ws(e){if(!e[wa]){e[wa]=!0,o.forEach(function(i){i!=="selectionchange"&&(Pp.has(i)||lo(i,!1,e),lo(i,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[wa]||(n[wa]=!0,lo("selectionchange",!1,n))}}function yu(e,n,i,l){switch(Bc(n)){case 1:var d=Gm;break;case 4:d=Km;break;default:d=Vi}i=d.bind(null,n,i,e),d=void 0,!tr||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),l?d!==void 0?e.addEventListener(n,i,{capture:!0,passive:d}):e.addEventListener(n,i,!0):d!==void 0?e.addEventListener(n,i,{passive:d}):e.addEventListener(n,i,!1)}function co(e,n,i,l,d){var m=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var x=l.tag;if(x===3||x===4){var k=l.stateNode.containerInfo;if(k===d||k.nodeType===8&&k.parentNode===d)break;if(x===4)for(x=l.return;x!==null;){var I=x.tag;if((I===3||I===4)&&(I=x.stateNode.containerInfo,I===d||I.nodeType===8&&I.parentNode===d))return;x=x.return}for(;k!==null;){if(x=ir(k),x===null)return;if(I=x.tag,I===5||I===6){l=m=x;continue e}k=k.parentNode}}l=l.return}na(function(){var U=m,X=wt(i),te=[];e:{var Q=hu.get(e);if(Q!==void 0){var ye=qi,be=e;switch(e){case"keypress":if(ma(i)===0)break e;case"keydown":case"keyup":ye=lp;break;case"focusin":be="focus",ye=Qi;break;case"focusout":be="blur",ye=Qi;break;case"beforeblur":case"afterblur":ye=Qi;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=Wc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Jm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=dp;break;case cu:case uu:case du:ye=Zm;break;case fu:ye=hp;break;case"scroll":ye=qm;break;case"wheel":ye=pp;break;case"copy":case"cut":case"paste":ye=tp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=Vc}var Ne=(n&4)!==0,ct=!Ne&&e==="scroll",z=Ne?Q!==null?Q+"Capture":null:Q;Ne=[];for(var _=U,B;_!==null;){B=_;var le=B.stateNode;if(B.tag===5&&le!==null&&(B=le,z!==null&&(le=Sn(_,z),le!=null&&Ne.push(js(_,le,B)))),ct)break;_=_.return}0<Ne.length&&(Q=new ye(Q,be,null,i,X),te.push({event:Q,listeners:Ne}))}}if((n&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",Q&&i!==Et&&(be=i.relatedTarget||i.fromElement)&&(ir(be)||be[kn]))break e;if((ye||Q)&&(Q=X.window===X?X:(Q=X.ownerDocument)?Q.defaultView||Q.parentWindow:window,ye?(be=i.relatedTarget||i.toElement,ye=U,be=be?ir(be):null,be!==null&&(ct=ar(be),be!==ct||be.tag!==5&&be.tag!==6)&&(be=null)):(ye=null,be=U),ye!==be)){if(Ne=Wc,le="onMouseLeave",z="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(Ne=Vc,le="onPointerLeave",z="onPointerEnter",_="pointer"),ct=ye==null?Q:$r(ye),B=be==null?Q:$r(be),Q=new Ne(le,_+"leave",ye,i,X),Q.target=ct,Q.relatedTarget=B,le=null,ir(X)===U&&(Ne=new Ne(z,_+"enter",be,i,X),Ne.target=B,Ne.relatedTarget=ct,le=Ne),ct=le,ye&&be)t:{for(Ne=ye,z=be,_=0,B=Ne;B;B=Pr(B))_++;for(B=0,le=z;le;le=Pr(le))B++;for(;0<_-B;)Ne=Pr(Ne),_--;for(;0<B-_;)z=Pr(z),B--;for(;_--;){if(Ne===z||z!==null&&Ne===z.alternate)break t;Ne=Pr(Ne),z=Pr(z)}Ne=null}else Ne=null;ye!==null&&vu(te,Q,ye,Ne,!1),be!==null&&ct!==null&&vu(te,ct,be,Ne,!0)}}e:{if(Q=U?$r(U):window,ye=Q.nodeName&&Q.nodeName.toLowerCase(),ye==="select"||ye==="input"&&Q.type==="file")var Ce=Sp;else if(Qc(Q))if(Zc)Ce=Cp;else{Ce=kp;var Re=bp}else(ye=Q.nodeName)&&ye.toLowerCase()==="input"&&(Q.type==="checkbox"||Q.type==="radio")&&(Ce=Np);if(Ce&&(Ce=Ce(e,U))){Xc(te,Ce,i,X);break e}Re&&Re(e,Q,U),e==="focusout"&&(Re=Q._wrapperState)&&Re.controlled&&Q.type==="number"&&dt(Q,"number",Q.value)}switch(Re=U?$r(U):window,e){case"focusin":(Qc(Re)||Re.contentEditable==="true")&&(Ir=Re,ro=U,vs=null);break;case"focusout":vs=ro=Ir=null;break;case"mousedown":so=!0;break;case"contextmenu":case"mouseup":case"dragend":so=!1,ou(te,i,X);break;case"selectionchange":if(Rp)break;case"keydown":case"keyup":ou(te,i,X)}var Ie;if(Zi)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Rr?Yc(e,i)&&(Pe="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(Pe="onCompositionStart");Pe&&(Gc&&i.locale!=="ko"&&(Rr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Rr&&(Ie=Dc()):(Mn=X,Ki="value"in Mn?Mn.value:Mn.textContent,Rr=!0)),Re=ja(U,Pe),0<Re.length&&(Pe=new Hc(Pe,e,null,i,X),te.push({event:Pe,listeners:Re}),Ie?Pe.data=Ie:(Ie=Jc(i),Ie!==null&&(Pe.data=Ie)))),(Ie=yp?vp(e,i):xp(e,i))&&(U=ja(U,"onBeforeInput"),0<U.length&&(X=new Hc("onBeforeInput","beforeinput",null,i,X),te.push({event:X,listeners:U}),X.data=Ie))}gu(te,n)})}function js(e,n,i){return{instance:e,listener:n,currentTarget:i}}function ja(e,n){for(var i=n+"Capture",l=[];e!==null;){var d=e,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Sn(e,i),m!=null&&l.unshift(js(e,m,d)),m=Sn(e,n),m!=null&&l.push(js(e,m,d))),e=e.return}return l}function Pr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function vu(e,n,i,l,d){for(var m=n._reactName,x=[];i!==null&&i!==l;){var k=i,I=k.alternate,U=k.stateNode;if(I!==null&&I===l)break;k.tag===5&&U!==null&&(k=U,d?(I=Sn(i,m),I!=null&&x.unshift(js(i,I,k))):d||(I=Sn(i,m),I!=null&&x.push(js(i,I,k)))),i=i.return}x.length!==0&&e.push({event:n,listeners:x})}var _p=/\r\n?/g,$p=/\u0000|\uFFFD/g;function xu(e){return(typeof e=="string"?e:""+e).replace(_p,`
|
|
38
|
+
`).replace($p,"")}function Sa(e,n,i){if(n=xu(n),xu(e)!==n&&i)throw Error(a(425))}function ba(){}var uo=null,fo=null;function ho(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var mo=typeof setTimeout=="function"?setTimeout:void 0,Lp=typeof clearTimeout=="function"?clearTimeout:void 0,wu=typeof Promise=="function"?Promise:void 0,zp=typeof queueMicrotask=="function"?queueMicrotask:typeof wu<"u"?function(e){return wu.resolve(null).then(e).catch(Fp)}:mo;function Fp(e){setTimeout(function(){throw e})}function po(e,n){var i=n,l=0;do{var d=i.nextSibling;if(e.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(l===0){e.removeChild(d),ds(n);return}l--}else i!=="$"&&i!=="$?"&&i!=="$!"||l++;i=d}while(i);ds(n)}function Dn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function ju(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(n===0)return e;n--}else i==="/$"&&n++}e=e.previousSibling}return null}var _r=Math.random().toString(36).slice(2),yn="__reactFiber$"+_r,Ss="__reactProps$"+_r,kn="__reactContainer$"+_r,go="__reactEvents$"+_r,Op="__reactListeners$"+_r,Mp="__reactHandles$"+_r;function ir(e){var n=e[yn];if(n)return n;for(var i=e.parentNode;i;){if(n=i[kn]||i[yn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(e=ju(e);e!==null;){if(i=e[yn])return i;e=ju(e)}return n}e=i,i=e.parentNode}return null}function bs(e){return e=e[yn]||e[kn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function $r(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function ka(e){return e[Ss]||null}var yo=[],Lr=-1;function Un(e){return{current:e}}function et(e){0>Lr||(e.current=yo[Lr],yo[Lr]=null,Lr--)}function Qe(e,n){Lr++,yo[Lr]=e.current,e.current=n}var Wn={},Tt=Un(Wn),Lt=Un(!1),or=Wn;function zr(e,n){var i=e.type.contextTypes;if(!i)return Wn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=n[m];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=d),d}function zt(e){return e=e.childContextTypes,e!=null}function Na(){et(Lt),et(Tt)}function Su(e,n,i){if(Tt.current!==Wn)throw Error(a(168));Qe(Tt,n),Qe(Lt,i)}function bu(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var d in l)if(!(d in n))throw Error(a(108,ke(e)||"Unknown",d));return H({},i,l)}function Ca(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wn,or=Tt.current,Qe(Tt,e),Qe(Lt,Lt.current),!0}function ku(e,n,i){var l=e.stateNode;if(!l)throw Error(a(169));i?(e=bu(e,n,or),l.__reactInternalMemoizedMergedChildContext=e,et(Lt),et(Tt),Qe(Tt,e)):et(Lt),Qe(Lt,i)}var Nn=null,Ea=!1,vo=!1;function Nu(e){Nn===null?Nn=[e]:Nn.push(e)}function Bp(e){Ea=!0,Nu(e)}function Hn(){if(!vo&&Nn!==null){vo=!0;var e=0,n=Ke;try{var i=Nn;for(Ke=1;e<i.length;e++){var l=i[e];do l=l(!0);while(l!==null)}Nn=null,Ea=!1}catch(d){throw Nn!==null&&(Nn=Nn.slice(e+1)),Ec(Mi,Hn),d}finally{Ke=n,vo=!1}}return null}var Fr=[],Or=0,Ta=null,Ra=0,Yt=[],Jt=0,lr=null,Cn=1,En="";function cr(e,n){Fr[Or++]=Ra,Fr[Or++]=Ta,Ta=e,Ra=n}function Cu(e,n,i){Yt[Jt++]=Cn,Yt[Jt++]=En,Yt[Jt++]=lr,lr=e;var l=Cn;e=En;var d=32-sn(l)-1;l&=~(1<<d),i+=1;var m=32-sn(n)+d;if(30<m){var x=d-d%5;m=(l&(1<<x)-1).toString(32),l>>=x,d-=x,Cn=1<<32-sn(n)+d|i<<d|l,En=m+e}else Cn=1<<m|i<<d|l,En=e}function xo(e){e.return!==null&&(cr(e,1),Cu(e,1,0))}function wo(e){for(;e===Ta;)Ta=Fr[--Or],Fr[Or]=null,Ra=Fr[--Or],Fr[Or]=null;for(;e===lr;)lr=Yt[--Jt],Yt[Jt]=null,En=Yt[--Jt],Yt[Jt]=null,Cn=Yt[--Jt],Yt[Jt]=null}var Ht=null,Vt=null,rt=!1,on=null;function Eu(e,n){var i=en(5,null,null,0);i.elementType="DELETED",i.stateNode=n,i.return=e,n=e.deletions,n===null?(e.deletions=[i],e.flags|=16):n.push(i)}function Tu(e,n){switch(e.tag){case 5:var i=e.type;return n=n.nodeType!==1||i.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=Dn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=lr!==null?{id:Cn,overflow:En}:null,e.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=en(18,null,null,0),i.stateNode=n,i.return=e,e.child=i,Ht=e,Vt=null,!0):!1;default:return!1}}function jo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function So(e){if(rt){var n=Vt;if(n){var i=n;if(!Tu(e,n)){if(jo(e))throw Error(a(418));n=Dn(i.nextSibling);var l=Ht;n&&Tu(e,n)?Eu(l,i):(e.flags=e.flags&-4097|2,rt=!1,Ht=e)}}else{if(jo(e))throw Error(a(418));e.flags=e.flags&-4097|2,rt=!1,Ht=e}}}function Ru(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ht=e}function Ia(e){if(e!==Ht)return!1;if(!rt)return Ru(e),rt=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!ho(e.type,e.memoizedProps)),n&&(n=Vt)){if(jo(e))throw Iu(),Error(a(418));for(;n;)Eu(e,n),n=Dn(n.nextSibling)}if(Ru(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(n===0){Vt=Dn(e.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}e=e.nextSibling}Vt=null}}else Vt=Ht?Dn(e.stateNode.nextSibling):null;return!0}function Iu(){for(var e=Vt;e;)e=Dn(e.nextSibling)}function Mr(){Vt=Ht=null,rt=!1}function bo(e){on===null?on=[e]:on.push(e)}var Dp=A.ReactCurrentBatchConfig;function ks(e,n,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var l=i.stateNode}if(!l)throw Error(a(147,e));var d=l,m=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===m?n.ref:(n=function(x){var k=d.refs;x===null?delete k[m]:k[m]=x},n._stringRef=m,n)}if(typeof e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Aa(e,n){throw e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Au(e){var n=e._init;return n(e._payload)}function Pu(e){function n(z,_){if(e){var B=z.deletions;B===null?(z.deletions=[_],z.flags|=16):B.push(_)}}function i(z,_){if(!e)return null;for(;_!==null;)n(z,_),_=_.sibling;return null}function l(z,_){for(z=new Map;_!==null;)_.key!==null?z.set(_.key,_):z.set(_.index,_),_=_.sibling;return z}function d(z,_){return z=Xn(z,_),z.index=0,z.sibling=null,z}function m(z,_,B){return z.index=B,e?(B=z.alternate,B!==null?(B=B.index,B<_?(z.flags|=2,_):B):(z.flags|=2,_)):(z.flags|=1048576,_)}function x(z){return e&&z.alternate===null&&(z.flags|=2),z}function k(z,_,B,le){return _===null||_.tag!==6?(_=ml(B,z.mode,le),_.return=z,_):(_=d(_,B),_.return=z,_)}function I(z,_,B,le){var Ce=B.type;return Ce===q?X(z,_,B.props.children,le,B.key):_!==null&&(_.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===he&&Au(Ce)===_.type)?(le=d(_,B.props),le.ref=ks(z,_,B),le.return=z,le):(le=ti(B.type,B.key,B.props,null,z.mode,le),le.ref=ks(z,_,B),le.return=z,le)}function U(z,_,B,le){return _===null||_.tag!==4||_.stateNode.containerInfo!==B.containerInfo||_.stateNode.implementation!==B.implementation?(_=pl(B,z.mode,le),_.return=z,_):(_=d(_,B.children||[]),_.return=z,_)}function X(z,_,B,le,Ce){return _===null||_.tag!==7?(_=yr(B,z.mode,le,Ce),_.return=z,_):(_=d(_,B),_.return=z,_)}function te(z,_,B){if(typeof _=="string"&&_!==""||typeof _=="number")return _=ml(""+_,z.mode,B),_.return=z,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case F:return B=ti(_.type,_.key,_.props,null,z.mode,B),B.ref=ks(z,null,_),B.return=z,B;case G:return _=pl(_,z.mode,B),_.return=z,_;case he:var le=_._init;return te(z,le(_._payload),B)}if(Ve(_)||O(_))return _=yr(_,z.mode,B,null),_.return=z,_;Aa(z,_)}return null}function Q(z,_,B,le){var Ce=_!==null?_.key:null;if(typeof B=="string"&&B!==""||typeof B=="number")return Ce!==null?null:k(z,_,""+B,le);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case F:return B.key===Ce?I(z,_,B,le):null;case G:return B.key===Ce?U(z,_,B,le):null;case he:return Ce=B._init,Q(z,_,Ce(B._payload),le)}if(Ve(B)||O(B))return Ce!==null?null:X(z,_,B,le,null);Aa(z,B)}return null}function ye(z,_,B,le,Ce){if(typeof le=="string"&&le!==""||typeof le=="number")return z=z.get(B)||null,k(_,z,""+le,Ce);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case F:return z=z.get(le.key===null?B:le.key)||null,I(_,z,le,Ce);case G:return z=z.get(le.key===null?B:le.key)||null,U(_,z,le,Ce);case he:var Re=le._init;return ye(z,_,B,Re(le._payload),Ce)}if(Ve(le)||O(le))return z=z.get(B)||null,X(_,z,le,Ce,null);Aa(_,le)}return null}function be(z,_,B,le){for(var Ce=null,Re=null,Ie=_,Pe=_=0,bt=null;Ie!==null&&Pe<B.length;Pe++){Ie.index>Pe?(bt=Ie,Ie=null):bt=Ie.sibling;var Ge=Q(z,Ie,B[Pe],le);if(Ge===null){Ie===null&&(Ie=bt);break}e&&Ie&&Ge.alternate===null&&n(z,Ie),_=m(Ge,_,Pe),Re===null?Ce=Ge:Re.sibling=Ge,Re=Ge,Ie=bt}if(Pe===B.length)return i(z,Ie),rt&&cr(z,Pe),Ce;if(Ie===null){for(;Pe<B.length;Pe++)Ie=te(z,B[Pe],le),Ie!==null&&(_=m(Ie,_,Pe),Re===null?Ce=Ie:Re.sibling=Ie,Re=Ie);return rt&&cr(z,Pe),Ce}for(Ie=l(z,Ie);Pe<B.length;Pe++)bt=ye(Ie,z,Pe,B[Pe],le),bt!==null&&(e&&bt.alternate!==null&&Ie.delete(bt.key===null?Pe:bt.key),_=m(bt,_,Pe),Re===null?Ce=bt:Re.sibling=bt,Re=bt);return e&&Ie.forEach(function(Zn){return n(z,Zn)}),rt&&cr(z,Pe),Ce}function Ne(z,_,B,le){var Ce=O(B);if(typeof Ce!="function")throw Error(a(150));if(B=Ce.call(B),B==null)throw Error(a(151));for(var Re=Ce=null,Ie=_,Pe=_=0,bt=null,Ge=B.next();Ie!==null&&!Ge.done;Pe++,Ge=B.next()){Ie.index>Pe?(bt=Ie,Ie=null):bt=Ie.sibling;var Zn=Q(z,Ie,Ge.value,le);if(Zn===null){Ie===null&&(Ie=bt);break}e&&Ie&&Zn.alternate===null&&n(z,Ie),_=m(Zn,_,Pe),Re===null?Ce=Zn:Re.sibling=Zn,Re=Zn,Ie=bt}if(Ge.done)return i(z,Ie),rt&&cr(z,Pe),Ce;if(Ie===null){for(;!Ge.done;Pe++,Ge=B.next())Ge=te(z,Ge.value,le),Ge!==null&&(_=m(Ge,_,Pe),Re===null?Ce=Ge:Re.sibling=Ge,Re=Ge);return rt&&cr(z,Pe),Ce}for(Ie=l(z,Ie);!Ge.done;Pe++,Ge=B.next())Ge=ye(Ie,z,Pe,Ge.value,le),Ge!==null&&(e&&Ge.alternate!==null&&Ie.delete(Ge.key===null?Pe:Ge.key),_=m(Ge,_,Pe),Re===null?Ce=Ge:Re.sibling=Ge,Re=Ge);return e&&Ie.forEach(function(wg){return n(z,wg)}),rt&&cr(z,Pe),Ce}function ct(z,_,B,le){if(typeof B=="object"&&B!==null&&B.type===q&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case F:e:{for(var Ce=B.key,Re=_;Re!==null;){if(Re.key===Ce){if(Ce=B.type,Ce===q){if(Re.tag===7){i(z,Re.sibling),_=d(Re,B.props.children),_.return=z,z=_;break e}}else if(Re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===he&&Au(Ce)===Re.type){i(z,Re.sibling),_=d(Re,B.props),_.ref=ks(z,Re,B),_.return=z,z=_;break e}i(z,Re);break}else n(z,Re);Re=Re.sibling}B.type===q?(_=yr(B.props.children,z.mode,le,B.key),_.return=z,z=_):(le=ti(B.type,B.key,B.props,null,z.mode,le),le.ref=ks(z,_,B),le.return=z,z=le)}return x(z);case G:e:{for(Re=B.key;_!==null;){if(_.key===Re)if(_.tag===4&&_.stateNode.containerInfo===B.containerInfo&&_.stateNode.implementation===B.implementation){i(z,_.sibling),_=d(_,B.children||[]),_.return=z,z=_;break e}else{i(z,_);break}else n(z,_);_=_.sibling}_=pl(B,z.mode,le),_.return=z,z=_}return x(z);case he:return Re=B._init,ct(z,_,Re(B._payload),le)}if(Ve(B))return be(z,_,B,le);if(O(B))return Ne(z,_,B,le);Aa(z,B)}return typeof B=="string"&&B!==""||typeof B=="number"?(B=""+B,_!==null&&_.tag===6?(i(z,_.sibling),_=d(_,B),_.return=z,z=_):(i(z,_),_=ml(B,z.mode,le),_.return=z,z=_),x(z)):i(z,_)}return ct}var Br=Pu(!0),_u=Pu(!1),Pa=Un(null),_a=null,Dr=null,ko=null;function No(){ko=Dr=_a=null}function Co(e){var n=Pa.current;et(Pa),e._currentValue=n}function Eo(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Ur(e,n){_a=e,ko=Dr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Ft=!0),e.firstContext=null)}function Qt(e){var n=e._currentValue;if(ko!==e)if(e={context:e,memoizedValue:n,next:null},Dr===null){if(_a===null)throw Error(a(308));Dr=e,_a.dependencies={lanes:0,firstContext:e}}else Dr=Dr.next=e;return n}var ur=null;function To(e){ur===null?ur=[e]:ur.push(e)}function $u(e,n,i,l){var d=n.interleaved;return d===null?(i.next=i,To(n)):(i.next=d.next,d.next=i),n.interleaved=i,Tn(e,l)}function Tn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Vn=!1;function Ro(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Rn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gn(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(He&2)!==0){var d=l.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),l.pending=n,Tn(e,i)}return d=l.interleaved,d===null?(n.next=n,To(l)):(n.next=d.next,d.next=n),l.interleaved=n,Tn(e,i)}function $a(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Ui(e,i)}}function zu(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var x={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=x:m=m.next=x,i=i.next}while(i!==null);m===null?d=m=n:m=m.next=n}else d=m=n;i={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function La(e,n,i,l){var d=e.updateQueue;Vn=!1;var m=d.firstBaseUpdate,x=d.lastBaseUpdate,k=d.shared.pending;if(k!==null){d.shared.pending=null;var I=k,U=I.next;I.next=null,x===null?m=U:x.next=U,x=I;var X=e.alternate;X!==null&&(X=X.updateQueue,k=X.lastBaseUpdate,k!==x&&(k===null?X.firstBaseUpdate=U:k.next=U,X.lastBaseUpdate=I))}if(m!==null){var te=d.baseState;x=0,X=U=I=null,k=m;do{var Q=k.lane,ye=k.eventTime;if((l&Q)===Q){X!==null&&(X=X.next={eventTime:ye,lane:0,tag:k.tag,payload:k.payload,callback:k.callback,next:null});e:{var be=e,Ne=k;switch(Q=n,ye=i,Ne.tag){case 1:if(be=Ne.payload,typeof be=="function"){te=be.call(ye,te,Q);break e}te=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Ne.payload,Q=typeof be=="function"?be.call(ye,te,Q):be,Q==null)break e;te=H({},te,Q);break e;case 2:Vn=!0}}k.callback!==null&&k.lane!==0&&(e.flags|=64,Q=d.effects,Q===null?d.effects=[k]:Q.push(k))}else ye={eventTime:ye,lane:Q,tag:k.tag,payload:k.payload,callback:k.callback,next:null},X===null?(U=X=ye,I=te):X=X.next=ye,x|=Q;if(k=k.next,k===null){if(k=d.shared.pending,k===null)break;Q=k,k=Q.next,Q.next=null,d.lastBaseUpdate=Q,d.shared.pending=null}}while(!0);if(X===null&&(I=te),d.baseState=I,d.firstBaseUpdate=U,d.lastBaseUpdate=X,n=d.shared.interleaved,n!==null){d=n;do x|=d.lane,d=d.next;while(d!==n)}else m===null&&(d.shared.lanes=0);hr|=x,e.lanes=x,e.memoizedState=te}}function Fu(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],d=l.callback;if(d!==null){if(l.callback=null,l=i,typeof d!="function")throw Error(a(191,d));d.call(l)}}}var Ns={},vn=Un(Ns),Cs=Un(Ns),Es=Un(Ns);function dr(e){if(e===Ns)throw Error(a(174));return e}function Io(e,n){switch(Qe(Es,n),Qe(Cs,e),Qe(vn,Ns),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:me(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=me(n,e)}et(vn),Qe(vn,n)}function Wr(){et(vn),et(Cs),et(Es)}function Ou(e){dr(Es.current);var n=dr(vn.current),i=me(n,e.type);n!==i&&(Qe(Cs,e),Qe(vn,i))}function Ao(e){Cs.current===e&&(et(vn),et(Cs))}var at=Un(0);function za(e){for(var n=e;n!==null;){if(n.tag===13){var i=n.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Po=[];function _o(){for(var e=0;e<Po.length;e++)Po[e]._workInProgressVersionPrimary=null;Po.length=0}var Fa=A.ReactCurrentDispatcher,$o=A.ReactCurrentBatchConfig,fr=0,it=null,yt=null,jt=null,Oa=!1,Ts=!1,Rs=0,Up=0;function Rt(){throw Error(a(321))}function Lo(e,n){if(n===null)return!1;for(var i=0;i<n.length&&i<e.length;i++)if(!an(e[i],n[i]))return!1;return!0}function zo(e,n,i,l,d,m){if(fr=m,it=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,Fa.current=e===null||e.memoizedState===null?Gp:Kp,e=i(l,d),Ts){m=0;do{if(Ts=!1,Rs=0,25<=m)throw Error(a(301));m+=1,jt=yt=null,n.updateQueue=null,Fa.current=qp,e=i(l,d)}while(Ts)}if(Fa.current=Da,n=yt!==null&&yt.next!==null,fr=0,jt=yt=it=null,Oa=!1,n)throw Error(a(300));return e}function Fo(){var e=Rs!==0;return Rs=0,e}function xn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?it.memoizedState=jt=e:jt=jt.next=e,jt}function Xt(){if(yt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=yt.next;var n=jt===null?it.memoizedState:jt.next;if(n!==null)jt=n,yt=e;else{if(e===null)throw Error(a(310));yt=e,e={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},jt===null?it.memoizedState=jt=e:jt=jt.next=e}return jt}function Is(e,n){return typeof n=="function"?n(e):n}function Oo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=yt,d=l.baseQueue,m=i.pending;if(m!==null){if(d!==null){var x=d.next;d.next=m.next,m.next=x}l.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,l=l.baseState;var k=x=null,I=null,U=m;do{var X=U.lane;if((fr&X)===X)I!==null&&(I=I.next={lane:0,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null}),l=U.hasEagerState?U.eagerState:e(l,U.action);else{var te={lane:X,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null};I===null?(k=I=te,x=l):I=I.next=te,it.lanes|=X,hr|=X}U=U.next}while(U!==null&&U!==m);I===null?x=l:I.next=k,an(l,n.memoizedState)||(Ft=!0),n.memoizedState=l,n.baseState=x,n.baseQueue=I,i.lastRenderedState=l}if(e=i.interleaved,e!==null){d=e;do m=d.lane,it.lanes|=m,hr|=m,d=d.next;while(d!==e)}else d===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Mo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=i.dispatch,d=i.pending,m=n.memoizedState;if(d!==null){i.pending=null;var x=d=d.next;do m=e(m,x.action),x=x.next;while(x!==d);an(m,n.memoizedState)||(Ft=!0),n.memoizedState=m,n.baseQueue===null&&(n.baseState=m),i.lastRenderedState=m}return[m,l]}function Mu(){}function Bu(e,n){var i=it,l=Xt(),d=n(),m=!an(l.memoizedState,d);if(m&&(l.memoizedState=d,Ft=!0),l=l.queue,Bo(Wu.bind(null,i,l,e),[e]),l.getSnapshot!==n||m||jt!==null&&jt.memoizedState.tag&1){if(i.flags|=2048,As(9,Uu.bind(null,i,l,d,n),void 0,null),St===null)throw Error(a(349));(fr&30)!==0||Du(i,n,d)}return d}function Du(e,n,i){e.flags|=16384,e={getSnapshot:n,value:i},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.stores=[e]):(i=n.stores,i===null?n.stores=[e]:i.push(e))}function Uu(e,n,i,l){n.value=i,n.getSnapshot=l,Hu(n)&&Vu(e)}function Wu(e,n,i){return i(function(){Hu(n)&&Vu(e)})}function Hu(e){var n=e.getSnapshot;e=e.value;try{var i=n();return!an(e,i)}catch{return!0}}function Vu(e){var n=Tn(e,1);n!==null&&dn(n,e,1,-1)}function Gu(e){var n=xn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Is,lastRenderedState:e},n.queue=e,e=e.dispatch=Vp.bind(null,it,e),[n.memoizedState,e]}function As(e,n,i,l){return e={tag:e,create:n,destroy:i,deps:l,next:null},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.lastEffect=e.next=e):(i=n.lastEffect,i===null?n.lastEffect=e.next=e:(l=i.next,i.next=e,e.next=l,n.lastEffect=e)),e}function Ku(){return Xt().memoizedState}function Ma(e,n,i,l){var d=xn();it.flags|=e,d.memoizedState=As(1|n,i,void 0,l===void 0?null:l)}function Ba(e,n,i,l){var d=Xt();l=l===void 0?null:l;var m=void 0;if(yt!==null){var x=yt.memoizedState;if(m=x.destroy,l!==null&&Lo(l,x.deps)){d.memoizedState=As(n,i,m,l);return}}it.flags|=e,d.memoizedState=As(1|n,i,m,l)}function qu(e,n){return Ma(8390656,8,e,n)}function Bo(e,n){return Ba(2048,8,e,n)}function Yu(e,n){return Ba(4,2,e,n)}function Ju(e,n){return Ba(4,4,e,n)}function Qu(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Xu(e,n,i){return i=i!=null?i.concat([e]):null,Ba(4,4,Qu.bind(null,n,e),i)}function Do(){}function Zu(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Lo(n,l[1])?l[0]:(i.memoizedState=[e,n],e)}function ed(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Lo(n,l[1])?l[0]:(e=e(),i.memoizedState=[e,n],e)}function td(e,n,i){return(fr&21)===0?(e.baseState&&(e.baseState=!1,Ft=!0),e.memoizedState=i):(an(i,n)||(i=Ac(),it.lanes|=i,hr|=i,e.baseState=!0),n)}function Wp(e,n){var i=Ke;Ke=i!==0&&4>i?i:4,e(!0);var l=$o.transition;$o.transition={};try{e(!1),n()}finally{Ke=i,$o.transition=l}}function nd(){return Xt().memoizedState}function Hp(e,n,i){var l=Jn(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},rd(e))sd(n,i);else if(i=$u(e,n,i,l),i!==null){var d=_t();dn(i,e,l,d),ad(i,n,l)}}function Vp(e,n,i){var l=Jn(e),d={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(rd(e))sd(n,d);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var x=n.lastRenderedState,k=m(x,i);if(d.hasEagerState=!0,d.eagerState=k,an(k,x)){var I=n.interleaved;I===null?(d.next=d,To(n)):(d.next=I.next,I.next=d),n.interleaved=d;return}}catch{}finally{}i=$u(e,n,d,l),i!==null&&(d=_t(),dn(i,e,l,d),ad(i,n,l))}}function rd(e){var n=e.alternate;return e===it||n!==null&&n===it}function sd(e,n){Ts=Oa=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function ad(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Ui(e,i)}}var Da={readContext:Qt,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useInsertionEffect:Rt,useLayoutEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useMutableSource:Rt,useSyncExternalStore:Rt,useId:Rt,unstable_isNewReconciler:!1},Gp={readContext:Qt,useCallback:function(e,n){return xn().memoizedState=[e,n===void 0?null:n],e},useContext:Qt,useEffect:qu,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ma(4194308,4,Qu.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ma(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ma(4,2,e,n)},useMemo:function(e,n){var i=xn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=xn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Hp.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var n=xn();return e={current:e},n.memoizedState=e},useState:Gu,useDebugValue:Do,useDeferredValue:function(e){return xn().memoizedState=e},useTransition:function(){var e=Gu(!1),n=e[0];return e=Wp.bind(null,e[1]),xn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=it,d=xn();if(rt){if(i===void 0)throw Error(a(407));i=i()}else{if(i=n(),St===null)throw Error(a(349));(fr&30)!==0||Du(l,n,i)}d.memoizedState=i;var m={value:i,getSnapshot:n};return d.queue=m,qu(Wu.bind(null,l,m,e),[e]),l.flags|=2048,As(9,Uu.bind(null,l,m,i,n),void 0,null),i},useId:function(){var e=xn(),n=St.identifierPrefix;if(rt){var i=En,l=Cn;i=(l&~(1<<32-sn(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Rs++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=Up++,n=":"+n+"r"+i.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Kp={readContext:Qt,useCallback:Zu,useContext:Qt,useEffect:Bo,useImperativeHandle:Xu,useInsertionEffect:Yu,useLayoutEffect:Ju,useMemo:ed,useReducer:Oo,useRef:Ku,useState:function(){return Oo(Is)},useDebugValue:Do,useDeferredValue:function(e){var n=Xt();return td(n,yt.memoizedState,e)},useTransition:function(){var e=Oo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:Mu,useSyncExternalStore:Bu,useId:nd,unstable_isNewReconciler:!1},qp={readContext:Qt,useCallback:Zu,useContext:Qt,useEffect:Bo,useImperativeHandle:Xu,useInsertionEffect:Yu,useLayoutEffect:Ju,useMemo:ed,useReducer:Mo,useRef:Ku,useState:function(){return Mo(Is)},useDebugValue:Do,useDeferredValue:function(e){var n=Xt();return yt===null?n.memoizedState=e:td(n,yt.memoizedState,e)},useTransition:function(){var e=Mo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:Mu,useSyncExternalStore:Bu,useId:nd,unstable_isNewReconciler:!1};function ln(e,n){if(e&&e.defaultProps){n=H({},n),e=e.defaultProps;for(var i in e)n[i]===void 0&&(n[i]=e[i]);return n}return n}function Uo(e,n,i,l){n=e.memoizedState,i=i(l,n),i=i==null?n:H({},n,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Ua={isMounted:function(e){return(e=e._reactInternals)?ar(e)===e:!1},enqueueSetState:function(e,n,i){e=e._reactInternals;var l=_t(),d=Jn(e),m=Rn(l,d);m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,d),n!==null&&(dn(n,e,d,l),$a(n,e,d))},enqueueReplaceState:function(e,n,i){e=e._reactInternals;var l=_t(),d=Jn(e),m=Rn(l,d);m.tag=1,m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,d),n!==null&&(dn(n,e,d,l),$a(n,e,d))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var i=_t(),l=Jn(e),d=Rn(i,l);d.tag=2,n!=null&&(d.callback=n),n=Gn(e,d,l),n!==null&&(dn(n,e,l,i),$a(n,e,l))}};function id(e,n,i,l,d,m,x){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,m,x):n.prototype&&n.prototype.isPureReactComponent?!ys(i,l)||!ys(d,m):!0}function od(e,n,i){var l=!1,d=Wn,m=n.contextType;return typeof m=="object"&&m!==null?m=Qt(m):(d=zt(n)?or:Tt.current,l=n.contextTypes,m=(l=l!=null)?zr(e,d):Wn),n=new n(i,m),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Ua,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=m),n}function ld(e,n,i,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(i,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(i,l),n.state!==e&&Ua.enqueueReplaceState(n,n.state,null)}function Wo(e,n,i,l){var d=e.stateNode;d.props=i,d.state=e.memoizedState,d.refs={},Ro(e);var m=n.contextType;typeof m=="object"&&m!==null?d.context=Qt(m):(m=zt(n)?or:Tt.current,d.context=zr(e,m)),d.state=e.memoizedState,m=n.getDerivedStateFromProps,typeof m=="function"&&(Uo(e,n,m,i),d.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(n=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),n!==d.state&&Ua.enqueueReplaceState(d,d.state,null),La(e,i,d,l),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function Hr(e,n){try{var i="",l=n;do i+=ee(l),l=l.return;while(l);var d=i}catch(m){d=`
|
|
39
39
|
Error generating stack: `+m.message+`
|
|
40
|
-
`+m.stack}return{value:e,source:n,stack:d,digest:null}}function Ho(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function Vo(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Yp=typeof WeakMap=="function"?WeakMap:Map;function cd(e,n,i){i=Rn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){Ya||(Ya=!0,il=l),Vo(e,n)},i}function ud(e,n,i){i=Rn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var d=n.value;i.payload=function(){return l(d)},i.callback=function(){Vo(e,n)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){Vo(e,n),typeof l!="function"&&(qn===null?qn=new Set([this]):qn.add(this));var x=n.stack;this.componentDidCatch(n.value,{componentStack:x!==null?x:""})}),i}function dd(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new Yp;var d=new Set;l.set(n,d)}else d=l.get(n),d===void 0&&(d=new Set,l.set(n,d));d.has(i)||(d.add(i),e=cg.bind(null,e,n,i),n.then(e,e))}function fd(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function hd(e,n,i,l,d){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Rn(-1,1),n.tag=2,Gn(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Jp=A.ReactCurrentOwner,Ft=!1;function Pt(e,n,i,l){n.child=e===null?_u(n,null,i,l):Br(n,e.child,i,l)}function md(e,n,i,l,d){i=i.render;var m=n.ref;return Ur(n,d),l=zo(e,n,i,l,m,d),i=Fo(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,In(e,n,d)):(rt&&i&&xo(n),n.flags|=1,Pt(e,n,l,d),n.child)}function pd(e,n,i,l,d){if(e===null){var m=i.type;return typeof m=="function"&&!hl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=m,gd(e,n,m,l,d)):(e=ti(i.type,null,l,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(m=e.child,(e.lanes&d)===0){var x=m.memoizedProps;if(i=i.compare,i=i!==null?i:ys,i(x,l)&&e.ref===n.ref)return In(e,n,d)}return n.flags|=1,e=Xn(m,l),e.ref=n.ref,e.return=n,n.child=e}function gd(e,n,i,l,d){if(e!==null){var m=e.memoizedProps;if(ys(m,l)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=l=m,(e.lanes&d)!==0)(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,In(e,n,d)}return Go(e,n,i,l,d)}function yd(e,n,i){var l=n.pendingProps,d=l.children,m=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qe(Gr,Gt),Gt|=i;else{if((i&1073741824)===0)return e=m!==null?m.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Qe(Gr,Gt),Gt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=m!==null?m.baseLanes:i,Qe(Gr,Gt),Gt|=l}else m!==null?(l=m.baseLanes|i,n.memoizedState=null):l=i,Qe(Gr,Gt),Gt|=l;return Pt(e,n,d,i),n.child}function vd(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Go(e,n,i,l,d){var m=zt(i)?or:Tt.current;return m=zr(n,m),Ur(n,d),i=zo(e,n,i,l,m,d),l=Fo(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,In(e,n,d)):(rt&&l&&xo(n),n.flags|=1,Pt(e,n,i,d),n.child)}function xd(e,n,i,l,d){if(zt(i)){var m=!0;Ca(n)}else m=!1;if(Ur(n,d),n.stateNode===null)Ha(e,n),od(n,i,l),Wo(n,i,l,d),l=!0;else if(e===null){var x=n.stateNode,k=n.memoizedProps;x.props=k;var I=x.context,U=i.contextType;typeof U=="object"&&U!==null?U=Qt(U):(U=zt(i)?or:Tt.current,U=zr(n,U));var X=i.getDerivedStateFromProps,te=typeof X=="function"||typeof x.getSnapshotBeforeUpdate=="function";te||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(k!==l||I!==U)&&ld(n,x,l,U),Vn=!1;var Q=n.memoizedState;x.state=Q,La(n,l,x,d),I=n.memoizedState,k!==l||Q!==I||Lt.current||Vn?(typeof X=="function"&&(Uo(n,i,X,l),I=n.memoizedState),(k=Vn||id(n,i,k,l,Q,I,U))?(te||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=I),x.props=l,x.state=I,x.context=U,l=k):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{x=n.stateNode,Lu(e,n),k=n.memoizedProps,U=n.type===n.elementType?k:ln(n.type,k),x.props=U,te=n.pendingProps,Q=x.context,I=i.contextType,typeof I=="object"&&I!==null?I=Qt(I):(I=zt(i)?or:Tt.current,I=zr(n,I));var ye=i.getDerivedStateFromProps;(X=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(k!==te||Q!==I)&&ld(n,x,l,I),Vn=!1,Q=n.memoizedState,x.state=Q,La(n,l,x,d);var be=n.memoizedState;k!==te||Q!==be||Lt.current||Vn?(typeof ye=="function"&&(Uo(n,i,ye,l),be=n.memoizedState),(U=Vn||id(n,i,U,l,Q,be,I)||!1)?(X||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(l,be,I),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(l,be,I)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=be),x.props=l,x.state=be,x.context=I,l=U):(typeof x.componentDidUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=1024),l=!1)}return Ko(e,n,i,l,m,d)}function Ko(e,n,i,l,d,m){vd(e,n);var x=(n.flags&128)!==0;if(!l&&!x)return d&&ku(n,i,!1),In(e,n,m);l=n.stateNode,Jp.current=n;var k=x&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&x?(n.child=Br(n,e.child,null,m),n.child=Br(n,null,k,m)):Pt(e,n,k,m),n.memoizedState=l.state,d&&ku(n,i,!0),n.child}function wd(e){var n=e.stateNode;n.pendingContext?Su(e,n.pendingContext,n.pendingContext!==n.context):n.context&&Su(e,n.context,!1),Io(e,n.containerInfo)}function jd(e,n,i,l,d){return Mr(),bo(d),n.flags|=256,Pt(e,n,i,l),n.child}var qo={dehydrated:null,treeContext:null,retryLane:0};function Yo(e){return{baseLanes:e,cachePool:null,transitions:null}}function Sd(e,n,i){var l=n.pendingProps,d=at.current,m=!1,x=(n.flags&128)!==0,k;if((k=x)||(k=e!==null&&e.memoizedState===null?!1:(d&2)!==0),k?(m=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),Qe(at,d&1),e===null)return So(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(x=l.children,e=l.fallback,m?(l=n.mode,m=n.child,x={mode:"hidden",children:x},(l&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=x):m=ni(x,l,0,null),e=yr(e,l,i,null),m.return=n,e.return=n,m.sibling=e,n.child=m,n.child.memoizedState=Yo(i),n.memoizedState=qo,e):Jo(n,x));if(d=e.memoizedState,d!==null&&(k=d.dehydrated,k!==null))return Qp(e,n,x,l,k,d,i);if(m){m=l.fallback,x=n.mode,d=e.child,k=d.sibling;var I={mode:"hidden",children:l.children};return(x&1)===0&&n.child!==d?(l=n.child,l.childLanes=0,l.pendingProps=I,n.deletions=null):(l=Xn(d,I),l.subtreeFlags=d.subtreeFlags&14680064),k!==null?m=Xn(k,m):(m=yr(m,x,i,null),m.flags|=2),m.return=n,l.return=n,l.sibling=m,n.child=l,l=m,m=n.child,x=e.child.memoizedState,x=x===null?Yo(i):{baseLanes:x.baseLanes|i,cachePool:null,transitions:x.transitions},m.memoizedState=x,m.childLanes=e.childLanes&~i,n.memoizedState=qo,l}return m=e.child,e=m.sibling,l=Xn(m,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function Jo(e,n){return n=ni({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Wa(e,n,i,l){return l!==null&&bo(l),Br(n,e.child,null,i),e=Jo(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Qp(e,n,i,l,d,m,x){if(i)return n.flags&256?(n.flags&=-257,l=Ho(Error(a(422))),Wa(e,n,x,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(m=l.fallback,d=n.mode,l=ni({mode:"visible",children:l.children},d,0,null),m=yr(m,d,x,null),m.flags|=2,l.return=n,m.return=n,l.sibling=m,n.child=l,(n.mode&1)!==0&&Br(n,e.child,null,x),n.child.memoizedState=Yo(x),n.memoizedState=qo,m);if((n.mode&1)===0)return Wa(e,n,x,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var k=l.dgst;return l=k,m=Error(a(419)),l=Ho(m,l,void 0),Wa(e,n,x,l)}if(k=(x&e.childLanes)!==0,Ft||k){if(l=St,l!==null){switch(x&-x){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|x))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,Tn(e,d),dn(l,e,d,-1))}return fl(),l=Ho(Error(a(421))),Wa(e,n,x,l)}return d.data==="$?"?(n.flags|=128,n.child=e.child,n=ug.bind(null,e),d._reactRetry=n,null):(e=m.treeContext,Vt=Dn(d.nextSibling),Ht=n,rt=!0,on=null,e!==null&&(Yt[Jt++]=Cn,Yt[Jt++]=En,Yt[Jt++]=lr,Cn=e.id,En=e.overflow,lr=n),n=Jo(n,l.children),n.flags|=4096,n)}function bd(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Eo(e.return,n,i)}function Qo(e,n,i,l,d){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:d}:(m.isBackwards=n,m.rendering=null,m.renderingStartTime=0,m.last=l,m.tail=i,m.tailMode=d)}function kd(e,n,i){var l=n.pendingProps,d=l.revealOrder,m=l.tail;if(Pt(e,n,l.children,i),l=at.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&bd(e,i,n);else if(e.tag===19)bd(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Qe(at,l),(n.mode&1)===0)n.memoizedState=null;else switch(d){case"forwards":for(i=n.child,d=null;i!==null;)e=i.alternate,e!==null&&za(e)===null&&(d=i),i=i.sibling;i=d,i===null?(d=n.child,n.child=null):(d=i.sibling,i.sibling=null),Qo(n,!1,d,i,m);break;case"backwards":for(i=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&za(e)===null){n.child=d;break}e=d.sibling,d.sibling=i,i=d,d=e}Qo(n,!0,i,null,m);break;case"together":Qo(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Ha(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function In(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),hr|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,i=Xn(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Xn(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Xp(e,n,i){switch(n.tag){case 3:wd(n),Mr();break;case 5:Ou(n);break;case 1:zt(n.type)&&Ca(n);break;case 4:Io(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,d=n.memoizedProps.value;Qe(Pa,l._currentValue),l._currentValue=d;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Qe(at,at.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?Sd(e,n,i):(Qe(at,at.current&1),e=In(e,n,i),e!==null?e.sibling:null);Qe(at,at.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return kd(e,n,i);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),Qe(at,at.current),l)break;return null;case 22:case 23:return n.lanes=0,yd(e,n,i)}return In(e,n,i)}var Nd,Xo,Cd,Ed;Nd=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Xo=function(){},Cd=function(e,n,i,l){var d=e.memoizedProps;if(d!==l){e=n.stateNode,dr(vn.current);var m=null;switch(i){case"input":d=_e(e,d),l=_e(e,l),m=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),m=[];break;case"textarea":d=gt(e,d),l=gt(e,l),m=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=ba)}nt(i,l);var x;i=null;for(U in d)if(!l.hasOwnProperty(U)&&d.hasOwnProperty(U)&&d[U]!=null)if(U==="style"){var k=d[U];for(x in k)k.hasOwnProperty(x)&&(i||(i={}),i[x]="")}else U!=="dangerouslySetInnerHTML"&&U!=="children"&&U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(c.hasOwnProperty(U)?m||(m=[]):(m=m||[]).push(U,null));for(U in l){var I=l[U];if(k=d!=null?d[U]:void 0,l.hasOwnProperty(U)&&I!==k&&(I!=null||k!=null))if(U==="style")if(k){for(x in k)!k.hasOwnProperty(x)||I&&I.hasOwnProperty(x)||(i||(i={}),i[x]="");for(x in I)I.hasOwnProperty(x)&&k[x]!==I[x]&&(i||(i={}),i[x]=I[x])}else i||(m||(m=[]),m.push(U,i)),i=I;else U==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,k=k?k.__html:void 0,I!=null&&k!==I&&(m=m||[]).push(U,I)):U==="children"?typeof I!="string"&&typeof I!="number"||(m=m||[]).push(U,""+I):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&(c.hasOwnProperty(U)?(I!=null&&U==="onScroll"&&Ze("scroll",e),m||k===I||(m=[])):(m=m||[]).push(U,I))}i&&(m=m||[]).push("style",i);var U=m;(n.updateQueue=U)&&(n.flags|=4)}},Ed=function(e,n,i,l){i!==l&&(n.flags|=4)};function Ps(e,n){if(!rt)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var d=e.child;d!==null;)i|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)i|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Zp(e,n,i){var l=n.pendingProps;switch(wo(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(n),null;case 1:return zt(n.type)&&Na(),It(n),null;case 3:return l=n.stateNode,Wr(),et(Lt),et(Tt),_o(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ia(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,on!==null&&(cl(on),on=null))),Xo(e,n),It(n),null;case 5:Ao(n);var d=dr(Es.current);if(i=n.type,e!==null&&n.stateNode!=null)Cd(e,n,i,l,d),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(a(166));return It(n),null}if(e=dr(vn.current),Ia(n)){l=n.stateNode,i=n.type;var m=n.memoizedProps;switch(l[yn]=n,l[Ss]=m,e=(n.mode&1)!==0,i){case"dialog":Ze("cancel",l),Ze("close",l);break;case"iframe":case"object":case"embed":Ze("load",l);break;case"video":case"audio":for(d=0;d<xs.length;d++)Ze(xs[d],l);break;case"source":Ze("error",l);break;case"img":case"image":case"link":Ze("error",l),Ze("load",l);break;case"details":Ze("toggle",l);break;case"input":Ue(l,m),Ze("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!m.multiple},Ze("invalid",l);break;case"textarea":ft(l,m),Ze("invalid",l)}nt(i,m),d=null;for(var x in m)if(m.hasOwnProperty(x)){var k=m[x];x==="children"?typeof k=="string"?l.textContent!==k&&(m.suppressHydrationWarning!==!0&&Sa(l.textContent,k,e),d=["children",k]):typeof k=="number"&&l.textContent!==""+k&&(m.suppressHydrationWarning!==!0&&Sa(l.textContent,k,e),d=["children",""+k]):c.hasOwnProperty(x)&&k!=null&&x==="onScroll"&&Ze("scroll",l)}switch(i){case"input":Ee(l),$e(l,m,!0);break;case"textarea":Ee(l),P(l);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(l.onclick=ba)}l=d,n.updateQueue=l,l!==null&&(n.flags|=4)}else{x=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=ae(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=x.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=x.createElement(i,{is:l.is}):(e=x.createElement(i),i==="select"&&(x=e,l.multiple?x.multiple=!0:l.size&&(x.size=l.size))):e=x.createElementNS(e,i),e[yn]=n,e[Ss]=l,Nd(e,n,!1,!1),n.stateNode=e;e:{switch(x=kt(i,l),i){case"dialog":Ze("cancel",e),Ze("close",e),d=l;break;case"iframe":case"object":case"embed":Ze("load",e),d=l;break;case"video":case"audio":for(d=0;d<xs.length;d++)Ze(xs[d],e);d=l;break;case"source":Ze("error",e),d=l;break;case"img":case"image":case"link":Ze("error",e),Ze("load",e),d=l;break;case"details":Ze("toggle",e),d=l;break;case"input":Ue(e,l),d=_e(e,l),Ze("invalid",e);break;case"option":d=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},d=H({},l,{value:void 0}),Ze("invalid",e);break;case"textarea":ft(e,l),d=gt(e,l),Ze("invalid",e);break;default:d=l}nt(i,d),k=d;for(m in k)if(k.hasOwnProperty(m)){var I=k[m];m==="style"?pn(e,I):m==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,I!=null&&ue(e,I)):m==="children"?typeof I=="string"?(i!=="textarea"||I!=="")&&Oe(e,I):typeof I=="number"&&Oe(e,""+I):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(c.hasOwnProperty(m)?I!=null&&m==="onScroll"&&Ze("scroll",e):I!=null&&$(e,m,I,x))}switch(i){case"input":Ee(e),$e(e,l,!1);break;case"textarea":Ee(e),P(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ve(l.value));break;case"select":e.multiple=!!l.multiple,m=l.value,m!=null?tt(e,!!l.multiple,m,!1):l.defaultValue!=null&&tt(e,!!l.multiple,l.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=ba)}switch(i){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return It(n),null;case 6:if(e&&n.stateNode!=null)Ed(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(a(166));if(i=dr(Es.current),dr(vn.current),Ia(n)){if(l=n.stateNode,i=n.memoizedProps,l[yn]=n,(m=l.nodeValue!==i)&&(e=Ht,e!==null))switch(e.tag){case 3:Sa(l.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Sa(l.nodeValue,i,(e.mode&1)!==0)}m&&(n.flags|=4)}else l=(i.nodeType===9?i:i.ownerDocument).createTextNode(l),l[yn]=n,n.stateNode=l}return It(n),null;case 13:if(et(at),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rt&&Vt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Iu(),Mr(),n.flags|=98560,m=!1;else if(m=Ia(n),l!==null&&l.dehydrated!==null){if(e===null){if(!m)throw Error(a(318));if(m=n.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[yn]=n}else Mr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;It(n),m=!1}else on!==null&&(cl(on),on=null),m=!0;if(!m)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=i,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,(n.mode&1)!==0&&(e===null||(at.current&1)!==0?vt===0&&(vt=3):fl())),n.updateQueue!==null&&(n.flags|=4),It(n),null);case 4:return Wr(),Xo(e,n),e===null&&ws(n.stateNode.containerInfo),It(n),null;case 10:return Co(n.type._context),It(n),null;case 17:return zt(n.type)&&Na(),It(n),null;case 19:if(et(at),m=n.memoizedState,m===null)return It(n),null;if(l=(n.flags&128)!==0,x=m.rendering,x===null)if(l)Ps(m,!1);else{if(vt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=za(e),x!==null){for(n.flags|=128,Ps(m,!1),l=x.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=i,i=n.child;i!==null;)m=i,e=l,m.flags&=14680066,x=m.alternate,x===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=x.childLanes,m.lanes=x.lanes,m.child=x.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=x.memoizedProps,m.memoizedState=x.memoizedState,m.updateQueue=x.updateQueue,m.type=x.type,e=x.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return Qe(at,at.current&1|2),n.child}e=e.sibling}m.tail!==null&<()>Kr&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304)}else{if(!l)if(e=za(x),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ps(m,!0),m.tail===null&&m.tailMode==="hidden"&&!x.alternate&&!rt)return It(n),null}else 2*lt()-m.renderingStartTime>Kr&&i!==1073741824&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304);m.isBackwards?(x.sibling=n.child,n.child=x):(i=m.last,i!==null?i.sibling=x:n.child=x,m.last=x)}return m.tail!==null?(n=m.tail,m.rendering=n,m.tail=n.sibling,m.renderingStartTime=lt(),n.sibling=null,i=at.current,Qe(at,l?i&1|2:i&1),n):(It(n),null);case 22:case 23:return dl(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(It(n),n.subtreeFlags&6&&(n.flags|=8192)):It(n),null;case 24:return null;case 25:return null}throw Error(a(156,n.tag))}function eg(e,n){switch(wo(n),n.tag){case 1:return zt(n.type)&&Na(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Wr(),et(Lt),et(Tt),_o(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ao(n),null;case 13:if(et(at),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Mr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return et(at),null;case 4:return Wr(),null;case 10:return Co(n.type._context),null;case 22:case 23:return dl(),null;case 24:return null;default:return null}}var Va=!1,At=!1,tg=typeof WeakSet=="function"?WeakSet:Set,we=null;function Vr(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){ot(e,n,l)}else i.current=null}function Zo(e,n,i){try{i()}catch(l){ot(e,n,l)}}var Td=!1;function ng(e,n){if(uo=da,e=iu(),no(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var d=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var x=0,k=-1,I=-1,U=0,X=0,te=e,Q=null;t:for(;;){for(var ye;te!==i||d!==0&&te.nodeType!==3||(k=x+d),te!==m||l!==0&&te.nodeType!==3||(I=x+l),te.nodeType===3&&(x+=te.nodeValue.length),(ye=te.firstChild)!==null;)Q=te,te=ye;for(;;){if(te===e)break t;if(Q===i&&++U===d&&(k=x),Q===m&&++X===l&&(I=x),(ye=te.nextSibling)!==null)break;te=Q,Q=te.parentNode}te=ye}i=k===-1||I===-1?null:{start:k,end:I}}else i=null}i=i||{start:0,end:0}}else i=null;for(fo={focusedElem:e,selectionRange:i},da=!1,we=n;we!==null;)if(n=we,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,we=e;else for(;we!==null;){n=we;try{var be=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(be!==null){var Ne=be.memoizedProps,ct=be.memoizedState,z=n.stateNode,_=z.getSnapshotBeforeUpdate(n.elementType===n.type?Ne:ln(n.type,Ne),ct);z.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var B=n.stateNode.containerInfo;B.nodeType===1?B.textContent="":B.nodeType===9&&B.documentElement&&B.removeChild(B.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(le){ot(n,n.return,le)}if(e=n.sibling,e!==null){e.return=n.return,we=e;break}we=n.return}return be=Td,Td=!1,be}function _s(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&e)===e){var m=d.destroy;d.destroy=void 0,m!==void 0&&Zo(n,i,m)}d=d.next}while(d!==l)}}function Ga(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function el(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Rd(e){var n=e.alternate;n!==null&&(e.alternate=null,Rd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[yn],delete n[Ss],delete n[go],delete n[Op],delete n[Mp])),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 Id(e){return e.tag===5||e.tag===3||e.tag===4}function Ad(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Id(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 tl(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=ba));else if(l!==4&&(e=e.child,e!==null))for(tl(e,n,i),e=e.sibling;e!==null;)tl(e,n,i),e=e.sibling}function nl(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(nl(e,n,i),e=e.sibling;e!==null;)nl(e,n,i),e=e.sibling}var Nt=null,cn=!1;function Kn(e,n,i){for(i=i.child;i!==null;)Pd(e,n,i),i=i.sibling}function Pd(e,n,i){if(gn&&typeof gn.onCommitFiberUnmount=="function")try{gn.onCommitFiberUnmount(aa,i)}catch{}switch(i.tag){case 5:At||Vr(i,n);case 6:var l=Nt,d=cn;Nt=null,Kn(e,n,i),Nt=l,cn=d,Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Nt.removeChild(i.stateNode));break;case 18:Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?po(e.parentNode,i):e.nodeType===1&&po(e,i),ds(e)):po(Nt,i.stateNode));break;case 4:l=Nt,d=cn,Nt=i.stateNode.containerInfo,cn=!0,Kn(e,n,i),Nt=l,cn=d;break;case 0:case 11:case 14:case 15:if(!At&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var m=d,x=m.destroy;m=m.tag,x!==void 0&&((m&2)!==0||(m&4)!==0)&&Zo(i,n,x),d=d.next}while(d!==l)}Kn(e,n,i);break;case 1:if(!At&&(Vr(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(k){ot(i,n,k)}Kn(e,n,i);break;case 21:Kn(e,n,i);break;case 22:i.mode&1?(At=(l=At)||i.memoizedState!==null,Kn(e,n,i),At=l):Kn(e,n,i);break;default:Kn(e,n,i)}}function _d(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new tg),n.forEach(function(l){var d=dg.bind(null,e,l);i.has(l)||(i.add(l),l.then(d,d))})}}function un(e,n){var i=n.deletions;if(i!==null)for(var l=0;l<i.length;l++){var d=i[l];try{var m=e,x=n,k=x;e:for(;k!==null;){switch(k.tag){case 5:Nt=k.stateNode,cn=!1;break e;case 3:Nt=k.stateNode.containerInfo,cn=!0;break e;case 4:Nt=k.stateNode.containerInfo,cn=!0;break e}k=k.return}if(Nt===null)throw Error(a(160));Pd(m,x,d),Nt=null,cn=!1;var I=d.alternate;I!==null&&(I.return=null),d.return=null}catch(U){ot(d,n,U)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)$d(n,e),n=n.sibling}function $d(e,n){var i=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(un(n,e),wn(e),l&4){try{_s(3,e,e.return),Ga(3,e)}catch(Ne){ot(e,e.return,Ne)}try{_s(5,e,e.return)}catch(Ne){ot(e,e.return,Ne)}}break;case 1:un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return);break;case 5:if(un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return),e.flags&32){var d=e.stateNode;try{Oe(d,"")}catch(Ne){ot(e,e.return,Ne)}}if(l&4&&(d=e.stateNode,d!=null)){var m=e.memoizedProps,x=i!==null?i.memoizedProps:m,k=e.type,I=e.updateQueue;if(e.updateQueue=null,I!==null)try{k==="input"&&m.type==="radio"&&m.name!=null&&se(d,m),kt(k,x);var U=kt(k,m);for(x=0;x<I.length;x+=2){var X=I[x],te=I[x+1];X==="style"?pn(d,te):X==="dangerouslySetInnerHTML"?ue(d,te):X==="children"?Oe(d,te):$(d,X,te,U)}switch(k){case"input":je(d,m);break;case"textarea":ze(d,m);break;case"select":var Q=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var ye=m.value;ye!=null?tt(d,!!m.multiple,ye,!1):Q!==!!m.multiple&&(m.defaultValue!=null?tt(d,!!m.multiple,m.defaultValue,!0):tt(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ss]=m}catch(Ne){ot(e,e.return,Ne)}}break;case 6:if(un(n,e),wn(e),l&4){if(e.stateNode===null)throw Error(a(162));d=e.stateNode,m=e.memoizedProps;try{d.nodeValue=m}catch(Ne){ot(e,e.return,Ne)}}break;case 3:if(un(n,e),wn(e),l&4&&i!==null&&i.memoizedState.isDehydrated)try{ds(n.containerInfo)}catch(Ne){ot(e,e.return,Ne)}break;case 4:un(n,e),wn(e);break;case 13:un(n,e),wn(e),d=e.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(al=lt())),l&4&&_d(e);break;case 22:if(X=i!==null&&i.memoizedState!==null,e.mode&1?(At=(U=At)||X,un(n,e),At=U):un(n,e),wn(e),l&8192){if(U=e.memoizedState!==null,(e.stateNode.isHidden=U)&&!X&&(e.mode&1)!==0)for(we=e,X=e.child;X!==null;){for(te=we=X;we!==null;){switch(Q=we,ye=Q.child,Q.tag){case 0:case 11:case 14:case 15:_s(4,Q,Q.return);break;case 1:Vr(Q,Q.return);var be=Q.stateNode;if(typeof be.componentWillUnmount=="function"){l=Q,i=Q.return;try{n=l,be.props=n.memoizedProps,be.state=n.memoizedState,be.componentWillUnmount()}catch(Ne){ot(l,i,Ne)}}break;case 5:Vr(Q,Q.return);break;case 22:if(Q.memoizedState!==null){Fd(te);continue}}ye!==null?(ye.return=Q,we=ye):Fd(te)}X=X.sibling}e:for(X=null,te=e;;){if(te.tag===5){if(X===null){X=te;try{d=te.stateNode,U?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(k=te.stateNode,I=te.memoizedProps.style,x=I!=null&&I.hasOwnProperty("display")?I.display:null,k.style.display=ht("display",x))}catch(Ne){ot(e,e.return,Ne)}}}else if(te.tag===6){if(X===null)try{te.stateNode.nodeValue=U?"":te.memoizedProps}catch(Ne){ot(e,e.return,Ne)}}else if((te.tag!==22&&te.tag!==23||te.memoizedState===null||te===e)&&te.child!==null){te.child.return=te,te=te.child;continue}if(te===e)break e;for(;te.sibling===null;){if(te.return===null||te.return===e)break e;X===te&&(X=null),te=te.return}X===te&&(X=null),te.sibling.return=te.return,te=te.sibling}}break;case 19:un(n,e),wn(e),l&4&&_d(e);break;case 21:break;default:un(n,e),wn(e)}}function wn(e){var n=e.flags;if(n&2){try{e:{for(var i=e.return;i!==null;){if(Id(i)){var l=i;break e}i=i.return}throw Error(a(160))}switch(l.tag){case 5:var d=l.stateNode;l.flags&32&&(Oe(d,""),l.flags&=-33);var m=Ad(e);nl(e,m,d);break;case 3:case 4:var x=l.stateNode.containerInfo,k=Ad(e);tl(e,k,x);break;default:throw Error(a(161))}}catch(I){ot(e,e.return,I)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function rg(e,n,i){we=e,Ld(e)}function Ld(e,n,i){for(var l=(e.mode&1)!==0;we!==null;){var d=we,m=d.child;if(d.tag===22&&l){var x=d.memoizedState!==null||Va;if(!x){var k=d.alternate,I=k!==null&&k.memoizedState!==null||At;k=Va;var U=At;if(Va=x,(At=I)&&!U)for(we=d;we!==null;)x=we,I=x.child,x.tag===22&&x.memoizedState!==null?Od(d):I!==null?(I.return=x,we=I):Od(d);for(;m!==null;)we=m,Ld(m),m=m.sibling;we=d,Va=k,At=U}zd(e)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,we=m):zd(e)}}function zd(e){for(;we!==null;){var n=we;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:At||Ga(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!At)if(i===null)l.componentDidMount();else{var d=n.elementType===n.type?i.memoizedProps:ln(n.type,i.memoizedProps);l.componentDidUpdate(d,i.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var m=n.updateQueue;m!==null&&Fu(n,m,l);break;case 3:var x=n.updateQueue;if(x!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}Fu(n,x,i)}break;case 5:var k=n.stateNode;if(i===null&&n.flags&4){i=k;var I=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":I.autoFocus&&i.focus();break;case"img":I.src&&(i.src=I.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var U=n.alternate;if(U!==null){var X=U.memoizedState;if(X!==null){var te=X.dehydrated;te!==null&&ds(te)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}At||n.flags&512&&el(n)}catch(Q){ot(n,n.return,Q)}}if(n===e){we=null;break}if(i=n.sibling,i!==null){i.return=n.return,we=i;break}we=n.return}}function Fd(e){for(;we!==null;){var n=we;if(n===e){we=null;break}var i=n.sibling;if(i!==null){i.return=n.return,we=i;break}we=n.return}}function Od(e){for(;we!==null;){var n=we;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{Ga(4,n)}catch(I){ot(n,i,I)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var d=n.return;try{l.componentDidMount()}catch(I){ot(n,d,I)}}var m=n.return;try{el(n)}catch(I){ot(n,m,I)}break;case 5:var x=n.return;try{el(n)}catch(I){ot(n,x,I)}}}catch(I){ot(n,n.return,I)}if(n===e){we=null;break}var k=n.sibling;if(k!==null){k.return=n.return,we=k;break}we=n.return}}var sg=Math.ceil,Ka=A.ReactCurrentDispatcher,rl=A.ReactCurrentOwner,Zt=A.ReactCurrentBatchConfig,We=0,St=null,mt=null,Ct=0,Gt=0,Gr=Un(0),vt=0,$s=null,hr=0,qa=0,sl=0,Ls=null,Ot=null,al=0,Kr=1/0,An=null,Ya=!1,il=null,qn=null,Ja=!1,Yn=null,Qa=0,zs=0,ol=null,Xa=-1,Za=0;function _t(){return(We&6)!==0?lt():Xa!==-1?Xa:Xa=lt()}function Jn(e){return(e.mode&1)===0?1:(We&2)!==0&&Ct!==0?Ct&-Ct:Dp.transition!==null?(Za===0&&(Za=Ac()),Za):(e=Ke,e!==0||(e=window.event,e=e===void 0?16:Bc(e.type)),e)}function dn(e,n,i,l){if(50<zs)throw zs=0,ol=null,Error(a(185));is(e,i,l),((We&2)===0||e!==St)&&(e===St&&((We&2)===0&&(qa|=i),vt===4&&Qn(e,Ct)),Mt(e,l),i===1&&We===0&&(n.mode&1)===0&&(Kr=lt()+500,Ea&&Hn()))}function Mt(e,n){var i=e.callbackNode;Dm(e,n);var l=la(e,e===St?Ct:0);if(l===0)i!==null&&Tc(i),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(i!=null&&Tc(i),n===1)e.tag===0?Bp(Bd.bind(null,e)):Nu(Bd.bind(null,e)),zp(function(){(We&6)===0&&Hn()}),i=null;else{switch(Pc(l)){case 1:i=Mi;break;case 4:i=Rc;break;case 16:i=sa;break;case 536870912:i=Ic;break;default:i=sa}i=qd(i,Md.bind(null,e))}e.callbackPriority=n,e.callbackNode=i}}function Md(e,n){if(Xa=-1,Za=0,(We&6)!==0)throw Error(a(327));var i=e.callbackNode;if(qr()&&e.callbackNode!==i)return null;var l=la(e,e===St?Ct:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||n)n=ei(e,l);else{n=l;var d=We;We|=2;var m=Ud();(St!==e||Ct!==n)&&(An=null,Kr=lt()+500,pr(e,n));do try{og();break}catch(k){Dd(e,k)}while(!0);No(),Ka.current=m,We=d,mt!==null?n=0:(St=null,Ct=0,n=vt)}if(n!==0){if(n===2&&(d=Bi(e),d!==0&&(l=d,n=ll(e,d))),n===1)throw i=$s,pr(e,0),Qn(e,l),Mt(e,lt()),i;if(n===6)Qn(e,l);else{if(d=e.current.alternate,(l&30)===0&&!ag(d)&&(n=ei(e,l),n===2&&(m=Bi(e),m!==0&&(l=m,n=ll(e,m))),n===1))throw i=$s,pr(e,0),Qn(e,l),Mt(e,lt()),i;switch(e.finishedWork=d,e.finishedLanes=l,n){case 0:case 1:throw Error(a(345));case 2:gr(e,Ot,An);break;case 3:if(Qn(e,l),(l&130023424)===l&&(n=al+500-lt(),10<n)){if(la(e,0)!==0)break;if(d=e.suspendedLanes,(d&l)!==l){_t(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=mo(gr.bind(null,e,Ot,An),n);break}gr(e,Ot,An);break;case 4:if(Qn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,d=-1;0<l;){var x=31-sn(l);m=1<<x,x=n[x],x>d&&(d=x),l&=~m}if(l=d,l=lt()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*sg(l/1960))-l,10<l){e.timeoutHandle=mo(gr.bind(null,e,Ot,An),l);break}gr(e,Ot,An);break;case 5:gr(e,Ot,An);break;default:throw Error(a(329))}}}return Mt(e,lt()),e.callbackNode===i?Md.bind(null,e):null}function ll(e,n){var i=Ls;return e.current.memoizedState.isDehydrated&&(pr(e,n).flags|=256),e=ei(e,n),e!==2&&(n=Ot,Ot=i,n!==null&&cl(n)),e}function cl(e){Ot===null?Ot=e:Ot.push.apply(Ot,e)}function ag(e){for(var n=e;;){if(n.flags&16384){var i=n.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var l=0;l<i.length;l++){var d=i[l],m=d.getSnapshot;d=d.value;try{if(!an(m(),d))return!1}catch{return!1}}}if(i=n.child,n.subtreeFlags&16384&&i!==null)i.return=n,n=i;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Qn(e,n){for(n&=~sl,n&=~qa,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var i=31-sn(n),l=1<<i;e[i]=-1,n&=~l}}function Bd(e){if((We&6)!==0)throw Error(a(327));qr();var n=la(e,0);if((n&1)===0)return Mt(e,lt()),null;var i=ei(e,n);if(e.tag!==0&&i===2){var l=Bi(e);l!==0&&(n=l,i=ll(e,l))}if(i===1)throw i=$s,pr(e,0),Qn(e,n),Mt(e,lt()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,gr(e,Ot,An),Mt(e,lt()),null}function ul(e,n){var i=We;We|=1;try{return e(n)}finally{We=i,We===0&&(Kr=lt()+500,Ea&&Hn())}}function mr(e){Yn!==null&&Yn.tag===0&&(We&6)===0&&qr();var n=We;We|=1;var i=Zt.transition,l=Ke;try{if(Zt.transition=null,Ke=1,e)return e()}finally{Ke=l,Zt.transition=i,We=n,(We&6)===0&&Hn()}}function dl(){Gt=Gr.current,et(Gr)}function pr(e,n){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,Lp(i)),mt!==null)for(i=mt.return;i!==null;){var l=i;switch(wo(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&Na();break;case 3:Wr(),et(Lt),et(Tt),_o();break;case 5:Ao(l);break;case 4:Wr();break;case 13:et(at);break;case 19:et(at);break;case 10:Co(l.type._context);break;case 22:case 23:dl()}i=i.return}if(St=e,mt=e=Xn(e.current,null),Ct=Gt=n,vt=0,$s=null,sl=qa=hr=0,Ot=Ls=null,ur!==null){for(n=0;n<ur.length;n++)if(i=ur[n],l=i.interleaved,l!==null){i.interleaved=null;var d=l.next,m=i.pending;if(m!==null){var x=m.next;m.next=d,l.next=x}i.pending=l}ur=null}return e}function Dd(e,n){do{var i=mt;try{if(No(),Fa.current=Da,Oa){for(var l=it.memoizedState;l!==null;){var d=l.queue;d!==null&&(d.pending=null),l=l.next}Oa=!1}if(fr=0,jt=yt=it=null,Ts=!1,Rs=0,rl.current=null,i===null||i.return===null){vt=1,$s=n,mt=null;break}e:{var m=e,x=i.return,k=i,I=n;if(n=Ct,k.flags|=32768,I!==null&&typeof I=="object"&&typeof I.then=="function"){var U=I,X=k,te=X.tag;if((X.mode&1)===0&&(te===0||te===11||te===15)){var Q=X.alternate;Q?(X.updateQueue=Q.updateQueue,X.memoizedState=Q.memoizedState,X.lanes=Q.lanes):(X.updateQueue=null,X.memoizedState=null)}var ye=fd(x);if(ye!==null){ye.flags&=-257,hd(ye,x,k,m,n),ye.mode&1&&dd(m,U,n),n=ye,I=U;var be=n.updateQueue;if(be===null){var Ne=new Set;Ne.add(I),n.updateQueue=Ne}else be.add(I);break e}else{if((n&1)===0){dd(m,U,n),fl();break e}I=Error(a(426))}}else if(rt&&k.mode&1){var ct=fd(x);if(ct!==null){(ct.flags&65536)===0&&(ct.flags|=256),hd(ct,x,k,m,n),bo(Hr(I,k));break e}}m=I=Hr(I,k),vt!==4&&(vt=2),Ls===null?Ls=[m]:Ls.push(m),m=x;do{switch(m.tag){case 3:m.flags|=65536,n&=-n,m.lanes|=n;var z=cd(m,I,n);zu(m,z);break e;case 1:k=I;var _=m.type,B=m.stateNode;if((m.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||B!==null&&typeof B.componentDidCatch=="function"&&(qn===null||!qn.has(B)))){m.flags|=65536,n&=-n,m.lanes|=n;var le=ud(m,k,n);zu(m,le);break e}}m=m.return}while(m!==null)}Hd(i)}catch(Ce){n=Ce,mt===i&&i!==null&&(mt=i=i.return);continue}break}while(!0)}function Ud(){var e=Ka.current;return Ka.current=Da,e===null?Da:e}function fl(){(vt===0||vt===3||vt===2)&&(vt=4),St===null||(hr&268435455)===0&&(qa&268435455)===0||Qn(St,Ct)}function ei(e,n){var i=We;We|=2;var l=Ud();(St!==e||Ct!==n)&&(An=null,pr(e,n));do try{ig();break}catch(d){Dd(e,d)}while(!0);if(No(),We=i,Ka.current=l,mt!==null)throw Error(a(261));return St=null,Ct=0,vt}function ig(){for(;mt!==null;)Wd(mt)}function og(){for(;mt!==null&&!Pm();)Wd(mt)}function Wd(e){var n=Kd(e.alternate,e,Gt);e.memoizedProps=e.pendingProps,n===null?Hd(e):mt=n,rl.current=null}function Hd(e){var n=e;do{var i=n.alternate;if(e=n.return,(n.flags&32768)===0){if(i=Zp(i,n,Gt),i!==null){mt=i;return}}else{if(i=eg(i,n),i!==null){i.flags&=32767,mt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{vt=6,mt=null;return}}if(n=n.sibling,n!==null){mt=n;return}mt=n=e}while(n!==null);vt===0&&(vt=5)}function gr(e,n,i){var l=Ke,d=Zt.transition;try{Zt.transition=null,Ke=1,lg(e,n,i,l)}finally{Zt.transition=d,Ke=l}return null}function lg(e,n,i,l){do qr();while(Yn!==null);if((We&6)!==0)throw Error(a(327));i=e.finishedWork;var d=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var m=i.lanes|i.childLanes;if(Um(e,m),e===St&&(mt=St=null,Ct=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Ja||(Ja=!0,qd(sa,function(){return qr(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=Zt.transition,Zt.transition=null;var x=Ke;Ke=1;var k=We;We|=4,rl.current=null,ng(e,i),$d(i,e),Tp(fo),da=!!uo,fo=uo=null,e.current=i,rg(i),_m(),We=k,Ke=x,Zt.transition=m}else e.current=i;if(Ja&&(Ja=!1,Yn=e,Qa=d),m=e.pendingLanes,m===0&&(qn=null),zm(i.stateNode),Mt(e,lt()),n!==null)for(l=e.onRecoverableError,i=0;i<n.length;i++)d=n[i],l(d.value,{componentStack:d.stack,digest:d.digest});if(Ya)throw Ya=!1,e=il,il=null,e;return(Qa&1)!==0&&e.tag!==0&&qr(),m=e.pendingLanes,(m&1)!==0?e===ol?zs++:(zs=0,ol=e):zs=0,Hn(),null}function qr(){if(Yn!==null){var e=Pc(Qa),n=Zt.transition,i=Ke;try{if(Zt.transition=null,Ke=16>e?16:e,Yn===null)var l=!1;else{if(e=Yn,Yn=null,Qa=0,(We&6)!==0)throw Error(a(331));var d=We;for(We|=4,we=e.current;we!==null;){var m=we,x=m.child;if((we.flags&16)!==0){var k=m.deletions;if(k!==null){for(var I=0;I<k.length;I++){var U=k[I];for(we=U;we!==null;){var X=we;switch(X.tag){case 0:case 11:case 15:_s(8,X,m)}var te=X.child;if(te!==null)te.return=X,we=te;else for(;we!==null;){X=we;var Q=X.sibling,ye=X.return;if(Rd(X),X===U){we=null;break}if(Q!==null){Q.return=ye,we=Q;break}we=ye}}}var be=m.alternate;if(be!==null){var Ne=be.child;if(Ne!==null){be.child=null;do{var ct=Ne.sibling;Ne.sibling=null,Ne=ct}while(Ne!==null)}}we=m}}if((m.subtreeFlags&2064)!==0&&x!==null)x.return=m,we=x;else e:for(;we!==null;){if(m=we,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:_s(9,m,m.return)}var z=m.sibling;if(z!==null){z.return=m.return,we=z;break e}we=m.return}}var _=e.current;for(we=_;we!==null;){x=we;var B=x.child;if((x.subtreeFlags&2064)!==0&&B!==null)B.return=x,we=B;else e:for(x=_;we!==null;){if(k=we,(k.flags&2048)!==0)try{switch(k.tag){case 0:case 11:case 15:Ga(9,k)}}catch(Ce){ot(k,k.return,Ce)}if(k===x){we=null;break e}var le=k.sibling;if(le!==null){le.return=k.return,we=le;break e}we=k.return}}if(We=d,Hn(),gn&&typeof gn.onPostCommitFiberRoot=="function")try{gn.onPostCommitFiberRoot(aa,e)}catch{}l=!0}return l}finally{Ke=i,Zt.transition=n}}return!1}function Vd(e,n,i){n=Hr(i,n),n=cd(e,n,1),e=Gn(e,n,1),n=_t(),e!==null&&(is(e,1,n),Mt(e,n))}function ot(e,n,i){if(e.tag===3)Vd(e,e,i);else for(;n!==null;){if(n.tag===3){Vd(n,e,i);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(qn===null||!qn.has(l))){e=Hr(i,e),e=ud(n,e,1),n=Gn(n,e,1),e=_t(),n!==null&&(is(n,1,e),Mt(n,e));break}}n=n.return}}function cg(e,n,i){var l=e.pingCache;l!==null&&l.delete(n),n=_t(),e.pingedLanes|=e.suspendedLanes&i,St===e&&(Ct&i)===i&&(vt===4||vt===3&&(Ct&130023424)===Ct&&500>lt()-al?pr(e,0):sl|=i),Mt(e,n)}function Gd(e,n){n===0&&((e.mode&1)===0?n=1:(n=oa,oa<<=1,(oa&130023424)===0&&(oa=4194304)));var i=_t();e=Tn(e,n),e!==null&&(is(e,n,i),Mt(e,i))}function ug(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Gd(e,i)}function dg(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,d=e.memoizedState;d!==null&&(i=d.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(a(314))}l!==null&&l.delete(n),Gd(e,i)}var Kd;Kd=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Lt.current)Ft=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Ft=!1,Xp(e,n,i);Ft=(e.flags&131072)!==0}else Ft=!1,rt&&(n.flags&1048576)!==0&&Cu(n,Ra,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ha(e,n),e=n.pendingProps;var d=zr(n,Tt.current);Ur(n,i),d=zo(null,n,l,e,d,i);var m=Fo();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,zt(l)?(m=!0,Ca(n)):m=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Ro(n),d.updater=Ua,n.stateNode=d,d._reactInternals=n,Wo(n,l,e,i),n=Ko(null,n,l,!0,m,i)):(n.tag=0,rt&&m&&xo(n),Pt(null,n,d,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ha(e,n),e=n.pendingProps,d=l._init,l=d(l._payload),n.type=l,d=n.tag=hg(l),e=ln(l,e),d){case 0:n=Go(null,n,l,e,i);break e;case 1:n=xd(null,n,l,e,i);break e;case 11:n=md(null,n,l,e,i);break e;case 14:n=pd(null,n,l,ln(l.type,e),i);break e}throw Error(a(306,l,""))}return n;case 0:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),Go(e,n,l,d,i);case 1:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),xd(e,n,l,d,i);case 3:e:{if(wd(n),e===null)throw Error(a(387));l=n.pendingProps,m=n.memoizedState,d=m.element,Lu(e,n),La(n,l,null,i);var x=n.memoizedState;if(l=x.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){d=Hr(Error(a(423)),n),n=jd(e,n,l,i,d);break e}else if(l!==d){d=Hr(Error(a(424)),n),n=jd(e,n,l,i,d);break e}else for(Vt=Dn(n.stateNode.containerInfo.firstChild),Ht=n,rt=!0,on=null,i=_u(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Mr(),l===d){n=In(e,n,i);break e}Pt(e,n,l,i)}n=n.child}return n;case 5:return Ou(n),e===null&&So(n),l=n.type,d=n.pendingProps,m=e!==null?e.memoizedProps:null,x=d.children,ho(l,d)?x=null:m!==null&&ho(l,m)&&(n.flags|=32),vd(e,n),Pt(e,n,x,i),n.child;case 6:return e===null&&So(n),null;case 13:return Sd(e,n,i);case 4:return Io(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Br(n,null,l,i):Pt(e,n,l,i),n.child;case 11:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),md(e,n,l,d,i);case 7:return Pt(e,n,n.pendingProps,i),n.child;case 8:return Pt(e,n,n.pendingProps.children,i),n.child;case 12:return Pt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,d=n.pendingProps,m=n.memoizedProps,x=d.value,Qe(Pa,l._currentValue),l._currentValue=x,m!==null)if(an(m.value,x)){if(m.children===d.children&&!Lt.current){n=In(e,n,i);break e}}else for(m=n.child,m!==null&&(m.return=n);m!==null;){var k=m.dependencies;if(k!==null){x=m.child;for(var I=k.firstContext;I!==null;){if(I.context===l){if(m.tag===1){I=Rn(-1,i&-i),I.tag=2;var U=m.updateQueue;if(U!==null){U=U.shared;var X=U.pending;X===null?I.next=I:(I.next=X.next,X.next=I),U.pending=I}}m.lanes|=i,I=m.alternate,I!==null&&(I.lanes|=i),Eo(m.return,i,n),k.lanes|=i;break}I=I.next}}else if(m.tag===10)x=m.type===n.type?null:m.child;else if(m.tag===18){if(x=m.return,x===null)throw Error(a(341));x.lanes|=i,k=x.alternate,k!==null&&(k.lanes|=i),Eo(x,i,n),x=m.sibling}else x=m.child;if(x!==null)x.return=m;else for(x=m;x!==null;){if(x===n){x=null;break}if(m=x.sibling,m!==null){m.return=x.return,x=m;break}x=x.return}m=x}Pt(e,n,d.children,i),n=n.child}return n;case 9:return d=n.type,l=n.pendingProps.children,Ur(n,i),d=Qt(d),l=l(d),n.flags|=1,Pt(e,n,l,i),n.child;case 14:return l=n.type,d=ln(l,n.pendingProps),d=ln(l.type,d),pd(e,n,l,d,i);case 15:return gd(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),Ha(e,n),n.tag=1,zt(l)?(e=!0,Ca(n)):e=!1,Ur(n,i),od(n,l,d),Wo(n,l,d,i),Ko(null,n,l,!0,e,i);case 19:return kd(e,n,i);case 22:return yd(e,n,i)}throw Error(a(156,n.tag))};function qd(e,n){return Ec(e,n)}function fg(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function en(e,n,i,l){return new fg(e,n,i,l)}function hl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hg(e){if(typeof e=="function")return hl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===D)return 11;if(e===Z)return 14}return 2}function Xn(e,n){var i=e.alternate;return i===null?(i=en(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ti(e,n,i,l,d,m){var x=2;if(l=e,typeof e=="function")hl(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case q:return yr(i.children,d,m,n);case de:x=8,d|=8;break;case K:return e=en(12,i,n,d|2),e.elementType=K,e.lanes=m,e;case ce:return e=en(13,i,n,d),e.elementType=ce,e.lanes=m,e;case re:return e=en(19,i,n,d),e.elementType=re,e.lanes=m,e;case ge:return ni(i,d,m,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case oe:x=10;break e;case V:x=9;break e;case D:x=11;break e;case Z:x=14;break e;case he:x=16,l=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return n=en(x,i,n,d),n.elementType=e,n.type=l,n.lanes=m,n}function yr(e,n,i,l){return e=en(7,e,l,n),e.lanes=i,e}function ni(e,n,i,l){return e=en(22,e,l,n),e.elementType=ge,e.lanes=i,e.stateNode={isHidden:!1},e}function ml(e,n,i){return e=en(6,e,null,n),e.lanes=i,e}function pl(e,n,i){return n=en(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function mg(e,n,i,l,d){this.tag=n,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=Di(0),this.expirationTimes=Di(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Di(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function gl(e,n,i,l,d,m,x,k,I){return e=new mg(e,n,i,k,I),n===1?(n=1,m===!0&&(n|=8)):n=0,m=en(3,null,null,n),e.current=m,m.stateNode=e,m.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ro(m),e}function pg(e,n,i){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:G,key:l==null?null:""+l,children:e,containerInfo:n,implementation:i}}function Yd(e){if(!e)return Wn;e=e._reactInternals;e:{if(ar(e)!==e||e.tag!==1)throw Error(a(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(zt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(a(171))}if(e.tag===1){var i=e.type;if(zt(i))return bu(e,i,n)}return n}function Jd(e,n,i,l,d,m,x,k,I){return e=gl(i,l,!0,e,d,m,x,k,I),e.context=Yd(null),i=e.current,l=_t(),d=Jn(i),m=Rn(l,d),m.callback=n??null,Gn(i,m,d),e.current.lanes=d,is(e,d,l),Mt(e,l),e}function ri(e,n,i,l){var d=n.current,m=_t(),x=Jn(d);return i=Yd(i),n.context===null?n.context=i:n.pendingContext=i,n=Rn(m,x),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=Gn(d,n,x),e!==null&&(dn(e,d,x,m),$a(e,d,x)),x}function si(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Qd(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<n?i:n}}function yl(e,n){Qd(e,n),(e=e.alternate)&&Qd(e,n)}function gg(){return null}var Xd=typeof reportError=="function"?reportError:function(e){console.error(e)};function vl(e){this._internalRoot=e}ai.prototype.render=vl.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));ri(e,n,null,null)},ai.prototype.unmount=vl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;mr(function(){ri(null,e,null,null)}),n[kn]=null}};function ai(e){this._internalRoot=e}ai.prototype.unstable_scheduleHydration=function(e){if(e){var n=Lc();e={blockedOn:null,target:e,priority:n};for(var i=0;i<On.length&&n!==0&&n<On[i].priority;i++);On.splice(i,0,e),i===0&&Oc(e)}};function xl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ii(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zd(){}function yg(e,n,i,l,d){if(d){if(typeof l=="function"){var m=l;l=function(){var U=si(x);m.call(U)}}var x=Jd(n,l,e,0,null,!1,!1,"",Zd);return e._reactRootContainer=x,e[kn]=x.current,ws(e.nodeType===8?e.parentNode:e),mr(),x}for(;d=e.lastChild;)e.removeChild(d);if(typeof l=="function"){var k=l;l=function(){var U=si(I);k.call(U)}}var I=gl(e,0,!1,null,null,!1,!1,"",Zd);return e._reactRootContainer=I,e[kn]=I.current,ws(e.nodeType===8?e.parentNode:e),mr(function(){ri(n,I,i,l)}),I}function oi(e,n,i,l,d){var m=i._reactRootContainer;if(m){var x=m;if(typeof d=="function"){var k=d;d=function(){var I=si(x);k.call(I)}}ri(n,x,e,d)}else x=yg(i,n,e,d,l);return si(x)}_c=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var i=as(n.pendingLanes);i!==0&&(Ui(n,i|1),Mt(n,lt()),(We&6)===0&&(Kr=lt()+500,Hn()))}break;case 13:mr(function(){var l=Tn(e,1);if(l!==null){var d=_t();dn(l,e,1,d)}}),yl(e,1)}},Wi=function(e){if(e.tag===13){var n=Tn(e,134217728);if(n!==null){var i=_t();dn(n,e,134217728,i)}yl(e,134217728)}},$c=function(e){if(e.tag===13){var n=Jn(e),i=Tn(e,n);if(i!==null){var l=_t();dn(i,e,n,l)}yl(e,n)}},Lc=function(){return Ke},zc=function(e,n){var i=Ke;try{return Ke=e,n()}finally{Ke=i}},ie=function(e,n,i){switch(n){case"input":if(je(e,i),n=i.name,i.type==="radio"&&n!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<i.length;n++){var l=i[n];if(l!==e&&l.form===e.form){var d=ka(l);if(!d)throw Error(a(90));Le(l),je(l,d)}}}break;case"textarea":ze(e,i);break;case"select":n=i.value,n!=null&&tt(e,!!i.multiple,n,!1)}},Ut=ul,er=mr;var vg={usingClientEntryPoint:!1,Events:[bs,$r,ka,Fe,Je,ul]},Fs={findFiberByHostInstance:ir,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xg={bundleType:Fs.bundleType,version:Fs.version,rendererPackageName:Fs.rendererPackageName,rendererConfig:Fs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Nc(e),e===null?null:e.stateNode},findFiberByHostInstance:Fs.findFiberByHostInstance||gg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var li=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!li.isDisabled&&li.supportsFiber)try{aa=li.inject(xg),gn=li}catch{}}return Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vg,Bt.createPortal=function(e,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xl(n))throw Error(a(200));return pg(e,n,null,i)},Bt.createRoot=function(e,n){if(!xl(e))throw Error(a(299));var i=!1,l="",d=Xd;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=gl(e,1,!1,null,null,i,!1,l,d),e[kn]=n.current,ws(e.nodeType===8?e.parentNode:e),new vl(n)},Bt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=Nc(n),e=e===null?null:e.stateNode,e},Bt.flushSync=function(e){return mr(e)},Bt.hydrate=function(e,n,i){if(!ii(n))throw Error(a(200));return oi(null,e,n,!0,i)},Bt.hydrateRoot=function(e,n,i){if(!xl(e))throw Error(a(405));var l=i!=null&&i.hydratedSources||null,d=!1,m="",x=Xd;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(x=i.onRecoverableError)),n=Jd(n,null,e,1,i??null,d,!1,m,x),e[kn]=n.current,ws(e),l)for(e=0;e<l.length;e++)i=l[e],d=i._getVersion,d=d(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,d]:n.mutableSourceEagerHydrationData.push(i,d);return new ai(n)},Bt.render=function(e,n,i){if(!ii(n))throw Error(a(200));return oi(null,e,n,!1,i)},Bt.unmountComponentAtNode=function(e){if(!ii(e))throw Error(a(40));return e._reactRootContainer?(mr(function(){oi(null,null,e,!1,function(){e._reactRootContainer=null,e[kn]=null})}),!0):!1},Bt.unstable_batchedUpdates=ul,Bt.unstable_renderSubtreeIntoContainer=function(e,n,i,l){if(!ii(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return oi(e,n,i,!1,l)},Bt.version="18.3.1-next-f1338f8080-20240426",Bt}var lf;function sh(){if(lf)return Sl.exports;lf=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Sl.exports=Tg(),Sl.exports}var cf;function Rg(){if(cf)return ci;cf=1;var t=sh();return ci.createRoot=t.createRoot,ci.hydrateRoot=t.hydrateRoot,ci}var Ig=Rg();/**
|
|
40
|
+
`+m.stack}return{value:e,source:n,stack:d,digest:null}}function Ho(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function Vo(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Yp=typeof WeakMap=="function"?WeakMap:Map;function cd(e,n,i){i=Rn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){Ya||(Ya=!0,il=l),Vo(e,n)},i}function ud(e,n,i){i=Rn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var d=n.value;i.payload=function(){return l(d)},i.callback=function(){Vo(e,n)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){Vo(e,n),typeof l!="function"&&(qn===null?qn=new Set([this]):qn.add(this));var x=n.stack;this.componentDidCatch(n.value,{componentStack:x!==null?x:""})}),i}function dd(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new Yp;var d=new Set;l.set(n,d)}else d=l.get(n),d===void 0&&(d=new Set,l.set(n,d));d.has(i)||(d.add(i),e=cg.bind(null,e,n,i),n.then(e,e))}function fd(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function hd(e,n,i,l,d){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Rn(-1,1),n.tag=2,Gn(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Jp=A.ReactCurrentOwner,Ft=!1;function Pt(e,n,i,l){n.child=e===null?_u(n,null,i,l):Br(n,e.child,i,l)}function md(e,n,i,l,d){i=i.render;var m=n.ref;return Ur(n,d),l=zo(e,n,i,l,m,d),i=Fo(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,In(e,n,d)):(rt&&i&&xo(n),n.flags|=1,Pt(e,n,l,d),n.child)}function pd(e,n,i,l,d){if(e===null){var m=i.type;return typeof m=="function"&&!hl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=m,gd(e,n,m,l,d)):(e=ti(i.type,null,l,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(m=e.child,(e.lanes&d)===0){var x=m.memoizedProps;if(i=i.compare,i=i!==null?i:ys,i(x,l)&&e.ref===n.ref)return In(e,n,d)}return n.flags|=1,e=Xn(m,l),e.ref=n.ref,e.return=n,n.child=e}function gd(e,n,i,l,d){if(e!==null){var m=e.memoizedProps;if(ys(m,l)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=l=m,(e.lanes&d)!==0)(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,In(e,n,d)}return Go(e,n,i,l,d)}function yd(e,n,i){var l=n.pendingProps,d=l.children,m=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qe(Gr,Gt),Gt|=i;else{if((i&1073741824)===0)return e=m!==null?m.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Qe(Gr,Gt),Gt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=m!==null?m.baseLanes:i,Qe(Gr,Gt),Gt|=l}else m!==null?(l=m.baseLanes|i,n.memoizedState=null):l=i,Qe(Gr,Gt),Gt|=l;return Pt(e,n,d,i),n.child}function vd(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Go(e,n,i,l,d){var m=zt(i)?or:Tt.current;return m=zr(n,m),Ur(n,d),i=zo(e,n,i,l,m,d),l=Fo(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~d,In(e,n,d)):(rt&&l&&xo(n),n.flags|=1,Pt(e,n,i,d),n.child)}function xd(e,n,i,l,d){if(zt(i)){var m=!0;Ca(n)}else m=!1;if(Ur(n,d),n.stateNode===null)Ha(e,n),od(n,i,l),Wo(n,i,l,d),l=!0;else if(e===null){var x=n.stateNode,k=n.memoizedProps;x.props=k;var I=x.context,U=i.contextType;typeof U=="object"&&U!==null?U=Qt(U):(U=zt(i)?or:Tt.current,U=zr(n,U));var X=i.getDerivedStateFromProps,te=typeof X=="function"||typeof x.getSnapshotBeforeUpdate=="function";te||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(k!==l||I!==U)&&ld(n,x,l,U),Vn=!1;var Q=n.memoizedState;x.state=Q,La(n,l,x,d),I=n.memoizedState,k!==l||Q!==I||Lt.current||Vn?(typeof X=="function"&&(Uo(n,i,X,l),I=n.memoizedState),(k=Vn||id(n,i,k,l,Q,I,U))?(te||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=I),x.props=l,x.state=I,x.context=U,l=k):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{x=n.stateNode,Lu(e,n),k=n.memoizedProps,U=n.type===n.elementType?k:ln(n.type,k),x.props=U,te=n.pendingProps,Q=x.context,I=i.contextType,typeof I=="object"&&I!==null?I=Qt(I):(I=zt(i)?or:Tt.current,I=zr(n,I));var ye=i.getDerivedStateFromProps;(X=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(k!==te||Q!==I)&&ld(n,x,l,I),Vn=!1,Q=n.memoizedState,x.state=Q,La(n,l,x,d);var be=n.memoizedState;k!==te||Q!==be||Lt.current||Vn?(typeof ye=="function"&&(Uo(n,i,ye,l),be=n.memoizedState),(U=Vn||id(n,i,U,l,Q,be,I)||!1)?(X||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(l,be,I),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(l,be,I)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=be),x.props=l,x.state=be,x.context=I,l=U):(typeof x.componentDidUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||k===e.memoizedProps&&Q===e.memoizedState||(n.flags|=1024),l=!1)}return Ko(e,n,i,l,m,d)}function Ko(e,n,i,l,d,m){vd(e,n);var x=(n.flags&128)!==0;if(!l&&!x)return d&&ku(n,i,!1),In(e,n,m);l=n.stateNode,Jp.current=n;var k=x&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&x?(n.child=Br(n,e.child,null,m),n.child=Br(n,null,k,m)):Pt(e,n,k,m),n.memoizedState=l.state,d&&ku(n,i,!0),n.child}function wd(e){var n=e.stateNode;n.pendingContext?Su(e,n.pendingContext,n.pendingContext!==n.context):n.context&&Su(e,n.context,!1),Io(e,n.containerInfo)}function jd(e,n,i,l,d){return Mr(),bo(d),n.flags|=256,Pt(e,n,i,l),n.child}var qo={dehydrated:null,treeContext:null,retryLane:0};function Yo(e){return{baseLanes:e,cachePool:null,transitions:null}}function Sd(e,n,i){var l=n.pendingProps,d=at.current,m=!1,x=(n.flags&128)!==0,k;if((k=x)||(k=e!==null&&e.memoizedState===null?!1:(d&2)!==0),k?(m=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),Qe(at,d&1),e===null)return So(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(x=l.children,e=l.fallback,m?(l=n.mode,m=n.child,x={mode:"hidden",children:x},(l&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=x):m=ni(x,l,0,null),e=yr(e,l,i,null),m.return=n,e.return=n,m.sibling=e,n.child=m,n.child.memoizedState=Yo(i),n.memoizedState=qo,e):Jo(n,x));if(d=e.memoizedState,d!==null&&(k=d.dehydrated,k!==null))return Qp(e,n,x,l,k,d,i);if(m){m=l.fallback,x=n.mode,d=e.child,k=d.sibling;var I={mode:"hidden",children:l.children};return(x&1)===0&&n.child!==d?(l=n.child,l.childLanes=0,l.pendingProps=I,n.deletions=null):(l=Xn(d,I),l.subtreeFlags=d.subtreeFlags&14680064),k!==null?m=Xn(k,m):(m=yr(m,x,i,null),m.flags|=2),m.return=n,l.return=n,l.sibling=m,n.child=l,l=m,m=n.child,x=e.child.memoizedState,x=x===null?Yo(i):{baseLanes:x.baseLanes|i,cachePool:null,transitions:x.transitions},m.memoizedState=x,m.childLanes=e.childLanes&~i,n.memoizedState=qo,l}return m=e.child,e=m.sibling,l=Xn(m,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function Jo(e,n){return n=ni({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Wa(e,n,i,l){return l!==null&&bo(l),Br(n,e.child,null,i),e=Jo(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Qp(e,n,i,l,d,m,x){if(i)return n.flags&256?(n.flags&=-257,l=Ho(Error(a(422))),Wa(e,n,x,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(m=l.fallback,d=n.mode,l=ni({mode:"visible",children:l.children},d,0,null),m=yr(m,d,x,null),m.flags|=2,l.return=n,m.return=n,l.sibling=m,n.child=l,(n.mode&1)!==0&&Br(n,e.child,null,x),n.child.memoizedState=Yo(x),n.memoizedState=qo,m);if((n.mode&1)===0)return Wa(e,n,x,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var k=l.dgst;return l=k,m=Error(a(419)),l=Ho(m,l,void 0),Wa(e,n,x,l)}if(k=(x&e.childLanes)!==0,Ft||k){if(l=St,l!==null){switch(x&-x){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|x))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,Tn(e,d),dn(l,e,d,-1))}return fl(),l=Ho(Error(a(421))),Wa(e,n,x,l)}return d.data==="$?"?(n.flags|=128,n.child=e.child,n=ug.bind(null,e),d._reactRetry=n,null):(e=m.treeContext,Vt=Dn(d.nextSibling),Ht=n,rt=!0,on=null,e!==null&&(Yt[Jt++]=Cn,Yt[Jt++]=En,Yt[Jt++]=lr,Cn=e.id,En=e.overflow,lr=n),n=Jo(n,l.children),n.flags|=4096,n)}function bd(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Eo(e.return,n,i)}function Qo(e,n,i,l,d){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:d}:(m.isBackwards=n,m.rendering=null,m.renderingStartTime=0,m.last=l,m.tail=i,m.tailMode=d)}function kd(e,n,i){var l=n.pendingProps,d=l.revealOrder,m=l.tail;if(Pt(e,n,l.children,i),l=at.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&bd(e,i,n);else if(e.tag===19)bd(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Qe(at,l),(n.mode&1)===0)n.memoizedState=null;else switch(d){case"forwards":for(i=n.child,d=null;i!==null;)e=i.alternate,e!==null&&za(e)===null&&(d=i),i=i.sibling;i=d,i===null?(d=n.child,n.child=null):(d=i.sibling,i.sibling=null),Qo(n,!1,d,i,m);break;case"backwards":for(i=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&za(e)===null){n.child=d;break}e=d.sibling,d.sibling=i,i=d,d=e}Qo(n,!0,i,null,m);break;case"together":Qo(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Ha(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function In(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),hr|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,i=Xn(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Xn(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Xp(e,n,i){switch(n.tag){case 3:wd(n),Mr();break;case 5:Ou(n);break;case 1:zt(n.type)&&Ca(n);break;case 4:Io(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,d=n.memoizedProps.value;Qe(Pa,l._currentValue),l._currentValue=d;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Qe(at,at.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?Sd(e,n,i):(Qe(at,at.current&1),e=In(e,n,i),e!==null?e.sibling:null);Qe(at,at.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return kd(e,n,i);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),Qe(at,at.current),l)break;return null;case 22:case 23:return n.lanes=0,yd(e,n,i)}return In(e,n,i)}var Nd,Xo,Cd,Ed;Nd=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Xo=function(){},Cd=function(e,n,i,l){var d=e.memoizedProps;if(d!==l){e=n.stateNode,dr(vn.current);var m=null;switch(i){case"input":d=_e(e,d),l=_e(e,l),m=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),m=[];break;case"textarea":d=gt(e,d),l=gt(e,l),m=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=ba)}nt(i,l);var x;i=null;for(U in d)if(!l.hasOwnProperty(U)&&d.hasOwnProperty(U)&&d[U]!=null)if(U==="style"){var k=d[U];for(x in k)k.hasOwnProperty(x)&&(i||(i={}),i[x]="")}else U!=="dangerouslySetInnerHTML"&&U!=="children"&&U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(c.hasOwnProperty(U)?m||(m=[]):(m=m||[]).push(U,null));for(U in l){var I=l[U];if(k=d!=null?d[U]:void 0,l.hasOwnProperty(U)&&I!==k&&(I!=null||k!=null))if(U==="style")if(k){for(x in k)!k.hasOwnProperty(x)||I&&I.hasOwnProperty(x)||(i||(i={}),i[x]="");for(x in I)I.hasOwnProperty(x)&&k[x]!==I[x]&&(i||(i={}),i[x]=I[x])}else i||(m||(m=[]),m.push(U,i)),i=I;else U==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,k=k?k.__html:void 0,I!=null&&k!==I&&(m=m||[]).push(U,I)):U==="children"?typeof I!="string"&&typeof I!="number"||(m=m||[]).push(U,""+I):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&(c.hasOwnProperty(U)?(I!=null&&U==="onScroll"&&Ze("scroll",e),m||k===I||(m=[])):(m=m||[]).push(U,I))}i&&(m=m||[]).push("style",i);var U=m;(n.updateQueue=U)&&(n.flags|=4)}},Ed=function(e,n,i,l){i!==l&&(n.flags|=4)};function Ps(e,n){if(!rt)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var d=e.child;d!==null;)i|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)i|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Zp(e,n,i){var l=n.pendingProps;switch(wo(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(n),null;case 1:return zt(n.type)&&Na(),It(n),null;case 3:return l=n.stateNode,Wr(),et(Lt),et(Tt),_o(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ia(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,on!==null&&(cl(on),on=null))),Xo(e,n),It(n),null;case 5:Ao(n);var d=dr(Es.current);if(i=n.type,e!==null&&n.stateNode!=null)Cd(e,n,i,l,d),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(a(166));return It(n),null}if(e=dr(vn.current),Ia(n)){l=n.stateNode,i=n.type;var m=n.memoizedProps;switch(l[yn]=n,l[Ss]=m,e=(n.mode&1)!==0,i){case"dialog":Ze("cancel",l),Ze("close",l);break;case"iframe":case"object":case"embed":Ze("load",l);break;case"video":case"audio":for(d=0;d<xs.length;d++)Ze(xs[d],l);break;case"source":Ze("error",l);break;case"img":case"image":case"link":Ze("error",l),Ze("load",l);break;case"details":Ze("toggle",l);break;case"input":We(l,m),Ze("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!m.multiple},Ze("invalid",l);break;case"textarea":ft(l,m),Ze("invalid",l)}nt(i,m),d=null;for(var x in m)if(m.hasOwnProperty(x)){var k=m[x];x==="children"?typeof k=="string"?l.textContent!==k&&(m.suppressHydrationWarning!==!0&&Sa(l.textContent,k,e),d=["children",k]):typeof k=="number"&&l.textContent!==""+k&&(m.suppressHydrationWarning!==!0&&Sa(l.textContent,k,e),d=["children",""+k]):c.hasOwnProperty(x)&&k!=null&&x==="onScroll"&&Ze("scroll",l)}switch(i){case"input":Ee(l),$e(l,m,!0);break;case"textarea":Ee(l),P(l);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(l.onclick=ba)}l=d,n.updateQueue=l,l!==null&&(n.flags|=4)}else{x=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=ae(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=x.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=x.createElement(i,{is:l.is}):(e=x.createElement(i),i==="select"&&(x=e,l.multiple?x.multiple=!0:l.size&&(x.size=l.size))):e=x.createElementNS(e,i),e[yn]=n,e[Ss]=l,Nd(e,n,!1,!1),n.stateNode=e;e:{switch(x=kt(i,l),i){case"dialog":Ze("cancel",e),Ze("close",e),d=l;break;case"iframe":case"object":case"embed":Ze("load",e),d=l;break;case"video":case"audio":for(d=0;d<xs.length;d++)Ze(xs[d],e);d=l;break;case"source":Ze("error",e),d=l;break;case"img":case"image":case"link":Ze("error",e),Ze("load",e),d=l;break;case"details":Ze("toggle",e),d=l;break;case"input":We(e,l),d=_e(e,l),Ze("invalid",e);break;case"option":d=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},d=H({},l,{value:void 0}),Ze("invalid",e);break;case"textarea":ft(e,l),d=gt(e,l),Ze("invalid",e);break;default:d=l}nt(i,d),k=d;for(m in k)if(k.hasOwnProperty(m)){var I=k[m];m==="style"?pn(e,I):m==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,I!=null&&ue(e,I)):m==="children"?typeof I=="string"?(i!=="textarea"||I!=="")&&Oe(e,I):typeof I=="number"&&Oe(e,""+I):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(c.hasOwnProperty(m)?I!=null&&m==="onScroll"&&Ze("scroll",e):I!=null&&$(e,m,I,x))}switch(i){case"input":Ee(e),$e(e,l,!1);break;case"textarea":Ee(e),P(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ve(l.value));break;case"select":e.multiple=!!l.multiple,m=l.value,m!=null?tt(e,!!l.multiple,m,!1):l.defaultValue!=null&&tt(e,!!l.multiple,l.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=ba)}switch(i){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return It(n),null;case 6:if(e&&n.stateNode!=null)Ed(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(a(166));if(i=dr(Es.current),dr(vn.current),Ia(n)){if(l=n.stateNode,i=n.memoizedProps,l[yn]=n,(m=l.nodeValue!==i)&&(e=Ht,e!==null))switch(e.tag){case 3:Sa(l.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Sa(l.nodeValue,i,(e.mode&1)!==0)}m&&(n.flags|=4)}else l=(i.nodeType===9?i:i.ownerDocument).createTextNode(l),l[yn]=n,n.stateNode=l}return It(n),null;case 13:if(et(at),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rt&&Vt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Iu(),Mr(),n.flags|=98560,m=!1;else if(m=Ia(n),l!==null&&l.dehydrated!==null){if(e===null){if(!m)throw Error(a(318));if(m=n.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[yn]=n}else Mr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;It(n),m=!1}else on!==null&&(cl(on),on=null),m=!0;if(!m)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=i,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,(n.mode&1)!==0&&(e===null||(at.current&1)!==0?vt===0&&(vt=3):fl())),n.updateQueue!==null&&(n.flags|=4),It(n),null);case 4:return Wr(),Xo(e,n),e===null&&ws(n.stateNode.containerInfo),It(n),null;case 10:return Co(n.type._context),It(n),null;case 17:return zt(n.type)&&Na(),It(n),null;case 19:if(et(at),m=n.memoizedState,m===null)return It(n),null;if(l=(n.flags&128)!==0,x=m.rendering,x===null)if(l)Ps(m,!1);else{if(vt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=za(e),x!==null){for(n.flags|=128,Ps(m,!1),l=x.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=i,i=n.child;i!==null;)m=i,e=l,m.flags&=14680066,x=m.alternate,x===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=x.childLanes,m.lanes=x.lanes,m.child=x.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=x.memoizedProps,m.memoizedState=x.memoizedState,m.updateQueue=x.updateQueue,m.type=x.type,e=x.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return Qe(at,at.current&1|2),n.child}e=e.sibling}m.tail!==null&<()>Kr&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304)}else{if(!l)if(e=za(x),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ps(m,!0),m.tail===null&&m.tailMode==="hidden"&&!x.alternate&&!rt)return It(n),null}else 2*lt()-m.renderingStartTime>Kr&&i!==1073741824&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304);m.isBackwards?(x.sibling=n.child,n.child=x):(i=m.last,i!==null?i.sibling=x:n.child=x,m.last=x)}return m.tail!==null?(n=m.tail,m.rendering=n,m.tail=n.sibling,m.renderingStartTime=lt(),n.sibling=null,i=at.current,Qe(at,l?i&1|2:i&1),n):(It(n),null);case 22:case 23:return dl(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(It(n),n.subtreeFlags&6&&(n.flags|=8192)):It(n),null;case 24:return null;case 25:return null}throw Error(a(156,n.tag))}function eg(e,n){switch(wo(n),n.tag){case 1:return zt(n.type)&&Na(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Wr(),et(Lt),et(Tt),_o(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ao(n),null;case 13:if(et(at),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Mr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return et(at),null;case 4:return Wr(),null;case 10:return Co(n.type._context),null;case 22:case 23:return dl(),null;case 24:return null;default:return null}}var Va=!1,At=!1,tg=typeof WeakSet=="function"?WeakSet:Set,we=null;function Vr(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){ot(e,n,l)}else i.current=null}function Zo(e,n,i){try{i()}catch(l){ot(e,n,l)}}var Td=!1;function ng(e,n){if(uo=da,e=iu(),no(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var d=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var x=0,k=-1,I=-1,U=0,X=0,te=e,Q=null;t:for(;;){for(var ye;te!==i||d!==0&&te.nodeType!==3||(k=x+d),te!==m||l!==0&&te.nodeType!==3||(I=x+l),te.nodeType===3&&(x+=te.nodeValue.length),(ye=te.firstChild)!==null;)Q=te,te=ye;for(;;){if(te===e)break t;if(Q===i&&++U===d&&(k=x),Q===m&&++X===l&&(I=x),(ye=te.nextSibling)!==null)break;te=Q,Q=te.parentNode}te=ye}i=k===-1||I===-1?null:{start:k,end:I}}else i=null}i=i||{start:0,end:0}}else i=null;for(fo={focusedElem:e,selectionRange:i},da=!1,we=n;we!==null;)if(n=we,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,we=e;else for(;we!==null;){n=we;try{var be=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(be!==null){var Ne=be.memoizedProps,ct=be.memoizedState,z=n.stateNode,_=z.getSnapshotBeforeUpdate(n.elementType===n.type?Ne:ln(n.type,Ne),ct);z.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var B=n.stateNode.containerInfo;B.nodeType===1?B.textContent="":B.nodeType===9&&B.documentElement&&B.removeChild(B.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(le){ot(n,n.return,le)}if(e=n.sibling,e!==null){e.return=n.return,we=e;break}we=n.return}return be=Td,Td=!1,be}function _s(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&e)===e){var m=d.destroy;d.destroy=void 0,m!==void 0&&Zo(n,i,m)}d=d.next}while(d!==l)}}function Ga(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function el(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Rd(e){var n=e.alternate;n!==null&&(e.alternate=null,Rd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[yn],delete n[Ss],delete n[go],delete n[Op],delete n[Mp])),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 Id(e){return e.tag===5||e.tag===3||e.tag===4}function Ad(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Id(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 tl(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=ba));else if(l!==4&&(e=e.child,e!==null))for(tl(e,n,i),e=e.sibling;e!==null;)tl(e,n,i),e=e.sibling}function nl(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(nl(e,n,i),e=e.sibling;e!==null;)nl(e,n,i),e=e.sibling}var Nt=null,cn=!1;function Kn(e,n,i){for(i=i.child;i!==null;)Pd(e,n,i),i=i.sibling}function Pd(e,n,i){if(gn&&typeof gn.onCommitFiberUnmount=="function")try{gn.onCommitFiberUnmount(aa,i)}catch{}switch(i.tag){case 5:At||Vr(i,n);case 6:var l=Nt,d=cn;Nt=null,Kn(e,n,i),Nt=l,cn=d,Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Nt.removeChild(i.stateNode));break;case 18:Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?po(e.parentNode,i):e.nodeType===1&&po(e,i),ds(e)):po(Nt,i.stateNode));break;case 4:l=Nt,d=cn,Nt=i.stateNode.containerInfo,cn=!0,Kn(e,n,i),Nt=l,cn=d;break;case 0:case 11:case 14:case 15:if(!At&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var m=d,x=m.destroy;m=m.tag,x!==void 0&&((m&2)!==0||(m&4)!==0)&&Zo(i,n,x),d=d.next}while(d!==l)}Kn(e,n,i);break;case 1:if(!At&&(Vr(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(k){ot(i,n,k)}Kn(e,n,i);break;case 21:Kn(e,n,i);break;case 22:i.mode&1?(At=(l=At)||i.memoizedState!==null,Kn(e,n,i),At=l):Kn(e,n,i);break;default:Kn(e,n,i)}}function _d(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new tg),n.forEach(function(l){var d=dg.bind(null,e,l);i.has(l)||(i.add(l),l.then(d,d))})}}function un(e,n){var i=n.deletions;if(i!==null)for(var l=0;l<i.length;l++){var d=i[l];try{var m=e,x=n,k=x;e:for(;k!==null;){switch(k.tag){case 5:Nt=k.stateNode,cn=!1;break e;case 3:Nt=k.stateNode.containerInfo,cn=!0;break e;case 4:Nt=k.stateNode.containerInfo,cn=!0;break e}k=k.return}if(Nt===null)throw Error(a(160));Pd(m,x,d),Nt=null,cn=!1;var I=d.alternate;I!==null&&(I.return=null),d.return=null}catch(U){ot(d,n,U)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)$d(n,e),n=n.sibling}function $d(e,n){var i=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(un(n,e),wn(e),l&4){try{_s(3,e,e.return),Ga(3,e)}catch(Ne){ot(e,e.return,Ne)}try{_s(5,e,e.return)}catch(Ne){ot(e,e.return,Ne)}}break;case 1:un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return);break;case 5:if(un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return),e.flags&32){var d=e.stateNode;try{Oe(d,"")}catch(Ne){ot(e,e.return,Ne)}}if(l&4&&(d=e.stateNode,d!=null)){var m=e.memoizedProps,x=i!==null?i.memoizedProps:m,k=e.type,I=e.updateQueue;if(e.updateQueue=null,I!==null)try{k==="input"&&m.type==="radio"&&m.name!=null&&se(d,m),kt(k,x);var U=kt(k,m);for(x=0;x<I.length;x+=2){var X=I[x],te=I[x+1];X==="style"?pn(d,te):X==="dangerouslySetInnerHTML"?ue(d,te):X==="children"?Oe(d,te):$(d,X,te,U)}switch(k){case"input":je(d,m);break;case"textarea":ze(d,m);break;case"select":var Q=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var ye=m.value;ye!=null?tt(d,!!m.multiple,ye,!1):Q!==!!m.multiple&&(m.defaultValue!=null?tt(d,!!m.multiple,m.defaultValue,!0):tt(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ss]=m}catch(Ne){ot(e,e.return,Ne)}}break;case 6:if(un(n,e),wn(e),l&4){if(e.stateNode===null)throw Error(a(162));d=e.stateNode,m=e.memoizedProps;try{d.nodeValue=m}catch(Ne){ot(e,e.return,Ne)}}break;case 3:if(un(n,e),wn(e),l&4&&i!==null&&i.memoizedState.isDehydrated)try{ds(n.containerInfo)}catch(Ne){ot(e,e.return,Ne)}break;case 4:un(n,e),wn(e);break;case 13:un(n,e),wn(e),d=e.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(al=lt())),l&4&&_d(e);break;case 22:if(X=i!==null&&i.memoizedState!==null,e.mode&1?(At=(U=At)||X,un(n,e),At=U):un(n,e),wn(e),l&8192){if(U=e.memoizedState!==null,(e.stateNode.isHidden=U)&&!X&&(e.mode&1)!==0)for(we=e,X=e.child;X!==null;){for(te=we=X;we!==null;){switch(Q=we,ye=Q.child,Q.tag){case 0:case 11:case 14:case 15:_s(4,Q,Q.return);break;case 1:Vr(Q,Q.return);var be=Q.stateNode;if(typeof be.componentWillUnmount=="function"){l=Q,i=Q.return;try{n=l,be.props=n.memoizedProps,be.state=n.memoizedState,be.componentWillUnmount()}catch(Ne){ot(l,i,Ne)}}break;case 5:Vr(Q,Q.return);break;case 22:if(Q.memoizedState!==null){Fd(te);continue}}ye!==null?(ye.return=Q,we=ye):Fd(te)}X=X.sibling}e:for(X=null,te=e;;){if(te.tag===5){if(X===null){X=te;try{d=te.stateNode,U?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(k=te.stateNode,I=te.memoizedProps.style,x=I!=null&&I.hasOwnProperty("display")?I.display:null,k.style.display=ht("display",x))}catch(Ne){ot(e,e.return,Ne)}}}else if(te.tag===6){if(X===null)try{te.stateNode.nodeValue=U?"":te.memoizedProps}catch(Ne){ot(e,e.return,Ne)}}else if((te.tag!==22&&te.tag!==23||te.memoizedState===null||te===e)&&te.child!==null){te.child.return=te,te=te.child;continue}if(te===e)break e;for(;te.sibling===null;){if(te.return===null||te.return===e)break e;X===te&&(X=null),te=te.return}X===te&&(X=null),te.sibling.return=te.return,te=te.sibling}}break;case 19:un(n,e),wn(e),l&4&&_d(e);break;case 21:break;default:un(n,e),wn(e)}}function wn(e){var n=e.flags;if(n&2){try{e:{for(var i=e.return;i!==null;){if(Id(i)){var l=i;break e}i=i.return}throw Error(a(160))}switch(l.tag){case 5:var d=l.stateNode;l.flags&32&&(Oe(d,""),l.flags&=-33);var m=Ad(e);nl(e,m,d);break;case 3:case 4:var x=l.stateNode.containerInfo,k=Ad(e);tl(e,k,x);break;default:throw Error(a(161))}}catch(I){ot(e,e.return,I)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function rg(e,n,i){we=e,Ld(e)}function Ld(e,n,i){for(var l=(e.mode&1)!==0;we!==null;){var d=we,m=d.child;if(d.tag===22&&l){var x=d.memoizedState!==null||Va;if(!x){var k=d.alternate,I=k!==null&&k.memoizedState!==null||At;k=Va;var U=At;if(Va=x,(At=I)&&!U)for(we=d;we!==null;)x=we,I=x.child,x.tag===22&&x.memoizedState!==null?Od(d):I!==null?(I.return=x,we=I):Od(d);for(;m!==null;)we=m,Ld(m),m=m.sibling;we=d,Va=k,At=U}zd(e)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,we=m):zd(e)}}function zd(e){for(;we!==null;){var n=we;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:At||Ga(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!At)if(i===null)l.componentDidMount();else{var d=n.elementType===n.type?i.memoizedProps:ln(n.type,i.memoizedProps);l.componentDidUpdate(d,i.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var m=n.updateQueue;m!==null&&Fu(n,m,l);break;case 3:var x=n.updateQueue;if(x!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}Fu(n,x,i)}break;case 5:var k=n.stateNode;if(i===null&&n.flags&4){i=k;var I=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":I.autoFocus&&i.focus();break;case"img":I.src&&(i.src=I.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var U=n.alternate;if(U!==null){var X=U.memoizedState;if(X!==null){var te=X.dehydrated;te!==null&&ds(te)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}At||n.flags&512&&el(n)}catch(Q){ot(n,n.return,Q)}}if(n===e){we=null;break}if(i=n.sibling,i!==null){i.return=n.return,we=i;break}we=n.return}}function Fd(e){for(;we!==null;){var n=we;if(n===e){we=null;break}var i=n.sibling;if(i!==null){i.return=n.return,we=i;break}we=n.return}}function Od(e){for(;we!==null;){var n=we;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{Ga(4,n)}catch(I){ot(n,i,I)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var d=n.return;try{l.componentDidMount()}catch(I){ot(n,d,I)}}var m=n.return;try{el(n)}catch(I){ot(n,m,I)}break;case 5:var x=n.return;try{el(n)}catch(I){ot(n,x,I)}}}catch(I){ot(n,n.return,I)}if(n===e){we=null;break}var k=n.sibling;if(k!==null){k.return=n.return,we=k;break}we=n.return}}var sg=Math.ceil,Ka=A.ReactCurrentDispatcher,rl=A.ReactCurrentOwner,Zt=A.ReactCurrentBatchConfig,He=0,St=null,mt=null,Ct=0,Gt=0,Gr=Un(0),vt=0,$s=null,hr=0,qa=0,sl=0,Ls=null,Ot=null,al=0,Kr=1/0,An=null,Ya=!1,il=null,qn=null,Ja=!1,Yn=null,Qa=0,zs=0,ol=null,Xa=-1,Za=0;function _t(){return(He&6)!==0?lt():Xa!==-1?Xa:Xa=lt()}function Jn(e){return(e.mode&1)===0?1:(He&2)!==0&&Ct!==0?Ct&-Ct:Dp.transition!==null?(Za===0&&(Za=Ac()),Za):(e=Ke,e!==0||(e=window.event,e=e===void 0?16:Bc(e.type)),e)}function dn(e,n,i,l){if(50<zs)throw zs=0,ol=null,Error(a(185));is(e,i,l),((He&2)===0||e!==St)&&(e===St&&((He&2)===0&&(qa|=i),vt===4&&Qn(e,Ct)),Mt(e,l),i===1&&He===0&&(n.mode&1)===0&&(Kr=lt()+500,Ea&&Hn()))}function Mt(e,n){var i=e.callbackNode;Dm(e,n);var l=la(e,e===St?Ct:0);if(l===0)i!==null&&Tc(i),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(i!=null&&Tc(i),n===1)e.tag===0?Bp(Bd.bind(null,e)):Nu(Bd.bind(null,e)),zp(function(){(He&6)===0&&Hn()}),i=null;else{switch(Pc(l)){case 1:i=Mi;break;case 4:i=Rc;break;case 16:i=sa;break;case 536870912:i=Ic;break;default:i=sa}i=qd(i,Md.bind(null,e))}e.callbackPriority=n,e.callbackNode=i}}function Md(e,n){if(Xa=-1,Za=0,(He&6)!==0)throw Error(a(327));var i=e.callbackNode;if(qr()&&e.callbackNode!==i)return null;var l=la(e,e===St?Ct:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||n)n=ei(e,l);else{n=l;var d=He;He|=2;var m=Ud();(St!==e||Ct!==n)&&(An=null,Kr=lt()+500,pr(e,n));do try{og();break}catch(k){Dd(e,k)}while(!0);No(),Ka.current=m,He=d,mt!==null?n=0:(St=null,Ct=0,n=vt)}if(n!==0){if(n===2&&(d=Bi(e),d!==0&&(l=d,n=ll(e,d))),n===1)throw i=$s,pr(e,0),Qn(e,l),Mt(e,lt()),i;if(n===6)Qn(e,l);else{if(d=e.current.alternate,(l&30)===0&&!ag(d)&&(n=ei(e,l),n===2&&(m=Bi(e),m!==0&&(l=m,n=ll(e,m))),n===1))throw i=$s,pr(e,0),Qn(e,l),Mt(e,lt()),i;switch(e.finishedWork=d,e.finishedLanes=l,n){case 0:case 1:throw Error(a(345));case 2:gr(e,Ot,An);break;case 3:if(Qn(e,l),(l&130023424)===l&&(n=al+500-lt(),10<n)){if(la(e,0)!==0)break;if(d=e.suspendedLanes,(d&l)!==l){_t(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=mo(gr.bind(null,e,Ot,An),n);break}gr(e,Ot,An);break;case 4:if(Qn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,d=-1;0<l;){var x=31-sn(l);m=1<<x,x=n[x],x>d&&(d=x),l&=~m}if(l=d,l=lt()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*sg(l/1960))-l,10<l){e.timeoutHandle=mo(gr.bind(null,e,Ot,An),l);break}gr(e,Ot,An);break;case 5:gr(e,Ot,An);break;default:throw Error(a(329))}}}return Mt(e,lt()),e.callbackNode===i?Md.bind(null,e):null}function ll(e,n){var i=Ls;return e.current.memoizedState.isDehydrated&&(pr(e,n).flags|=256),e=ei(e,n),e!==2&&(n=Ot,Ot=i,n!==null&&cl(n)),e}function cl(e){Ot===null?Ot=e:Ot.push.apply(Ot,e)}function ag(e){for(var n=e;;){if(n.flags&16384){var i=n.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var l=0;l<i.length;l++){var d=i[l],m=d.getSnapshot;d=d.value;try{if(!an(m(),d))return!1}catch{return!1}}}if(i=n.child,n.subtreeFlags&16384&&i!==null)i.return=n,n=i;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Qn(e,n){for(n&=~sl,n&=~qa,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var i=31-sn(n),l=1<<i;e[i]=-1,n&=~l}}function Bd(e){if((He&6)!==0)throw Error(a(327));qr();var n=la(e,0);if((n&1)===0)return Mt(e,lt()),null;var i=ei(e,n);if(e.tag!==0&&i===2){var l=Bi(e);l!==0&&(n=l,i=ll(e,l))}if(i===1)throw i=$s,pr(e,0),Qn(e,n),Mt(e,lt()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,gr(e,Ot,An),Mt(e,lt()),null}function ul(e,n){var i=He;He|=1;try{return e(n)}finally{He=i,He===0&&(Kr=lt()+500,Ea&&Hn())}}function mr(e){Yn!==null&&Yn.tag===0&&(He&6)===0&&qr();var n=He;He|=1;var i=Zt.transition,l=Ke;try{if(Zt.transition=null,Ke=1,e)return e()}finally{Ke=l,Zt.transition=i,He=n,(He&6)===0&&Hn()}}function dl(){Gt=Gr.current,et(Gr)}function pr(e,n){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,Lp(i)),mt!==null)for(i=mt.return;i!==null;){var l=i;switch(wo(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&Na();break;case 3:Wr(),et(Lt),et(Tt),_o();break;case 5:Ao(l);break;case 4:Wr();break;case 13:et(at);break;case 19:et(at);break;case 10:Co(l.type._context);break;case 22:case 23:dl()}i=i.return}if(St=e,mt=e=Xn(e.current,null),Ct=Gt=n,vt=0,$s=null,sl=qa=hr=0,Ot=Ls=null,ur!==null){for(n=0;n<ur.length;n++)if(i=ur[n],l=i.interleaved,l!==null){i.interleaved=null;var d=l.next,m=i.pending;if(m!==null){var x=m.next;m.next=d,l.next=x}i.pending=l}ur=null}return e}function Dd(e,n){do{var i=mt;try{if(No(),Fa.current=Da,Oa){for(var l=it.memoizedState;l!==null;){var d=l.queue;d!==null&&(d.pending=null),l=l.next}Oa=!1}if(fr=0,jt=yt=it=null,Ts=!1,Rs=0,rl.current=null,i===null||i.return===null){vt=1,$s=n,mt=null;break}e:{var m=e,x=i.return,k=i,I=n;if(n=Ct,k.flags|=32768,I!==null&&typeof I=="object"&&typeof I.then=="function"){var U=I,X=k,te=X.tag;if((X.mode&1)===0&&(te===0||te===11||te===15)){var Q=X.alternate;Q?(X.updateQueue=Q.updateQueue,X.memoizedState=Q.memoizedState,X.lanes=Q.lanes):(X.updateQueue=null,X.memoizedState=null)}var ye=fd(x);if(ye!==null){ye.flags&=-257,hd(ye,x,k,m,n),ye.mode&1&&dd(m,U,n),n=ye,I=U;var be=n.updateQueue;if(be===null){var Ne=new Set;Ne.add(I),n.updateQueue=Ne}else be.add(I);break e}else{if((n&1)===0){dd(m,U,n),fl();break e}I=Error(a(426))}}else if(rt&&k.mode&1){var ct=fd(x);if(ct!==null){(ct.flags&65536)===0&&(ct.flags|=256),hd(ct,x,k,m,n),bo(Hr(I,k));break e}}m=I=Hr(I,k),vt!==4&&(vt=2),Ls===null?Ls=[m]:Ls.push(m),m=x;do{switch(m.tag){case 3:m.flags|=65536,n&=-n,m.lanes|=n;var z=cd(m,I,n);zu(m,z);break e;case 1:k=I;var _=m.type,B=m.stateNode;if((m.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||B!==null&&typeof B.componentDidCatch=="function"&&(qn===null||!qn.has(B)))){m.flags|=65536,n&=-n,m.lanes|=n;var le=ud(m,k,n);zu(m,le);break e}}m=m.return}while(m!==null)}Hd(i)}catch(Ce){n=Ce,mt===i&&i!==null&&(mt=i=i.return);continue}break}while(!0)}function Ud(){var e=Ka.current;return Ka.current=Da,e===null?Da:e}function fl(){(vt===0||vt===3||vt===2)&&(vt=4),St===null||(hr&268435455)===0&&(qa&268435455)===0||Qn(St,Ct)}function ei(e,n){var i=He;He|=2;var l=Ud();(St!==e||Ct!==n)&&(An=null,pr(e,n));do try{ig();break}catch(d){Dd(e,d)}while(!0);if(No(),He=i,Ka.current=l,mt!==null)throw Error(a(261));return St=null,Ct=0,vt}function ig(){for(;mt!==null;)Wd(mt)}function og(){for(;mt!==null&&!Pm();)Wd(mt)}function Wd(e){var n=Kd(e.alternate,e,Gt);e.memoizedProps=e.pendingProps,n===null?Hd(e):mt=n,rl.current=null}function Hd(e){var n=e;do{var i=n.alternate;if(e=n.return,(n.flags&32768)===0){if(i=Zp(i,n,Gt),i!==null){mt=i;return}}else{if(i=eg(i,n),i!==null){i.flags&=32767,mt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{vt=6,mt=null;return}}if(n=n.sibling,n!==null){mt=n;return}mt=n=e}while(n!==null);vt===0&&(vt=5)}function gr(e,n,i){var l=Ke,d=Zt.transition;try{Zt.transition=null,Ke=1,lg(e,n,i,l)}finally{Zt.transition=d,Ke=l}return null}function lg(e,n,i,l){do qr();while(Yn!==null);if((He&6)!==0)throw Error(a(327));i=e.finishedWork;var d=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var m=i.lanes|i.childLanes;if(Um(e,m),e===St&&(mt=St=null,Ct=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Ja||(Ja=!0,qd(sa,function(){return qr(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=Zt.transition,Zt.transition=null;var x=Ke;Ke=1;var k=He;He|=4,rl.current=null,ng(e,i),$d(i,e),Tp(fo),da=!!uo,fo=uo=null,e.current=i,rg(i),_m(),He=k,Ke=x,Zt.transition=m}else e.current=i;if(Ja&&(Ja=!1,Yn=e,Qa=d),m=e.pendingLanes,m===0&&(qn=null),zm(i.stateNode),Mt(e,lt()),n!==null)for(l=e.onRecoverableError,i=0;i<n.length;i++)d=n[i],l(d.value,{componentStack:d.stack,digest:d.digest});if(Ya)throw Ya=!1,e=il,il=null,e;return(Qa&1)!==0&&e.tag!==0&&qr(),m=e.pendingLanes,(m&1)!==0?e===ol?zs++:(zs=0,ol=e):zs=0,Hn(),null}function qr(){if(Yn!==null){var e=Pc(Qa),n=Zt.transition,i=Ke;try{if(Zt.transition=null,Ke=16>e?16:e,Yn===null)var l=!1;else{if(e=Yn,Yn=null,Qa=0,(He&6)!==0)throw Error(a(331));var d=He;for(He|=4,we=e.current;we!==null;){var m=we,x=m.child;if((we.flags&16)!==0){var k=m.deletions;if(k!==null){for(var I=0;I<k.length;I++){var U=k[I];for(we=U;we!==null;){var X=we;switch(X.tag){case 0:case 11:case 15:_s(8,X,m)}var te=X.child;if(te!==null)te.return=X,we=te;else for(;we!==null;){X=we;var Q=X.sibling,ye=X.return;if(Rd(X),X===U){we=null;break}if(Q!==null){Q.return=ye,we=Q;break}we=ye}}}var be=m.alternate;if(be!==null){var Ne=be.child;if(Ne!==null){be.child=null;do{var ct=Ne.sibling;Ne.sibling=null,Ne=ct}while(Ne!==null)}}we=m}}if((m.subtreeFlags&2064)!==0&&x!==null)x.return=m,we=x;else e:for(;we!==null;){if(m=we,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:_s(9,m,m.return)}var z=m.sibling;if(z!==null){z.return=m.return,we=z;break e}we=m.return}}var _=e.current;for(we=_;we!==null;){x=we;var B=x.child;if((x.subtreeFlags&2064)!==0&&B!==null)B.return=x,we=B;else e:for(x=_;we!==null;){if(k=we,(k.flags&2048)!==0)try{switch(k.tag){case 0:case 11:case 15:Ga(9,k)}}catch(Ce){ot(k,k.return,Ce)}if(k===x){we=null;break e}var le=k.sibling;if(le!==null){le.return=k.return,we=le;break e}we=k.return}}if(He=d,Hn(),gn&&typeof gn.onPostCommitFiberRoot=="function")try{gn.onPostCommitFiberRoot(aa,e)}catch{}l=!0}return l}finally{Ke=i,Zt.transition=n}}return!1}function Vd(e,n,i){n=Hr(i,n),n=cd(e,n,1),e=Gn(e,n,1),n=_t(),e!==null&&(is(e,1,n),Mt(e,n))}function ot(e,n,i){if(e.tag===3)Vd(e,e,i);else for(;n!==null;){if(n.tag===3){Vd(n,e,i);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(qn===null||!qn.has(l))){e=Hr(i,e),e=ud(n,e,1),n=Gn(n,e,1),e=_t(),n!==null&&(is(n,1,e),Mt(n,e));break}}n=n.return}}function cg(e,n,i){var l=e.pingCache;l!==null&&l.delete(n),n=_t(),e.pingedLanes|=e.suspendedLanes&i,St===e&&(Ct&i)===i&&(vt===4||vt===3&&(Ct&130023424)===Ct&&500>lt()-al?pr(e,0):sl|=i),Mt(e,n)}function Gd(e,n){n===0&&((e.mode&1)===0?n=1:(n=oa,oa<<=1,(oa&130023424)===0&&(oa=4194304)));var i=_t();e=Tn(e,n),e!==null&&(is(e,n,i),Mt(e,i))}function ug(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Gd(e,i)}function dg(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,d=e.memoizedState;d!==null&&(i=d.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(a(314))}l!==null&&l.delete(n),Gd(e,i)}var Kd;Kd=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Lt.current)Ft=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Ft=!1,Xp(e,n,i);Ft=(e.flags&131072)!==0}else Ft=!1,rt&&(n.flags&1048576)!==0&&Cu(n,Ra,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ha(e,n),e=n.pendingProps;var d=zr(n,Tt.current);Ur(n,i),d=zo(null,n,l,e,d,i);var m=Fo();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,zt(l)?(m=!0,Ca(n)):m=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Ro(n),d.updater=Ua,n.stateNode=d,d._reactInternals=n,Wo(n,l,e,i),n=Ko(null,n,l,!0,m,i)):(n.tag=0,rt&&m&&xo(n),Pt(null,n,d,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ha(e,n),e=n.pendingProps,d=l._init,l=d(l._payload),n.type=l,d=n.tag=hg(l),e=ln(l,e),d){case 0:n=Go(null,n,l,e,i);break e;case 1:n=xd(null,n,l,e,i);break e;case 11:n=md(null,n,l,e,i);break e;case 14:n=pd(null,n,l,ln(l.type,e),i);break e}throw Error(a(306,l,""))}return n;case 0:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),Go(e,n,l,d,i);case 1:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),xd(e,n,l,d,i);case 3:e:{if(wd(n),e===null)throw Error(a(387));l=n.pendingProps,m=n.memoizedState,d=m.element,Lu(e,n),La(n,l,null,i);var x=n.memoizedState;if(l=x.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){d=Hr(Error(a(423)),n),n=jd(e,n,l,i,d);break e}else if(l!==d){d=Hr(Error(a(424)),n),n=jd(e,n,l,i,d);break e}else for(Vt=Dn(n.stateNode.containerInfo.firstChild),Ht=n,rt=!0,on=null,i=_u(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Mr(),l===d){n=In(e,n,i);break e}Pt(e,n,l,i)}n=n.child}return n;case 5:return Ou(n),e===null&&So(n),l=n.type,d=n.pendingProps,m=e!==null?e.memoizedProps:null,x=d.children,ho(l,d)?x=null:m!==null&&ho(l,m)&&(n.flags|=32),vd(e,n),Pt(e,n,x,i),n.child;case 6:return e===null&&So(n),null;case 13:return Sd(e,n,i);case 4:return Io(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Br(n,null,l,i):Pt(e,n,l,i),n.child;case 11:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),md(e,n,l,d,i);case 7:return Pt(e,n,n.pendingProps,i),n.child;case 8:return Pt(e,n,n.pendingProps.children,i),n.child;case 12:return Pt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,d=n.pendingProps,m=n.memoizedProps,x=d.value,Qe(Pa,l._currentValue),l._currentValue=x,m!==null)if(an(m.value,x)){if(m.children===d.children&&!Lt.current){n=In(e,n,i);break e}}else for(m=n.child,m!==null&&(m.return=n);m!==null;){var k=m.dependencies;if(k!==null){x=m.child;for(var I=k.firstContext;I!==null;){if(I.context===l){if(m.tag===1){I=Rn(-1,i&-i),I.tag=2;var U=m.updateQueue;if(U!==null){U=U.shared;var X=U.pending;X===null?I.next=I:(I.next=X.next,X.next=I),U.pending=I}}m.lanes|=i,I=m.alternate,I!==null&&(I.lanes|=i),Eo(m.return,i,n),k.lanes|=i;break}I=I.next}}else if(m.tag===10)x=m.type===n.type?null:m.child;else if(m.tag===18){if(x=m.return,x===null)throw Error(a(341));x.lanes|=i,k=x.alternate,k!==null&&(k.lanes|=i),Eo(x,i,n),x=m.sibling}else x=m.child;if(x!==null)x.return=m;else for(x=m;x!==null;){if(x===n){x=null;break}if(m=x.sibling,m!==null){m.return=x.return,x=m;break}x=x.return}m=x}Pt(e,n,d.children,i),n=n.child}return n;case 9:return d=n.type,l=n.pendingProps.children,Ur(n,i),d=Qt(d),l=l(d),n.flags|=1,Pt(e,n,l,i),n.child;case 14:return l=n.type,d=ln(l,n.pendingProps),d=ln(l.type,d),pd(e,n,l,d,i);case 15:return gd(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:ln(l,d),Ha(e,n),n.tag=1,zt(l)?(e=!0,Ca(n)):e=!1,Ur(n,i),od(n,l,d),Wo(n,l,d,i),Ko(null,n,l,!0,e,i);case 19:return kd(e,n,i);case 22:return yd(e,n,i)}throw Error(a(156,n.tag))};function qd(e,n){return Ec(e,n)}function fg(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function en(e,n,i,l){return new fg(e,n,i,l)}function hl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hg(e){if(typeof e=="function")return hl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===D)return 11;if(e===Z)return 14}return 2}function Xn(e,n){var i=e.alternate;return i===null?(i=en(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ti(e,n,i,l,d,m){var x=2;if(l=e,typeof e=="function")hl(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case q:return yr(i.children,d,m,n);case de:x=8,d|=8;break;case K:return e=en(12,i,n,d|2),e.elementType=K,e.lanes=m,e;case ce:return e=en(13,i,n,d),e.elementType=ce,e.lanes=m,e;case re:return e=en(19,i,n,d),e.elementType=re,e.lanes=m,e;case ge:return ni(i,d,m,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case oe:x=10;break e;case V:x=9;break e;case D:x=11;break e;case Z:x=14;break e;case he:x=16,l=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return n=en(x,i,n,d),n.elementType=e,n.type=l,n.lanes=m,n}function yr(e,n,i,l){return e=en(7,e,l,n),e.lanes=i,e}function ni(e,n,i,l){return e=en(22,e,l,n),e.elementType=ge,e.lanes=i,e.stateNode={isHidden:!1},e}function ml(e,n,i){return e=en(6,e,null,n),e.lanes=i,e}function pl(e,n,i){return n=en(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function mg(e,n,i,l,d){this.tag=n,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=Di(0),this.expirationTimes=Di(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Di(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function gl(e,n,i,l,d,m,x,k,I){return e=new mg(e,n,i,k,I),n===1?(n=1,m===!0&&(n|=8)):n=0,m=en(3,null,null,n),e.current=m,m.stateNode=e,m.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ro(m),e}function pg(e,n,i){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:G,key:l==null?null:""+l,children:e,containerInfo:n,implementation:i}}function Yd(e){if(!e)return Wn;e=e._reactInternals;e:{if(ar(e)!==e||e.tag!==1)throw Error(a(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(zt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(a(171))}if(e.tag===1){var i=e.type;if(zt(i))return bu(e,i,n)}return n}function Jd(e,n,i,l,d,m,x,k,I){return e=gl(i,l,!0,e,d,m,x,k,I),e.context=Yd(null),i=e.current,l=_t(),d=Jn(i),m=Rn(l,d),m.callback=n??null,Gn(i,m,d),e.current.lanes=d,is(e,d,l),Mt(e,l),e}function ri(e,n,i,l){var d=n.current,m=_t(),x=Jn(d);return i=Yd(i),n.context===null?n.context=i:n.pendingContext=i,n=Rn(m,x),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=Gn(d,n,x),e!==null&&(dn(e,d,x,m),$a(e,d,x)),x}function si(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Qd(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<n?i:n}}function yl(e,n){Qd(e,n),(e=e.alternate)&&Qd(e,n)}function gg(){return null}var Xd=typeof reportError=="function"?reportError:function(e){console.error(e)};function vl(e){this._internalRoot=e}ai.prototype.render=vl.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));ri(e,n,null,null)},ai.prototype.unmount=vl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;mr(function(){ri(null,e,null,null)}),n[kn]=null}};function ai(e){this._internalRoot=e}ai.prototype.unstable_scheduleHydration=function(e){if(e){var n=Lc();e={blockedOn:null,target:e,priority:n};for(var i=0;i<On.length&&n!==0&&n<On[i].priority;i++);On.splice(i,0,e),i===0&&Oc(e)}};function xl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ii(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zd(){}function yg(e,n,i,l,d){if(d){if(typeof l=="function"){var m=l;l=function(){var U=si(x);m.call(U)}}var x=Jd(n,l,e,0,null,!1,!1,"",Zd);return e._reactRootContainer=x,e[kn]=x.current,ws(e.nodeType===8?e.parentNode:e),mr(),x}for(;d=e.lastChild;)e.removeChild(d);if(typeof l=="function"){var k=l;l=function(){var U=si(I);k.call(U)}}var I=gl(e,0,!1,null,null,!1,!1,"",Zd);return e._reactRootContainer=I,e[kn]=I.current,ws(e.nodeType===8?e.parentNode:e),mr(function(){ri(n,I,i,l)}),I}function oi(e,n,i,l,d){var m=i._reactRootContainer;if(m){var x=m;if(typeof d=="function"){var k=d;d=function(){var I=si(x);k.call(I)}}ri(n,x,e,d)}else x=yg(i,n,e,d,l);return si(x)}_c=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var i=as(n.pendingLanes);i!==0&&(Ui(n,i|1),Mt(n,lt()),(He&6)===0&&(Kr=lt()+500,Hn()))}break;case 13:mr(function(){var l=Tn(e,1);if(l!==null){var d=_t();dn(l,e,1,d)}}),yl(e,1)}},Wi=function(e){if(e.tag===13){var n=Tn(e,134217728);if(n!==null){var i=_t();dn(n,e,134217728,i)}yl(e,134217728)}},$c=function(e){if(e.tag===13){var n=Jn(e),i=Tn(e,n);if(i!==null){var l=_t();dn(i,e,n,l)}yl(e,n)}},Lc=function(){return Ke},zc=function(e,n){var i=Ke;try{return Ke=e,n()}finally{Ke=i}},ie=function(e,n,i){switch(n){case"input":if(je(e,i),n=i.name,i.type==="radio"&&n!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<i.length;n++){var l=i[n];if(l!==e&&l.form===e.form){var d=ka(l);if(!d)throw Error(a(90));Le(l),je(l,d)}}}break;case"textarea":ze(e,i);break;case"select":n=i.value,n!=null&&tt(e,!!i.multiple,n,!1)}},Ut=ul,er=mr;var vg={usingClientEntryPoint:!1,Events:[bs,$r,ka,Fe,Je,ul]},Fs={findFiberByHostInstance:ir,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xg={bundleType:Fs.bundleType,version:Fs.version,rendererPackageName:Fs.rendererPackageName,rendererConfig:Fs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Nc(e),e===null?null:e.stateNode},findFiberByHostInstance:Fs.findFiberByHostInstance||gg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var li=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!li.isDisabled&&li.supportsFiber)try{aa=li.inject(xg),gn=li}catch{}}return Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vg,Bt.createPortal=function(e,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xl(n))throw Error(a(200));return pg(e,n,null,i)},Bt.createRoot=function(e,n){if(!xl(e))throw Error(a(299));var i=!1,l="",d=Xd;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=gl(e,1,!1,null,null,i,!1,l,d),e[kn]=n.current,ws(e.nodeType===8?e.parentNode:e),new vl(n)},Bt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=Nc(n),e=e===null?null:e.stateNode,e},Bt.flushSync=function(e){return mr(e)},Bt.hydrate=function(e,n,i){if(!ii(n))throw Error(a(200));return oi(null,e,n,!0,i)},Bt.hydrateRoot=function(e,n,i){if(!xl(e))throw Error(a(405));var l=i!=null&&i.hydratedSources||null,d=!1,m="",x=Xd;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(x=i.onRecoverableError)),n=Jd(n,null,e,1,i??null,d,!1,m,x),e[kn]=n.current,ws(e),l)for(e=0;e<l.length;e++)i=l[e],d=i._getVersion,d=d(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,d]:n.mutableSourceEagerHydrationData.push(i,d);return new ai(n)},Bt.render=function(e,n,i){if(!ii(n))throw Error(a(200));return oi(null,e,n,!1,i)},Bt.unmountComponentAtNode=function(e){if(!ii(e))throw Error(a(40));return e._reactRootContainer?(mr(function(){oi(null,null,e,!1,function(){e._reactRootContainer=null,e[kn]=null})}),!0):!1},Bt.unstable_batchedUpdates=ul,Bt.unstable_renderSubtreeIntoContainer=function(e,n,i,l){if(!ii(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return oi(e,n,i,!1,l)},Bt.version="18.3.1-next-f1338f8080-20240426",Bt}var lf;function sh(){if(lf)return Sl.exports;lf=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Sl.exports=Tg(),Sl.exports}var cf;function Rg(){if(cf)return ci;cf=1;var t=sh();return ci.createRoot=t.createRoot,ci.hydrateRoot=t.hydrateRoot,ci}var Ig=Rg();/**
|
|
41
41
|
* react-router v7.18.4
|
|
42
42
|
*
|
|
43
43
|
* Copyright (c) Remix Software Inc.
|
|
@@ -48,7 +48,7 @@ Error generating stack: `+m.message+`
|
|
|
48
48
|
* @license MIT
|
|
49
49
|
*/var Jl=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,ah=/^[\\/]{2}/;function Ag(t,s){return s+t.replace(/\\/g,"/")}var uf="popstate";function df(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function Pg(t={}){function s(o,c){var v;let u=(v=c.state)==null?void 0:v.masked,{pathname:h,search:g,hash:p}=u||o.location;return Fl("",{pathname:h,search:g,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",u?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,c){return typeof c=="string"?c:br(c)}return $g(s,a,null,t)}function st(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function rn(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function _g(){return Math.random().toString(36).substring(2,10)}function ff(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Fl(t,s,a=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?es(s):s,state:a,key:s&&s.key||o||_g(),mask:c}}function br({pathname:t="/",search:s="",hash:a=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function es(t){let s={};if(t){let a=t.indexOf("#");a>=0&&(s.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(s.search=t.substring(o),t=t.substring(0,o)),t&&(s.pathname=t)}return s}function $g(t,s,a,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,h=c.history,g="POP",p=null,v=y();v==null&&(v=0,h.replaceState({...h.state,idx:v},""));function y(){return(h.state||{idx:null}).idx}function w(){g="POP";let C=y(),T=C==null?null:C-v;v=C,p&&p({action:g,location:S.location,delta:T})}function j(C,T){g="PUSH";let R=df(C)?C:Fl(S.location,C,T);v=y()+1;let $=ff(R,v),A=S.createHref(R.mask||R);try{h.pushState($,"",A)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;c.location.assign(A)}u&&p&&p({action:g,location:S.location,delta:1})}function N(C,T){g="REPLACE";let R=df(C)?C:Fl(S.location,C,T);v=y();let $=ff(R,v),A=S.createHref(R.mask||R);h.replaceState($,"",A),u&&p&&p({action:g,location:S.location,delta:0})}function E(C){return Lg(c,C)}let S={get action(){return g},get location(){return t(c,h)},listen(C){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(uf,w),p=C,()=>{c.removeEventListener(uf,w),p=null}},createHref(C){return s(c,C)},createURL:E,encodeLocation(C){let T=E(C);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:j,replace:N,go(C){return h.go(C)}};return S}function Lg(t,s,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),st(o,"No window.location.(origin|href) available to create URL");let c=typeof s=="string"?s:br(s);return c=c.replace(/ $/,"%20"),!a&&ah.test(c)&&(c=o+c),new URL(c,o)}function ih(t,s,a="/"){return zg(t,s,a,!1)}function zg(t,s,a,o,c){let u=typeof s=="string"?es(s):s,h=_n(u.pathname||"/",a);if(h==null)return null;let g=Fg(t),p=null,v=qg(h);for(let y=0;p==null&&y<g.length;++y)p=Kg(g[y],v,o);return p}function Fg(t){let s=oh(t);return Og(s),s}function oh(t,s=[],a=[],o="",c=!1){let u=(h,g,p=c,v)=>{let y={relativePath:v===void 0?h.path||"":v,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;st(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let w=fn([o,y.relativePath]),j=a.concat(y);h.children&&h.children.length>0&&(st(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),oh(h.children,s,j,w,p)),!(h.path==null&&!h.index)&&s.push({path:w,score:Vg(w,h.index),routesMeta:j.map((N,E)=>{let[S,C]=uh(N.relativePath,N.caseSensitive,E===j.length-1);return{...N,matcher:S,compiledParams:C}})})};return t.forEach((h,g)=>{var p;if(h.path===""||!((p=h.path)!=null&&p.includes("?")))u(h,g);else for(let v of lh(h.path))u(h,g,!0,v)}),s}function lh(t){let s=t.split("/");if(s.length===0)return[];let[a,...o]=s,c=a.endsWith("?"),u=a.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let h=lh(o.join("/")),g=[];return g.push(...h.map(p=>p===""?u:[u,p].join("/"))),c&&g.push(...h),g.map(p=>t.startsWith("/")&&p===""?"/":p)}function Og(t){t.sort((s,a)=>s.score!==a.score?a.score-s.score:Gg(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var Mg=/^:[\w-]+$/,Bg=3,Dg=2,Ug=1,Wg=10,Hg=-2,hf=t=>t==="*";function Vg(t,s){let a=t.split("/"),o=a.length;return a.some(hf)&&(o+=Hg),s&&(o+=Dg),a.filter(c=>!hf(c)).reduce((c,u)=>c+(Mg.test(u)?Bg:u===""?Ug:Wg),o)}function Gg(t,s){return t.length===s.length&&t.slice(0,-1).every((o,c)=>o===s[c])?t[t.length-1]-s[s.length-1]:0}function Kg(t,s,a=!1){let{routesMeta:o}=t,c={},u="/",h=[];for(let g=0;g<o.length;++g){let p=o[g],v=g===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",w={path:p.relativePath,caseSensitive:p.caseSensitive,end:v},j=p.matcher&&p.compiledParams?ch(w,y,p.matcher,p.compiledParams):Si(w,y),N=p.route;if(!j&&v&&a&&!o[o.length-1].route.index&&(j=Si({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!j)return null;Object.assign(c,j.params),h.push({params:c,pathname:fn([u,j.pathname]),pathnameBase:Qg(fn([u,j.pathnameBase])),route:N}),j.pathnameBase!=="/"&&(u=fn([u,j.pathnameBase]))}return h}function Si(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[a,o]=uh(t.path,t.caseSensitive,t.end);return ch(t,s,a,o)}function ch(t,s,a,o){let c=s.match(a);if(!c)return null;let u=c[0],h=Xr(u,1),g=c.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:w},j)=>{if(y==="*"){let E=g[j]||"";h=Xr(u.slice(0,u.length-E.length),1)}const N=g[j];return w&&!N?v[y]=void 0:v[y]=(N||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:h,pattern:t}}function uh(t,s=!1,a=!0){rn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,g,p,v,y)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let w=y.charAt(v+h.length);return w&&w!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,s?void 0:"i"),o]}function qg(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return rn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function _n(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Yg(t,s="/"){let{pathname:a,search:o="",hash:c=""}=typeof t=="string"?es(t):t,u;return a?(a=dh(a),a.startsWith("/")||a.startsWith("\\")?u=mf(a.substring(1),"/"):u=mf(a,s)):u=s,{pathname:u,search:Xg(o),hash:Zg(c)}}function mf(t,s){let a=Xr(s).split("/");return t.split("/").forEach(c=>{c===".."?a.length>1&&a.pop():c!=="."&&a.push(c)}),a.length>1?a.join("/"):"/"}function Nl(t,s,a,o){return`Cannot include a '${t}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Jg(t){return t.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Ql(t){let s=Jg(t);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Pi(t,s,a,o=!1){let c;typeof t=="string"?c=es(t):(c={...t},st(!c.pathname||!c.pathname.includes("?"),Nl("?","pathname","search",c)),st(!c.pathname||!c.pathname.includes("#"),Nl("#","pathname","hash",c)),st(!c.search||!c.search.includes("#"),Nl("#","search","hash",c)));let u=t===""||c.pathname==="",h=u?"/":c.pathname,g;if(h==null)g=a;else{let w=s.length-1;if(!o&&h.startsWith("..")){let j=h.split("/");for(;j[0]==="..";)j.shift(),w-=1;c.pathname=j.join("/")}g=w>=0?s[w]:"/"}let p=Yg(c,g),v=h&&h!=="/"&&h.endsWith("/"),y=(u||h===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(v||y)&&(p.pathname+="/"),p}var dh=t=>t.replace(/[\\/]{2,}/g,"/"),fn=t=>dh(t.join("/"));function Xr(t,s=0){let a=t.length;for(;a>s&&t.charCodeAt(a-1)===47;)a--;return a===t.length?t:t.slice(0,a)}var Qg=t=>Xr(t).replace(/^\/*/,"/"),Xg=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Zg=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,ey=class{constructor(t,s,a,o=!1){this.status=t,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function ty(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function ny(t){let s=t.map(a=>a.route.path).filter(Boolean);return fn(s)||"/"}var fh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function hh(t,s){let a=t;if(typeof a!="string"||!Jl.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,c=!1;if(fh)try{let u=new URL(window.location.href),h=ah.test(a)?new URL(Ag(a,u.protocol)):new URL(a),g=_n(h.pathname,s);h.origin===u.origin&&g!=null?a=g+h.search+h.hash:c=!0}catch{rn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var pf=new URL("http://localhost");function Xl(t){if(t.createURL)return t.createURL("/");try{return new URL(t.createHref("/"),pf)}catch{return pf}}function Cl(t,s){return t.origin===s.origin&&(t.origin!=="null"||t.protocol===s.protocol&&t.host===s.host)}function ry(t,s){if(t.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return t.toLowerCase().startsWith(a)?s.host===""||t.slice(a.length).startsWith("//"):!1}function Zl(t,s,a,o){let c=null;try{c=t==null?null:new URL(t,a)}catch{}let u=new URL(s,a),h=c!=null&&!Cl(c,a),g=!Cl(u,a);if(o==="reject"){if(h||g)throw new Error("External navigation is not allowed")}else if(g&&(c==null||!ry(t,c)||!Cl(c,u)))throw new Error("External navigation is not allowed")}var mh=["POST","PUT","PATCH","DELETE"];new Set(mh);var sy=["GET",...mh];new Set(sy);var ay=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function iy(t){try{return ay.includes(new URL(t).protocol)}catch{return!1}}var ts=f.createContext(null);ts.displayName="DataRouter";var _i=f.createContext(null);_i.displayName="DataRouterState";var ph=f.createContext(!1);function oy(){return f.useContext(ph)}var gh=f.createContext({isTransitioning:!1});gh.displayName="ViewTransition";var ly=f.createContext(new Map);ly.displayName="Fetchers";var cy=f.createContext(null);cy.displayName="Await";var qt=f.createContext(null);qt.displayName="Navigation";var Xs=f.createContext(null);Xs.displayName="Location";var hn=f.createContext({outlet:null,matches:[],isDataRoute:!1});hn.displayName="Route";var ec=f.createContext(null);ec.displayName="RouteError";var yh="REACT_ROUTER_ERROR",uy="REDIRECT",dy="ROUTE_ERROR_RESPONSE";function fy(t){if(t.startsWith(`${yh}:${uy}:{`))try{let s=JSON.parse(t.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function hy(t){if(t.startsWith(`${yh}:${dy}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new ey(s.status,s.statusText,s.data)}catch{}}function my(t,{relative:s}={}){st(ns(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=f.useContext(qt),{hash:c,pathname:u,search:h}=Zs(t,{relative:s}),g=u;return a!=="/"&&(g=u==="/"?a:fn([a,u])),o.createHref({pathname:g,search:h,hash:c})}function ns(){return f.useContext(Xs)!=null}function Dt(){return st(ns(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(Xs).location}var vh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function xh(t){f.useContext(qt).static||f.useLayoutEffect(t)}function mn(){let{isDataRoute:t}=f.useContext(hn);return t?Ry():py()}function py(){st(ns(),"useNavigate() may be used only in the context of a <Router> component.");let t=f.useContext(ts),{basename:s,navigator:a}=f.useContext(qt),{matches:o}=f.useContext(hn),{pathname:c}=Dt(),u=JSON.stringify(Ql(o)),h=f.useRef(!1);return xh(()=>{h.current=!0}),f.useCallback((p,v={})=>{if(rn(h.current,vh),!h.current)return;if(typeof p=="number"){a.go(p);return}let y=Pi(p,JSON.parse(u),c,v.relative==="path");t==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:fn([s,y.pathname])),Zl(typeof p=="string"?p:br(p),a.createHref(y),Xl(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,c,t])}var gy=f.createContext(null);function yy(t){let s=f.useContext(hn).outlet;return f.useMemo(()=>s&&f.createElement(gy.Provider,{value:t},s),[s,t])}function Zs(t,{relative:s}={}){let{matches:a}=f.useContext(hn),{pathname:o}=Dt(),c=JSON.stringify(Ql(a));return f.useMemo(()=>Pi(t,JSON.parse(c),o,s==="path"),[t,c,o,s])}function vy(t,s){return wh(t,s)}function wh(t,s,a){var C;st(ns(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=f.useContext(qt),{matches:c}=f.useContext(hn),u=c[c.length-1],h=u?u.params:{},g=u?u.pathname:"/",p=u?u.pathnameBase:"/",v=u&&u.route;{let T=v&&v.path||"";Sh(g,!v||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${T}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
50
50
|
|
|
51
|
-
Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let y=Dt(),w;if(s){let T=typeof s=="string"?es(s):s;st(p==="/"||((C=T.pathname)==null?void 0:C.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${T.pathname}" was given in the \`location\` prop.`),w=T}else w=y;let j=w.pathname||"/",N=j;if(p!=="/"){let T=p.replace(/^\//,"").split("/");N="/"+j.replace(/^\//,"").split("/").slice(T.length).join("/")}let E=a&&a.state.matches.length?a.state.matches.map(T=>Object.assign(T,{route:a.manifest[T.route.id]||T.route})):ih(t,{pathname:N});rn(v||E!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),rn(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=by(E&&E.map(T=>Object.assign({},T,{params:Object.assign({},h,T.params),pathname:fn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:fn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,a);return s&&S?f.createElement(Xs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function xy(){let t=Ty(),s=ty(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",t),h=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:u},"ErrorBoundary")," or"," ",f.createElement("code",{style:u},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},s),a?f.createElement("pre",{style:c},a):null,h)}var wy=f.createElement(xy,null),jh=class extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=hy(t.digest);a&&(t=a)}let s=t!==void 0?f.createElement(hn.Provider,{value:this.props.routeContext},f.createElement(ec.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?f.createElement(jy,{error:t},s):s}};jh.contextType=ph;var El=new WeakMap;function jy({children:t,error:s}){let{basename:a,navigator:o}=f.useContext(qt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let c=fy(s.digest);if(c){let u=El.get(s);if(u)throw u;let h=hh(c.location,a),g=h.absoluteURL||h.to;if(Zl(c.location,g,Xl(o),"allow-explicit"),iy(g))throw new Error("Invalid redirect location");if(fh&&!El.get(s))if(h.isExternal||c.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(h.to,{replace:c.replace}));throw El.set(s,p),p}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return t}function Sy({routeContext:t,match:s,children:a}){let o=f.useContext(ts);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),f.createElement(hn.Provider,{value:t},a)}function by(t,s=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(w=>w.route.id&&(u==null?void 0:u[w.route.id])!==void 0);st(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let h=!1,g=-1;if(a&&o){h=o.renderFallback;for(let y=0;y<c.length;y++){let w=c[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(g=y),w.route.id){let{loaderData:j,errors:N}=o,E=w.route.loader&&!j.hasOwnProperty(w.route.id)&&(!N||N[w.route.id]===void 0);if(w.route.lazy||E){a.isStatic&&(h=!0),g>=0?c=c.slice(0,g+1):c=[c[0]];break}}}}let p=a==null?void 0:a.onError,v=o&&p?(y,w)=>{var j,N;p(y,{location:o.location,params:((N=(j=o.matches)==null?void 0:j[0])==null?void 0:N.params)??{},pattern:ny(o.matches),errorInfo:w})}:void 0;return c.reduceRight((y,w,j)=>{let N,E=!1,S=null,C=null;o&&(N=u&&w.route.id?u[w.route.id]:void 0,S=w.route.errorElement||wy,h&&(g<0&&j===0?(Sh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):g===j&&(E=!0,C=w.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,j+1)),R=()=>{let $;return N?$=S:E?$=C:w.route.Component?$=f.createElement(w.route.Component,null):w.route.element?$=w.route.element:$=y,f.createElement(Sy,{match:w,routeContext:{outlet:y,matches:T,isDataRoute:o!=null},children:$})};return o&&(w.route.ErrorBoundary||w.route.errorElement||j===0)?f.createElement(jh,{location:o.location,revalidation:o.revalidation,component:S,error:N,children:R(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:v}):R()},null)}function tc(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ky(t){let s=f.useContext(ts);return st(s,tc(t)),s}function Ny(t){let s=f.useContext(_i);return st(s,tc(t)),s}function Cy(t){let s=f.useContext(hn);return st(s,tc(t)),s}function nc(t){let s=Cy(t),a=s.matches[s.matches.length-1];return st(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function Ey(){return nc("useRouteId")}function Ty(){var o;let t=f.useContext(ec),s=Ny("useRouteError"),a=nc("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function Ry(){let{router:t}=ky("useNavigate"),s=nc("useNavigate"),a=f.useRef(!1);return xh(()=>{a.current=!0}),f.useCallback(async(c,u={})=>{rn(a.current,vh),a.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:s,...u}))},[t,s])}var gf={};function Sh(t,s,a){!s&&!gf[t]&&(gf[t]=!0,rn(!1,a))}f.memo(Iy);function Iy({routes:t,manifest:s,future:a,state:o,isStatic:c,onError:u}){return wh(t,void 0,{manifest:s,state:o,isStatic:c,onError:u})}function Pn({to:t,replace:s,state:a,relative:o}){st(ns(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c,navigator:u}=f.useContext(qt);rn(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:h}=f.useContext(hn),{pathname:g}=Dt(),p=mn(),v=Pi(t,Ql(h),g,o==="path");Zl(typeof t=="string"?t:br(t),u.createHref(v),Xl(u),"reject");let y=JSON.stringify(v);return f.useEffect(()=>{p(JSON.parse(y),{replace:s,state:a,relative:o})},[p,y,o,s,a]),null}function Ay(t){return yy(t.context)}function Xe(t){st(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Py({basename:t="/",children:s=null,location:a,navigationType:o="POP",navigator:c,static:u=!1,useTransitions:h}){st(!ns(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=t.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:g,navigator:c,static:u,useTransitions:h,future:{}}),[g,c,u,h]);typeof a=="string"&&(a=es(a));let{pathname:v="/",search:y="",hash:w="",state:j=null,key:N="default",mask:E}=a,S=f.useMemo(()=>{let C=_n(v,g);return C==null?null:{location:{pathname:C,search:y,hash:w,state:j,key:N,mask:E},navigationType:o}},[g,v,y,w,j,N,o,E]);return rn(S!=null,`<Router basename="${g}"> is not able to match the URL "${v}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:f.createElement(qt.Provider,{value:p},f.createElement(Xs.Provider,{children:s,value:S}))}function _y({children:t,location:s}){return vy(Ol(t),s)}function Ol(t,s=[]){let a=[];return f.Children.forEach(t,(o,c)=>{if(!f.isValidElement(o))return;let u=[...s,c];if(o.type===f.Fragment){a.push.apply(a,Ol(o.props.children,u));return}st(o.type===Xe,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),st(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=Ol(o.props.children,u)),a.push(h)}),a}var gi="get",yi="application/x-www-form-urlencoded";function $i(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function $y(t){return $i(t)&&t.tagName.toLowerCase()==="button"}function Ly(t){return $i(t)&&t.tagName.toLowerCase()==="form"}function zy(t){return $i(t)&&t.tagName.toLowerCase()==="input"}function Fy(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Oy(t,s){return t.button===0&&(!s||s==="_self")&&!Fy(t)}function Ml(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,a)=>{let o=t[a];return s.concat(Array.isArray(o)?o.map(c=>[a,c]):[[a,o]])},[]))}function My(t,s){let a=Ml(t);return s&&s.forEach((o,c)=>{a.has(c)||s.getAll(c).forEach(u=>{a.append(c,u)})}),a}var ui=null;function By(){if(ui===null)try{new FormData(document.createElement("form"),0),ui=!1}catch{ui=!0}return ui}var Dy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Tl(t){return t!=null&&!Dy.has(t)?(rn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${yi}"`),null):t}function Uy(t,s){let a,o,c,u,h;if(Ly(t)){let g=t.getAttribute("action");o=g?_n(g,s):null,a=t.getAttribute("method")||gi,c=Tl(t.getAttribute("enctype"))||yi,u=new FormData(t)}else if($y(t)||zy(t)&&(t.type==="submit"||t.type==="image")){let g=t.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=t.getAttribute("formaction")||g.getAttribute("action");if(o=p?_n(p,s):null,a=t.getAttribute("formmethod")||g.getAttribute("method")||gi,c=Tl(t.getAttribute("formenctype"))||Tl(g.getAttribute("enctype"))||yi,u=new FormData(g,t),!By()){let{name:v,type:y,value:w}=t;if(y==="image"){let j=v?`${v}.`:"";u.append(`${j}x`,"0"),u.append(`${j}y`,"0")}else v&&u.append(v,w)}}else{if($i(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=gi,o=null,c=yi,h=t}return u&&c==="text/plain"&&(h=u,u=void 0),{action:o,method:a.toLowerCase(),encType:c,formData:u,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function rc(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function bh(t,s,a,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return a?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&_n(c.pathname,s)==="/"?c.pathname=`${Xr(s)}/_root.${o}`:c.pathname=`${Xr(c.pathname)}.${o}`,c}async function Wy(t,s){if(t.id in s)return s[t.id];try{let a=await import(t.module);return s[t.id]=a,a}catch(a){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Hy(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Vy(t,s,a){let o=await Promise.all(t.map(async c=>{let u=s.routes[c.route.id];if(u){let h=await Wy(u,a);return h.links?h.links():[]}return[]}));return Yy(o.flat(1).filter(Hy).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function yf(t,s,a,o,c,u){let h=(p,v)=>a[v]?p.route.id!==a[v].route.id:!0,g=(p,v)=>{var y;return a[v].pathname!==p.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==p.params["*"]};return u==="assets"?s.filter((p,v)=>h(p,v)||g(p,v)):u==="data"?s.filter((p,v)=>{var w;let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(h(p,v)||g(p,v))return!0;if(p.route.shouldRevalidate){let j=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(t,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function Gy(t,s,{includeHydrateFallback:a}={}){return Ky(t.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),a&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Ky(t){return[...new Set(t)]}function qy(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Yy(t,s){let a=new Set;return new Set(s),t.reduce((o,c)=>{let u=JSON.stringify(qy(c));return a.has(u)||(a.add(u),o.push({key:u,link:c})),o},[])}function sc(){let t=f.useContext(ts);return rc(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Jy(){let t=f.useContext(_i);return rc(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ac=f.createContext(void 0);ac.displayName="FrameworkContext";function Li(){let t=f.useContext(ac);return rc(t,"You must render this element inside a <HydratedRouter> element"),t}function Qy(t,s){let a=f.useContext(ac),[o,c]=f.useState(!1),[u,h]=f.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:w}=s,j=f.useRef(null);f.useEffect(()=>{if(t==="render"&&h(!0),t==="viewport"){let S=T=>{T.forEach(R=>{h(R.isIntersecting)})},C=new IntersectionObserver(S,{threshold:.5});return j.current&&C.observe(j.current),()=>{C.disconnect()}}},[t]),f.useEffect(()=>{if(o){let S=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(S)}}},[o]);let N=()=>{c(!0)},E=()=>{c(!1),h(!1)};return a?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Bs(g,N),onBlur:Bs(p,E),onMouseEnter:Bs(v,N),onMouseLeave:Bs(y,E),onTouchStart:Bs(w,N)}]:[!1,j,{}]}function Bs(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function Xy({page:t,...s}){let a=oy(),{nonce:o}=Li(),{router:c}=sc(),u=f.useMemo(()=>ih(c.routes,t,c.basename),[c.routes,t,c.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?f.createElement(ev,{page:t,matches:u,...s}):f.createElement(tv,{page:t,matches:u,...s})):null}function Zy(t){let{manifest:s,routeModules:a}=Li(),[o,c]=f.useState([]);return f.useEffect(()=>{let u=!1;return Vy(t,s,a).then(h=>{u||c(h)}),()=>{u=!0}},[t,s,a]),o}function ev({page:t,matches:s,...a}){let o=Dt(),{future:c}=Li(),{basename:u}=sc(),h=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let g=bh(t,u,c.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?p=!0:v.push(y.route.id);return p&&v.length>0&&g.searchParams.set("_routes",v.join(",")),[g.pathname+g.search]},[u,c.v8_trailingSlashAwareDataRequests,t,o,s]);return f.createElement(f.Fragment,null,h.map(g=>f.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function tv({page:t,matches:s,...a}){let o=Dt(),{future:c,manifest:u,routeModules:h}=Li(),{basename:g}=sc(),{loaderData:p,matches:v}=Jy(),y=f.useMemo(()=>yf(t,s,v,u,o,"data"),[t,s,v,u,o]),w=f.useMemo(()=>yf(t,s,v,u,o,"assets"),[t,s,v,u,o]),j=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let S=new Set,C=!1;if(s.forEach(R=>{var A;let $=u.routes[R.route.id];!$||!$.hasLoader||(!y.some(F=>F.route.id===R.route.id)&&R.route.id in p&&((A=h[R.route.id])!=null&&A.shouldRevalidate)||$.hasClientLoader?C=!0:S.add(R.route.id))}),S.size===0)return[];let T=bh(t,g,c.v8_trailingSlashAwareDataRequests,"data");return C&&S.size>0&&T.searchParams.set("_routes",s.filter(R=>S.has(R.route.id)).map(R=>R.route.id).join(",")),[T.pathname+T.search]},[g,c.v8_trailingSlashAwareDataRequests,p,o,u,y,s,t,h]),N=f.useMemo(()=>Gy(w,u),[w,u]),E=Zy(w);return f.createElement(f.Fragment,null,j.map(S=>f.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),N.map(S=>f.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),E.map(({key:S,link:C})=>f.createElement("link",{key:S,nonce:a.nonce,...C,crossOrigin:C.crossOrigin??a.crossOrigin})))}function nv(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var rv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{rv&&(window.__reactRouterVersion="7.18.4")}catch{}function sv({basename:t,children:s,useTransitions:a,window:o}){let c=f.useRef();c.current==null&&(c.current=Pg({window:o,v5Compat:!0}));let u=c.current,[h,g]=f.useState({action:u.action,location:u.location}),p=f.useCallback(v=>{a===!1?g(v):f.startTransition(()=>g(v))},[a]);return f.useLayoutEffect(()=>u.listen(p),[u,p]),f.createElement(Py,{basename:t,children:s,location:h.location,navigationType:h.action,navigator:u,useTransitions:a})}var xt=f.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:c,reloadDocument:u,replace:h,mask:g,state:p,target:v,to:y,preventScrollReset:w,viewTransition:j,defaultShouldRevalidate:N,...E},S){let{basename:C,navigator:T,useTransitions:R}=f.useContext(qt),$=typeof y=="string"&&Jl.test(y),A=hh(y,C);y=A.to;let F=my(y,{relative:c}),G=Dt(),q=null;if(g){let Z=Pi(g,[],G.mask?G.mask.pathname:"/",!0);C!=="/"&&(Z.pathname=Z.pathname==="/"?C:fn([C,Z.pathname])),q=T.createHref(Z)}let[de,K,oe]=Qy(o,E),V=ov(y,{replace:h,mask:g,state:p,target:v,preventScrollReset:w,relative:c,viewTransition:j,defaultShouldRevalidate:N,useTransitions:R});function D(Z){s&&s(Z),Z.defaultPrevented||V(Z)}let ce=!(A.isExternal||u),re=f.createElement("a",{...E,...oe,href:(ce?q:void 0)||A.absoluteURL||F,onClick:ce?D:s,ref:nv(S,K),target:v,"data-discover":!$&&a==="render"?"true":void 0});return de&&!$?f.createElement(f.Fragment,null,re,f.createElement(Xy,{page:F})):re});xt.displayName="Link";var ic=f.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:c=!1,style:u,to:h,viewTransition:g,children:p,...v},y){let w=Zs(h,{relative:v.relative}),j=Dt(),N=f.useContext(_i),{navigator:E,basename:S}=f.useContext(qt),C=N!=null&&fv(w)&&g===!0,T=E.encodeLocation?E.encodeLocation(w).pathname:w.pathname,R=j.pathname,$=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;a||(R=R.toLowerCase(),$=$?$.toLowerCase():null,T=T.toLowerCase()),$&&S&&($=_n($,S)||$);const A=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let F=R===T||!c&&R.startsWith(T)&&R.charAt(A)==="/",G=$!=null&&($===T||!c&&$.startsWith(T)&&$.charAt(T.length)==="/"),q={isActive:F,isPending:G,isTransitioning:C},de=F?s:void 0,K;typeof o=="function"?K=o(q):K=[o,F?"active":null,G?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let oe=typeof u=="function"?u(q):u;return f.createElement(xt,{...v,"aria-current":de,className:K,ref:y,style:oe,to:h,viewTransition:g},typeof p=="function"?p(q):p)});ic.displayName="NavLink";var av=f.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:c,state:u,method:h=gi,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:j,...N},E)=>{let{useTransitions:S}=f.useContext(qt),C=uv(),T=dv(g,{relative:v}),R=h.toLowerCase()==="get"?"get":"post",$=typeof g=="string"&&Jl.test(g),A=F=>{if(p&&p(F),F.defaultPrevented)return;F.preventDefault();let G=F.nativeEvent.submitter,q=(G==null?void 0:G.getAttribute("formmethod"))||h,de=()=>C(G||F.currentTarget,{fetcherKey:s,method:q,navigate:a,replace:c,state:u,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:j});S&&a!==!1?f.startTransition(()=>de()):de()};return f.createElement("form",{ref:E,method:R,action:T,onSubmit:o?p:A,...N,"data-discover":!$&&t==="render"?"true":void 0})});av.displayName="Form";function iv(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kh(t){let s=f.useContext(ts);return st(s,iv(t)),s}function ov(t,{target:s,replace:a,mask:o,state:c,preventScrollReset:u,relative:h,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=mn(),w=Dt(),j=Zs(t,{relative:h});return f.useCallback(N=>{if(Oy(N,s)){N.preventDefault();let E=a!==void 0?a:br(w)===br(j),S=()=>y(t,{replace:E,mask:o,state:c,preventScrollReset:u,relative:h,viewTransition:g,defaultShouldRevalidate:p});v?f.startTransition(()=>S()):S()}},[w,y,j,a,o,c,s,t,u,h,g,p,v])}function oc(t){rn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=f.useRef(Ml(t)),a=f.useRef(!1),o=Dt(),c=f.useMemo(()=>My(o.search,a.current?null:s.current),[o.search]),u=mn(),h=f.useCallback((g,p)=>{const v=Ml(typeof g=="function"?g(new URLSearchParams(c)):g);a.current=!0,u("?"+v,p)},[u,c]);return[c,h]}var lv=0,cv=()=>`__${String(++lv)}__`;function uv(){let{router:t}=kh("useSubmit"),{basename:s}=f.useContext(qt),a=Ey(),o=t.fetch,c=t.navigate;return f.useCallback(async(u,h={})=>{let{action:g,method:p,encType:v,formData:y,body:w}=Uy(u,s);if(h.navigate===!1){let j=h.fetcherKey||cv();await o(j,a,h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:y,body:w,formMethod:h.method||p,formEncType:h.encType||v,flushSync:h.flushSync})}else await c(h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:y,body:w,formMethod:h.method||p,formEncType:h.encType||v,replace:h.replace,state:h.state,fromRouteId:a,flushSync:h.flushSync,viewTransition:h.viewTransition})},[o,c,s,a])}function dv(t,{relative:s}={}){let{basename:a}=f.useContext(qt),o=f.useContext(hn);st(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Zs(t||".",{relative:s})},h=Dt();if(t==null){u.search=h.search;let g=new URLSearchParams(u.search),p=g.getAll("index");if(p.some(y=>y==="")){g.delete("index"),p.filter(w=>w).forEach(w=>g.append("index",w));let y=g.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:fn([a,u.pathname])),br(u)}function fv(t,{relative:s}={}){let a=f.useContext(gh);st(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=kh("useViewTransitionState"),c=Zs(t,{relative:s});if(!a.isTransitioning)return!1;let u=_n(a.currentLocation.pathname,o)||a.currentLocation.pathname,h=_n(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Si(c.pathname,h)!=null||Si(c.pathname,u)!=null}var hv=sh();const wr="owner";function mv(t){const s=t||wr;return s===wr?[wr]:[s,wr]}function pv(t){const s=new Map;for(const a of t)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function gv(t,s){const a=s||wr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(wr)?wr:a}class Nh extends Error{constructor(a){super("different_account");Os(this,"summary");this.name="DifferentAccountError",this.summary=a}}function De(t,s){const a=t??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function yv(t){const s=t==null?void 0:t.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class vv{constructor(){Os(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const u=await o.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Nh(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(De(u,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const a=await s.json();return a.groups??a}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(u=>{var h,g;return{authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(p=>!(u.attestedDomains??[]).includes(p)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",earliest_expiry:(h=u.attestations)!=null&&h.length?new Date(Math.min(...u.attestations.map(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=u.attestations)!=null&&g.length?Math.max(0,Math.min(...u.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",c=await this.fetch(`/denials${o}`);if(!c.ok)throw new Error(`Failed to fetch denials: ${c.status}`);return c.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);return(await c.json()).tickets??[]}async fetchEvidenceBundle(){var c;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(De(a,`Export failed (${s.status})`));const o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(De(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(De(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(De(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var c;const s=await this.fetch("/api/report/export");if(!s.ok){const u=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(De(u,`Export failed (${s.status})`))}const a=await s.text(),o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(De(c,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(u,`Create group failed: ${a.status}`))}const o=await a.json(),c=o.group||o;return{id:c.id,name:c.name,myDomains:c.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(De(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const c=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(c,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(De(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(De(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const c=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(De(c,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(De(c,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const c=await o.json();return(c==null?void 0:c.config)??null}async setTeamProfileConfig(s,a,o){const c=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!c.ok){const u=await c.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(De(u,`setTeamProfileConfig failed: ${c.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?yv(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(De(c,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",c=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!c.ok)throw new Error(`Failed to fetch proposals: ${c.status}`);return(await c.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(mv(s).map(c=>this.getProposals(c,a)));return pv(o)}async resolveProposal(s,a,o,c){const{noteEncrypted:u,contentHash:h,shownHash:g,note:p,...v}=c??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...v,...u?{note_encrypted:u}:p?{note:p}:{},...h?{content_hash:h}:{},...g?{shown_hash:g}:{}})});if(!y.ok){const w=await y.json().catch(()=>({error:"Failed"}));throw new Error(De(w,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const c=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`getProposal failed: ${a.status}`))}const o=await a.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,a,o){const c={};a&&(c.content_hash=a),o&&(c.shown_hash=o);const u=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:Object.keys(c).length>0?JSON.stringify(c):void 0});if(!u.ok){const h=await u.json().catch(()=>({error:"Failed"}));throw new Error(De(h,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(s,a,o,c){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:g,note:p,...v}=a??{};u={...v,...g?{note_encrypted:g}:p?{note:p}:{}}}o&&(u.content_hash=o),c&&(u.shown_hash=c);const h=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!h.ok){const g=await h.json().catch(()=>({error:"Failed"}));throw new Error(De(g,`rejectProposal failed: ${h.status}`))}return h.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to store the shown snapshot: ${o.status}`);return o.json()}async getShownSnapshot(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(c,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(c=>{var g,p;const u=c.owner??{userId:""};return{authorization_id:c.authorization_id??c.authorizationId,profile_id:c.profileId??c.profile_id,path:c.path??"",title:c.title??null,sp_status:c.status??c.sp_status??null,frame:c.bounds??c.frame??{},required_domains:c.requiredDomains??c.required_domains??[],attested_domains:c.attestedDomains??c.attested_domains??[],missing_domains:(c.requiredDomains??c.required_domains??[]).filter(v=>!(c.attestedDomains??c.attested_domains??[]).includes(v)),deferred_commitment_domains:c.deferredCommitmentDomains??c.deferred_commitment_domains??[],approvers_frozen:c.approversFrozen??c.approvers_frozen??[],above_cap:c.aboveCap??c.above_cap??!1,created_at:c.createdAt?new Date(c.createdAt*1e3).toISOString():c.created_at??"",earliest_expiry:(g=c.mandates)!=null&&g.length?new Date(Math.min(...c.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=c.mandates)!=null&&p.length?Math.max(0,Math.min(...c.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);const u=await c.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const c=o.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${c?"?"+c:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const h=await u.json();return{receipts:h.tickets??[],nextBefore:h.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",c=await this.getMyProposals(s.domain,o);let u=[];if(o==="all"){const h=[],g=new Date;for(let v=0;v<a;v++){const y=new Date(g);y.setUTCDate(g.getUTCDate()-v),h.push(y.toISOString().slice(0,10))}u=(await Promise.all(h.map(v=>this.getMyReceipts({date:v,profile:s.profile})))).flat()}return{proposals:c,receipts:u}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(De(o,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(De(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:De(o,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Save failed"}));throw new Error(De(c,`Save failed: ${o.status}`))}}}const M=new vv,Ch=f.createContext(null);function xv({children:t}){const[s,a]=f.useState(null),[o,c]=f.useState("personal"),[u,h]=f.useState(null),[g,p]=f.useState(""),[v,y]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState(null),[S,C]=f.useState(!1),[T,R]=f.useState(""),$=f.useRef(!1),A=f.useRef(null),F=f.useCallback(async()=>{if($.current)try{const V=await M.getMyTeam();if(E(V.pendingRequest),V.group&&V.membership){const{group:D,membership:ce}=V;y(D),j(ce),c("team"),h(D);const re=A.current??ce.domains[0]??"owner";p(re)}else y(null),j(null),c("personal")}catch{}},[]);f.useEffect(()=>{const V=()=>{document.visibilityState==="visible"&&F()};return document.addEventListener("visibilitychange",V),()=>document.removeEventListener("visibilitychange",V)},[F]),f.useEffect(()=>{fetch("/health").then(V=>V.json()).then(V=>{var D;((D=V.session)==null?void 0:D.lockedReason)==="as-url-changed"&&R(`Authority Server changed to ${V.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const G=f.useCallback(async(V,D={})=>{C(!0),R("");try{M.setApiKey(V),$.current=!0;const ce=await M.login(V,D);a(ce),A.current=ce.id;const re=await M.getGroups(),Z=re.find(he=>he.isPersonal)??re[0]??null;h(Z),p("owner"),await F()}catch(ce){throw M.clearApiKey(),$.current=!1,R(ce instanceof Error?ce.message:"Login failed"),ce}finally{C(!1)}},[F]),q=f.useCallback(async()=>{await M.logout(),M.clearApiKey(),$.current=!1,A.current=null,a(null),h(null),p(""),y(null),j(null),E(null),c("personal"),R("")},[]),de=f.useCallback(V=>{M.clearApiKey(),$.current=!1,A.current=null,a(null),h(null),p(""),y(null),j(null),E(null),c("personal"),R(V??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),K=f.useCallback(()=>R(""),[]),oe=f.useCallback((V,D)=>{h(V),p(D)},[]);return r.jsx(Ch.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:w,pendingRequest:N,isLoading:S,error:T,login:G,logout:q,clearError:K,handleSessionLocked:de,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:oe,refreshGroups:F},children:t})}function pt(){const t=f.useContext(Ch);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const Eh=f.createContext(null);function wv({children:t}){const{user:s}=pt(),a=f.useRef(null),[o,c]=f.useState(!1),u=f.useRef(new Map),h=f.useCallback((g,p)=>{const v=u.current;return v.has(g)||v.set(g,new Set),v.get(g).add(p),()=>{var y;(y=v.get(g))==null||y.delete(p)}},[]);return f.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,c(!1));return}if(a.current)return;const g=M.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);a.current=p,p.onopen=()=>c(!0),p.onerror=()=>c(!1);const v=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const y of v)p.addEventListener(y,w=>{let j;try{j=JSON.parse(w.data)}catch{j=null}const N=u.current.get(y);if(N)for(const E of N)try{E(j)}catch(S){console.error(`[EventSource] handler for "${y}" threw:`,S)}});return()=>{p.close(),a.current=null,c(!1)}},[s]),r.jsx(Eh.Provider,{value:{connected:o,addListener:h},children:t})}function Ge(t,s){const a=f.useContext(Eh);if(!a)return;const{addListener:o}=a;f.useEffect(()=>o(t,s),[t,s,o])}const Gs="suveren-theme",vf="hap-theme";function di(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(vf);s!==null&&localStorage.getItem(Gs)===null&&localStorage.setItem(Gs,s),s!==null&&localStorage.removeItem(vf)})();function Th(){const[t,s]=f.useState(()=>{const u=localStorage.getItem(Gs);return u==="light"||u==="dark"?u:"system"}),[a,o]=f.useState(()=>di(t));f.useEffect(()=>{const u=document.documentElement,h=di(t);u.setAttribute("data-theme",h),t==="system"?localStorage.removeItem(Gs):localStorage.setItem(Gs,t),o(di(t))},[t]),f.useEffect(()=>{if(t!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>o(di("system"));return u.addEventListener("change",h),()=>u.removeEventListener("change",h)},[t]);const c=f.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:c}}const jv=300*1e3,Sv=2e3;function lc(){const[t,s]=f.useState(!1),[a,o]=f.useState("docker"),[c,u]=f.useState(""),[h,g]=f.useState(null),[p,v]=f.useState(!1),[y,w]=f.useState(!1),[j,N]=f.useState(!1),E=f.useRef(null);return f.useEffect(()=>{let S=!1;const C=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(A=>A.json()).then(A=>{S||(A.installMethod&&o(A.installMethod),typeof A.latestVersion<"u"&&g(A.latestVersion),A.updateAvailable&&s(!0),A.version&&(u(A.version),E.current===null?E.current=A.version:A.version!==E.current&&A.version!=="dev"&&v(!0)))}).catch(()=>{})};C(!0);const T=setInterval(()=>C(!1),j?Sv:jv),R=()=>{document.visibilityState==="visible"&&C(!1)};return document.addEventListener("visibilitychange",R),window.addEventListener("focus",R),()=>{S=!0,clearInterval(T),document.removeEventListener("visibilitychange",R),window.removeEventListener("focus",R)}},[j]),{updateAvailable:t&&!y,installMethod:a,version:c,latestVersion:h,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>w(!0)}}function bv(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function kv(){const[t,s]=f.useState({managed:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(bv(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Nv({size:t=20}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),r.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Cv(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const xf={system:"◑",light:"☀",dark:"☾"};function cc({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:c}=pt(),{theme:u,toggle:h}=Th(),{version:g,updateAvailable:p,latestVersion:v}=lc(),{managed:y}=kv(),w=Cv(g),j=o==="team"&&c?`Team ${c.name}`:"Personal";return r.jsx("nav",{className:"top-nav",children:r.jsxs("div",{className:"top-nav-inner",children:[r.jsxs("div",{className:"logo-group",children:[r.jsx(Nv,{size:20}),r.jsx("span",{className:"logo",children:"Suveren"}),r.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&r.jsxs("span",{className:"gw-version",title:p&&v?`Running v${w} — v${v} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",w,p&&v?` → ${v}`:""]})]}),r.jsx("div",{className:"nav-spacer"}),r.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${j} — set by your IT`:j,children:[j,y&&r.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),r.jsx("span",{className:"user-chip",children:r.jsx("strong",{children:s.name})}),r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${u}`,children:xf[u]}),r.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${u}`,children:xf[u]})}),s&&t&&r.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function uc(t,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(t.authorization_id))return"revoked";switch(t.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return t.remaining_seconds===null||t.remaining_seconds<=0?"expired":t.missing_domains.length>0?"pending":"active"}function Rh(t){return t==="expired"||t==="revoked"}function Ih(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&Rh(uc(t,s))}function bi(t,s){return Ih(t,s)?"archived":uc(t,s)}function Ah(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[bi(o,s)].push(o);return a}function Ev(t,s){return s==="expired"?t.earliest_expiry?{iso:t.earliest_expiry,meaning:"expired"}:null:t.created_at?{iso:t.created_at,meaning:"created"}:null}function nn(t,s,a){const o=f.useRef(t);o.current=t,f.useEffect(()=>{let c=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",h=()=>{u()&&o.current()},g=()=>{c===null&&(c=setInterval(h,s))},p=()=>{c!==null&&(clearInterval(c),c=null)},v=()=>{u()?(o.current(),g()):p()};return u()&&(o.current(),g()),document.addEventListener("visibilitychange",v),()=>{p(),document.removeEventListener("visibilitychange",v)}},[s,a])}function dc(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(h.simulation===!0)}).catch(()=>{})};o();const c=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",u)}},[]),t}function Tv(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function qs(t){return!!(t!=null&&t.simulation)}const Ph=f.createContext(null),Rv=3e4,Iv=5e3,Av=3e5;function Pv(t,s,a){return s===0?"loading":t!=null&&t.running?"running":t!=null&&t.paused?"paused":t!=null&&t.error?"error":t&&a?"starting":"not-running"}function _v({children:t}){const[s,a]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=f.useRef(null),c=f.useCallback(async()=>{let y=!1;const[w,j]=await Promise.all([M.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),M.getMcpHealth().catch(()=>null)]);a(E=>({...E,manifests:w.manifests,integrations:(j==null?void 0:j.integrations)??E.integrations,activeSessions:(j==null?void 0:j.activeSessions)??E.activeSessions,mcpServerUp:!!j,manifestsError:y,fetchCount:E.fetchCount+1}));const N=w.manifests.filter(E=>E.oauth);if(N.length>0){const E=await Promise.all(N.map(async S=>[S.id,await M.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(E)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const w=s.integrations.find(j=>j.id===y.id);return w&&!w.running&&!w.paused});Ge("integration-changed",c),nn(c,u?Iv:Av);const h=f.useMemo(()=>{const y=new Map(s.integrations.map(N=>[N.id,N])),w=Date.now();u&&o.current===null?o.current=w:u||(o.current=null);const j=o.current!==null&&w-o.current<Rv;return s.manifests.map(N=>{const E=y.get(N.id),S=Pv(E,s.fetchCount,j),C=s.authHealth[N.id];return{id:N.id,manifest:N,integration:E,state:S,authStatus:C==null?void 0:C.status,authAccount:C==null?void 0:C.account,authError:C==null?void 0:C.error}})},[s,u]),g=dc(),p=f.useMemo(()=>h.filter(y=>!(g&&!qs(y.manifest))&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[h,g]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:h,attentionCount:p,activeSessions:s.activeSessions,refresh:c};return r.jsx(Ph.Provider,{value:v,children:t})}function fc(){const t=f.useContext(Ph);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const $v={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},hc=t=>$v[t]??t,Lv={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function zv(t){return(t&&Lv[t])??{chip:"Blocked",sev:"info"}}function Fv(t){const s=hc(t.integrationId);switch(t.reason){case"resource":return t.integrationId==="calendar"?r.jsxs(r.Fragment,{children:["Tried to read your ",r.jsx("b",{children:t.target??"restricted"})," calendar"]}):r.jsxs(r.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return r.jsxs(r.Fragment,{children:["Tried to open a message in ",r.jsx("b",{children:"spam or trash"})]});case"age":return r.jsxs(r.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return r.jsxs(r.Fragment,{children:["Your ",s," has ",r.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return r.jsxs(r.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return r.jsxs(r.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return r.jsx(r.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return r.jsx(r.Fragment,{children:t.detail})}}function _h(t,s){const a=Math.max(0,(s-t)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const wf=5,Ov=1440*60*1e3,vi=7;function Mv(t,s){const a=s-vi*Ov;return{recent:t.filter(o=>o.ts>=a),all:t}}function Bv(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(!1),h=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:j})=>{s(j),u(!1)}).catch(()=>u(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,12e4),c||t===null)return null;const{recent:g,all:p}=Mv(t,Date.now()),v=a?p:g.slice(0,wf),y=p.length-g.length,w=(j,N)=>{const E=zv(j.reason);return r.jsxs("div",{className:"rb-row",children:[r.jsx("span",{className:`rb-dot ${E.sev==="act"?"act":E.sev==="info"?"info":""}`,"aria-hidden":"true"}),r.jsxs("div",{className:"rb-body",children:[r.jsx("div",{className:"rb-line",children:Fv(j)}),r.jsxs("div",{className:"rb-meta",children:[r.jsx("span",{className:`rb-chip ${E.sev==="act"?"act":E.sev==="warn"?"warn":""}`,children:E.chip}),r.jsx("span",{className:"rb-via",children:hc(j.integrationId)})]}),E.fixTo&&r.jsx(xt,{className:"rb-fix",to:E.fixTo,children:"Set a read window →"})]}),r.jsx("div",{className:"rb-when",children:_h(j.ts,Date.now())})]},`${j.ts}-${N}`)};return r.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Recent blocks"}),(a?p.length:g.length)>0&&r.jsx("span",{className:"rb-count",children:a?p.length:g.length})]}),v.length===0?r.jsxs("div",{className:"rb-empty",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsxs("h3",{children:["Nothing blocked in the last ",vi," days"]}),r.jsx("p",{children:"Your agent has stayed within every limit you set."}),y>0&&r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["Show the last 30 days (",y,")"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"rb-sub",children:[a?"Last 30 days. ":`Last ${vi} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),r.jsx("div",{className:"rb-rows",children:v.map(w)}),!a&&p.length>v.length&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",p.length," blocks from the last 30 days"]})}),a&&p.length>Math.min(g.length,wf)&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!1),children:["Show only the last ",vi," days"]})})]})]})}function Ys(t){return t.kind??"read"}function Dv(t,s){var u,h,g,p;if(!s)return"";if(!t)return s;const a=(h=(u=t.scopeSchema)==null?void 0:u.fields)==null?void 0:h[s];if(a!=null&&a.displayName)return a.displayName;const o=((g=t.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.displayName)return o[s].displayName;const c=Object.values(o).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===s);return c!=null&&c.displayName?c.displayName:s}const Uv={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",read:"Read blocked"},Wv={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function jf(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Hv(t,s){const a=Ys(t),o=jf(t.value),c=jf(t.limit);switch(a){case"bound":return o&&c?`${s||"Value"} ${o} is above the limit ${c}.`:t.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:t.detail;case"cumulative":return o&&c?`${o} of ${c} used — the limit is reached.`:t.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return t.detail}}function Vv(t){const s=Ys(t),a=hc(t.integrationId),o=t.mandateTitle?` · mandate "${t.mandateTitle}"`:t.mandateId?` · mandate ${t.mandateId.slice(0,14)}…`:"",c=t.who==="authority-server"?"refused by the Authority Server":s==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=t.code?` (${t.code})`:"";return`${a} · ${t.tool}${o} · ${c}${u}`}function Gv(t,s){const a=Ys(t),o=Dv(s,t.field);return{title:Uv[a],sentence:Hv(t,o),sourceLine:Vv(t),whatYouCanDo:Wv[a]}}function $h(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}const Kv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/blocked",icon:"⛔",label:"Blocked",statusKey:"blocked"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function qv(){const{activeDomain:t}=pt(),[s,a]=f.useState({}),o=f.useCallback(async()=>{try{const[c,u,h,g,p,v,y]=await Promise.all([M.getCredential("ai-config").catch(()=>null),M.getMyAttestations().catch(()=>null),M.getMyProposals(t).catch(()=>null),M.getProposalsForApprover().catch(()=>null),M.getAgentContext().catch(()=>""),M.getArchivedMandates().catch(()=>[]),M.getDenials({limit:200}).catch(()=>null)]),w={};if(c&&!c.configured&&(w.assistant=1),u){const S=Ah(u,{archivedSet:new Set(v)}).expired.length;S>0&&(w.authorizations=S)}const j=(h==null?void 0:h.length)??0,N=(g==null?void 0:g.length)??0,E=j+N;if(E>0&&(w.proposals=E),(!p||!p.trim())&&(w.brief=1),y){const S=$h(y.records,Date.now());S>0&&(w.blocked=S)}a(w)}catch{}},[t]);return Ge("attestation-changed",o),Ge("proposal-added",o),Ge("proposal-resolved",o),Ge("proposal-approved",o),Ge("proposal-rejected",o),Ge("team-membership-changed",o),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),nn(o,3e5,t),s}const Yv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},Jv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function Qv(){const{mode:t,group:s,domain:a,activeTeam:o}=pt(),c=qv(),{attentionCount:u}=fc(),h={...c};u>0&&(h.integrations=u);const g=Kv.filter(j=>!j.teamOnly||t==="team"),p=f.useRef(null),[v,y]=f.useState(null),w=Dt();return f.useEffect(()=>{if(p.current===null){p.current=t;return}p.current!==t&&(t==="team"&&o?y(`You are now acting in team context — ${o.name}`):t==="personal"&&y("You have left the team — back to personal context"),p.current=t)},[t,o]),f.useEffect(()=>{y(null)},[w.pathname]),r.jsxs("div",{className:"sidebar",children:[r.jsx("ul",{className:"sidebar-nav",children:g.map(j=>{const N=j.statusKey?h[j.statusKey]:0;return r.jsx("li",{children:r.jsxs(ic,{to:j.to,end:j.to==="/",className:({isActive:E})=>`sidebar-item${E?" active":""}`,children:[r.jsx("span",{className:"icon",children:j.icon}),j.label,N?r.jsx("span",{style:Yv,children:N}):null]})},j.to)})}),r.jsxs("div",{className:"sidebar-context",children:[r.jsx("div",{className:"ctx-label",children:"Active context"}),r.jsx("div",{className:"ctx-value",children:t==="personal"?"personal":s?`${s.name} / ${a}`:a})]}),v&&r.jsx("div",{style:Jv,role:"status","aria-live":"polite",children:v})]})}const Rl="suveren:updatedTo";function Xv(t){return t==="managed"||t==="msi"?null:t==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":t==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Zv="Updates for this gateway come from your company's IT — no action needed here.";function ex(t){return t==="managed"?"update-banner is-managed":"update-banner"}const tx="Download the new installer and run it. Your settings and mandates stay.";function nx(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function rx(){const t=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of t)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function Lh(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:c,startFastPolling:u,dismiss:h}=lc(),[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(()=>{try{const $=sessionStorage.getItem(Rl);if($)return sessionStorage.removeItem(Rl),$}catch{}return null}),N=Xv(s),E=f.useRef(null),S=$=>{try{sessionStorage.setItem(Rl,$||o||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!w)return;const $=setTimeout(()=>j(null),6e3);return()=>clearTimeout($)},[w]),f.useEffect(()=>{if(!g||!c)return;const $=()=>rx()?!1:(S(a),!0);if($())return;const A=setInterval($,1500);return()=>clearInterval(A)},[g,c,a]),f.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const C=t&&!g&&!w||!!w&&!g;f.useEffect(()=>{if(!C){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const $=()=>{var G;const F=((G=E.current)==null?void 0:G.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${F}px`)};$();const A=new ResizeObserver($);return E.current&&A.observe(E.current),()=>{A.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[C]);const T=()=>{p(!0),u()},R=async()=>{if(N)try{await navigator.clipboard.writeText(N),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return r.jsxs(r.Fragment,{children:[w&&!g&&r.jsx("div",{ref:E,className:"update-banner is-live",role:"status","aria-live":"polite",children:r.jsxs("div",{className:"update-banner-row",children:[r.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",w&&w!=="✓"?` — ${w} is live`:" — now live","."]}),r.jsx("button",{className:"update-banner-x",onClick:()=>j(null),"aria-label":"Dismiss",children:"×"})]})}),t&&!g&&!w&&r.jsxs("div",{ref:E,className:ex(s),role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"update-banner-row",children:[r.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&r.jsx("a",{className:"btn btn-sm btn-secondary",href:nx(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:T,children:"Update"}),r.jsx("button",{className:"update-banner-x",onClick:h,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&r.jsx("p",{className:"update-banner-hint",children:Zv}),s==="msi"&&r.jsx("p",{className:"update-banner-hint",children:tx})]}),g&&r.jsx("div",{className:"update-overlay",children:r.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[r.jsx("div",{className:"update-spinner"}),r.jsxs("h2",{children:["Finishing the update","…"]}),r.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",r.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),r.jsxs("div",{className:"update-cmd-row",children:[r.jsx("code",{className:"update-cmd",children:N}),r.jsx("button",{className:"btn btn-sm btn-primary",onClick:R,children:v?"Copied":"Copy"})]}),r.jsxs("div",{className:"update-status",children:[r.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),r.jsxs("div",{className:"update-overlay-actions",children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),r.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function zh(){const t=dc(),s=f.useRef(null);return f.useEffect(()=>{if(!t){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const c=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${c}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[t]),t?r.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:r.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const sx={system:"◑",light:"☀",dark:"☾"},ax=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function ix({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:c,logout:u}=pt(),{theme:h,toggle:g}=Th(),p=Dt();return f.useEffect(()=>{s()},[p.pathname]),t?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),r.jsxs("div",{className:"mobile-menu-panel",children:[a&&r.jsxs("div",{className:"mobile-menu-header",children:[r.jsx("strong",{children:a.name}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${c}`:c||"personal"})]}),r.jsx("nav",{className:"mobile-menu-nav",children:ax.map(v=>r.jsxs(ic,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:s,children:[r.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),r.jsxs("div",{className:"mobile-menu-footer",children:[r.jsxs("button",{className:"mobile-menu-action",onClick:()=>{g()},children:[r.jsx("span",{className:"icon",children:sx[h]}),"Theme: ",h]}),r.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function Fh(t){return t.status==="pending"}function ox(t,s){return t.filter(Fh).length+s.length}const vr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],lx=500;function Oh(){const{user:t,domain:s}=pt(),[a,o]=f.useState(0),c=f.useRef(null),u=f.useCallback(async()=>{if(!t){o(0);return}try{const[g,p]=await Promise.all([M.getMyProposals(s).catch(()=>[]),M.getProposalsForApprover().catch(()=>[])]);o(ox(g,p))}catch{o(0)}},[t,s]),h=f.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{u()},lx)},[u]);return f.useEffect(()=>(u(),()=>{c.current&&clearTimeout(c.current)}),[u]),Ge(vr[0],h),Ge(vr[1],h),Ge(vr[2],h),Ge(vr[3],h),Ge(vr[4],h),Ge(vr[5],h),Ge(vr[6],h),a}const Sf="Suveren",cx="/favicon.svg",ux="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",fi={x1:74.54,y1:22.74,x2:94.46,y2:34.24},dx=14,fx="#f59e0b";function hx(t){const s=mc(t);return s>0?`(${s}) ${Sf}`:Sf}function mc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function mx(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
51
|
+
Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let y=Dt(),w;if(s){let T=typeof s=="string"?es(s):s;st(p==="/"||((C=T.pathname)==null?void 0:C.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${T.pathname}" was given in the \`location\` prop.`),w=T}else w=y;let j=w.pathname||"/",N=j;if(p!=="/"){let T=p.replace(/^\//,"").split("/");N="/"+j.replace(/^\//,"").split("/").slice(T.length).join("/")}let E=a&&a.state.matches.length?a.state.matches.map(T=>Object.assign(T,{route:a.manifest[T.route.id]||T.route})):ih(t,{pathname:N});rn(v||E!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),rn(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=by(E&&E.map(T=>Object.assign({},T,{params:Object.assign({},h,T.params),pathname:fn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:fn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,a);return s&&S?f.createElement(Xs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function xy(){let t=Ty(),s=ty(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",t),h=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:u},"ErrorBoundary")," or"," ",f.createElement("code",{style:u},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},s),a?f.createElement("pre",{style:c},a):null,h)}var wy=f.createElement(xy,null),jh=class extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=hy(t.digest);a&&(t=a)}let s=t!==void 0?f.createElement(hn.Provider,{value:this.props.routeContext},f.createElement(ec.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?f.createElement(jy,{error:t},s):s}};jh.contextType=ph;var El=new WeakMap;function jy({children:t,error:s}){let{basename:a,navigator:o}=f.useContext(qt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let c=fy(s.digest);if(c){let u=El.get(s);if(u)throw u;let h=hh(c.location,a),g=h.absoluteURL||h.to;if(Zl(c.location,g,Xl(o),"allow-explicit"),iy(g))throw new Error("Invalid redirect location");if(fh&&!El.get(s))if(h.isExternal||c.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(h.to,{replace:c.replace}));throw El.set(s,p),p}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return t}function Sy({routeContext:t,match:s,children:a}){let o=f.useContext(ts);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),f.createElement(hn.Provider,{value:t},a)}function by(t,s=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(w=>w.route.id&&(u==null?void 0:u[w.route.id])!==void 0);st(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let h=!1,g=-1;if(a&&o){h=o.renderFallback;for(let y=0;y<c.length;y++){let w=c[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(g=y),w.route.id){let{loaderData:j,errors:N}=o,E=w.route.loader&&!j.hasOwnProperty(w.route.id)&&(!N||N[w.route.id]===void 0);if(w.route.lazy||E){a.isStatic&&(h=!0),g>=0?c=c.slice(0,g+1):c=[c[0]];break}}}}let p=a==null?void 0:a.onError,v=o&&p?(y,w)=>{var j,N;p(y,{location:o.location,params:((N=(j=o.matches)==null?void 0:j[0])==null?void 0:N.params)??{},pattern:ny(o.matches),errorInfo:w})}:void 0;return c.reduceRight((y,w,j)=>{let N,E=!1,S=null,C=null;o&&(N=u&&w.route.id?u[w.route.id]:void 0,S=w.route.errorElement||wy,h&&(g<0&&j===0?(Sh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):g===j&&(E=!0,C=w.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,j+1)),R=()=>{let $;return N?$=S:E?$=C:w.route.Component?$=f.createElement(w.route.Component,null):w.route.element?$=w.route.element:$=y,f.createElement(Sy,{match:w,routeContext:{outlet:y,matches:T,isDataRoute:o!=null},children:$})};return o&&(w.route.ErrorBoundary||w.route.errorElement||j===0)?f.createElement(jh,{location:o.location,revalidation:o.revalidation,component:S,error:N,children:R(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:v}):R()},null)}function tc(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ky(t){let s=f.useContext(ts);return st(s,tc(t)),s}function Ny(t){let s=f.useContext(_i);return st(s,tc(t)),s}function Cy(t){let s=f.useContext(hn);return st(s,tc(t)),s}function nc(t){let s=Cy(t),a=s.matches[s.matches.length-1];return st(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function Ey(){return nc("useRouteId")}function Ty(){var o;let t=f.useContext(ec),s=Ny("useRouteError"),a=nc("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function Ry(){let{router:t}=ky("useNavigate"),s=nc("useNavigate"),a=f.useRef(!1);return xh(()=>{a.current=!0}),f.useCallback(async(c,u={})=>{rn(a.current,vh),a.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:s,...u}))},[t,s])}var gf={};function Sh(t,s,a){!s&&!gf[t]&&(gf[t]=!0,rn(!1,a))}f.memo(Iy);function Iy({routes:t,manifest:s,future:a,state:o,isStatic:c,onError:u}){return wh(t,void 0,{manifest:s,state:o,isStatic:c,onError:u})}function Pn({to:t,replace:s,state:a,relative:o}){st(ns(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c,navigator:u}=f.useContext(qt);rn(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:h}=f.useContext(hn),{pathname:g}=Dt(),p=mn(),v=Pi(t,Ql(h),g,o==="path");Zl(typeof t=="string"?t:br(t),u.createHref(v),Xl(u),"reject");let y=JSON.stringify(v);return f.useEffect(()=>{p(JSON.parse(y),{replace:s,state:a,relative:o})},[p,y,o,s,a]),null}function Ay(t){return yy(t.context)}function Xe(t){st(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Py({basename:t="/",children:s=null,location:a,navigationType:o="POP",navigator:c,static:u=!1,useTransitions:h}){st(!ns(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=t.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:g,navigator:c,static:u,useTransitions:h,future:{}}),[g,c,u,h]);typeof a=="string"&&(a=es(a));let{pathname:v="/",search:y="",hash:w="",state:j=null,key:N="default",mask:E}=a,S=f.useMemo(()=>{let C=_n(v,g);return C==null?null:{location:{pathname:C,search:y,hash:w,state:j,key:N,mask:E},navigationType:o}},[g,v,y,w,j,N,o,E]);return rn(S!=null,`<Router basename="${g}"> is not able to match the URL "${v}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:f.createElement(qt.Provider,{value:p},f.createElement(Xs.Provider,{children:s,value:S}))}function _y({children:t,location:s}){return vy(Ol(t),s)}function Ol(t,s=[]){let a=[];return f.Children.forEach(t,(o,c)=>{if(!f.isValidElement(o))return;let u=[...s,c];if(o.type===f.Fragment){a.push.apply(a,Ol(o.props.children,u));return}st(o.type===Xe,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),st(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=Ol(o.props.children,u)),a.push(h)}),a}var gi="get",yi="application/x-www-form-urlencoded";function $i(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function $y(t){return $i(t)&&t.tagName.toLowerCase()==="button"}function Ly(t){return $i(t)&&t.tagName.toLowerCase()==="form"}function zy(t){return $i(t)&&t.tagName.toLowerCase()==="input"}function Fy(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Oy(t,s){return t.button===0&&(!s||s==="_self")&&!Fy(t)}function Ml(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,a)=>{let o=t[a];return s.concat(Array.isArray(o)?o.map(c=>[a,c]):[[a,o]])},[]))}function My(t,s){let a=Ml(t);return s&&s.forEach((o,c)=>{a.has(c)||s.getAll(c).forEach(u=>{a.append(c,u)})}),a}var ui=null;function By(){if(ui===null)try{new FormData(document.createElement("form"),0),ui=!1}catch{ui=!0}return ui}var Dy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Tl(t){return t!=null&&!Dy.has(t)?(rn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${yi}"`),null):t}function Uy(t,s){let a,o,c,u,h;if(Ly(t)){let g=t.getAttribute("action");o=g?_n(g,s):null,a=t.getAttribute("method")||gi,c=Tl(t.getAttribute("enctype"))||yi,u=new FormData(t)}else if($y(t)||zy(t)&&(t.type==="submit"||t.type==="image")){let g=t.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=t.getAttribute("formaction")||g.getAttribute("action");if(o=p?_n(p,s):null,a=t.getAttribute("formmethod")||g.getAttribute("method")||gi,c=Tl(t.getAttribute("formenctype"))||Tl(g.getAttribute("enctype"))||yi,u=new FormData(g,t),!By()){let{name:v,type:y,value:w}=t;if(y==="image"){let j=v?`${v}.`:"";u.append(`${j}x`,"0"),u.append(`${j}y`,"0")}else v&&u.append(v,w)}}else{if($i(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=gi,o=null,c=yi,h=t}return u&&c==="text/plain"&&(h=u,u=void 0),{action:o,method:a.toLowerCase(),encType:c,formData:u,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function rc(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function bh(t,s,a,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return a?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&_n(c.pathname,s)==="/"?c.pathname=`${Xr(s)}/_root.${o}`:c.pathname=`${Xr(c.pathname)}.${o}`,c}async function Wy(t,s){if(t.id in s)return s[t.id];try{let a=await import(t.module);return s[t.id]=a,a}catch(a){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Hy(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Vy(t,s,a){let o=await Promise.all(t.map(async c=>{let u=s.routes[c.route.id];if(u){let h=await Wy(u,a);return h.links?h.links():[]}return[]}));return Yy(o.flat(1).filter(Hy).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function yf(t,s,a,o,c,u){let h=(p,v)=>a[v]?p.route.id!==a[v].route.id:!0,g=(p,v)=>{var y;return a[v].pathname!==p.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==p.params["*"]};return u==="assets"?s.filter((p,v)=>h(p,v)||g(p,v)):u==="data"?s.filter((p,v)=>{var w;let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(h(p,v)||g(p,v))return!0;if(p.route.shouldRevalidate){let j=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(t,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function Gy(t,s,{includeHydrateFallback:a}={}){return Ky(t.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),a&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Ky(t){return[...new Set(t)]}function qy(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Yy(t,s){let a=new Set;return new Set(s),t.reduce((o,c)=>{let u=JSON.stringify(qy(c));return a.has(u)||(a.add(u),o.push({key:u,link:c})),o},[])}function sc(){let t=f.useContext(ts);return rc(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Jy(){let t=f.useContext(_i);return rc(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ac=f.createContext(void 0);ac.displayName="FrameworkContext";function Li(){let t=f.useContext(ac);return rc(t,"You must render this element inside a <HydratedRouter> element"),t}function Qy(t,s){let a=f.useContext(ac),[o,c]=f.useState(!1),[u,h]=f.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:w}=s,j=f.useRef(null);f.useEffect(()=>{if(t==="render"&&h(!0),t==="viewport"){let S=T=>{T.forEach(R=>{h(R.isIntersecting)})},C=new IntersectionObserver(S,{threshold:.5});return j.current&&C.observe(j.current),()=>{C.disconnect()}}},[t]),f.useEffect(()=>{if(o){let S=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(S)}}},[o]);let N=()=>{c(!0)},E=()=>{c(!1),h(!1)};return a?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Bs(g,N),onBlur:Bs(p,E),onMouseEnter:Bs(v,N),onMouseLeave:Bs(y,E),onTouchStart:Bs(w,N)}]:[!1,j,{}]}function Bs(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function Xy({page:t,...s}){let a=oy(),{nonce:o}=Li(),{router:c}=sc(),u=f.useMemo(()=>ih(c.routes,t,c.basename),[c.routes,t,c.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?f.createElement(ev,{page:t,matches:u,...s}):f.createElement(tv,{page:t,matches:u,...s})):null}function Zy(t){let{manifest:s,routeModules:a}=Li(),[o,c]=f.useState([]);return f.useEffect(()=>{let u=!1;return Vy(t,s,a).then(h=>{u||c(h)}),()=>{u=!0}},[t,s,a]),o}function ev({page:t,matches:s,...a}){let o=Dt(),{future:c}=Li(),{basename:u}=sc(),h=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let g=bh(t,u,c.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?p=!0:v.push(y.route.id);return p&&v.length>0&&g.searchParams.set("_routes",v.join(",")),[g.pathname+g.search]},[u,c.v8_trailingSlashAwareDataRequests,t,o,s]);return f.createElement(f.Fragment,null,h.map(g=>f.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function tv({page:t,matches:s,...a}){let o=Dt(),{future:c,manifest:u,routeModules:h}=Li(),{basename:g}=sc(),{loaderData:p,matches:v}=Jy(),y=f.useMemo(()=>yf(t,s,v,u,o,"data"),[t,s,v,u,o]),w=f.useMemo(()=>yf(t,s,v,u,o,"assets"),[t,s,v,u,o]),j=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let S=new Set,C=!1;if(s.forEach(R=>{var A;let $=u.routes[R.route.id];!$||!$.hasLoader||(!y.some(F=>F.route.id===R.route.id)&&R.route.id in p&&((A=h[R.route.id])!=null&&A.shouldRevalidate)||$.hasClientLoader?C=!0:S.add(R.route.id))}),S.size===0)return[];let T=bh(t,g,c.v8_trailingSlashAwareDataRequests,"data");return C&&S.size>0&&T.searchParams.set("_routes",s.filter(R=>S.has(R.route.id)).map(R=>R.route.id).join(",")),[T.pathname+T.search]},[g,c.v8_trailingSlashAwareDataRequests,p,o,u,y,s,t,h]),N=f.useMemo(()=>Gy(w,u),[w,u]),E=Zy(w);return f.createElement(f.Fragment,null,j.map(S=>f.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),N.map(S=>f.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),E.map(({key:S,link:C})=>f.createElement("link",{key:S,nonce:a.nonce,...C,crossOrigin:C.crossOrigin??a.crossOrigin})))}function nv(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var rv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{rv&&(window.__reactRouterVersion="7.18.4")}catch{}function sv({basename:t,children:s,useTransitions:a,window:o}){let c=f.useRef();c.current==null&&(c.current=Pg({window:o,v5Compat:!0}));let u=c.current,[h,g]=f.useState({action:u.action,location:u.location}),p=f.useCallback(v=>{a===!1?g(v):f.startTransition(()=>g(v))},[a]);return f.useLayoutEffect(()=>u.listen(p),[u,p]),f.createElement(Py,{basename:t,children:s,location:h.location,navigationType:h.action,navigator:u,useTransitions:a})}var xt=f.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:c,reloadDocument:u,replace:h,mask:g,state:p,target:v,to:y,preventScrollReset:w,viewTransition:j,defaultShouldRevalidate:N,...E},S){let{basename:C,navigator:T,useTransitions:R}=f.useContext(qt),$=typeof y=="string"&&Jl.test(y),A=hh(y,C);y=A.to;let F=my(y,{relative:c}),G=Dt(),q=null;if(g){let Z=Pi(g,[],G.mask?G.mask.pathname:"/",!0);C!=="/"&&(Z.pathname=Z.pathname==="/"?C:fn([C,Z.pathname])),q=T.createHref(Z)}let[de,K,oe]=Qy(o,E),V=ov(y,{replace:h,mask:g,state:p,target:v,preventScrollReset:w,relative:c,viewTransition:j,defaultShouldRevalidate:N,useTransitions:R});function D(Z){s&&s(Z),Z.defaultPrevented||V(Z)}let ce=!(A.isExternal||u),re=f.createElement("a",{...E,...oe,href:(ce?q:void 0)||A.absoluteURL||F,onClick:ce?D:s,ref:nv(S,K),target:v,"data-discover":!$&&a==="render"?"true":void 0});return de&&!$?f.createElement(f.Fragment,null,re,f.createElement(Xy,{page:F})):re});xt.displayName="Link";var ic=f.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:c=!1,style:u,to:h,viewTransition:g,children:p,...v},y){let w=Zs(h,{relative:v.relative}),j=Dt(),N=f.useContext(_i),{navigator:E,basename:S}=f.useContext(qt),C=N!=null&&fv(w)&&g===!0,T=E.encodeLocation?E.encodeLocation(w).pathname:w.pathname,R=j.pathname,$=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;a||(R=R.toLowerCase(),$=$?$.toLowerCase():null,T=T.toLowerCase()),$&&S&&($=_n($,S)||$);const A=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let F=R===T||!c&&R.startsWith(T)&&R.charAt(A)==="/",G=$!=null&&($===T||!c&&$.startsWith(T)&&$.charAt(T.length)==="/"),q={isActive:F,isPending:G,isTransitioning:C},de=F?s:void 0,K;typeof o=="function"?K=o(q):K=[o,F?"active":null,G?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let oe=typeof u=="function"?u(q):u;return f.createElement(xt,{...v,"aria-current":de,className:K,ref:y,style:oe,to:h,viewTransition:g},typeof p=="function"?p(q):p)});ic.displayName="NavLink";var av=f.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:c,state:u,method:h=gi,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:j,...N},E)=>{let{useTransitions:S}=f.useContext(qt),C=uv(),T=dv(g,{relative:v}),R=h.toLowerCase()==="get"?"get":"post",$=typeof g=="string"&&Jl.test(g),A=F=>{if(p&&p(F),F.defaultPrevented)return;F.preventDefault();let G=F.nativeEvent.submitter,q=(G==null?void 0:G.getAttribute("formmethod"))||h,de=()=>C(G||F.currentTarget,{fetcherKey:s,method:q,navigate:a,replace:c,state:u,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:j});S&&a!==!1?f.startTransition(()=>de()):de()};return f.createElement("form",{ref:E,method:R,action:T,onSubmit:o?p:A,...N,"data-discover":!$&&t==="render"?"true":void 0})});av.displayName="Form";function iv(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kh(t){let s=f.useContext(ts);return st(s,iv(t)),s}function ov(t,{target:s,replace:a,mask:o,state:c,preventScrollReset:u,relative:h,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=mn(),w=Dt(),j=Zs(t,{relative:h});return f.useCallback(N=>{if(Oy(N,s)){N.preventDefault();let E=a!==void 0?a:br(w)===br(j),S=()=>y(t,{replace:E,mask:o,state:c,preventScrollReset:u,relative:h,viewTransition:g,defaultShouldRevalidate:p});v?f.startTransition(()=>S()):S()}},[w,y,j,a,o,c,s,t,u,h,g,p,v])}function oc(t){rn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=f.useRef(Ml(t)),a=f.useRef(!1),o=Dt(),c=f.useMemo(()=>My(o.search,a.current?null:s.current),[o.search]),u=mn(),h=f.useCallback((g,p)=>{const v=Ml(typeof g=="function"?g(new URLSearchParams(c)):g);a.current=!0,u("?"+v,p)},[u,c]);return[c,h]}var lv=0,cv=()=>`__${String(++lv)}__`;function uv(){let{router:t}=kh("useSubmit"),{basename:s}=f.useContext(qt),a=Ey(),o=t.fetch,c=t.navigate;return f.useCallback(async(u,h={})=>{let{action:g,method:p,encType:v,formData:y,body:w}=Uy(u,s);if(h.navigate===!1){let j=h.fetcherKey||cv();await o(j,a,h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:y,body:w,formMethod:h.method||p,formEncType:h.encType||v,flushSync:h.flushSync})}else await c(h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:y,body:w,formMethod:h.method||p,formEncType:h.encType||v,replace:h.replace,state:h.state,fromRouteId:a,flushSync:h.flushSync,viewTransition:h.viewTransition})},[o,c,s,a])}function dv(t,{relative:s}={}){let{basename:a}=f.useContext(qt),o=f.useContext(hn);st(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Zs(t||".",{relative:s})},h=Dt();if(t==null){u.search=h.search;let g=new URLSearchParams(u.search),p=g.getAll("index");if(p.some(y=>y==="")){g.delete("index"),p.filter(w=>w).forEach(w=>g.append("index",w));let y=g.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:fn([a,u.pathname])),br(u)}function fv(t,{relative:s}={}){let a=f.useContext(gh);st(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=kh("useViewTransitionState"),c=Zs(t,{relative:s});if(!a.isTransitioning)return!1;let u=_n(a.currentLocation.pathname,o)||a.currentLocation.pathname,h=_n(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Si(c.pathname,h)!=null||Si(c.pathname,u)!=null}var hv=sh();const wr="owner";function mv(t){const s=t||wr;return s===wr?[wr]:[s,wr]}function pv(t){const s=new Map;for(const a of t)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function gv(t,s){const a=s||wr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(wr)?wr:a}class Nh extends Error{constructor(a){super("different_account");Os(this,"summary");this.name="DifferentAccountError",this.summary=a}}function De(t,s){const a=t??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function yv(t){const s=t==null?void 0:t.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class vv{constructor(){Os(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const u=await o.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Nh(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(De(u,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const a=await s.json();return a.groups??a}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(u=>{var h,g;return{authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(p=>!(u.attestedDomains??[]).includes(p)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",earliest_expiry:(h=u.attestations)!=null&&h.length?new Date(Math.min(...u.attestations.map(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=u.attestations)!=null&&g.length?Math.max(0,Math.min(...u.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",c=await this.fetch(`/denials${o}`);if(!c.ok)throw new Error(`Failed to fetch denials: ${c.status}`);return c.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);return(await c.json()).tickets??[]}async fetchEvidenceBundle(){var c;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(De(a,`Export failed (${s.status})`));const o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(De(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(De(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(De(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var c;const s=await this.fetch("/api/report/export");if(!s.ok){const u=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(De(u,`Export failed (${s.status})`))}const a=await s.text(),o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(De(c,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(u,`Create group failed: ${a.status}`))}const o=await a.json(),c=o.group||o;return{id:c.id,name:c.name,myDomains:c.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(De(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const c=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(c,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(De(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(De(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const c=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(De(c,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(De(c,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const c=await o.json();return(c==null?void 0:c.config)??null}async setTeamProfileConfig(s,a,o){const c=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!c.ok){const u=await c.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(De(u,`setTeamProfileConfig failed: ${c.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?yv(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(De(c,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",c=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!c.ok)throw new Error(`Failed to fetch proposals: ${c.status}`);return(await c.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(mv(s).map(c=>this.getProposals(c,a)));return pv(o)}async resolveProposal(s,a,o,c){const{noteEncrypted:u,contentHash:h,shownHash:g,note:p,...v}=c??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...v,...u?{note_encrypted:u}:p?{note:p}:{},...h?{content_hash:h}:{},...g?{shown_hash:g}:{}})});if(!y.ok){const w=await y.json().catch(()=>({error:"Failed"}));throw new Error(De(w,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const c=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`getProposal failed: ${a.status}`))}const o=await a.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,a,o){const c={};a&&(c.content_hash=a),o&&(c.shown_hash=o);const u=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:Object.keys(c).length>0?JSON.stringify(c):void 0});if(!u.ok){const h=await u.json().catch(()=>({error:"Failed"}));throw new Error(De(h,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(s,a,o,c){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:g,note:p,...v}=a??{};u={...v,...g?{note_encrypted:g}:p?{note:p}:{}}}o&&(u.content_hash=o),c&&(u.shown_hash=c);const h=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!h.ok){const g=await h.json().catch(()=>({error:"Failed"}));throw new Error(De(g,`rejectProposal failed: ${h.status}`))}return h.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to store the shown snapshot: ${o.status}`);return o.json()}async getShownSnapshot(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(c,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(c=>{var g,p;const u=c.owner??{userId:""};return{authorization_id:c.authorization_id??c.authorizationId,profile_id:c.profileId??c.profile_id,path:c.path??"",title:c.title??null,sp_status:c.status??c.sp_status??null,frame:c.bounds??c.frame??{},required_domains:c.requiredDomains??c.required_domains??[],attested_domains:c.attestedDomains??c.attested_domains??[],missing_domains:(c.requiredDomains??c.required_domains??[]).filter(v=>!(c.attestedDomains??c.attested_domains??[]).includes(v)),deferred_commitment_domains:c.deferredCommitmentDomains??c.deferred_commitment_domains??[],approvers_frozen:c.approversFrozen??c.approvers_frozen??[],above_cap:c.aboveCap??c.above_cap??!1,created_at:c.createdAt?new Date(c.createdAt*1e3).toISOString():c.created_at??"",earliest_expiry:(g=c.mandates)!=null&&g.length?new Date(Math.min(...c.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=c.mandates)!=null&&p.length?Math.max(0,Math.min(...c.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);const u=await c.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const c=o.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${c?"?"+c:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const h=await u.json();return{receipts:h.tickets??[],nextBefore:h.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",c=await this.getMyProposals(s.domain,o);let u=[];if(o==="all"){const h=[],g=new Date;for(let v=0;v<a;v++){const y=new Date(g);y.setUTCDate(g.getUTCDate()-v),h.push(y.toISOString().slice(0,10))}u=(await Promise.all(h.map(v=>this.getMyReceipts({date:v,profile:s.profile})))).flat()}return{proposals:c,receipts:u}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(De(o,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(De(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:De(o,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Save failed"}));throw new Error(De(c,`Save failed: ${o.status}`))}}}const M=new vv,Ch=f.createContext(null);function xv({children:t}){const[s,a]=f.useState(null),[o,c]=f.useState("personal"),[u,h]=f.useState(null),[g,p]=f.useState(""),[v,y]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState(null),[S,C]=f.useState(!1),[T,R]=f.useState(""),$=f.useRef(!1),A=f.useRef(null),F=f.useCallback(async()=>{if($.current)try{const V=await M.getMyTeam();if(E(V.pendingRequest),V.group&&V.membership){const{group:D,membership:ce}=V;y(D),j(ce),c("team"),h(D);const re=A.current??ce.domains[0]??"owner";p(re)}else y(null),j(null),c("personal")}catch{}},[]);f.useEffect(()=>{const V=()=>{document.visibilityState==="visible"&&F()};return document.addEventListener("visibilitychange",V),()=>document.removeEventListener("visibilitychange",V)},[F]),f.useEffect(()=>{fetch("/health").then(V=>V.json()).then(V=>{var D;((D=V.session)==null?void 0:D.lockedReason)==="as-url-changed"&&R(`Authority Server changed to ${V.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const G=f.useCallback(async(V,D={})=>{C(!0),R("");try{M.setApiKey(V),$.current=!0;const ce=await M.login(V,D);a(ce),A.current=ce.id;const re=await M.getGroups(),Z=re.find(he=>he.isPersonal)??re[0]??null;h(Z),p("owner"),await F()}catch(ce){throw M.clearApiKey(),$.current=!1,R(ce instanceof Error?ce.message:"Login failed"),ce}finally{C(!1)}},[F]),q=f.useCallback(async()=>{await M.logout(),M.clearApiKey(),$.current=!1,A.current=null,a(null),h(null),p(""),y(null),j(null),E(null),c("personal"),R("")},[]),de=f.useCallback(V=>{M.clearApiKey(),$.current=!1,A.current=null,a(null),h(null),p(""),y(null),j(null),E(null),c("personal"),R(V??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),K=f.useCallback(()=>R(""),[]),oe=f.useCallback((V,D)=>{h(V),p(D)},[]);return r.jsx(Ch.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:w,pendingRequest:N,isLoading:S,error:T,login:G,logout:q,clearError:K,handleSessionLocked:de,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:oe,refreshGroups:F},children:t})}function pt(){const t=f.useContext(Ch);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const Eh=f.createContext(null);function wv({children:t}){const{user:s}=pt(),a=f.useRef(null),[o,c]=f.useState(!1),u=f.useRef(new Map),h=f.useCallback((g,p)=>{const v=u.current;return v.has(g)||v.set(g,new Set),v.get(g).add(p),()=>{var y;(y=v.get(g))==null||y.delete(p)}},[]);return f.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,c(!1));return}if(a.current)return;const g=M.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);a.current=p,p.onopen=()=>c(!0),p.onerror=()=>c(!1);const v=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked","execution-failed"];for(const y of v)p.addEventListener(y,w=>{let j;try{j=JSON.parse(w.data)}catch{j=null}const N=u.current.get(y);if(N)for(const E of N)try{E(j)}catch(S){console.error(`[EventSource] handler for "${y}" threw:`,S)}});return()=>{p.close(),a.current=null,c(!1)}},[s]),r.jsx(Eh.Provider,{value:{connected:o,addListener:h},children:t})}function Ue(t,s){const a=f.useContext(Eh);if(!a)return;const{addListener:o}=a;f.useEffect(()=>o(t,s),[t,s,o])}const Gs="suveren-theme",vf="hap-theme";function di(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(vf);s!==null&&localStorage.getItem(Gs)===null&&localStorage.setItem(Gs,s),s!==null&&localStorage.removeItem(vf)})();function Th(){const[t,s]=f.useState(()=>{const u=localStorage.getItem(Gs);return u==="light"||u==="dark"?u:"system"}),[a,o]=f.useState(()=>di(t));f.useEffect(()=>{const u=document.documentElement,h=di(t);u.setAttribute("data-theme",h),t==="system"?localStorage.removeItem(Gs):localStorage.setItem(Gs,t),o(di(t))},[t]),f.useEffect(()=>{if(t!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>o(di("system"));return u.addEventListener("change",h),()=>u.removeEventListener("change",h)},[t]);const c=f.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:c}}const jv=300*1e3,Sv=2e3;function lc(){const[t,s]=f.useState(!1),[a,o]=f.useState("docker"),[c,u]=f.useState(""),[h,g]=f.useState(null),[p,v]=f.useState(!1),[y,w]=f.useState(!1),[j,N]=f.useState(!1),E=f.useRef(null);return f.useEffect(()=>{let S=!1;const C=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(A=>A.json()).then(A=>{S||(A.installMethod&&o(A.installMethod),typeof A.latestVersion<"u"&&g(A.latestVersion),A.updateAvailable&&s(!0),A.version&&(u(A.version),E.current===null?E.current=A.version:A.version!==E.current&&A.version!=="dev"&&v(!0)))}).catch(()=>{})};C(!0);const T=setInterval(()=>C(!1),j?Sv:jv),R=()=>{document.visibilityState==="visible"&&C(!1)};return document.addEventListener("visibilitychange",R),window.addEventListener("focus",R),()=>{S=!0,clearInterval(T),document.removeEventListener("visibilitychange",R),window.removeEventListener("focus",R)}},[j]),{updateAvailable:t&&!y,installMethod:a,version:c,latestVersion:h,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>w(!0)}}function bv(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function kv(){const[t,s]=f.useState({managed:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(bv(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Nv({size:t=20}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),r.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Cv(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const xf={system:"◑",light:"☀",dark:"☾"};function cc({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:c}=pt(),{theme:u,toggle:h}=Th(),{version:g,updateAvailable:p,latestVersion:v}=lc(),{managed:y}=kv(),w=Cv(g),j=o==="team"&&c?`Team ${c.name}`:"Personal";return r.jsx("nav",{className:"top-nav",children:r.jsxs("div",{className:"top-nav-inner",children:[r.jsxs("div",{className:"logo-group",children:[r.jsx(Nv,{size:20}),r.jsx("span",{className:"logo",children:"Suveren"}),r.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&r.jsxs("span",{className:"gw-version",title:p&&v?`Running v${w} — v${v} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",w,p&&v?` → ${v}`:""]})]}),r.jsx("div",{className:"nav-spacer"}),r.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${j} — set by your IT`:j,children:[j,y&&r.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),r.jsx("span",{className:"user-chip",children:r.jsx("strong",{children:s.name})}),r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${u}`,children:xf[u]}),r.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${u}`,children:xf[u]})}),s&&t&&r.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function uc(t,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(t.authorization_id))return"revoked";switch(t.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return t.remaining_seconds===null||t.remaining_seconds<=0?"expired":t.missing_domains.length>0?"pending":"active"}function Rh(t){return t==="expired"||t==="revoked"}function Ih(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&Rh(uc(t,s))}function bi(t,s){return Ih(t,s)?"archived":uc(t,s)}function Ah(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[bi(o,s)].push(o);return a}function Ev(t,s){return s==="expired"?t.earliest_expiry?{iso:t.earliest_expiry,meaning:"expired"}:null:t.created_at?{iso:t.created_at,meaning:"created"}:null}function nn(t,s,a){const o=f.useRef(t);o.current=t,f.useEffect(()=>{let c=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",h=()=>{u()&&o.current()},g=()=>{c===null&&(c=setInterval(h,s))},p=()=>{c!==null&&(clearInterval(c),c=null)},v=()=>{u()?(o.current(),g()):p()};return u()&&(o.current(),g()),document.addEventListener("visibilitychange",v),()=>{p(),document.removeEventListener("visibilitychange",v)}},[s,a])}function dc(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(h.simulation===!0)}).catch(()=>{})};o();const c=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",u)}},[]),t}function Tv(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function qs(t){return!!(t!=null&&t.simulation)}const Ph=f.createContext(null),Rv=3e4,Iv=5e3,Av=3e5;function Pv(t,s,a){return s===0?"loading":t!=null&&t.running?"running":t!=null&&t.paused?"paused":t!=null&&t.error?"error":t&&a?"starting":"not-running"}function _v({children:t}){const[s,a]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=f.useRef(null),c=f.useCallback(async()=>{let y=!1;const[w,j]=await Promise.all([M.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),M.getMcpHealth().catch(()=>null)]);a(E=>({...E,manifests:w.manifests,integrations:(j==null?void 0:j.integrations)??E.integrations,activeSessions:(j==null?void 0:j.activeSessions)??E.activeSessions,mcpServerUp:!!j,manifestsError:y,fetchCount:E.fetchCount+1}));const N=w.manifests.filter(E=>E.oauth);if(N.length>0){const E=await Promise.all(N.map(async S=>[S.id,await M.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(E)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const w=s.integrations.find(j=>j.id===y.id);return w&&!w.running&&!w.paused});Ue("integration-changed",c),nn(c,u?Iv:Av);const h=f.useMemo(()=>{const y=new Map(s.integrations.map(N=>[N.id,N])),w=Date.now();u&&o.current===null?o.current=w:u||(o.current=null);const j=o.current!==null&&w-o.current<Rv;return s.manifests.map(N=>{const E=y.get(N.id),S=Pv(E,s.fetchCount,j),C=s.authHealth[N.id];return{id:N.id,manifest:N,integration:E,state:S,authStatus:C==null?void 0:C.status,authAccount:C==null?void 0:C.account,authError:C==null?void 0:C.error}})},[s,u]),g=dc(),p=f.useMemo(()=>h.filter(y=>!(g&&!qs(y.manifest))&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[h,g]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:h,attentionCount:p,activeSessions:s.activeSessions,refresh:c};return r.jsx(Ph.Provider,{value:v,children:t})}function fc(){const t=f.useContext(Ph);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const $v={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},hc=t=>$v[t]??t,Lv={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function zv(t){return(t&&Lv[t])??{chip:"Blocked",sev:"info"}}function Fv(t){const s=hc(t.integrationId);switch(t.reason){case"resource":return t.integrationId==="calendar"?r.jsxs(r.Fragment,{children:["Tried to read your ",r.jsx("b",{children:t.target??"restricted"})," calendar"]}):r.jsxs(r.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return r.jsxs(r.Fragment,{children:["Tried to open a message in ",r.jsx("b",{children:"spam or trash"})]});case"age":return r.jsxs(r.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return r.jsxs(r.Fragment,{children:["Your ",s," has ",r.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return r.jsxs(r.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return r.jsxs(r.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return r.jsx(r.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return r.jsx(r.Fragment,{children:t.detail})}}function _h(t,s){const a=Math.max(0,(s-t)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const wf=5,Ov=1440*60*1e3,vi=7;function Mv(t,s){const a=s-vi*Ov;return{recent:t.filter(o=>o.ts>=a),all:t}}function Bv(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(!1),h=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:j})=>{s(j),u(!1)}).catch(()=>u(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,12e4),c||t===null)return null;const{recent:g,all:p}=Mv(t,Date.now()),v=a?p:g.slice(0,wf),y=p.length-g.length,w=(j,N)=>{const E=zv(j.reason);return r.jsxs("div",{className:"rb-row",children:[r.jsx("span",{className:`rb-dot ${E.sev==="act"?"act":E.sev==="info"?"info":""}`,"aria-hidden":"true"}),r.jsxs("div",{className:"rb-body",children:[r.jsx("div",{className:"rb-line",children:Fv(j)}),r.jsxs("div",{className:"rb-meta",children:[r.jsx("span",{className:`rb-chip ${E.sev==="act"?"act":E.sev==="warn"?"warn":""}`,children:E.chip}),r.jsx("span",{className:"rb-via",children:hc(j.integrationId)})]}),E.fixTo&&r.jsx(xt,{className:"rb-fix",to:E.fixTo,children:"Set a read window →"})]}),r.jsx("div",{className:"rb-when",children:_h(j.ts,Date.now())})]},`${j.ts}-${N}`)};return r.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Recent blocks"}),(a?p.length:g.length)>0&&r.jsx("span",{className:"rb-count",children:a?p.length:g.length})]}),v.length===0?r.jsxs("div",{className:"rb-empty",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsxs("h3",{children:["Nothing blocked in the last ",vi," days"]}),r.jsx("p",{children:"Your agent has stayed within every limit you set."}),y>0&&r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["Show the last 30 days (",y,")"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"rb-sub",children:[a?"Last 30 days. ":`Last ${vi} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),r.jsx("div",{className:"rb-rows",children:v.map(w)}),!a&&p.length>v.length&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",p.length," blocks from the last 30 days"]})}),a&&p.length>Math.min(g.length,wf)&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!1),children:["Show only the last ",vi," days"]})})]})]})}function Ys(t){return t.kind??"read"}function Dv(t,s){var u,h,g,p;if(!s)return"";if(!t)return s;const a=(h=(u=t.scopeSchema)==null?void 0:u.fields)==null?void 0:h[s];if(a!=null&&a.displayName)return a.displayName;const o=((g=t.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.displayName)return o[s].displayName;const c=Object.values(o).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===s);return c!=null&&c.displayName?c.displayName:s}const Uv={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",read:"Read blocked"},Wv={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function jf(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Hv(t,s){const a=Ys(t),o=jf(t.value),c=jf(t.limit);switch(a){case"bound":return o&&c?`${s||"Value"} ${o} is above the limit ${c}.`:t.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:t.detail;case"cumulative":return o&&c?`${o} of ${c} used — the limit is reached.`:t.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return t.detail}}function Vv(t){const s=Ys(t),a=hc(t.integrationId),o=t.mandateTitle?` · mandate "${t.mandateTitle}"`:t.mandateId?` · mandate ${t.mandateId.slice(0,14)}…`:"",c=t.who==="authority-server"?"refused by the Authority Server":s==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=t.code?` (${t.code})`:"";return`${a} · ${t.tool}${o} · ${c}${u}`}function Gv(t,s){const a=Ys(t),o=Dv(s,t.field);return{title:Uv[a],sentence:Hv(t,o),sourceLine:Vv(t),whatYouCanDo:Wv[a]}}function $h(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}const Kv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/blocked",icon:"⛔",label:"Blocked",statusKey:"blocked"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function qv(){const{activeDomain:t}=pt(),[s,a]=f.useState({}),o=f.useCallback(async()=>{try{const[c,u,h,g,p,v,y]=await Promise.all([M.getCredential("ai-config").catch(()=>null),M.getMyAttestations().catch(()=>null),M.getMyProposals(t).catch(()=>null),M.getProposalsForApprover().catch(()=>null),M.getAgentContext().catch(()=>""),M.getArchivedMandates().catch(()=>[]),M.getDenials({limit:200}).catch(()=>null)]),w={};if(c&&!c.configured&&(w.assistant=1),u){const S=Ah(u,{archivedSet:new Set(v)}).expired.length;S>0&&(w.authorizations=S)}const j=(h==null?void 0:h.length)??0,N=(g==null?void 0:g.length)??0,E=j+N;if(E>0&&(w.proposals=E),(!p||!p.trim())&&(w.brief=1),y){const S=$h(y.records,Date.now());S>0&&(w.blocked=S)}a(w)}catch{}},[t]);return Ue("attestation-changed",o),Ue("proposal-added",o),Ue("proposal-resolved",o),Ue("proposal-approved",o),Ue("proposal-rejected",o),Ue("team-membership-changed",o),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),nn(o,3e5,t),s}const Yv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},Jv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function Qv(){const{mode:t,group:s,domain:a,activeTeam:o}=pt(),c=qv(),{attentionCount:u}=fc(),h={...c};u>0&&(h.integrations=u);const g=Kv.filter(j=>!j.teamOnly||t==="team"),p=f.useRef(null),[v,y]=f.useState(null),w=Dt();return f.useEffect(()=>{if(p.current===null){p.current=t;return}p.current!==t&&(t==="team"&&o?y(`You are now acting in team context — ${o.name}`):t==="personal"&&y("You have left the team — back to personal context"),p.current=t)},[t,o]),f.useEffect(()=>{y(null)},[w.pathname]),r.jsxs("div",{className:"sidebar",children:[r.jsx("ul",{className:"sidebar-nav",children:g.map(j=>{const N=j.statusKey?h[j.statusKey]:0;return r.jsx("li",{children:r.jsxs(ic,{to:j.to,end:j.to==="/",className:({isActive:E})=>`sidebar-item${E?" active":""}`,children:[r.jsx("span",{className:"icon",children:j.icon}),j.label,N?r.jsx("span",{style:Yv,children:N}):null]})},j.to)})}),r.jsxs("div",{className:"sidebar-context",children:[r.jsx("div",{className:"ctx-label",children:"Active context"}),r.jsx("div",{className:"ctx-value",children:t==="personal"?"personal":s?`${s.name} / ${a}`:a})]}),v&&r.jsx("div",{style:Jv,role:"status","aria-live":"polite",children:v})]})}const Rl="suveren:updatedTo";function Xv(t){return t==="managed"||t==="msi"?null:t==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":t==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Zv="Updates for this gateway come from your company's IT — no action needed here.";function ex(t){return t==="managed"?"update-banner is-managed":"update-banner"}const tx="Download the new installer and run it. Your settings and mandates stay.";function nx(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function rx(){const t=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of t)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function Lh(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:c,startFastPolling:u,dismiss:h}=lc(),[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(()=>{try{const $=sessionStorage.getItem(Rl);if($)return sessionStorage.removeItem(Rl),$}catch{}return null}),N=Xv(s),E=f.useRef(null),S=$=>{try{sessionStorage.setItem(Rl,$||o||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!w)return;const $=setTimeout(()=>j(null),6e3);return()=>clearTimeout($)},[w]),f.useEffect(()=>{if(!g||!c)return;const $=()=>rx()?!1:(S(a),!0);if($())return;const A=setInterval($,1500);return()=>clearInterval(A)},[g,c,a]),f.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const C=t&&!g&&!w||!!w&&!g;f.useEffect(()=>{if(!C){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const $=()=>{var G;const F=((G=E.current)==null?void 0:G.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${F}px`)};$();const A=new ResizeObserver($);return E.current&&A.observe(E.current),()=>{A.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[C]);const T=()=>{p(!0),u()},R=async()=>{if(N)try{await navigator.clipboard.writeText(N),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return r.jsxs(r.Fragment,{children:[w&&!g&&r.jsx("div",{ref:E,className:"update-banner is-live",role:"status","aria-live":"polite",children:r.jsxs("div",{className:"update-banner-row",children:[r.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",w&&w!=="✓"?` — ${w} is live`:" — now live","."]}),r.jsx("button",{className:"update-banner-x",onClick:()=>j(null),"aria-label":"Dismiss",children:"×"})]})}),t&&!g&&!w&&r.jsxs("div",{ref:E,className:ex(s),role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"update-banner-row",children:[r.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&r.jsx("a",{className:"btn btn-sm btn-secondary",href:nx(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:T,children:"Update"}),r.jsx("button",{className:"update-banner-x",onClick:h,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&r.jsx("p",{className:"update-banner-hint",children:Zv}),s==="msi"&&r.jsx("p",{className:"update-banner-hint",children:tx})]}),g&&r.jsx("div",{className:"update-overlay",children:r.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[r.jsx("div",{className:"update-spinner"}),r.jsxs("h2",{children:["Finishing the update","…"]}),r.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",r.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),r.jsxs("div",{className:"update-cmd-row",children:[r.jsx("code",{className:"update-cmd",children:N}),r.jsx("button",{className:"btn btn-sm btn-primary",onClick:R,children:v?"Copied":"Copy"})]}),r.jsxs("div",{className:"update-status",children:[r.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),r.jsxs("div",{className:"update-overlay-actions",children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),r.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function zh(){const t=dc(),s=f.useRef(null);return f.useEffect(()=>{if(!t){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const c=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${c}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[t]),t?r.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:r.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const sx={system:"◑",light:"☀",dark:"☾"},ax=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function ix({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:c,logout:u}=pt(),{theme:h,toggle:g}=Th(),p=Dt();return f.useEffect(()=>{s()},[p.pathname]),t?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),r.jsxs("div",{className:"mobile-menu-panel",children:[a&&r.jsxs("div",{className:"mobile-menu-header",children:[r.jsx("strong",{children:a.name}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${c}`:c||"personal"})]}),r.jsx("nav",{className:"mobile-menu-nav",children:ax.map(v=>r.jsxs(ic,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:s,children:[r.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),r.jsxs("div",{className:"mobile-menu-footer",children:[r.jsxs("button",{className:"mobile-menu-action",onClick:()=>{g()},children:[r.jsx("span",{className:"icon",children:sx[h]}),"Theme: ",h]}),r.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function Fh(t){return t.status==="pending"}function ox(t,s){return t.filter(Fh).length+s.length}const vr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],lx=500;function Oh(){const{user:t,domain:s}=pt(),[a,o]=f.useState(0),c=f.useRef(null),u=f.useCallback(async()=>{if(!t){o(0);return}try{const[g,p]=await Promise.all([M.getMyProposals(s).catch(()=>[]),M.getProposalsForApprover().catch(()=>[])]);o(ox(g,p))}catch{o(0)}},[t,s]),h=f.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{u()},lx)},[u]);return f.useEffect(()=>(u(),()=>{c.current&&clearTimeout(c.current)}),[u]),Ue(vr[0],h),Ue(vr[1],h),Ue(vr[2],h),Ue(vr[3],h),Ue(vr[4],h),Ue(vr[5],h),Ue(vr[6],h),a}const Sf="Suveren",cx="/favicon.svg",ux="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",fi={x1:74.54,y1:22.74,x2:94.46,y2:34.24},dx=14,fx="#f59e0b";function hx(t){const s=mc(t);return s>0?`(${s}) ${Sf}`:Sf}function mc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function mx(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
52
|
<path class="m" d="${ux}"/>
|
|
53
53
|
<line class="m" x1="${fi.x1}" y1="${fi.y1}" x2="${fi.x2}" y2="${fi.y2}"/>
|
|
54
54
|
<circle cx="103" cy="103" r="25" fill="${fx}"/>
|
|
@@ -62,21 +62,21 @@ url = "${t}/mcp"
|
|
|
62
62
|
|
|
63
63
|
Or: codex mcp add suveren --url ${t}/mcp`},other:{label:"Other",snippet:t=>`Streamable HTTP: POST ${t}/mcp
|
|
64
64
|
SSE transport: GET ${t}/sse
|
|
65
|
-
Health check: GET ${t}/health`}},kf=["claude-code","claude-desktop","chatgpt-codex","other"];function Bl({mcpEndpoint:t}){const[s,a]=f.useState(kf[0]),[o,c]=f.useState(!1),u=f.useCallback(async g=>{try{await navigator.clipboard.writeText(g),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),h=bf[s].snippet(t);return r.jsxs("div",{children:[r.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),r.jsx("div",{className:"mcp-endpoint",children:t}),r.jsx("div",{className:"mcp-tabs",children:kf.map(g=>r.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:bf[g].label},g))}),r.jsx("pre",{className:"mcp-snippet",children:h}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(h),children:o?"Copied":"Copy"})]})}const Dl="suveren-setup-ai-skipped",Ul="suveren-setup-agent-done",Wl="suveren-setup-dismissed",Tx={"hap-setup-ai-skipped":Dl,"hap-setup-agent-done":Ul,"hap-setup-dismissed":Wl};function Rx(){for(const[t,s]of Object.entries(Tx)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}Rx();function Ix({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:c}){const[u,h]=f.useState(()=>localStorage.getItem(Dl)==="true"),[g,p]=f.useState(()=>localStorage.getItem(Ul)==="true"),[v,y]=f.useState(()=>localStorage.getItem(Wl)==="true"),[w,j]=f.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:t?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||g?"done":"pending"}],E=N.filter(A=>A.status==="done"||A.status==="skipped").length,S=E===N.length,C=f.useCallback(()=>{localStorage.setItem(Dl,"true"),h(!0)},[]),T=f.useCallback(()=>{localStorage.setItem(Ul,"true"),p(!0),j(null)},[]),R=f.useCallback(()=>{localStorage.setItem(Wl,"true"),y(!0)},[]);if(v||S)return null;const $=N.findIndex(A=>A.status==="pending");return r.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[r.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),r.jsx("button",{onClick:R,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:N.map((A,F)=>{const G=F===$,q=A.status==="done"||A.status==="skipped"?"●":"○",de=A.status==="done"?"var(--success)":A.status==="skipped"?"var(--text-tertiary)":G?"var(--accent)":"var(--text-tertiary)";return r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:G?"0.75rem":"0.25rem 0",borderRadius:G?"0.5rem":void 0,background:G?"var(--accent-subtle)":void 0},children:[r.jsx("span",{style:{color:de,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:q}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A.to&&A.status==="pending"?r.jsx(xt,{to:A.to,style:{fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:A.label}):A.status==="pending"&&F===3?r.jsx("button",{onClick:()=>j(w===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)"},children:A.label}):r.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:A.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:A.label}),A.optional&&A.status==="pending"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),A.status==="skipped"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),A.detail&&A.status==="pending"&&G&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:A.detail})]}),A.optional&&A.status==="pending"&&r.jsx("button",{onClick:C,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),A.to&&A.status==="pending"&&r.jsx(xt,{to:A.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),F===3&&w===3&&r.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[r.jsx(Bl,{mcpEndpoint:c}),r.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},F)})}),r.jsxs("div",{style:{marginTop:"1.25rem"},children:[r.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${E/N.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[E," of ",N.length," complete"]})]})]})}function Wh(t,s=null){const a=[t.hasContact,t.hasDelegationMandate,t.delegationProposalCount>0],o=a.every(Boolean),c=t.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),h=s!==null&&a[s]===!1?s:u,g=t.managed?"managed":"self",p=v=>a[v]?{status:"done"}:v!==h?{status:"todo"}:v===1?{status:"open",variant:g,simulationOn:t.simulationOn}:v===0?{status:"open",variant:g}:{status:"open"};return{visible:c,step1:p(0),step2:p(1),step3:p(2)}}const Ax="/mandates?new=1&profile=delegation";function Nf({text:t}){const[s,a]=f.useState(!1),o=f.useCallback(async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t]);return r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Il({todo:t,onOpen:s,children:a}){return t?r.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):r.jsx("span",{className:"flow-step-title",children:a})}function Px({contact:t,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:u,mcpEndpoint:h}){const g={hasContact:t!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:u},[p,v]=f.useState(null),y=Wh(g,p);if(!y.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${h}/mcp`;return r.jsxs("div",{className:"card setup-card",children:[r.jsx("h2",{className:"card-title",children:"Get started"}),r.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&t?r.jsxs("span",{className:"flow-step-title flow-done-title",children:[t.clientName," connected · last contact ",_h(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):r.jsx(Il,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&r.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"For your IT"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Bl,{mcpEndpoint:h})})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:w}),r.jsx(Nf,{text:w})]})}),r.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"Set it up by hand"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Bl,{mcpEndpoint:h})})]})]})})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?r.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",r.jsx(xt,{to:"/mandates",children:"review or revoke under Mandates"})]}):r.jsx(Il,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),r.jsxs("ul",{className:"bound-list",children:[r.jsx("li",{children:"Read the setup guides"}),r.jsx("li",{children:"Propose new mandates — each waits for your approval"}),r.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?r.jsxs(r.Fragment,{children:[r.jsx(xt,{to:Ax,className:"btn btn-primary",children:"Give the Delegation mandate →"}),r.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&r.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):r.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":r.jsxs(r.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",r.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),r.jsx(Il,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),r.jsx(Nf,{text:"How do I start with Suveren?"})]})}),r.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",r.jsx(xt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function _x(){const[t,s]=f.useState(null);return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),t}function $x(t){if(!t||typeof t!="object")return{simulation:null,locked:!1};const s=Array.isArray(t.policyLocked)&&t.policyLocked.includes("simulation");return{simulation:typeof t.simulation=="boolean"?t.simulation:null,locked:s}}function Hh(){const[t,s]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s($x(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Lx(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function zx(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(Lx(h))}).catch(()=>{})};o();const c=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",u)}},[]),t}function jr({variant:t="base",style:s,className:a,...o}){const c=t==="title"?"skeleton skeleton-title":t==="line"?"skeleton skeleton-line":t==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return r.jsx("span",{className:`${c}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}function Al(){return r.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[r.jsx(jr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[r.jsx(jr,{variant:"line",style:{width:"35%"}}),r.jsx(jr,{variant:"line-sm",style:{width:"65%"}})]})]})}function Fx(){const[t,s]=f.useState([]);return nn(async()=>{try{const{skipped:o}=await M.getSkippedCommitments();s(o)}catch{}},3e4),t.length===0?null:r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[r.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",t.length,")"]}),r.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),r.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:t.map(o=>r.jsxs("li",{style:{marginBottom:"0.35rem"},children:[r.jsx("code",{children:o.tool})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Ox(t,s){return s&&!qs(t.manifest)}function Mx(t,s=!1){var o;const a=[];for(const c of t)Ox(c,s)||(c.state==="error"?a.push({label:"Integration error",detail:(o=c.integration)!=null&&o.error?`${c.manifest.name}: ${c.integration.error}`:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):c.state==="not-running"&&(qs(c.manifest)?a.push({label:`${c.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):a.push({label:"Integration stopped",detail:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return a}function Bx(t){const s=t.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Dx=1800;function Yr(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Ux(){const{domain:t}=pt(),[s,a]=f.useState([]),[o,c]=f.useState([]),[u,h]=f.useState([]),[g,p]=f.useState(!0),[v,y]=f.useState(!1),[w,j]=f.useState([]),[N,E]=f.useState(!1),[S,C]=f.useState(!1),[T,R]=f.useState(null),[$,A]=f.useState(!1),{entries:F,activeSessions:G,loading:q}=fc(),de=_x(),K=!q,{simulation:oe}=Hh(),V=oe===!0,D=zx(),ce=f.useCallback(()=>{M.getMyAttestations().then(ne=>{a(ne),y(!0)}).catch(()=>y(!0)),M.getArchivedMandates().then(j).catch(()=>j([])),M.getMyProposals(t).then(ne=>{c(ne),E(!0)}).catch(()=>E(!0)),M.getProposalsForApprover().then(ne=>h(ne)).catch(()=>h([])),M.getCredential("ai-config").then(ne=>{p(ne.configured),C(!0)}).catch(()=>C(!0)),M.getAgentContact().then(ne=>{R(ne.contact),A(!0)}).catch(()=>A(!0))},[t]);Ge("attestation-changed",ce),Ge("proposal-added",ce),Ge("proposal-resolved",ce),Ge("proposal-approved",ce),Ge("proposal-rejected",ce),nn(ce,3e5,t);const re=v&&N&&S&&K&&$&&oe!==null,Z=Ah(s,{archivedSet:new Set(w)}),he=Z.active,ge=Z.expired,Y=he.some(ne=>Yr(ne.profile_id)==="delegation"),O=he.filter(ne=>Yr(ne.profile_id)!=="delegation").length,H=o.filter(ne=>Yr(ne.profileId)==="delegation").length,b=Wh({hasContact:T!==null,hasDelegationMandate:Y,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:V}),L=V&&b.visible,J=he.filter(ne=>ne.remaining_seconds!==null&&ne.remaining_seconds<=Dx),W=o.filter(Fh),ee=F.filter(ne=>ne.state==="running"),xe=F.filter(ne=>ne.state==="starting"),ke=Bx(F),ve=[];for(const ne of u)ve.push({label:"Approval needed",detail:`${ne.tool} — above-cap action under ${Yr(ne.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const ne of W)ve.push({label:"Approval pending",detail:`${ne.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const ne of J){const Ae=Math.ceil((ne.remaining_seconds??0)/60);ve.push({label:"Expiring soon",detail:`${ne.title??Yr(ne.profile_id)} — ${Ae} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const ne of ge)ve.push({label:"Expired",detail:ne.title??Yr(ne.profile_id),to:"/mandates",color:"var(--danger)"});ve.push(...Mx(F,V));for(const ne of xe)ve.push({label:"Integration starting",detail:`${ne.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const ne of F)ne.authStatus==="failed"&&ne.state!=="not-running"&&ne.state!=="error"&&ne.state!=="paused"&&ve.push({label:"Reconnect needed",detail:`${ne.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return g||ve.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Dashboard"})}),re&&de&&(L?r.jsx(Px,{contact:T,hasDelegationMandate:Y,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:V,mcpEndpoint:de}):!V&&r.jsx(Ix,{aiConfigured:g,hasRunningIntegration:ee.length>0,hasActiveAuth:he.length>0,hasAgentConnected:G>0,mcpEndpoint:de})),!L&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[r.jsx(xt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[v?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:he.length>0?"var(--success)":"var(--text-tertiary)"},children:he.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),r.jsx(xt,{to:"/approvals",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[N?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:W.length>0?"var(--warning)":"var(--text-tertiary)"},children:W.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),r.jsx(xt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[v?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ge.length>0?"var(--danger)":"var(--text-tertiary)"},children:ge.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),r.jsx(xt,{to:"/integrations",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[K?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ee.length>0?"var(--success)":"var(--text-tertiary)"},children:ee.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),r.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Needs your attention"}),ve.length>0&&r.jsx("span",{className:"rb-count",children:ve.length})]}),ve.length>0?r.jsx("div",{className:"attention-rows",children:ve.map((ne,Ae)=>r.jsxs(xt,{to:ne.to,className:"attention-row",children:[r.jsx("span",{className:"attention-dot",style:{background:ne.color},"aria-hidden":"true"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:ne.label}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ne.detail})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},Ae))}):re?r.jsxs("div",{className:"all-clear",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsx("h3",{children:"All clear"}),r.jsx("p",{children:"Nothing needs your attention."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[r.jsx(Al,{}),r.jsx(Al,{}),r.jsx(Al,{})]})]})]}),ke&&r.jsxs("div",{className:"sim-paused-summary",role:"status",children:[r.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),r.jsxs("span",{children:[r.jsxs("b",{children:[ke.count," real system",ke.count===1?"":"s"," ",ke.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ke.namesText,"."]})]}),r.jsx(Fx,{}),r.jsx(Bv,{})]})}const Wx=["Scope & Limits","Intent","Sign"];function Vh({currentStep:t,onStepClick:s}){const a=mn();return r.jsxs("div",{className:"wizard-progress",children:[r.jsx("ol",{className:"wizard-steps",children:Wx.map((o,c)=>{const u=c+2,h=u<t,g=u===t,p=u-1<t,v=h&&!!s;return r.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[r.jsx("button",{type:"button",className:`step-circle${h?" completed":""}${g?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${h?" (done)":g?" (current)":""}`,children:h?"✓":c+1}),r.jsx("span",{className:`step-label-text${g?" current":h?" completed":""}`,children:o})]},u)})}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}const Cf=40,Hx={delegation:"Delegation"};function ut(t,s){const a=t.lastIndexOf("/"),o=a>=0?t.slice(a+1):t,c=o.indexOf("@"),u=c>=0?o.slice(0,c):o,h=Hx[u.toLowerCase()];return h||(s?s.slice(0,Cf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,Cf))}function Vx({profileId:t,bounds:s,groupName:a,domain:o,onSwitch:c}){return r.jsxs("div",{className:"context-strip",children:[a&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"context-strip-label",children:"Team:"}),r.jsxs("span",{children:[r.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),t&&r.jsxs("span",{children:[r.jsx("strong",{children:"Profile:"})," ",ut(t)]}),s&&r.jsxs("span",{children:[r.jsx("strong",{children:"Bounds:"})," ",s]}),c&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:c,children:"Switch"})]})}function Gx({integrationId:t,field:s,value:a,onChange:o,disabled:c,onLabels:u}){const[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState(!0);f.useEffect(()=>{let E=!1;return M.discoverScopeField(t,s).then(S=>{var C;E||(g(S.options),w(!1),(C=S.options)!=null&&C.length&&(u==null||u(Object.fromEntries(S.options.map(T=>[T.value,T.label])))))}).catch(S=>{E||(v(S instanceof Error?S.message:String(S)),w(!1))}),()=>{E=!0}},[t,s]);const j=new Set(a.split(",").map(E=>E.trim()).filter(Boolean)),N=E=>{const S=new Set(j);S.has(E)?S.delete(E):S.add(E),o(Array.from(S).join(","))};return y?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",t,"…"]}):p||!h?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"no response","). Enter values manually, separated by commas."]}),r.jsx("input",{className:"form-input",type:"text",value:a,onChange:E=>o(E.target.value),disabled:c})]}):h.length===0?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",t," for this field."]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:h.map(E=>{const S=E.extras??{},C=typeof S.access=="string"?S.access:void 0,T=C==="reader",R=S.primary===!0;return r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:T?"var(--text-tertiary)":"var(--text-primary)",cursor:c||T?"not-allowed":"pointer"},title:T?"Read-only — you can authorize list/read but not writes":void 0,children:[r.jsx("input",{type:"checkbox",checked:j.has(String(E.value)),onChange:()=>N(String(E.value)),disabled:c||T}),r.jsx("span",{children:E.label||E.value}),R&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),C&&r.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",C]})]},E.value)})})}function yc(t){if(t.type!=="number")return 0;const s=t.boundType,a=t.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function Kx(t,s){if(s!==void 0)return String(s);const a=t.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):yc(t)===1?"1":""}function Gh(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function Ef(t,s){const a=yc(t),o=Gh(t),c=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,c):c}function vc(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}function qx(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Yx(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Jx(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function Qx(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function Tf(t,s){const a=t.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Xx(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function Zx(t){return t?t==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:t==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:t==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:t==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:t.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function e0(t,s){if(!t||!s)return"";const a=Number(t);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),c=a%60;return c===0?`${o} hour${o!==1?"s":""}`:`${o}h ${c}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function t0({id:t,value:s,onChange:a,disabled:o,placeholder:c,unit:u,min:h=0,max:g}){const p=Xx(u),v=Zx(u).filter(S=>g===void 0||S.value<=g),y=vc(u),w=e0(s,u),j=s===""?null:Number(s),N=()=>{const S=s===""?0:Number(s),C=S%p,T=C===0?S+p:S+(p-C);a(String(g!==void 0?Math.min(g,T):T))},E=()=>{const S=s===""?0:Number(s);if(S<=h)return;const C=S%p,T=C===0?S-p:S-C;a(String(Math.max(h,T)))};return r.jsxs("div",{className:"bounded-input",children:[r.jsxs("div",{className:"bounded-input-field",children:[r.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:E,disabled:o||s===""||Number(s)<=h,"aria-label":"Decrease",children:"−"}),r.jsx("input",{id:t,className:"stepper-input",type:"number",min:h,max:g,step:p,value:s,placeholder:c??String(h),onChange:S=>{const C=S.target.value;a(g!==void 0&&C!==""&&Number(C)>g?String(g):C)},onFocus:S=>S.target.select(),disabled:o}),r.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"aria-label":"Increase",children:"+"}),y&&r.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!o&&r.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(S=>r.jsx("button",{type:"button",className:`preset-chip${j===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&r.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function Rf({htmlFor:t,label:s,description:a}){const[o,c]=f.useState(!1);return r.jsxs("div",{className:"field-label-with-tip",children:[r.jsx("label",{className:"form-label",htmlFor:t,children:s}),a&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>c(u=>!u),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onBlur:()=>c(!1),children:"i"}),o&&r.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function n0({id:t,value:s,onChange:a,disabled:o,format:c,placeholder:u}){const[h,g]=f.useState(""),[p,v]=f.useState(!1),y=f.useRef(null),w=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],j=T=>{const R=T.trim();if(!R)return;if(!Tf(R,c)){v(!0);return}v(!1);const $=w.includes(R)?w:[...w,R];a($.join(",")),g("")},N=T=>{const R=w.filter(($,A)=>A!==T);a(R.join(","))},E=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?h.trim()&&(T.preventDefault(),j(h)):T.key==="Backspace"&&!h&&w.length>0&&N(w.length-1)},S=T=>{const R=T.clipboardData.getData("text");if(R.includes(",")){T.preventDefault();const A=R.split(",").map(G=>G.trim()).filter(Boolean).filter(G=>Tf(G,c)),F=[...new Set([...w,...A])];a(F.join(",")),g(""),v(!1)}},C=c==="email"?"Type email and press Enter...":"Type domain and press Enter...";return r.jsxs("div",{className:`tag-input${p?" tag-input-invalid":""}`,onClick:()=>{var T;return(T=y.current)==null?void 0:T.focus()},children:[w.map((T,R)=>r.jsxs("span",{className:"tag-pill",children:[T,!o&&r.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),N(R)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&r.jsx("input",{ref:y,id:t,className:"tag-input-field",type:"text",value:h,onChange:T=>{g(T.target.value),v(!1)},onKeyDown:E,onPaste:S,onBlur:()=>{h.trim()&&j(h)},placeholder:w.length===0?u??C:""})]})}function r0({id:t,options:s,value:a,onChange:o,disabled:c}){const u=a?a.split(",").map(g=>g.trim()).filter(Boolean):[],h=g=>{const p=u.includes(g)?u.filter(v=>v!==g):[...u,g];o(p.join(","))};return r.jsx("div",{className:"checkbox-group",id:t,children:s.map(g=>r.jsxs("label",{className:`checkbox-pill${u.includes(g)?" checkbox-pill-selected":""}`,children:[r.jsx("input",{type:"checkbox",checked:u.includes(g),onChange:()=>h(g),disabled:c}),r.jsx("span",{children:g})]},g))})}function If({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:c,readOnly:u,twoColumn:h,discoveryIntegrationId:g,onLabels:p}){const v=Yx(t,s),y=`${c}-field-${t}`,w=r.jsx(r.Fragment,{children:Qx(s)?r.jsx(r0,{id:y,options:s.enum,value:a,onChange:j=>o(t,j),disabled:u}):(()=>{const j=s.boundType;return(j==null?void 0:j.kind)==="enum"&&Array.isArray(j.values)})()?r.jsxs("select",{id:y,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:u,children:[r.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.enum?r.jsxs("select",{id:y,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:u,children:[r.jsx("option",{value:"",children:"Select..."}),s.enum.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.type==="number"?r.jsx(t0,{id:y,value:a,onChange:j=>o(t,j),disabled:u,unit:s.unit,min:yc(s),max:Gh(s)}):Jx(s)?r.jsx(n0,{id:y,value:a,onChange:j=>o(t,j),disabled:u,format:s.format}):g?r.jsx(Gx,{integrationId:g,field:t,value:a,onChange:j=>o(t,j),disabled:u,onLabels:j=>p==null?void 0:p(t,j)}):r.jsx("input",{id:y,className:"form-input",type:"text",value:a,onChange:j=>o(t,j.target.value),disabled:u})});return h?r.jsxs("div",{className:"bounds-field-row",children:[r.jsx("div",{className:"bounds-field-label",children:r.jsx(Rf,{htmlFor:y,label:v,description:s.description})}),r.jsx("div",{className:"bounds-field-input",children:w})]},`${c}-${t}`):r.jsxs("div",{className:"form-group",children:[r.jsx(Rf,{htmlFor:y,label:v,description:s.description}),w]},`${c}-${t}`)}function s0(t,s){if(!s)return"no-config";const a=s.caps,o=Array.isArray(s.approvers)&&s.approvers.length>0;if(!(a&&Object.keys(a).length>0))return o?"approvers-dormant":"no-config";let u=!1;for(const[h,g]of Object.entries(a)){const p=t[h];if(p===""||p===void 0)continue;const v=Number(p);if(!isNaN(v)&&v>g){u=!0;break}}return u?o?"above-approvers":"hard-ceiling":"within-cap"}function a0(t,s){const a=new Set;if(!s)return a;for(const[o,c]of Object.entries(s)){const u=t[o];if(u===""||u===void 0)continue;const h=Number(u);!isNaN(h)&&h>c&&a.add(o)}return a}function i0({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:c,initialContext:u,initialFrame:h,profileConfig:g,approverNames:p,adminName:v}){const y=t.boundsSchema,w=t.scopeSchema,j=y?Object.entries(y.fields).filter(([b,L])=>!(b==="profile"||b==="path"||L.enforced===!1||L.enforcedBy==="gatekeeper")):[],N=y?Object.entries(y.fields).filter(([,b])=>b.enforcedBy==="gatekeeper").filter(([,b])=>b.enforced!==!1).map(([b,L])=>L.displayName??b):[],E=w&&w.keyOrder.length>0?Object.entries(w.fields):[],S=c??h??{},C=u??{},T={};for(const[b,L]of j)T[b]=Kx(L,S[b]);const R={};for(const[b]of E)R[b]=C[b]!==void 0?String(C[b]):"";const[$,A]=f.useState(T),[F,G]=f.useState(R),[q,de]=f.useState({}),[K,oe]=f.useState(null);f.useEffect(()=>{const b=qx(t.id);M.getIntegrationManifests().then(({manifests:L})=>{const J=L.find(W=>W.profile===b&&W.contextDiscovery&&Object.keys(W.contextDiscovery).length>0);oe(J??null)}).catch(()=>oe(null))},[t.id]);const V=s0($,g),D=a0($,g==null?void 0:g.caps),ce=(b,L)=>{A(J=>({...J,[b]:L}))},re=(b,L)=>{G(J=>({...J,[b]:L}))},Z=()=>{const b={profile:t.id};for(const[J,W]of j)W.type==="number"?b[J]=Ef(W,$[J]):b[J]=$[J];const L={};for(const[J,W]of E)W.type==="number"?L[J]=F[J]===""?0:Number(F[J]):L[J]=F[J];return[b,L]},he=()=>{const[b,L]=Z();s(b,L,q)},ge=()=>{const b=(g==null?void 0:g.caps)??{},L={...$};for(const ee of D)b[ee]!==void 0&&(L[ee]=String(b[ee]));A(L);const J={profile:t.id};for(const[ee,xe]of j)xe.type==="number"?J[ee]=Ef(xe,L[ee]??""):J[ee]=L[ee]??"";const W={};for(const[ee,xe]of E)xe.type==="number"?W[ee]=F[ee]===""?0:Number(F[ee]):W[ee]=F[ee];s(J,W,q)},Y=b=>{const L=g==null?void 0:g.caps;if(!L||L[b]===void 0)return null;const J=L[b],W=D.has(b);return V==="hard-ceiling"&&W?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — exceeds team ceiling"]}):V==="above-approvers"&&W?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — above cap"]}):r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," ok"]})},O=()=>{var b;if(V==="no-config")return null;if(V==="approvers-dormant"){const L=p&&p.length>0?p.join(", "):"the configured approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",L]}),r.jsxs("div",{children:["No caps are set on this profile, so ",L," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(V==="within-cap")return r.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:r.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(V==="above-approvers"){const L=p&&p.length>0?p.join(", "):"the required approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),r.jsxs("div",{children:[r.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",L,". Within-cap actions run per the mode you choose."]})]})}if(V==="hard-ceiling"){const L=Array.from(D)[0],J=L?(b=g==null?void 0:g.caps)==null?void 0:b[L]:void 0,W=v??"the team admin";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),r.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",J??"the configured limit",". Lower your bound or ask ",W," to add an approver path above the cap."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ge,children:"Save below cap"}),a&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})}return null},H=V==="hard-ceiling";return r.jsxs("div",{children:[E.length>0&&r.jsxs("div",{className:"context-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🛡"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),E.map(([b,L])=>{var W;const J=!!((W=K==null?void 0:K.contextDiscovery)!=null&&W[b]);return r.jsx(If,{fieldKey:b,fieldDef:L,value:F[b],onChange:re,prefix:"context",readOnly:o,discoveryIntegrationId:J?K.id:void 0,onLabels:(ee,xe)=>de(ke=>({...ke,[ee]:xe}))},`context-${b}`)})]}),j.length>0&&r.jsxs("div",{className:"bounds-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🔒"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Limits"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),r.jsx("div",{className:"bounds-fields-grid",children:j.map(([b,L])=>{var J;return r.jsxs("div",{style:{display:"contents"},children:[r.jsx(If,{fieldKey:b,fieldDef:L,value:$[b],onChange:ce,prefix:"bounds",readOnly:o,twoColumn:!0}),V!=="no-config"&&((J=g==null?void 0:g.caps)==null?void 0:J[b])!==void 0&&r.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Y(b)})]},`bounds-${b}`)})}),O(),N.length>0&&r.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[N.join(", ")," ",N.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",r.jsx(xt,{to:"/integrations",children:"Integrations"}),"."]})]}),r.jsx("button",{className:"btn btn-primary",onClick:he,disabled:H,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function o0(t){var a;const s=t.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function l0(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const c0="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function ki({target:t,currentText:s,onApply:a,greeting:o,placeholder:c,title:u}){const[h,g]=f.useState([{role:"assistant",content:o??c0}]),[p,v]=f.useState(""),[y,w]=f.useState(!1),[j,N]=f.useState(null),E=f.useRef(null),S=f.useRef(null);f.useEffect(()=>{const R=E.current;if(!R)return;const $=h[h.length-1],A=S.current;!y&&($==null?void 0:$.role)==="assistant"&&h.length>1&&A?R.scrollTop=A.offsetTop:R.scrollTop=R.scrollHeight},[h,y]);const C=async()=>{const R=p.trim();if(!R||y)return;const $=[...h,{role:"user",content:R}];g($),v(""),N(null),w(!0);try{const A=await M.aiChat({target:t,currentText:s,messages:$.filter((F,G)=>!(G===0&&F.role==="assistant"))});A.success&&A.reply?g(F=>[...F,{role:"assistant",content:A.reply}]):N(A.error??"AI returned no reply")}catch(A){N(A instanceof Error?A.message:"Chat failed")}finally{w(!1)}},T=R=>{R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),C())};return r.jsxs("div",{className:"intent-chat",children:[r.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),r.jsxs("div",{ref:E,className:"chat-messages",children:[h.map((R,$)=>{const A=R.role==="assistant"?o0(R.content):null,F=A?l0(R.content):R.content;return r.jsx("div",{className:`chat-msg ${R.role}`,ref:$===h.length-1?S:void 0,children:r.jsxs("div",{className:"chat-msg-body",children:[F&&r.jsx("div",{className:"chat-msg-prose",children:F}),A!==null&&r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"chat-fenced-block",children:A}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(A),children:"Apply this draft"})]})]})},$)}),y&&r.jsx("div",{className:"chat-msg assistant",children:r.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),j&&r.jsx("div",{className:"error-message",children:j}),r.jsxs("div",{className:"chat-composer",children:[r.jsxs("div",{className:"chat-composer-pill",children:[r.jsx("textarea",{className:"chat-input",value:p,onChange:R=>v(R.target.value),onKeyDown:T,placeholder:c??"Ask for help articulating the intent…",rows:1,disabled:y}),r.jsx("button",{type:"button",className:"chat-send-btn",onClick:C,disabled:y||!p.trim(),"aria-label":"Send",children:"↑"})]}),r.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Kh({open:t,onClose:s,children:a,ariaLabel:o}){const c=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{var g;if(!t)return;u.current=document.activeElement,document.body.style.overflow="hidden";const h=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",h),(g=c.current)==null||g.focus(),()=>{document.removeEventListener("keydown",h),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[t,s]),hv.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`bottom-sheet-backdrop${t?" is-open":""}`,onClick:s,"aria-hidden":"true"}),r.jsxs("aside",{ref:c,className:`bottom-sheet${t?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[r.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),r.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function u0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function d0(t,s,a){if(s.length===0)return[{text:t,label:t,matched:null}];const o=[],c=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const v of[p.scope,...p.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!c.has(y)&&(c.add(y),o.push(v))}o.sort((p,v)=>v.length-p.length);const u=p=>{const v=p.toLowerCase();return s.filter(y=>{var w,j;return((w=y.scope)==null?void 0:w.toLowerCase())===v||((j=y.scope)==null?void 0:j.split(",").map(N=>N.trim().toLowerCase()).includes(v))})},h=["\\[\\d+\\]",...o.map(u0)],g=new RegExp(`(${h.join("|")})`,"gi");return t.split(g).filter(p=>p!=="").map(p=>{const v=/^\[(\d+)\]$/.exec(p);if(v){const y=s[Number(v[1])-1];if(y){const w=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",j=a?`${a}: ${w}`:w;return{text:p,label:j,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===p.toLowerCase())){const y=u(p);if(y.length>0)return{text:p,label:p,matched:y}}return{text:p,label:p,matched:null}})}const Af=`Why — What's the situation? Why does this need to happen?
|
|
65
|
+
Health check: GET ${t}/health`}},kf=["claude-code","claude-desktop","chatgpt-codex","other"];function Bl({mcpEndpoint:t}){const[s,a]=f.useState(kf[0]),[o,c]=f.useState(!1),u=f.useCallback(async g=>{try{await navigator.clipboard.writeText(g),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),h=bf[s].snippet(t);return r.jsxs("div",{children:[r.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),r.jsx("div",{className:"mcp-endpoint",children:t}),r.jsx("div",{className:"mcp-tabs",children:kf.map(g=>r.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:bf[g].label},g))}),r.jsx("pre",{className:"mcp-snippet",children:h}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(h),children:o?"Copied":"Copy"})]})}const Dl="suveren-setup-ai-skipped",Ul="suveren-setup-agent-done",Wl="suveren-setup-dismissed",Tx={"hap-setup-ai-skipped":Dl,"hap-setup-agent-done":Ul,"hap-setup-dismissed":Wl};function Rx(){for(const[t,s]of Object.entries(Tx)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}Rx();function Ix({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:c}){const[u,h]=f.useState(()=>localStorage.getItem(Dl)==="true"),[g,p]=f.useState(()=>localStorage.getItem(Ul)==="true"),[v,y]=f.useState(()=>localStorage.getItem(Wl)==="true"),[w,j]=f.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:t?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||g?"done":"pending"}],E=N.filter(A=>A.status==="done"||A.status==="skipped").length,S=E===N.length,C=f.useCallback(()=>{localStorage.setItem(Dl,"true"),h(!0)},[]),T=f.useCallback(()=>{localStorage.setItem(Ul,"true"),p(!0),j(null)},[]),R=f.useCallback(()=>{localStorage.setItem(Wl,"true"),y(!0)},[]);if(v||S)return null;const $=N.findIndex(A=>A.status==="pending");return r.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[r.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),r.jsx("button",{onClick:R,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:N.map((A,F)=>{const G=F===$,q=A.status==="done"||A.status==="skipped"?"●":"○",de=A.status==="done"?"var(--success)":A.status==="skipped"?"var(--text-tertiary)":G?"var(--accent)":"var(--text-tertiary)";return r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:G?"0.75rem":"0.25rem 0",borderRadius:G?"0.5rem":void 0,background:G?"var(--accent-subtle)":void 0},children:[r.jsx("span",{style:{color:de,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:q}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A.to&&A.status==="pending"?r.jsx(xt,{to:A.to,style:{fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:A.label}):A.status==="pending"&&F===3?r.jsx("button",{onClick:()=>j(w===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)"},children:A.label}):r.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:A.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:A.label}),A.optional&&A.status==="pending"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),A.status==="skipped"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),A.detail&&A.status==="pending"&&G&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:A.detail})]}),A.optional&&A.status==="pending"&&r.jsx("button",{onClick:C,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),A.to&&A.status==="pending"&&r.jsx(xt,{to:A.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),F===3&&w===3&&r.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[r.jsx(Bl,{mcpEndpoint:c}),r.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},F)})}),r.jsxs("div",{style:{marginTop:"1.25rem"},children:[r.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${E/N.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[E," of ",N.length," complete"]})]})]})}function Wh(t,s=null){const a=[t.hasContact,t.hasDelegationMandate,t.delegationProposalCount>0],o=a.every(Boolean),c=t.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),h=s!==null&&a[s]===!1?s:u,g=t.managed?"managed":"self",p=v=>a[v]?{status:"done"}:v!==h?{status:"todo"}:v===1?{status:"open",variant:g,simulationOn:t.simulationOn}:v===0?{status:"open",variant:g}:{status:"open"};return{visible:c,step1:p(0),step2:p(1),step3:p(2)}}const Ax="/mandates?new=1&profile=delegation";function Nf({text:t}){const[s,a]=f.useState(!1),o=f.useCallback(async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t]);return r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Il({todo:t,onOpen:s,children:a}){return t?r.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):r.jsx("span",{className:"flow-step-title",children:a})}function Px({contact:t,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:u,mcpEndpoint:h}){const g={hasContact:t!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:u},[p,v]=f.useState(null),y=Wh(g,p);if(!y.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${h}/mcp`;return r.jsxs("div",{className:"card setup-card",children:[r.jsx("h2",{className:"card-title",children:"Get started"}),r.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&t?r.jsxs("span",{className:"flow-step-title flow-done-title",children:[t.clientName," connected · last contact ",_h(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):r.jsx(Il,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&r.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"For your IT"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Bl,{mcpEndpoint:h})})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:w}),r.jsx(Nf,{text:w})]})}),r.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"Set it up by hand"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Bl,{mcpEndpoint:h})})]})]})})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?r.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",r.jsx(xt,{to:"/mandates",children:"review or revoke under Mandates"})]}):r.jsx(Il,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),r.jsxs("ul",{className:"bound-list",children:[r.jsx("li",{children:"Read the setup guides"}),r.jsx("li",{children:"Propose new mandates — each waits for your approval"}),r.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?r.jsxs(r.Fragment,{children:[r.jsx(xt,{to:Ax,className:"btn btn-primary",children:"Give the Delegation mandate →"}),r.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&r.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):r.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":r.jsxs(r.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",r.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),r.jsx(Il,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),r.jsx(Nf,{text:"How do I start with Suveren?"})]})}),r.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",r.jsx(xt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function _x(){const[t,s]=f.useState(null);return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),t}function $x(t){if(!t||typeof t!="object")return{simulation:null,locked:!1};const s=Array.isArray(t.policyLocked)&&t.policyLocked.includes("simulation");return{simulation:typeof t.simulation=="boolean"?t.simulation:null,locked:s}}function Hh(){const[t,s]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s($x(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Lx(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function zx(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(Lx(h))}).catch(()=>{})};o();const c=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",u)}},[]),t}function jr({variant:t="base",style:s,className:a,...o}){const c=t==="title"?"skeleton skeleton-title":t==="line"?"skeleton skeleton-line":t==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return r.jsx("span",{className:`${c}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}function Al(){return r.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[r.jsx(jr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[r.jsx(jr,{variant:"line",style:{width:"35%"}}),r.jsx(jr,{variant:"line-sm",style:{width:"65%"}})]})]})}function Fx(){const[t,s]=f.useState([]);return nn(async()=>{try{const{skipped:o}=await M.getSkippedCommitments();s(o)}catch{}},3e4),t.length===0?null:r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[r.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",t.length,")"]}),r.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),r.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:t.map(o=>r.jsxs("li",{style:{marginBottom:"0.35rem"},children:[r.jsx("code",{children:o.tool})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Ox(t,s){return s&&!qs(t.manifest)}function Mx(t,s=!1){var o;const a=[];for(const c of t)Ox(c,s)||(c.state==="error"?a.push({label:"Integration error",detail:(o=c.integration)!=null&&o.error?`${c.manifest.name}: ${c.integration.error}`:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):c.state==="not-running"&&(qs(c.manifest)?a.push({label:`${c.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):a.push({label:"Integration stopped",detail:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return a}function Bx(t){const s=t.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Dx=1800;function Yr(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Ux(){const{domain:t}=pt(),[s,a]=f.useState([]),[o,c]=f.useState([]),[u,h]=f.useState([]),[g,p]=f.useState(!0),[v,y]=f.useState(!1),[w,j]=f.useState([]),[N,E]=f.useState(!1),[S,C]=f.useState(!1),[T,R]=f.useState(null),[$,A]=f.useState(!1),{entries:F,activeSessions:G,loading:q}=fc(),de=_x(),K=!q,{simulation:oe}=Hh(),V=oe===!0,D=zx(),ce=f.useCallback(()=>{M.getMyAttestations().then(ne=>{a(ne),y(!0)}).catch(()=>y(!0)),M.getArchivedMandates().then(j).catch(()=>j([])),M.getMyProposals(t).then(ne=>{c(ne),E(!0)}).catch(()=>E(!0)),M.getProposalsForApprover().then(ne=>h(ne)).catch(()=>h([])),M.getCredential("ai-config").then(ne=>{p(ne.configured),C(!0)}).catch(()=>C(!0)),M.getAgentContact().then(ne=>{R(ne.contact),A(!0)}).catch(()=>A(!0))},[t]);Ue("attestation-changed",ce),Ue("proposal-added",ce),Ue("proposal-resolved",ce),Ue("proposal-approved",ce),Ue("proposal-rejected",ce),Ue("execution-failed",ce),nn(ce,3e5,t);const re=v&&N&&S&&K&&$&&oe!==null,Z=Ah(s,{archivedSet:new Set(w)}),he=Z.active,ge=Z.expired,Y=he.some(ne=>Yr(ne.profile_id)==="delegation"),O=he.filter(ne=>Yr(ne.profile_id)!=="delegation").length,H=o.filter(ne=>Yr(ne.profileId)==="delegation").length,b=Wh({hasContact:T!==null,hasDelegationMandate:Y,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:V}),L=V&&b.visible,J=he.filter(ne=>ne.remaining_seconds!==null&&ne.remaining_seconds<=Dx),W=o.filter(Fh),ee=F.filter(ne=>ne.state==="running"),xe=F.filter(ne=>ne.state==="starting"),ke=Bx(F),ve=[];for(const ne of u)ve.push({label:"Approval needed",detail:`${ne.tool} — above-cap action under ${Yr(ne.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const ne of W)ve.push({label:"Approval pending",detail:`${ne.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const ne of J){const Ae=Math.ceil((ne.remaining_seconds??0)/60);ve.push({label:"Expiring soon",detail:`${ne.title??Yr(ne.profile_id)} — ${Ae} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const ne of ge)ve.push({label:"Expired",detail:ne.title??Yr(ne.profile_id),to:"/mandates",color:"var(--danger)"});ve.push(...Mx(F,V));for(const ne of xe)ve.push({label:"Integration starting",detail:`${ne.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const ne of F)ne.authStatus==="failed"&&ne.state!=="not-running"&&ne.state!=="error"&&ne.state!=="paused"&&ve.push({label:"Reconnect needed",detail:`${ne.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return g||ve.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Dashboard"})}),re&&de&&(L?r.jsx(Px,{contact:T,hasDelegationMandate:Y,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:V,mcpEndpoint:de}):!V&&r.jsx(Ix,{aiConfigured:g,hasRunningIntegration:ee.length>0,hasActiveAuth:he.length>0,hasAgentConnected:G>0,mcpEndpoint:de})),!L&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[r.jsx(xt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[v?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:he.length>0?"var(--success)":"var(--text-tertiary)"},children:he.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),r.jsx(xt,{to:"/approvals",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[N?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:W.length>0?"var(--warning)":"var(--text-tertiary)"},children:W.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),r.jsx(xt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[v?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ge.length>0?"var(--danger)":"var(--text-tertiary)"},children:ge.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),r.jsx(xt,{to:"/integrations",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[K?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ee.length>0?"var(--success)":"var(--text-tertiary)"},children:ee.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),r.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Needs your attention"}),ve.length>0&&r.jsx("span",{className:"rb-count",children:ve.length})]}),ve.length>0?r.jsx("div",{className:"attention-rows",children:ve.map((ne,Ae)=>r.jsxs(xt,{to:ne.to,className:"attention-row",children:[r.jsx("span",{className:"attention-dot",style:{background:ne.color},"aria-hidden":"true"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:ne.label}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ne.detail})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},Ae))}):re?r.jsxs("div",{className:"all-clear",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsx("h3",{children:"All clear"}),r.jsx("p",{children:"Nothing needs your attention."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[r.jsx(Al,{}),r.jsx(Al,{}),r.jsx(Al,{})]})]})]}),ke&&r.jsxs("div",{className:"sim-paused-summary",role:"status",children:[r.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),r.jsxs("span",{children:[r.jsxs("b",{children:[ke.count," real system",ke.count===1?"":"s"," ",ke.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ke.namesText,"."]})]}),r.jsx(Fx,{}),r.jsx(Bv,{})]})}const Wx=["Scope & Limits","Intent","Sign"];function Vh({currentStep:t,onStepClick:s}){const a=mn();return r.jsxs("div",{className:"wizard-progress",children:[r.jsx("ol",{className:"wizard-steps",children:Wx.map((o,c)=>{const u=c+2,h=u<t,g=u===t,p=u-1<t,v=h&&!!s;return r.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[r.jsx("button",{type:"button",className:`step-circle${h?" completed":""}${g?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${h?" (done)":g?" (current)":""}`,children:h?"✓":c+1}),r.jsx("span",{className:`step-label-text${g?" current":h?" completed":""}`,children:o})]},u)})}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}const Cf=40,Hx={delegation:"Delegation"};function ut(t,s){const a=t.lastIndexOf("/"),o=a>=0?t.slice(a+1):t,c=o.indexOf("@"),u=c>=0?o.slice(0,c):o,h=Hx[u.toLowerCase()];return h||(s?s.slice(0,Cf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,Cf))}function Vx({profileId:t,bounds:s,groupName:a,domain:o,onSwitch:c}){return r.jsxs("div",{className:"context-strip",children:[a&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"context-strip-label",children:"Team:"}),r.jsxs("span",{children:[r.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),t&&r.jsxs("span",{children:[r.jsx("strong",{children:"Profile:"})," ",ut(t)]}),s&&r.jsxs("span",{children:[r.jsx("strong",{children:"Bounds:"})," ",s]}),c&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:c,children:"Switch"})]})}function Gx({integrationId:t,field:s,value:a,onChange:o,disabled:c,onLabels:u}){const[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState(!0);f.useEffect(()=>{let E=!1;return M.discoverScopeField(t,s).then(S=>{var C;E||(g(S.options),w(!1),(C=S.options)!=null&&C.length&&(u==null||u(Object.fromEntries(S.options.map(T=>[T.value,T.label])))))}).catch(S=>{E||(v(S instanceof Error?S.message:String(S)),w(!1))}),()=>{E=!0}},[t,s]);const j=new Set(a.split(",").map(E=>E.trim()).filter(Boolean)),N=E=>{const S=new Set(j);S.has(E)?S.delete(E):S.add(E),o(Array.from(S).join(","))};return y?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",t,"…"]}):p||!h?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"no response","). Enter values manually, separated by commas."]}),r.jsx("input",{className:"form-input",type:"text",value:a,onChange:E=>o(E.target.value),disabled:c})]}):h.length===0?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",t," for this field."]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:h.map(E=>{const S=E.extras??{},C=typeof S.access=="string"?S.access:void 0,T=C==="reader",R=S.primary===!0;return r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:T?"var(--text-tertiary)":"var(--text-primary)",cursor:c||T?"not-allowed":"pointer"},title:T?"Read-only — you can authorize list/read but not writes":void 0,children:[r.jsx("input",{type:"checkbox",checked:j.has(String(E.value)),onChange:()=>N(String(E.value)),disabled:c||T}),r.jsx("span",{children:E.label||E.value}),R&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),C&&r.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",C]})]},E.value)})})}function yc(t){if(t.type!=="number")return 0;const s=t.boundType,a=t.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function Kx(t,s){if(s!==void 0)return String(s);const a=t.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):yc(t)===1?"1":""}function Gh(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function Ef(t,s){const a=yc(t),o=Gh(t),c=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,c):c}function vc(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}function qx(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Yx(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Jx(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function Qx(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function Tf(t,s){const a=t.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Xx(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function Zx(t){return t?t==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:t==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:t==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:t==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:t.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function e0(t,s){if(!t||!s)return"";const a=Number(t);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),c=a%60;return c===0?`${o} hour${o!==1?"s":""}`:`${o}h ${c}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function t0({id:t,value:s,onChange:a,disabled:o,placeholder:c,unit:u,min:h=0,max:g}){const p=Xx(u),v=Zx(u).filter(S=>g===void 0||S.value<=g),y=vc(u),w=e0(s,u),j=s===""?null:Number(s),N=()=>{const S=s===""?0:Number(s),C=S%p,T=C===0?S+p:S+(p-C);a(String(g!==void 0?Math.min(g,T):T))},E=()=>{const S=s===""?0:Number(s);if(S<=h)return;const C=S%p,T=C===0?S-p:S-C;a(String(Math.max(h,T)))};return r.jsxs("div",{className:"bounded-input",children:[r.jsxs("div",{className:"bounded-input-field",children:[r.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:E,disabled:o||s===""||Number(s)<=h,"aria-label":"Decrease",children:"−"}),r.jsx("input",{id:t,className:"stepper-input",type:"number",min:h,max:g,step:p,value:s,placeholder:c??String(h),onChange:S=>{const C=S.target.value;a(g!==void 0&&C!==""&&Number(C)>g?String(g):C)},onFocus:S=>S.target.select(),disabled:o}),r.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"aria-label":"Increase",children:"+"}),y&&r.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!o&&r.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(S=>r.jsx("button",{type:"button",className:`preset-chip${j===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&r.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function Rf({htmlFor:t,label:s,description:a}){const[o,c]=f.useState(!1);return r.jsxs("div",{className:"field-label-with-tip",children:[r.jsx("label",{className:"form-label",htmlFor:t,children:s}),a&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>c(u=>!u),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onBlur:()=>c(!1),children:"i"}),o&&r.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function n0({id:t,value:s,onChange:a,disabled:o,format:c,placeholder:u}){const[h,g]=f.useState(""),[p,v]=f.useState(!1),y=f.useRef(null),w=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],j=T=>{const R=T.trim();if(!R)return;if(!Tf(R,c)){v(!0);return}v(!1);const $=w.includes(R)?w:[...w,R];a($.join(",")),g("")},N=T=>{const R=w.filter(($,A)=>A!==T);a(R.join(","))},E=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?h.trim()&&(T.preventDefault(),j(h)):T.key==="Backspace"&&!h&&w.length>0&&N(w.length-1)},S=T=>{const R=T.clipboardData.getData("text");if(R.includes(",")){T.preventDefault();const A=R.split(",").map(G=>G.trim()).filter(Boolean).filter(G=>Tf(G,c)),F=[...new Set([...w,...A])];a(F.join(",")),g(""),v(!1)}},C=c==="email"?"Type email and press Enter...":"Type domain and press Enter...";return r.jsxs("div",{className:`tag-input${p?" tag-input-invalid":""}`,onClick:()=>{var T;return(T=y.current)==null?void 0:T.focus()},children:[w.map((T,R)=>r.jsxs("span",{className:"tag-pill",children:[T,!o&&r.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),N(R)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&r.jsx("input",{ref:y,id:t,className:"tag-input-field",type:"text",value:h,onChange:T=>{g(T.target.value),v(!1)},onKeyDown:E,onPaste:S,onBlur:()=>{h.trim()&&j(h)},placeholder:w.length===0?u??C:""})]})}function r0({id:t,options:s,value:a,onChange:o,disabled:c}){const u=a?a.split(",").map(g=>g.trim()).filter(Boolean):[],h=g=>{const p=u.includes(g)?u.filter(v=>v!==g):[...u,g];o(p.join(","))};return r.jsx("div",{className:"checkbox-group",id:t,children:s.map(g=>r.jsxs("label",{className:`checkbox-pill${u.includes(g)?" checkbox-pill-selected":""}`,children:[r.jsx("input",{type:"checkbox",checked:u.includes(g),onChange:()=>h(g),disabled:c}),r.jsx("span",{children:g})]},g))})}function If({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:c,readOnly:u,twoColumn:h,discoveryIntegrationId:g,onLabels:p}){const v=Yx(t,s),y=`${c}-field-${t}`,w=r.jsx(r.Fragment,{children:Qx(s)?r.jsx(r0,{id:y,options:s.enum,value:a,onChange:j=>o(t,j),disabled:u}):(()=>{const j=s.boundType;return(j==null?void 0:j.kind)==="enum"&&Array.isArray(j.values)})()?r.jsxs("select",{id:y,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:u,children:[r.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.enum?r.jsxs("select",{id:y,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:u,children:[r.jsx("option",{value:"",children:"Select..."}),s.enum.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.type==="number"?r.jsx(t0,{id:y,value:a,onChange:j=>o(t,j),disabled:u,unit:s.unit,min:yc(s),max:Gh(s)}):Jx(s)?r.jsx(n0,{id:y,value:a,onChange:j=>o(t,j),disabled:u,format:s.format}):g?r.jsx(Gx,{integrationId:g,field:t,value:a,onChange:j=>o(t,j),disabled:u,onLabels:j=>p==null?void 0:p(t,j)}):r.jsx("input",{id:y,className:"form-input",type:"text",value:a,onChange:j=>o(t,j.target.value),disabled:u})});return h?r.jsxs("div",{className:"bounds-field-row",children:[r.jsx("div",{className:"bounds-field-label",children:r.jsx(Rf,{htmlFor:y,label:v,description:s.description})}),r.jsx("div",{className:"bounds-field-input",children:w})]},`${c}-${t}`):r.jsxs("div",{className:"form-group",children:[r.jsx(Rf,{htmlFor:y,label:v,description:s.description}),w]},`${c}-${t}`)}function s0(t,s){if(!s)return"no-config";const a=s.caps,o=Array.isArray(s.approvers)&&s.approvers.length>0;if(!(a&&Object.keys(a).length>0))return o?"approvers-dormant":"no-config";let u=!1;for(const[h,g]of Object.entries(a)){const p=t[h];if(p===""||p===void 0)continue;const v=Number(p);if(!isNaN(v)&&v>g){u=!0;break}}return u?o?"above-approvers":"hard-ceiling":"within-cap"}function a0(t,s){const a=new Set;if(!s)return a;for(const[o,c]of Object.entries(s)){const u=t[o];if(u===""||u===void 0)continue;const h=Number(u);!isNaN(h)&&h>c&&a.add(o)}return a}function i0({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:c,initialContext:u,initialFrame:h,profileConfig:g,approverNames:p,adminName:v}){const y=t.boundsSchema,w=t.scopeSchema,j=y?Object.entries(y.fields).filter(([b,L])=>!(b==="profile"||b==="path"||L.enforced===!1||L.enforcedBy==="gatekeeper")):[],N=y?Object.entries(y.fields).filter(([,b])=>b.enforcedBy==="gatekeeper").filter(([,b])=>b.enforced!==!1).map(([b,L])=>L.displayName??b):[],E=w&&w.keyOrder.length>0?Object.entries(w.fields):[],S=c??h??{},C=u??{},T={};for(const[b,L]of j)T[b]=Kx(L,S[b]);const R={};for(const[b]of E)R[b]=C[b]!==void 0?String(C[b]):"";const[$,A]=f.useState(T),[F,G]=f.useState(R),[q,de]=f.useState({}),[K,oe]=f.useState(null);f.useEffect(()=>{const b=qx(t.id);M.getIntegrationManifests().then(({manifests:L})=>{const J=L.find(W=>W.profile===b&&W.contextDiscovery&&Object.keys(W.contextDiscovery).length>0);oe(J??null)}).catch(()=>oe(null))},[t.id]);const V=s0($,g),D=a0($,g==null?void 0:g.caps),ce=(b,L)=>{A(J=>({...J,[b]:L}))},re=(b,L)=>{G(J=>({...J,[b]:L}))},Z=()=>{const b={profile:t.id};for(const[J,W]of j)W.type==="number"?b[J]=Ef(W,$[J]):b[J]=$[J];const L={};for(const[J,W]of E)W.type==="number"?L[J]=F[J]===""?0:Number(F[J]):L[J]=F[J];return[b,L]},he=()=>{const[b,L]=Z();s(b,L,q)},ge=()=>{const b=(g==null?void 0:g.caps)??{},L={...$};for(const ee of D)b[ee]!==void 0&&(L[ee]=String(b[ee]));A(L);const J={profile:t.id};for(const[ee,xe]of j)xe.type==="number"?J[ee]=Ef(xe,L[ee]??""):J[ee]=L[ee]??"";const W={};for(const[ee,xe]of E)xe.type==="number"?W[ee]=F[ee]===""?0:Number(F[ee]):W[ee]=F[ee];s(J,W,q)},Y=b=>{const L=g==null?void 0:g.caps;if(!L||L[b]===void 0)return null;const J=L[b],W=D.has(b);return V==="hard-ceiling"&&W?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — exceeds team ceiling"]}):V==="above-approvers"&&W?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — above cap"]}):r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," ok"]})},O=()=>{var b;if(V==="no-config")return null;if(V==="approvers-dormant"){const L=p&&p.length>0?p.join(", "):"the configured approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",L]}),r.jsxs("div",{children:["No caps are set on this profile, so ",L," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(V==="within-cap")return r.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:r.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(V==="above-approvers"){const L=p&&p.length>0?p.join(", "):"the required approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),r.jsxs("div",{children:[r.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",L,". Within-cap actions run per the mode you choose."]})]})}if(V==="hard-ceiling"){const L=Array.from(D)[0],J=L?(b=g==null?void 0:g.caps)==null?void 0:b[L]:void 0,W=v??"the team admin";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),r.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",J??"the configured limit",". Lower your bound or ask ",W," to add an approver path above the cap."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ge,children:"Save below cap"}),a&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})}return null},H=V==="hard-ceiling";return r.jsxs("div",{children:[E.length>0&&r.jsxs("div",{className:"context-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🛡"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),E.map(([b,L])=>{var W;const J=!!((W=K==null?void 0:K.contextDiscovery)!=null&&W[b]);return r.jsx(If,{fieldKey:b,fieldDef:L,value:F[b],onChange:re,prefix:"context",readOnly:o,discoveryIntegrationId:J?K.id:void 0,onLabels:(ee,xe)=>de(ke=>({...ke,[ee]:xe}))},`context-${b}`)})]}),j.length>0&&r.jsxs("div",{className:"bounds-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🔒"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Limits"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),r.jsx("div",{className:"bounds-fields-grid",children:j.map(([b,L])=>{var J;return r.jsxs("div",{style:{display:"contents"},children:[r.jsx(If,{fieldKey:b,fieldDef:L,value:$[b],onChange:ce,prefix:"bounds",readOnly:o,twoColumn:!0}),V!=="no-config"&&((J=g==null?void 0:g.caps)==null?void 0:J[b])!==void 0&&r.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Y(b)})]},`bounds-${b}`)})}),O(),N.length>0&&r.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[N.join(", ")," ",N.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",r.jsx(xt,{to:"/integrations",children:"Integrations"}),"."]})]}),r.jsx("button",{className:"btn btn-primary",onClick:he,disabled:H,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function o0(t){var a;const s=t.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function l0(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const c0="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function ki({target:t,currentText:s,onApply:a,greeting:o,placeholder:c,title:u}){const[h,g]=f.useState([{role:"assistant",content:o??c0}]),[p,v]=f.useState(""),[y,w]=f.useState(!1),[j,N]=f.useState(null),E=f.useRef(null),S=f.useRef(null);f.useEffect(()=>{const R=E.current;if(!R)return;const $=h[h.length-1],A=S.current;!y&&($==null?void 0:$.role)==="assistant"&&h.length>1&&A?R.scrollTop=A.offsetTop:R.scrollTop=R.scrollHeight},[h,y]);const C=async()=>{const R=p.trim();if(!R||y)return;const $=[...h,{role:"user",content:R}];g($),v(""),N(null),w(!0);try{const A=await M.aiChat({target:t,currentText:s,messages:$.filter((F,G)=>!(G===0&&F.role==="assistant"))});A.success&&A.reply?g(F=>[...F,{role:"assistant",content:A.reply}]):N(A.error??"AI returned no reply")}catch(A){N(A instanceof Error?A.message:"Chat failed")}finally{w(!1)}},T=R=>{R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),C())};return r.jsxs("div",{className:"intent-chat",children:[r.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),r.jsxs("div",{ref:E,className:"chat-messages",children:[h.map((R,$)=>{const A=R.role==="assistant"?o0(R.content):null,F=A?l0(R.content):R.content;return r.jsx("div",{className:`chat-msg ${R.role}`,ref:$===h.length-1?S:void 0,children:r.jsxs("div",{className:"chat-msg-body",children:[F&&r.jsx("div",{className:"chat-msg-prose",children:F}),A!==null&&r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"chat-fenced-block",children:A}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(A),children:"Apply this draft"})]})]})},$)}),y&&r.jsx("div",{className:"chat-msg assistant",children:r.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),j&&r.jsx("div",{className:"error-message",children:j}),r.jsxs("div",{className:"chat-composer",children:[r.jsxs("div",{className:"chat-composer-pill",children:[r.jsx("textarea",{className:"chat-input",value:p,onChange:R=>v(R.target.value),onKeyDown:T,placeholder:c??"Ask for help articulating the intent…",rows:1,disabled:y}),r.jsx("button",{type:"button",className:"chat-send-btn",onClick:C,disabled:y||!p.trim(),"aria-label":"Send",children:"↑"})]}),r.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Kh({open:t,onClose:s,children:a,ariaLabel:o}){const c=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{var g;if(!t)return;u.current=document.activeElement,document.body.style.overflow="hidden";const h=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",h),(g=c.current)==null||g.focus(),()=>{document.removeEventListener("keydown",h),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[t,s]),hv.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`bottom-sheet-backdrop${t?" is-open":""}`,onClick:s,"aria-hidden":"true"}),r.jsxs("aside",{ref:c,className:`bottom-sheet${t?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[r.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),r.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function u0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function d0(t,s,a){if(s.length===0)return[{text:t,label:t,matched:null}];const o=[],c=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const v of[p.scope,...p.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!c.has(y)&&(c.add(y),o.push(v))}o.sort((p,v)=>v.length-p.length);const u=p=>{const v=p.toLowerCase();return s.filter(y=>{var w,j;return((w=y.scope)==null?void 0:w.toLowerCase())===v||((j=y.scope)==null?void 0:j.split(",").map(N=>N.trim().toLowerCase()).includes(v))})},h=["\\[\\d+\\]",...o.map(u0)],g=new RegExp(`(${h.join("|")})`,"gi");return t.split(g).filter(p=>p!=="").map(p=>{const v=/^\[(\d+)\]$/.exec(p);if(v){const y=s[Number(v[1])-1];if(y){const w=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",j=a?`${a}: ${w}`:w;return{text:p,label:j,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===p.toLowerCase())){const y=u(p);if(y.length>0)return{text:p,label:p,matched:y}}return{text:p,label:p,matched:null}})}const Af=`Why — What's the situation? Why does this need to happen?
|
|
66
66
|
|
|
67
67
|
Goal — What should the agent try to achieve?
|
|
68
68
|
|
|
69
|
-
Watch out — What should the agent avoid or be careful about?`;function f0(t,s,a,o){return d0(t,s,o).map((c,u)=>{if(!c.matched)return r.jsx("span",{children:c.text},u);const h=c.matched;return r.jsx("button",{type:"button",onClick:()=>a(h),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:c.label},u)})}function h0(){var Le;const t=mn(),[s]=oc(),a=Number(s.get("step"))||2,[o,c]=f.useState(null),[u,h]=f.useState(null),[g,p]=f.useState(a),[v,y]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState({}),[S,C]=f.useState(Af),[T,R]=f.useState(!1),[$,A]=f.useState(null),[F,G]=f.useState(!0),[q,de]=f.useState(null),[K,oe]=f.useState([]),[V,D]=f.useState(void 0),[ce,re]=f.useState(!1),[Z,he]=f.useState(null),[ge,Y]=f.useState(null),[O,H]=f.useState(null),[b,L]=f.useState([]),[J,W]=f.useState(null);f.useEffect(()=>{var se;const fe=sessionStorage.getItem("agentAuth");if(!fe){t("/mandates?new=1");return}const _e=JSON.parse(fe);c(_e),_e.intentHint&&C(_e.intentHint),M.getCredential("ai-config").then(je=>A(je.configured)).catch(()=>A(!1));const
|
|
69
|
+
Watch out — What should the agent avoid or be careful about?`;function f0(t,s,a,o){return d0(t,s,o).map((c,u)=>{if(!c.matched)return r.jsx("span",{children:c.text},u);const h=c.matched;return r.jsx("button",{type:"button",onClick:()=>a(h),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:c.label},u)})}function h0(){var Le;const t=mn(),[s]=oc(),a=Number(s.get("step"))||2,[o,c]=f.useState(null),[u,h]=f.useState(null),[g,p]=f.useState(a),[v,y]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState({}),[S,C]=f.useState(Af),[T,R]=f.useState(!1),[$,A]=f.useState(null),[F,G]=f.useState(!0),[q,de]=f.useState(null),[K,oe]=f.useState([]),[V,D]=f.useState(void 0),[ce,re]=f.useState(!1),[Z,he]=f.useState(null),[ge,Y]=f.useState(null),[O,H]=f.useState(null),[b,L]=f.useState([]),[J,W]=f.useState(null);f.useEffect(()=>{var se;const fe=sessionStorage.getItem("agentAuth");if(!fe){t("/mandates?new=1");return}const _e=JSON.parse(fe);c(_e),_e.intentHint&&C(_e.intentHint),M.getCredential("ai-config").then(je=>A(je.configured)).catch(()=>A(!1));const We=sessionStorage.getItem("agentGate");if(We){const je=JSON.parse(We);je.bounds&&y(je.bounds),je.context&&j(je.context),(se=je.gateContent)!=null&&se.intent&&C(je.gateContent.intent)}M.getProfile(_e.profileId).then(je=>h(je)).catch(()=>t("/mandates?new=1")).finally(()=>G(!1)),_e.groupId&&Promise.all([M.getTeamProfileConfig(_e.groupId,_e.profileId).catch(()=>null),M.getGroupById(_e.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([je,$e,dt])=>{if(de(je),je){const Ve=new Map;for(const ze of dt){const P=ze.name&&ze.email?`${ze.name} (${ze.email})`:ze.name||ze.email||ze.id;Ve.set(ze.id,P)}const tt=($e==null?void 0:$e.members)??[];for(const ze of tt){const P=ze.userId??ze.id;P&&(ze.name&&ze.email?Ve.set(P,`${ze.name} (${ze.email})`):ze.name&&Ve.set(P,ze.name))}const gt=(je.approvers??[]).map(ze=>Ve.get(ze)??ze);oe(gt);const ft=tt.find(ze=>ze.role==="admin");if(ft){const ze=ft.userId??ft.id;ze&&D(Ve.get(ze)??ft.name)}}})},[t]);const ee=v?Object.entries(v).filter(([fe])=>fe!=="profile"&&fe!=="path").map(([fe,_e])=>`${fe} = ${_e}`).join(", "):"",xe=(fe,_e,We)=>{y(fe),j(_e),We&&E(We),p(3)},ke=S.trim()!==Af.trim()&&S.trim()!=="",ve=fe=>{ke&&!confirm("Replace your current intent with the AI draft?")||C(fe)},ne=()=>{const fe=u==null?void 0:u.ttl,_e={intent:S},We=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...We,bounds:v,context:w,contextLabels:N,gateContent:_e,ttlConfig:fe})),t("/mandates/new/sign")},Ae=async()=>{if(o){re(!0),he(null),Y(null),H(null),L([]),W(null);try{const fe=await M.aiIntentReview({profileId:o.profileId,newIntent:S,context:w??void 0});L(fe.grants??[]),fe.success?fe.review?he(fe.review):Y(fe.note??"No other mandates on this profile to compare against."):H(fe.error??"Check failed.")}catch(fe){H(fe instanceof Error?fe.message:"Check failed.")}finally{re(!1)}}},Ee=fe=>{C(fe),(Z||ge||O)&&(he(null),Y(null),H(null),L([]),W(null))};return F||!o||!u?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):r.jsxs(r.Fragment,{children:[r.jsx(Vh,{currentStep:g,onStepClick:fe=>{fe>=2&&p(fe)}}),r.jsx(Vx,{profileId:o.profileId,bounds:ee||void 0,groupName:o.groupName,domain:o.domain}),g===2&&r.jsx("div",{className:"card",children:r.jsx(i0,{profile:u,onConfirm:xe,onCancel:()=>t("/mandates?new=1"),initialBounds:v||void 0,initialContext:w||void 0,profileConfig:q,approverNames:K,adminName:V})}),g===3&&r.jsxs("div",{className:`intent-layout${$?"":" no-chat"}`,children:[$&&r.jsx("div",{className:"card intent-pane chat tool",children:r.jsx(ki,{target:{kind:"intent",profileId:o.profileId,bounds:ee||void 0},currentText:S,onApply:ve})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsx("h3",{className:"card-title",children:"What should your agent know?"}),r.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),r.jsx("textarea",{className:"intent-textarea",value:S,onChange:fe=>Ee(fe.target.value)}),r.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),$===!1&&r.jsxs("p",{className:"intent-ai-hint",children:[r.jsx(xt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),$&&r.jsxs("div",{style:{marginTop:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:Ae,disabled:ce||!ke,children:ce?"Checking…":"Check against my other grants"}),O&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),r.jsx("div",{className:"hint-body",children:O})]}),ge&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsx("div",{className:"hint-body",children:ge})]}),Z&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f0(Z,b,W,ut(o.profileId))}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),r.jsxs("div",{className:"intent-footer",children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(2),children:"Back"}),r.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ne,disabled:!ke,children:"Continue to Review"})]}),(((Le=q==null?void 0:q.approvers)==null?void 0:Le.length)??0)>0&&r.jsxs("div",{className:"hint-box",role:"note",children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsxs("div",{className:"hint-head",children:["Visible to ",K.length>0?K.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",K.length>0?K.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"floating-help",onClick:()=>R(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),r.jsx(Kh,{open:T,onClose:()=>R(!1),ariaLabel:"Intent assistant",children:r.jsx(ki,{target:{kind:"intent",profileId:o.profileId,bounds:ee||void 0},currentText:S,onApply:fe=>{ve(fe),R(!1)}})})]}),J&&r.jsx("div",{className:"modal-backdrop",onClick:fe=>fe.target===fe.currentTarget&&W(null),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:J.length>1?`Existing mandates (${J.length})`:"Existing mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>W(null),children:"×"})]}),r.jsx("div",{className:"modal-body",children:J.map((fe,_e)=>{var We;return r.jsxs("div",{style:{marginBottom:_e<J.length-1?"1rem":0,paddingBottom:_e<J.length-1?"1rem":0,borderBottom:_e<J.length-1?"1px solid var(--border)":"none"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("div",{style:{marginBottom:"0.75rem"},children:fe.scope}),r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),r.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((We=fe.intent)==null?void 0:We.trim())||"(no intent recorded)"}),Object.entries(fe.bounds).filter(([se])=>se!=="profile"&&se!=="path").length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(fe.bounds).filter(([se])=>se!=="profile"&&se!=="path").map(([se,je])=>`${se}: ${je}`).join(" · ")})]})]},_e)})})]})})]})]})}function m0(t){return t.normalize("NFC").replace(/\r\n?/g,`
|
|
70
70
|
`).split(`
|
|
71
71
|
`).map(c=>c.replace(/[ \t]+$/,"")).join(`
|
|
72
72
|
`).replace(/\n+$/,"")}async function xc(t){const a=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class p0 extends Error{constructor(a,o,c){super(c);Os(this,"code");Os(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function g0(t){const s=new TextEncoder().encode(t);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function qh(t,s,a){const o=[];for(const c of s){const u=t[c];if(u==null)continue;const h=String(u);if(h.includes(`
|
|
73
73
|
`)||h.includes("\r"))throw new p0(a,c,`Value for "${c}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);o.push(`${c}=${g0(h)}`)}return o.join(`
|
|
74
|
-
`)}async function xi(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=qh(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await xc(o)}`}async function Yh(t,s){const a=s.scopeSchema?qh(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await xc(a)}`}function Hl(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(c=>c===void 0?"null":Hl(c)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&a.push(JSON.stringify(o)+":"+Hl(c))}return"{"+a.join(",")+"}"}async function Jh(t){return`sha256:${await xc(Hl(t))}`}async function Ni(t){const s=new TextEncoder().encode(m0(t)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function Qh(t,s){if(!t.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:t.authorization_id,boundsHash:t.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function y0(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function v0(t){return t==="per-action"?"review":"automatic"}function Pf(t){return t?y0(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function x0(t,s){return s.includes(t)?t:s[0]??null}function _f(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function w0(t,s){for(const a of t)if(s.has(a))return!0;return!1}function j0(t,s,a){for(const o of t){const c=_f(s[o]),u=_f(a[o]);if(!(c.size===0||u.size===0)&&!w0(c,u))return!1}return!0}function S0(t){return t.length>24?`${t.slice(0,10)}…`:t}function Xh(t,s,a){const o=a==null?void 0:a[t];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const h=o==null?void 0:o[u];return h?`${h} (${S0(u)})`:u}).join(", ")}function Zh(t){var a;if(t.isPersonal)return{can:!0};if(!t.configLoaded)return{can:!0};const s=t.teamName?`"${t.teamName}"`:"this team";return(((a=t.approvers)==null?void 0:a.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${t.profileName} and name who may give its mandates.`}:!t.userId||!t.approvers.includes(t.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${t.profileName}'s approvers in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}const Ci=500,b0=["Lower the discount","Other recipient","Shorter","Different wording"];function wc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Ci?{valid:!1,error:`At most ${Ci} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function k0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function em(t,s){return t.toLowerCase().includes(s.toLowerCase())}function N0(t,s){const a=t.trim();if(a.length===0)return s;if(!em(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${k0(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function tm(){return{outcome:"rejected"}}function C0(t){const s=wc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function $f(){return{outcome:"replaced"}}function E0(t,s){if((t.pendingApprovers??[]).includes(s))return{route:"approver"};const a=t.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const T0={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function R0(t,s){const a=t.rejectedBy??t.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",c=a.note??("reason"in a?a.reason:void 0);return{kind:T0[o],who:a.userId===s?"You":a.userId,at:a.at,note:c}}function I0(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function A0(){var me,Te;const t=mn(),{user:s,mode:a,domain:o}=pt(),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState("per-action"),[j,N]=f.useState(1800),[E,S]=f.useState(86400),[C,T]=f.useState(""),[R,$]=f.useState("hours"),[A,F]=f.useState(""),[G,q]=f.useState(!0),[de,K]=f.useState(!1);f.useEffect(()=>{M.getIdentityDisclosure().then(ue=>K(ue.always)).catch(()=>{})},[]);const[oe,V]=f.useState(!1),[D,ce]=f.useState(""),[re,Z]=f.useState(null),[he,ge]=f.useState([]),[Y,O]=f.useState(!1),[H,b]=f.useState([]),[L,J]=f.useState(0);f.useEffect(()=>{var jn;const ue=sessionStorage.getItem("agentAuth"),Oe=sessionStorage.getItem("agentGate");if(!ue||!Oe){t("/mandates?new=1");return}const qe=JSON.parse(ue),Ye=JSON.parse(Oe),ht={bounds:Ye.bounds??{},context:Ye.context??{},contextLabels:Ye.contextLabels??void 0,gateContent:Ye.gateContent};u(qe),g(ht),Ye.ttlConfig&&(N(Ye.ttlConfig.default??1800),S(Ye.ttlConfig.max??86400)),Ye.templateMode==="automatic"?w("immediate"):Ye.templateMode==="review"&&w("per-action");const pn=((jn=Ye.ttlConfig)==null?void 0:jn.max)??86400;if(typeof Ye.templateTtl=="number"&&Ye.templateTtl>0){const nt=Math.min(Ye.templateTtl,pn);N(nt),[3600,86400,604800,2592e3,31536e3].includes(nt)||(nt%86400===0?(T(String(nt/86400)),$("days")):(T(String(Math.max(1,Math.round(nt/3600)))),$("hours")))}M.getProfile(qe.profileId).then(nt=>{var kt;if(v(nt),!A){const Et=nt.name??((kt=qe.profileId.split("/").pop())==null?void 0:kt.replace(/@.*$/,""))??"",wt=[];if(ht.context&&nt.scopeSchema)for(const Se of nt.scopeSchema.keyOrder){const pe=ht.context[Se];if(pe!==void 0&&pe!==""){const Me=String(pe).split(",").map(Fe=>Fe.trim()).filter(Boolean);wt.push(Me.join(", "))}}const ie=wt.length>0?`${Et}: ${wt.join(" · ")}`:Et;F(ie)}}).catch(()=>{}),qe.isPersonal?O(!0):Promise.all([M.getTeamProfileConfig(qe.groupId,qe.profileId).catch(()=>null),M.getGroupById(qe.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([nt,kt,Et])=>{if(Z(nt),nt){const wt=new Map;for(const pe of Et){const Me=pe.name&&pe.email?`${pe.name} (${pe.email})`:pe.name||pe.email||pe.id;wt.set(pe.id,Me)}const ie=(kt==null?void 0:kt.members)??[];for(const pe of ie){const Me=pe.userId??pe.id;Me&&(pe.name&&pe.email?wt.set(Me,`${pe.name} (${pe.email})`):pe.name&&wt.set(Me,pe.name))}const Se=(nt.approvers??[]).map(pe=>wt.get(pe)??pe);ge(Se)}}).finally(()=>{O(!0)})},[t]),f.useEffect(()=>{if(!(c!=null&&c.profileId))return;const ue=c.profileId,Oe=sessionStorage.getItem("agentEditReplaces");M.getEnrichedAuthorizations().then(qe=>{const Ye=qe.filter(ht=>ht.profileId===ue&&ht.authorizationId!==Oe).map(ht=>({authorizationId:ht.authorizationId,bounds:ht.bounds,context:ht.context??{},intent:ht.intent}));b(Ye)}).catch(()=>b([]))},[c==null?void 0:c.profileId]),f.useEffect(()=>{if(!p)return;const ue=x0(y,Pf(p));ue&&ue!==y&&w(ue)},[p,y]),f.useEffect(()=>{if(!h||!p||H.length===0){J(0);return}let ue=!1;return(async()=>{const Oe=await xi(h.bounds,p),qe=await Promise.all(H.map(Ye=>xi(Ye.bounds,p).catch(()=>null)));ue||J(qe.filter(Ye=>Ye===Oe).length)})().catch(()=>{ue||J(0)}),()=>{ue=!0}},[h,p,H]);const W=async()=>{if(!(!c||!h||!p||!s)){if(!c.groupId){ce("No active group; cannot create mandate.");return}V(!0),ce("");try{const ue=o||c.domain||"owner",Oe=await xi(h.bounds,p),qe=await Yh(h.context,p),[Ye,ht]=await Promise.all([Ni(h.gateContent.intent),Ni(JSON.stringify({profile:c.profileId,domain:ue,group:c.groupId}))]);let pn,jn,nt,kt;if(c.isTeam){const Fe=await M.getApproversPubkeys(c.groupId,c.profileId);if(Fe.length>0){const Je=await M.encryptIntent(h.gateContent.intent,Fe);pn=Je.intentCiphertext,jn=Je.encryptedKeys,nt=Je.approversFrozen,kt=Je.intentDisclosureHash}}const Et=`authz_${crypto.randomUUID()}`,wt=sessionStorage.getItem("agentEditReplaces")||void 0,ie=sessionStorage.getItem("agentReplacesProposal")||void 0,Se=await Jh(p),pe=await M.attest({authorization_id:Et,replaces:wt,profile_id:c.profileId,profile_hash:Se,supported_versions:["0.7"],bounds:h.bounds,bounds_hash:Oe,scope_hash:qe,domain:ue,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ye},execution_context_hash:ht,group_id:c.groupId,ttl:j,commitment_mode:v0(y),title:A.trim(),intent_ciphertext:pn,encrypted_keys:jn,approvers_frozen:nt,intent_disclosure_hash:kt,disclose_identity:G});try{await M.pushGateContent(Qh(pe,{boundsHash:Oe,contextHash:qe,context:h.context,contextLabels:h.contextLabels,gateContent:h.gateContent}))}catch(Fe){try{await M.revokeAttestation(Et,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Fe instanceof Error?Fe.message:"Unknown error"})`)}if(wt)try{await M.revokeAttestation(wt,`Replaced by ${Et} (edit)`),M.resyncGates().catch(()=>{})}catch{}let Me="";if(ie)try{const Fe=await M.getProposal(ie);if(Fe.status==="pending"){const Je=E0(Fe,(s==null?void 0:s.id)??"");Je?Je.route==="approver"?await M.rejectProposal(ie,$f()):await M.resolveProposal(ie,"reject",Je.domain,$f()):Me="you are not one of the people who may decide it"}}catch(Fe){Me=Fe instanceof Error?Fe.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Me){ce(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Me}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(Et)}`)}catch(ue){ce(ue instanceof Error?ue.message:"Signing the mandate failed")}finally{V(!1)}}};if(!c||!h)return r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ee=Object.entries(h.bounds).filter(([ue])=>ue!=="profile"&&ue!=="path"),xe=Object.entries(h.context),ve=((re==null?void 0:re.caps)!=null?Object.keys(re.caps):[]).length!==0,ne=he.length>0?he.join(", "):((re==null?void 0:re.approvers)??[]).join(", "),Ae=ve?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ne}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Ee=ve?`Over-cap actions will be reviewed by you and ${ne}. Within-cap actions run per the mode you chose above.`:`Approvers ${ne} can read your intent but won't gate any action — no caps configured on this profile.`,Le=!!((me=re==null?void 0:re.approvers)!=null&&me.length),fe=Zh({isPersonal:c.isPersonal,configLoaded:Y,approvers:re==null?void 0:re.approvers,userId:s==null?void 0:s.id,profileName:ut(c.profileId),teamName:c.groupName}),_e=!fe.can,Ue=Pf(p),se=Ue.length===0,je=j>E,$e={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},dt={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},He=((Te=p==null?void 0:p.scopeSchema)==null?void 0:Te.keyOrder)??[],tt=H.filter(ue=>j0(He,h.context,ue.context)),gt=tt.length>0,ft=ut(c.profileId),ze=ue=>{const Oe=Object.values(ue).map(qe=>String(qe).trim()).filter(Boolean);return Oe.length>0?Oe.join(", "):"all (unscoped)"},P=tt.map(ue=>ze(ue.context)).join("; "),ae=`This grant's scope overlaps an existing grant on ${ft} (scoped to: ${P}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return r.jsxs(r.Fragment,{children:[r.jsx(Vh,{currentStep:4,onStepClick:ue=>{ue<=3&&t(`/mandates/new/intent?step=${ue}`)}}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),c.upgradedFromProfileId&&p&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:["Updated to ",ut(c.profileId)," ",p.version," — the current version of this profile."]})]}),D&&r.jsx("div",{className:"error-message",children:D}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Title"]}),r.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${ut(c.profileId)}: daily operations`,value:A,onChange:ue=>F(ue.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[Ue.includes("per-action")&&r.jsxs("button",{onClick:()=>w("per-action"),style:dt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),Ue.includes("immediate")&&r.jsxs("button",{onClick:()=>w("immediate"),style:$e,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),Ue.length===1&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:Ue[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),se&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Duration"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(ue=>ue.seconds<=E).map(ue=>r.jsx("button",{onClick:()=>{N(ue.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:j===ue.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===ue.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:ue.label},ue.seconds)),r.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[r.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:C,onChange:ue=>{T(ue.target.value);const Oe=parseInt(ue.target.value,10);if(Oe>0){const qe=R==="days"?Oe*86400:Oe*3600;N(Math.min(qe,E))}}}),r.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:R,onChange:ue=>{$(ue.target.value);const Oe=parseInt(C,10);if(Oe>0){const qe=ue.target.value==="days"?Oe*86400:Oe*3600;N(Math.min(qe,E))}},children:[r.jsx("option",{value:"hours",children:"hours"}),r.jsx("option",{value:"days",children:"days"})]})]}),je&&r.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",E>=86400?`${Math.floor(E/86400)} days`:`${Math.floor(E/3600)} hours`]})]})]}),r.jsx("div",{className:"field-editable",children:r.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[r.jsx("input",{type:"checkbox",checked:de||G,disabled:de,onChange:ue=>q(ue.target.checked),style:{marginTop:"0.15rem"}}),r.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',de&&" Always on — you chose this in Settings."]})]})]})}),r.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Intent"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:h.gateContent.intent})]}),(!!ee.length||!!xe.length)&&r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Scope & Limits"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),r.jsxs("dl",{className:"info-kv",children:[xe.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:Xh(ue,Oe,h.contextLabels)})]},ue)),ee.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:String(Oe)})]},ue))]})]}),r.jsxs("div",{className:"info-block",children:[r.jsx("div",{className:"info-head",children:r.jsx("span",{className:"info-title",children:"Authority"})}),r.jsxs("dl",{className:"info-kv",children:[r.jsx("dt",{children:"Profile"}),r.jsxs("dd",{children:[ut(c.profileId),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:c.profileId})]}),!c.isPersonal&&c.groupName&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Team"}),r.jsx("dd",{children:c.groupName})]}),!c.isPersonal&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Approvers"}),r.jsx("dd",{children:Y?fe.can?r.jsxs(r.Fragment,{children:[ne,r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:Ae})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:fe.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${c.groupName??"this team"}`:"You cannot give this mandate"}),fe.code==="OWNER_NOT_APPROVER"&&r.jsx("div",{children:ne}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[fe.reason," ",fe.fix]})]}):r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),L>0?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),r.jsxs("div",{children:[L===1?`An active grant on ${ft} already has exactly these limits.`:`${L} active grants on ${ft} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",r.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,gt?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),r.jsx("div",{children:ae})]})]}):null,r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>t("/mandates/new/intent"),children:"Back"}),r.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:W,disabled:oe||!A.trim()||_e||se,children:oe?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),r.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Le?"block":"none"},children:Ee})]})]})}const P0={card:"💳",mail:"✉️"};function nm(t){return P0[t]??"🔧"}function _0(t){const s=t==null?void 0:t.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const $0=[0,7,30,90,365,3650];function hi(t){return t===null?"From your mandate":t===0?"Read nothing":t===1?"1 day back":t===365?"1 year back":t%365===0?`${t/365} years back`:`${t} days back`}function L0(t){return(t==null?void 0:t.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:t&&!t.running&&t.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Pl({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:c}){var ze;const[u,h]=f.useState({}),[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState({}),[N,E]=f.useState({}),[S,C]=f.useState(void 0),[T,R]=f.useState(!1),[$,A]=f.useState(null),[F,G]=f.useState(!1),[q,de]=f.useState(!1),[K,oe]=f.useState(!1),[V,D]=f.useState(!1),[ce,re]=f.useState({}),[Z,he]=f.useState(null),[ge,Y]=f.useState(!1),[O,H]=f.useState(null),[b,L]=f.useState(!1);f.useEffect(()=>{let P=!1;return M.getCredential(t.id).then(ae=>{var me;if(!(P||!ae.configured)){if(p(!0),y(!0),ae.fields){const Te={};for(const ue of t.credentials.fields)ae.fields[ue.key]!=null&&(Te[ue.key]=ae.fields[ue.key]);j(Te)}if(E(ae.secrets??{}),C(ae.updatedAt),t.oauth){const Te=((me=ae.fieldNames)==null?void 0:me.includes(t.oauth.tokenStorage))??!1;R(Te),Te&&M.getOAuthHealth(t.id).then(ue=>{P||A(ue)})}}}).catch(()=>{}),()=>{P=!0}},[t.id,t.oauth]);const J=_0(t.toolGating),W=s?s.readAgeDays??null:void 0,ee=ge&&Z?Z.value:W,xe=async P=>{he({value:P}),Y(!0),H(null);try{await M.setReadPolicy(t.id,P),c(P===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${hi(P).toLowerCase()}`),o()}catch(ae){H(ae instanceof Error?ae.message:"Could not save")}finally{Y(!1),he(null)}},ke=!!t.oauth||t.credentials.fields.some(P=>!P.optional),ve=t.oauth?T:g,ne=!ke||ve,Ae=a==="starting"?"starting":ne?s!=null&&s.running?"running":!g&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&g&&!T?"needs-oauth":"unconfigured",Ee=async()=>{if(t.credentials.fields.some(ae=>{var me;return(me=u[ae.key])==null?void 0:me.trim()})){G(!0);try{await M.setCredential(t.id,u),p(!0),h({}),t.oauth?c(`${t.name} credentials saved!`):(c(`${t.name} credentials saved — starting integration...`),await se())}catch{c(`Failed to save ${t.name} credentials`)}finally{G(!1)}}},Le=()=>{const P={};for(const ae of t.credentials.fields){const me=u[ae.key];ae.type==="password"?me!=null&&me.trim()&&(P[ae.key]=me):me!=null&&me!==(w[ae.key]??"")&&(P[ae.key]=me)}return P},fe=Object.keys(Le()).length>0,_e=async()=>{const P=Le();if(Object.keys(P).length!==0){G(!0);try{await M.setCredential(t.id,P),h({}),p(!0),t.oauth?c(`${t.name} credentials saved — now click Connect.`):(D(!1),c(`${t.name} credentials updated — restarting...`),await se())}catch{c(`Failed to update ${t.name} credentials`)}finally{G(!1)}}},Ue=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const P=setInterval(async()=>{var ae;try{const me=await M.getCredential(t.id);me.configured&&t.oauth&&((ae=me.fieldNames)!=null&&ae.includes(t.oauth.tokenStorage))&&(R(!0),D(!1),A(null),clearInterval(P),c(`${t.name} connected — starting integration...`),M.getOAuthHealth(t.id).then(A).catch(()=>{}),await se())}catch{}},2e3);setTimeout(()=>clearInterval(P),12e4)},se=async()=>{oe(!0);try{const P=await M.activateIntegration(t.id);P.warning?c(P.warning):c(`${t.name} integration started with ${P.tools.length} tools`),o()}catch(P){c(`Failed to start ${t.name}: ${P instanceof Error?P.message:"Unknown error"}`)}finally{oe(!1)}},je=async()=>{try{await M.removeMcpIntegration(t.id),c(`${t.name} integration removed`),o()}catch{c(`Failed to remove ${t.name}`)}},$e=nm(t.icon),dt=L0(s),He=Ae==="running"?{c:"int-chip-ok",t:"Running"}:Ae==="starting"?{c:"int-chip-idle",t:"Starting"}:dt.chip,tt=t.oauth&&T&&($==null?void 0:$.status)==="failed",gt=ke?tt?{c:"int-chip-bad",t:"Auth failed"}:ve?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ft=P=>P.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${t.id}/callback`);return r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[r.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:$e}),r.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:t.name}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[Ae!=="unconfigured"&&Ae!=="needs-oauth"&&r.jsxs("span",{className:`int-chip ${He.c}`,children:[r.jsx("span",{className:"int-dot"}),He.t]}),r.jsxs("span",{className:`int-chip ${gt.c}`,children:[r.jsx("span",{className:"int-dot"}),gt.t]}),Tv(t,w)&&r.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[r.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),t.oauth&&T&&r.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:$!=null&&$.account?r.jsxs(r.Fragment,{children:["Connected as ",r.jsx("b",{children:$.account})]}):r.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),tt&&!V&&r.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[r.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[t.name," stopped accepting the stored credentials"]}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[($==null?void 0:$.error)==="invalid_grant"?r.jsxs(r.Fragment,{children:["The refresh token was revoked (",r.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):$!=null&&$.error?r.jsxs(r.Fragment,{children:["The provider reported ",r.jsx("code",{children:$.error}),"."]}):r.jsx(r.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",t.name," actions are ",r.jsx("b",{children:"blocked"}),", not failing silently."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[r.jsxs("button",{className:"btn btn-primary btn-sm",onClick:Ue,children:["Reconnect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{h({...w}),D(!0)},children:"Edit credentials"})]})]}),r.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[r.jsx("summary",{children:"Details"}),r.jsxs("div",{className:"int-meta",children:[r.jsx("span",{className:"int-k",children:"What"}),r.jsx("span",{children:t.description}),t.profile&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Profile"}),r.jsx("span",{children:t.profile})]}),t.oauth&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Scopes"}),r.jsx("span",{children:((ze=t.oauth.scopes)==null?void 0:ze.join(", "))||"—"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Tools"}),r.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(Ae!=="running"||tt)&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("button",{onClick:()=>de(!q),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[r.jsx("span",{style:{transition:"transform 0.2s",transform:q?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),q&&r.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map((P,ae)=>r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[r.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:ae+1}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:P.title}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ft(P.description),P.link&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("a",{href:P.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},ae))})]}),Ae==="starting"&&r.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),V&&r.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",t.oauth?" Save, then Connect to re-link the account.":""]}),t.credentials.fields.map(P=>{var ae;return r.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[r.jsx("label",{className:"form-label",children:P.label}),P.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:ce[P.key]?"text":"password",name:`${t.id}-${P.key}-credential`,autoComplete:"new-password",placeholder:(ae=N[P.key])!=null&&ae.preview?`Unchanged — ends in ${N[P.key].preview}`:v?"Unchanged — paste a new value to replace":P.placeholder,value:u[P.key]||"",onChange:me=>h(Te=>({...Te,[P.key]:me.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>re(me=>({...me,[P.key]:!me[P.key]})),children:ce[P.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${P.key}-credential`,autoComplete:"off",placeholder:P.placeholder,value:u[P.key]||"",onChange:me=>h(Te=>({...Te,[P.key]:me.target.value}))})]},P.key)}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:_e,disabled:F||!fe,children:F?"Saving…":"Save"}),!fe&&!F&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),t.oauth&&r.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:Ue,children:["Connect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{D(!1),h({})},children:"Cancel"})]})]}),!V&&Ae==="running"&&s&&r.jsxs(r.Fragment,{children:[(Object.keys(w).length>0||Object.keys(N).length>0)&&r.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map(P=>{const ae=P.type==="password",me=N[P.key];return!ae&&w[P.key]==null||ae&&me==null?null:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:P.label}),r.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[ae?me.preview??"set":w[P.key],ae&&S&&r.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},P.key)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx(xt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(t.credentials.fields.length>0||t.oauth)&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{h({...w}),D(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:je,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),J&&ee!==void 0&&!b&&r.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),r.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ee===null?"window from your mandate":hi(ee).toLowerCase()}),ge&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),O&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:O})]}),r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>L(!0),children:"Edit"})]})}),J&&ee!==void 0&&b&&r.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),r.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>L(!1),children:"Done"})]}),r.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[$0.map(P=>{const ae=ee===P;return r.jsx("button",{className:`btn btn-sm ${ae?"btn-primary":"btn-secondary"}`,"aria-pressed":ae,disabled:ge,onClick:()=>xe(P),children:hi(P)},P)}),r.jsx("button",{className:`btn btn-sm ${ee===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ee===null,disabled:ge,onClick:()=>xe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:hi(null)})]}),r.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:O?r.jsx("span",{style:{color:"var(--danger)"},children:O}):ge?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ee===null?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ee===0?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):r.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ee," days is blocked, whoever it is from."]})})]}),r.jsx("div",{style:{display:"none"},children:r.jsx(xt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),Ae==="unconfigured"&&(()=>{const P=t.credentials.fields.every(Te=>Te.optional),ae=t.credentials.fields.some(Te=>!Te.optional),me=t.credentials.fields.some(Te=>{var ue;return(ue=u[Te.key])==null?void 0:ue.trim()});return r.jsxs(r.Fragment,{children:[v&&r.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",r.jsx("button",{onClick:()=>{p(!0),t.oauth&&R(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),t.oauth&&!v&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),t.setupHint&&!v&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:t.setupHint}),t.credentials.fields.map(Te=>r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:Te.label}),Te.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:ce[Te.key]?"text":"password",name:`${t.id}-${Te.key}-credential`,autoComplete:"new-password",placeholder:Te.placeholder,value:u[Te.key]||"",onChange:ue=>h(Oe=>({...Oe,[Te.key]:ue.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>re(ue=>({...ue,[Te.key]:!ue[Te.key]})),children:ce[Te.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${Te.key}-credential`,autoComplete:"off",placeholder:Te.placeholder,value:u[Te.key]||"",onChange:ue=>h(Oe=>({...Oe,[Te.key]:ue.target.value}))})]},Te.key)),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[me&&r.jsx("button",{className:"btn btn-primary",onClick:Ee,disabled:F||ae&&!t.credentials.fields.filter(Te=>!Te.optional).every(Te=>{var ue;return(ue=u[Te.key])==null?void 0:ue.trim()}),children:F?"Saving...":"Save & Encrypt"}),P&&!me&&r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":`Activate ${t.name}`})]})]})})(),Ae==="needs-oauth"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",t.name," account to authorize access."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsxs("button",{className:"btn btn-primary",onClick:Ue,children:["Connect ",t.name," Account"]}),r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),Ae==="ready"&&!s&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",t.oauth?`${t.name} account connected`:"Credentials configured"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":`Start ${t.name} Integration`}),!t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),R(!1)},children:"Change Credentials"})]})]}),Ae==="ready"&&s&&!s.running&&(dt.showStart?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[r.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:s.error}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":"Start"}),r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:je,children:"Disable"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),r.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:je,children:"Disable"})})]}))]})}function z0(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(h=>qs(h.manifest)),o=t.filter(h=>!qs(h.manifest)),c=o.filter(h=>h.state==="error"),u=o.filter(h=>h.state!=="error");return{grouped:!0,testSystems:a,realErrors:c,pausedReal:u,ungrouped:[]}}function F0({entry:t}){return r.jsxs("div",{className:"int-paused-row",children:[r.jsx("span",{"aria-hidden":"true",children:nm(t.manifest.icon)}),r.jsx("span",{className:"int-paused-name",children:t.manifest.name}),r.jsxs("span",{className:"int-chip int-chip-paused",children:[r.jsx("span",{className:"int-dot"}),"Paused"]})]})}function O0(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:c}=fc(),u=dc(),[h,g]=f.useState(""),p=f.useCallback(y=>{g(y),setTimeout(()=>g(""),5e3)},[]),v=z0(o,u);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Integrations"}),r.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),h&&r.jsx("div",{className:"alert alert-success",children:h}),t?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):v.grouped?r.jsxs(r.Fragment,{children:[v.testSystems.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Test systems"}),v.testSystems.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id))]}),(v.realErrors.length>0||v.pausedReal.length>0)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Real systems"}),v.realErrors.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id)),v.pausedReal.length>0&&r.jsxs("details",{className:"int-paused-group",open:!0,children:[r.jsxs("summary",{children:["Paused while simulation mode is on (",v.pausedReal.length,")"]}),r.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",r.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),v.pausedReal.map(y=>r.jsx(F0,{entry:y},y.id))]})]}),o.length===0&&r.jsx(Lf,{manifestsError:a})]}):r.jsxs(r.Fragment,{children:[o.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id)),o.length===0&&r.jsx(Lf,{manifestsError:a})]})]})}function Lf({manifestsError:t}){return t?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",r.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):r.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function M0(){var D,ce,re;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=pt(),c=mn(),[u,h]=f.useState(null),[g,p]=f.useState(!1),[v,y]=f.useState(""),[w,j]=f.useState(""),[N,E]=f.useState(!1),[S,C]=f.useState(""),[T,R]=f.useState("");f.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{typeof Z.spUrl=="string"&&R(Z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!t){h(null);return}M.getGroupById(t.id).then(Z=>{const he=Z.group??Z,ge=Z.members??[],Y=Z.isAdmin??!1,O=ge.map(H=>{const b=H.userId||H.id||"",L=H.role||(Y&&b===he.createdBy?"admin":"member");return{id:b,name:H.name||b.slice(0,8)||"Member",email:H.email||"",domains:H.domains||[],role:L,isAdmin:L==="admin"||Y&&b===he.createdBy}});h({id:he.id,name:he.name,members:O})}).catch(()=>h(null))},[t==null?void 0:t.id]);const $=(u==null?void 0:u.members.filter(Z=>Z.isAdmin))??[],A=(t==null?void 0:t.isAdmin)===!0&&$.length<=1&&$.some(Z=>Z.id===(o==null?void 0:o.id)),F=(t==null?void 0:t.name)??"",G=S.trim()===F&&!g,q=()=>{C(""),E(!0)},de=()=>{E(!1),C("")},K=async()=>{if(!(!t||!G)){p(!0),y("");try{await M.leaveTeam(t.id),await a(),j("You have left the team."),h(null),de()}catch(Z){y(Z instanceof Error?Z.message:"Failed to leave team")}finally{p(!1)}}},oe=t&&T?`${T}/dashboard/groups/${t.id}`:void 0,V=T?`${T}/dashboard/groups`:void 0;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Team"}),r.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&r.jsx("div",{className:"error-message",children:v}),w&&r.jsx("div",{className:"alert alert-success",children:w}),t?r.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"card-title",children:t.name}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=u==null?void 0:u.members)==null?void 0:D.length)??0," ",(((ce=u==null?void 0:u.members)==null?void 0:ce.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),r.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(re=u==null?void 0:u.members)==null?void 0:re.map(Z=>r.jsxs("div",{className:"member-row",children:[r.jsx("div",{className:"member-avatar",children:Z.name.split(" ").map(he=>he[0]).join("").slice(0,2).toUpperCase()}),r.jsxs("div",{className:"member-info",children:[r.jsx("div",{className:"member-name",children:Z.name}),r.jsx("div",{className:"member-email",children:Z.email})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Z.role})]},Z.id)),r.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[oe&&r.jsx("a",{className:"btn btn-secondary btn-sm",href:oe,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),r.jsx("span",{title:A?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:q,disabled:g||A,children:"Leave team"})})]})]}):r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[r.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>c("/onboarding"),children:"Join or create a team"}),V&&r.jsx("a",{className:"btn btn-ghost btn-sm",href:V,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&t&&r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:de,children:r.jsxs("div",{className:"card",onClick:Z=>Z.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[r.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",F,"?"]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsx("li",{children:"Revoke all mandates you created in this team's context"}),r.jsx("li",{children:"Reject any pending action proposals you authored"}),r.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",r.jsx("strong",{children:"personal"})," mandates are not affected."]}),r.jsxs("div",{className:"form-group",children:[r.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",r.jsx("code",{children:F})," to confirm:"]}),r.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Z=>C(Z.target.value),placeholder:F,disabled:g,autoFocus:!0})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:de,disabled:g,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:K,disabled:!G,children:g?"Leaving...":"Leave team"})]})]})})]})}const B0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),D0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function U0(t){const s=t.lastIndexOf("/"),a=s>=0?t.slice(s+1):t,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function Nr(t,s){const a=U0(t),o=s!=null&&s.icon&&B0.has(s.icon)?s.icon:D0[a]??"help-circle",c=ut(t,s==null?void 0:s.name);return{icon:o,name:c,testSetup:a==="delegation"}}function zi(t){return t.startsWith("setup__")}const W0={mail:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),r.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),r.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),r.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),r.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),r.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),r.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),r.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),r.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),r.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),r.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),r.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),r.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),r.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),r.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),r.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),r.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),r.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),r.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),r.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M9 3h6"}),r.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),r.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),r.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),r.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),r.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),r.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),r.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),r.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function rm({icon:t,className:s}){return r.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:W0[t]})}function ea({profileId:t,declared:s}){const{icon:a,name:o}=Nr(t,s);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"id-rail",children:[r.jsx(rm,{icon:a,className:"id-rail-icon"}),r.jsx("span",{className:"id-rail-name",children:o})]}),r.jsx("div",{className:"id-sep"})]})}const Js=t=>t.replace(/@.*$/,"").split("/").pop()??t,zf=t=>t.split("@")[1]??"";function H0(t,s){const a=new Map;for(const o of t){const c=Js(o.id);if(!s.has(c))continue;const u=a.get(c);(!u||zf(o.id).localeCompare(zf(u.id),void 0,{numeric:!0})>0)&&a.set(c,o)}return a}function V0(t,s,a,o){var g;const c=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>Js(p.profile))]),u=H0(t,c),h=[];for(const p of s){const v=p.profile?u.get(p.profile):void 0;v&&h.push({key:`connector:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"connector",ready:((g=a.find(y=>y.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const v=u.get(Js(p.profile));v&&h.push({key:`builtin:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return h}function G0(t,s,a){if(s)return t.find(o=>Js(o.profile.id)===Js(s)&&o.ready&&a(o))}function K0({onDismiss:t,preselectProfileId:s}){const a=mn(),{group:o,groupId:c,domain:u,user:h}=pt(),[g,p]=f.useState([]),[v,y]=f.useState([]),[w,j]=f.useState([]),[N,E]=f.useState([]),[S,C]=f.useState(!0),[T,R]=f.useState({});f.useEffect(()=>{Promise.all([M.listProfiles().catch(()=>[]),M.getIntegrationManifests().then(K=>K.manifests??[]).catch(()=>[]),M.getMcpHealth().catch(()=>null)]).then(async([K,oe,V])=>{if(p(K),y(oe),j((V==null?void 0:V.integrations)??[]),E((V==null?void 0:V.builtins)??[]),c){const D=await Promise.all(K.map(re=>M.getTeamProfileConfig(c,re.id).catch(()=>null))),ce={};K.forEach((re,Z)=>{const he=D[Z];he&&(ce[re.id]=he)}),R(ce)}}).finally(()=>C(!1))},[c]);const $=V0(g,v,w,N),A=K=>{var oe;return Zh({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,approvers:(oe=T[K.id])==null?void 0:oe.approvers,userId:h==null?void 0:h.id,profileName:ut(K.id),teamName:o==null?void 0:o.name})},F=K=>K in T,G=(K,oe)=>{if(!c){console.error("No active group when creating authorization");return}const V=F(K);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:K,groupId:c,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:V,isPersonal:!!(o!=null&&o.isPersonal),...oe?{intentHint:oe}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},q=(K,oe)=>{c&&G(K,oe)},de=f.useRef(!1);return f.useEffect(()=>{if(S||!s||de.current)return;const K=G0($,s,oe=>A(oe.profile).can);K&&(de.current=!0,q(K.profile.id,K.intentHint))},[S,s]),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
74
|
+
`)}async function xi(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=qh(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await xc(o)}`}async function Yh(t,s){const a=s.scopeSchema?qh(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await xc(a)}`}function Hl(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(c=>c===void 0?"null":Hl(c)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&a.push(JSON.stringify(o)+":"+Hl(c))}return"{"+a.join(",")+"}"}async function Jh(t){return`sha256:${await xc(Hl(t))}`}async function Ni(t){const s=new TextEncoder().encode(m0(t)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function Qh(t,s){if(!t.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:t.authorization_id,boundsHash:t.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function y0(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function v0(t){return t==="per-action"?"review":"automatic"}function Pf(t){return t?y0(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function x0(t,s){return s.includes(t)?t:s[0]??null}function _f(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function w0(t,s){for(const a of t)if(s.has(a))return!0;return!1}function j0(t,s,a){for(const o of t){const c=_f(s[o]),u=_f(a[o]);if(!(c.size===0||u.size===0)&&!w0(c,u))return!1}return!0}function S0(t){return t.length>24?`${t.slice(0,10)}…`:t}function Xh(t,s,a){const o=a==null?void 0:a[t];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const h=o==null?void 0:o[u];return h?`${h} (${S0(u)})`:u}).join(", ")}function Zh(t){var a;if(t.isPersonal)return{can:!0};if(!t.configLoaded)return{can:!0};const s=t.teamName?`"${t.teamName}"`:"this team";return(((a=t.approvers)==null?void 0:a.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${t.profileName} and name who may give its mandates.`}:!t.userId||!t.approvers.includes(t.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${t.profileName}'s approvers in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}const Ci=500,b0=["Lower the discount","Other recipient","Shorter","Different wording"];function wc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Ci?{valid:!1,error:`At most ${Ci} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function k0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function em(t,s){return t.toLowerCase().includes(s.toLowerCase())}function N0(t,s){const a=t.trim();if(a.length===0)return s;if(!em(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${k0(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function tm(){return{outcome:"rejected"}}function C0(t){const s=wc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function $f(){return{outcome:"replaced"}}function E0(t,s){if((t.pendingApprovers??[]).includes(s))return{route:"approver"};const a=t.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const T0={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function R0(t,s){const a=t.rejectedBy??t.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",c=a.note??("reason"in a?a.reason:void 0);return{kind:T0[o],who:a.userId===s?"You":a.userId,at:a.at,note:c}}function I0(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function A0(){var me,Te;const t=mn(),{user:s,mode:a,domain:o}=pt(),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState("per-action"),[j,N]=f.useState(1800),[E,S]=f.useState(86400),[C,T]=f.useState(""),[R,$]=f.useState("hours"),[A,F]=f.useState(""),[G,q]=f.useState(!0),[de,K]=f.useState(!1);f.useEffect(()=>{M.getIdentityDisclosure().then(ue=>K(ue.always)).catch(()=>{})},[]);const[oe,V]=f.useState(!1),[D,ce]=f.useState(""),[re,Z]=f.useState(null),[he,ge]=f.useState([]),[Y,O]=f.useState(!1),[H,b]=f.useState([]),[L,J]=f.useState(0);f.useEffect(()=>{var jn;const ue=sessionStorage.getItem("agentAuth"),Oe=sessionStorage.getItem("agentGate");if(!ue||!Oe){t("/mandates?new=1");return}const qe=JSON.parse(ue),Ye=JSON.parse(Oe),ht={bounds:Ye.bounds??{},context:Ye.context??{},contextLabels:Ye.contextLabels??void 0,gateContent:Ye.gateContent};u(qe),g(ht),Ye.ttlConfig&&(N(Ye.ttlConfig.default??1800),S(Ye.ttlConfig.max??86400)),Ye.templateMode==="automatic"?w("immediate"):Ye.templateMode==="review"&&w("per-action");const pn=((jn=Ye.ttlConfig)==null?void 0:jn.max)??86400;if(typeof Ye.templateTtl=="number"&&Ye.templateTtl>0){const nt=Math.min(Ye.templateTtl,pn);N(nt),[3600,86400,604800,2592e3,31536e3].includes(nt)||(nt%86400===0?(T(String(nt/86400)),$("days")):(T(String(Math.max(1,Math.round(nt/3600)))),$("hours")))}M.getProfile(qe.profileId).then(nt=>{var kt;if(v(nt),!A){const Et=nt.name??((kt=qe.profileId.split("/").pop())==null?void 0:kt.replace(/@.*$/,""))??"",wt=[];if(ht.context&&nt.scopeSchema)for(const Se of nt.scopeSchema.keyOrder){const pe=ht.context[Se];if(pe!==void 0&&pe!==""){const Me=String(pe).split(",").map(Fe=>Fe.trim()).filter(Boolean);wt.push(Me.join(", "))}}const ie=wt.length>0?`${Et}: ${wt.join(" · ")}`:Et;F(ie)}}).catch(()=>{}),qe.isPersonal?O(!0):Promise.all([M.getTeamProfileConfig(qe.groupId,qe.profileId).catch(()=>null),M.getGroupById(qe.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([nt,kt,Et])=>{if(Z(nt),nt){const wt=new Map;for(const pe of Et){const Me=pe.name&&pe.email?`${pe.name} (${pe.email})`:pe.name||pe.email||pe.id;wt.set(pe.id,Me)}const ie=(kt==null?void 0:kt.members)??[];for(const pe of ie){const Me=pe.userId??pe.id;Me&&(pe.name&&pe.email?wt.set(Me,`${pe.name} (${pe.email})`):pe.name&&wt.set(Me,pe.name))}const Se=(nt.approvers??[]).map(pe=>wt.get(pe)??pe);ge(Se)}}).finally(()=>{O(!0)})},[t]),f.useEffect(()=>{if(!(c!=null&&c.profileId))return;const ue=c.profileId,Oe=sessionStorage.getItem("agentEditReplaces");M.getEnrichedAuthorizations().then(qe=>{const Ye=qe.filter(ht=>ht.profileId===ue&&ht.authorizationId!==Oe).map(ht=>({authorizationId:ht.authorizationId,bounds:ht.bounds,context:ht.context??{},intent:ht.intent}));b(Ye)}).catch(()=>b([]))},[c==null?void 0:c.profileId]),f.useEffect(()=>{if(!p)return;const ue=x0(y,Pf(p));ue&&ue!==y&&w(ue)},[p,y]),f.useEffect(()=>{if(!h||!p||H.length===0){J(0);return}let ue=!1;return(async()=>{const Oe=await xi(h.bounds,p),qe=await Promise.all(H.map(Ye=>xi(Ye.bounds,p).catch(()=>null)));ue||J(qe.filter(Ye=>Ye===Oe).length)})().catch(()=>{ue||J(0)}),()=>{ue=!0}},[h,p,H]);const W=async()=>{if(!(!c||!h||!p||!s)){if(!c.groupId){ce("No active group; cannot create mandate.");return}V(!0),ce("");try{const ue=o||c.domain||"owner",Oe=await xi(h.bounds,p),qe=await Yh(h.context,p),[Ye,ht]=await Promise.all([Ni(h.gateContent.intent),Ni(JSON.stringify({profile:c.profileId,domain:ue,group:c.groupId}))]);let pn,jn,nt,kt;if(c.isTeam){const Fe=await M.getApproversPubkeys(c.groupId,c.profileId);if(Fe.length>0){const Je=await M.encryptIntent(h.gateContent.intent,Fe);pn=Je.intentCiphertext,jn=Je.encryptedKeys,nt=Je.approversFrozen,kt=Je.intentDisclosureHash}}const Et=`authz_${crypto.randomUUID()}`,wt=sessionStorage.getItem("agentEditReplaces")||void 0,ie=sessionStorage.getItem("agentReplacesProposal")||void 0,Se=await Jh(p),pe=await M.attest({authorization_id:Et,replaces:wt,profile_id:c.profileId,profile_hash:Se,supported_versions:["0.7"],bounds:h.bounds,bounds_hash:Oe,scope_hash:qe,domain:ue,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ye},execution_context_hash:ht,group_id:c.groupId,ttl:j,commitment_mode:v0(y),title:A.trim(),intent_ciphertext:pn,encrypted_keys:jn,approvers_frozen:nt,intent_disclosure_hash:kt,disclose_identity:G});try{await M.pushGateContent(Qh(pe,{boundsHash:Oe,contextHash:qe,context:h.context,contextLabels:h.contextLabels,gateContent:h.gateContent}))}catch(Fe){try{await M.revokeAttestation(Et,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Fe instanceof Error?Fe.message:"Unknown error"})`)}if(wt)try{await M.revokeAttestation(wt,`Replaced by ${Et} (edit)`),M.resyncGates().catch(()=>{})}catch{}let Me="";if(ie)try{const Fe=await M.getProposal(ie);if(Fe.status==="pending"){const Je=E0(Fe,(s==null?void 0:s.id)??"");Je?Je.route==="approver"?await M.rejectProposal(ie,$f()):await M.resolveProposal(ie,"reject",Je.domain,$f()):Me="you are not one of the people who may decide it"}}catch(Fe){Me=Fe instanceof Error?Fe.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Me){ce(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Me}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(Et)}`)}catch(ue){ce(ue instanceof Error?ue.message:"Signing the mandate failed")}finally{V(!1)}}};if(!c||!h)return r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ee=Object.entries(h.bounds).filter(([ue])=>ue!=="profile"&&ue!=="path"),xe=Object.entries(h.context),ve=((re==null?void 0:re.caps)!=null?Object.keys(re.caps):[]).length!==0,ne=he.length>0?he.join(", "):((re==null?void 0:re.approvers)??[]).join(", "),Ae=ve?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ne}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Ee=ve?`Over-cap actions will be reviewed by you and ${ne}. Within-cap actions run per the mode you chose above.`:`Approvers ${ne} can read your intent but won't gate any action — no caps configured on this profile.`,Le=!!((me=re==null?void 0:re.approvers)!=null&&me.length),fe=Zh({isPersonal:c.isPersonal,configLoaded:Y,approvers:re==null?void 0:re.approvers,userId:s==null?void 0:s.id,profileName:ut(c.profileId),teamName:c.groupName}),_e=!fe.can,We=Pf(p),se=We.length===0,je=j>E,$e={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},dt={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ve=((Te=p==null?void 0:p.scopeSchema)==null?void 0:Te.keyOrder)??[],tt=H.filter(ue=>j0(Ve,h.context,ue.context)),gt=tt.length>0,ft=ut(c.profileId),ze=ue=>{const Oe=Object.values(ue).map(qe=>String(qe).trim()).filter(Boolean);return Oe.length>0?Oe.join(", "):"all (unscoped)"},P=tt.map(ue=>ze(ue.context)).join("; "),ae=`This grant's scope overlaps an existing grant on ${ft} (scoped to: ${P}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return r.jsxs(r.Fragment,{children:[r.jsx(Vh,{currentStep:4,onStepClick:ue=>{ue<=3&&t(`/mandates/new/intent?step=${ue}`)}}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),c.upgradedFromProfileId&&p&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:["Updated to ",ut(c.profileId)," ",p.version," — the current version of this profile."]})]}),D&&r.jsx("div",{className:"error-message",children:D}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Title"]}),r.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${ut(c.profileId)}: daily operations`,value:A,onChange:ue=>F(ue.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[We.includes("per-action")&&r.jsxs("button",{onClick:()=>w("per-action"),style:dt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),We.includes("immediate")&&r.jsxs("button",{onClick:()=>w("immediate"),style:$e,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),We.length===1&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:We[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),se&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Duration"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(ue=>ue.seconds<=E).map(ue=>r.jsx("button",{onClick:()=>{N(ue.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:j===ue.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===ue.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:ue.label},ue.seconds)),r.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[r.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:C,onChange:ue=>{T(ue.target.value);const Oe=parseInt(ue.target.value,10);if(Oe>0){const qe=R==="days"?Oe*86400:Oe*3600;N(Math.min(qe,E))}}}),r.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:R,onChange:ue=>{$(ue.target.value);const Oe=parseInt(C,10);if(Oe>0){const qe=ue.target.value==="days"?Oe*86400:Oe*3600;N(Math.min(qe,E))}},children:[r.jsx("option",{value:"hours",children:"hours"}),r.jsx("option",{value:"days",children:"days"})]})]}),je&&r.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",E>=86400?`${Math.floor(E/86400)} days`:`${Math.floor(E/3600)} hours`]})]})]}),r.jsx("div",{className:"field-editable",children:r.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[r.jsx("input",{type:"checkbox",checked:de||G,disabled:de,onChange:ue=>q(ue.target.checked),style:{marginTop:"0.15rem"}}),r.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',de&&" Always on — you chose this in Settings."]})]})]})}),r.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Intent"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:h.gateContent.intent})]}),(!!ee.length||!!xe.length)&&r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Scope & Limits"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),r.jsxs("dl",{className:"info-kv",children:[xe.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:Xh(ue,Oe,h.contextLabels)})]},ue)),ee.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:String(Oe)})]},ue))]})]}),r.jsxs("div",{className:"info-block",children:[r.jsx("div",{className:"info-head",children:r.jsx("span",{className:"info-title",children:"Authority"})}),r.jsxs("dl",{className:"info-kv",children:[r.jsx("dt",{children:"Profile"}),r.jsxs("dd",{children:[ut(c.profileId),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:c.profileId})]}),!c.isPersonal&&c.groupName&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Team"}),r.jsx("dd",{children:c.groupName})]}),!c.isPersonal&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Approvers"}),r.jsx("dd",{children:Y?fe.can?r.jsxs(r.Fragment,{children:[ne,r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:Ae})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:fe.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${c.groupName??"this team"}`:"You cannot give this mandate"}),fe.code==="OWNER_NOT_APPROVER"&&r.jsx("div",{children:ne}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[fe.reason," ",fe.fix]})]}):r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),L>0?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),r.jsxs("div",{children:[L===1?`An active grant on ${ft} already has exactly these limits.`:`${L} active grants on ${ft} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",r.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,gt?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),r.jsx("div",{children:ae})]})]}):null,r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>t("/mandates/new/intent"),children:"Back"}),r.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:W,disabled:oe||!A.trim()||_e||se,children:oe?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),r.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Le?"block":"none"},children:Ee})]})]})}const P0={card:"💳",mail:"✉️"};function nm(t){return P0[t]??"🔧"}function _0(t){const s=t==null?void 0:t.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const $0=[0,7,30,90,365,3650];function hi(t){return t===null?"From your mandate":t===0?"Read nothing":t===1?"1 day back":t===365?"1 year back":t%365===0?`${t/365} years back`:`${t} days back`}function L0(t){return(t==null?void 0:t.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:t&&!t.running&&t.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Pl({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:c}){var ze;const[u,h]=f.useState({}),[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState({}),[N,E]=f.useState({}),[S,C]=f.useState(void 0),[T,R]=f.useState(!1),[$,A]=f.useState(null),[F,G]=f.useState(!1),[q,de]=f.useState(!1),[K,oe]=f.useState(!1),[V,D]=f.useState(!1),[ce,re]=f.useState({}),[Z,he]=f.useState(null),[ge,Y]=f.useState(!1),[O,H]=f.useState(null),[b,L]=f.useState(!1);f.useEffect(()=>{let P=!1;return M.getCredential(t.id).then(ae=>{var me;if(!(P||!ae.configured)){if(p(!0),y(!0),ae.fields){const Te={};for(const ue of t.credentials.fields)ae.fields[ue.key]!=null&&(Te[ue.key]=ae.fields[ue.key]);j(Te)}if(E(ae.secrets??{}),C(ae.updatedAt),t.oauth){const Te=((me=ae.fieldNames)==null?void 0:me.includes(t.oauth.tokenStorage))??!1;R(Te),Te&&M.getOAuthHealth(t.id).then(ue=>{P||A(ue)})}}}).catch(()=>{}),()=>{P=!0}},[t.id,t.oauth]);const J=_0(t.toolGating),W=s?s.readAgeDays??null:void 0,ee=ge&&Z?Z.value:W,xe=async P=>{he({value:P}),Y(!0),H(null);try{await M.setReadPolicy(t.id,P),c(P===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${hi(P).toLowerCase()}`),o()}catch(ae){H(ae instanceof Error?ae.message:"Could not save")}finally{Y(!1),he(null)}},ke=!!t.oauth||t.credentials.fields.some(P=>!P.optional),ve=t.oauth?T:g,ne=!ke||ve,Ae=a==="starting"?"starting":ne?s!=null&&s.running?"running":!g&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&g&&!T?"needs-oauth":"unconfigured",Ee=async()=>{if(t.credentials.fields.some(ae=>{var me;return(me=u[ae.key])==null?void 0:me.trim()})){G(!0);try{await M.setCredential(t.id,u),p(!0),h({}),t.oauth?c(`${t.name} credentials saved!`):(c(`${t.name} credentials saved — starting integration...`),await se())}catch{c(`Failed to save ${t.name} credentials`)}finally{G(!1)}}},Le=()=>{const P={};for(const ae of t.credentials.fields){const me=u[ae.key];ae.type==="password"?me!=null&&me.trim()&&(P[ae.key]=me):me!=null&&me!==(w[ae.key]??"")&&(P[ae.key]=me)}return P},fe=Object.keys(Le()).length>0,_e=async()=>{const P=Le();if(Object.keys(P).length!==0){G(!0);try{await M.setCredential(t.id,P),h({}),p(!0),t.oauth?c(`${t.name} credentials saved — now click Connect.`):(D(!1),c(`${t.name} credentials updated — restarting...`),await se())}catch{c(`Failed to update ${t.name} credentials`)}finally{G(!1)}}},We=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const P=setInterval(async()=>{var ae;try{const me=await M.getCredential(t.id);me.configured&&t.oauth&&((ae=me.fieldNames)!=null&&ae.includes(t.oauth.tokenStorage))&&(R(!0),D(!1),A(null),clearInterval(P),c(`${t.name} connected — starting integration...`),M.getOAuthHealth(t.id).then(A).catch(()=>{}),await se())}catch{}},2e3);setTimeout(()=>clearInterval(P),12e4)},se=async()=>{oe(!0);try{const P=await M.activateIntegration(t.id);P.warning?c(P.warning):c(`${t.name} integration started with ${P.tools.length} tools`),o()}catch(P){c(`Failed to start ${t.name}: ${P instanceof Error?P.message:"Unknown error"}`)}finally{oe(!1)}},je=async()=>{try{await M.removeMcpIntegration(t.id),c(`${t.name} integration removed`),o()}catch{c(`Failed to remove ${t.name}`)}},$e=nm(t.icon),dt=L0(s),Ve=Ae==="running"?{c:"int-chip-ok",t:"Running"}:Ae==="starting"?{c:"int-chip-idle",t:"Starting"}:dt.chip,tt=t.oauth&&T&&($==null?void 0:$.status)==="failed",gt=ke?tt?{c:"int-chip-bad",t:"Auth failed"}:ve?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ft=P=>P.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${t.id}/callback`);return r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[r.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:$e}),r.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:t.name}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[Ae!=="unconfigured"&&Ae!=="needs-oauth"&&r.jsxs("span",{className:`int-chip ${Ve.c}`,children:[r.jsx("span",{className:"int-dot"}),Ve.t]}),r.jsxs("span",{className:`int-chip ${gt.c}`,children:[r.jsx("span",{className:"int-dot"}),gt.t]}),Tv(t,w)&&r.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[r.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),t.oauth&&T&&r.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:$!=null&&$.account?r.jsxs(r.Fragment,{children:["Connected as ",r.jsx("b",{children:$.account})]}):r.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),tt&&!V&&r.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[r.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[t.name," stopped accepting the stored credentials"]}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[($==null?void 0:$.error)==="invalid_grant"?r.jsxs(r.Fragment,{children:["The refresh token was revoked (",r.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):$!=null&&$.error?r.jsxs(r.Fragment,{children:["The provider reported ",r.jsx("code",{children:$.error}),"."]}):r.jsx(r.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",t.name," actions are ",r.jsx("b",{children:"blocked"}),", not failing silently."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[r.jsxs("button",{className:"btn btn-primary btn-sm",onClick:We,children:["Reconnect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{h({...w}),D(!0)},children:"Edit credentials"})]})]}),r.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[r.jsx("summary",{children:"Details"}),r.jsxs("div",{className:"int-meta",children:[r.jsx("span",{className:"int-k",children:"What"}),r.jsx("span",{children:t.description}),t.profile&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Profile"}),r.jsx("span",{children:t.profile})]}),t.oauth&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Scopes"}),r.jsx("span",{children:((ze=t.oauth.scopes)==null?void 0:ze.join(", "))||"—"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Tools"}),r.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(Ae!=="running"||tt)&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("button",{onClick:()=>de(!q),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[r.jsx("span",{style:{transition:"transform 0.2s",transform:q?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),q&&r.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map((P,ae)=>r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[r.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:ae+1}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:P.title}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ft(P.description),P.link&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("a",{href:P.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},ae))})]}),Ae==="starting"&&r.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),V&&r.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",t.oauth?" Save, then Connect to re-link the account.":""]}),t.credentials.fields.map(P=>{var ae;return r.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[r.jsx("label",{className:"form-label",children:P.label}),P.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:ce[P.key]?"text":"password",name:`${t.id}-${P.key}-credential`,autoComplete:"new-password",placeholder:(ae=N[P.key])!=null&&ae.preview?`Unchanged — ends in ${N[P.key].preview}`:v?"Unchanged — paste a new value to replace":P.placeholder,value:u[P.key]||"",onChange:me=>h(Te=>({...Te,[P.key]:me.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>re(me=>({...me,[P.key]:!me[P.key]})),children:ce[P.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${P.key}-credential`,autoComplete:"off",placeholder:P.placeholder,value:u[P.key]||"",onChange:me=>h(Te=>({...Te,[P.key]:me.target.value}))})]},P.key)}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:_e,disabled:F||!fe,children:F?"Saving…":"Save"}),!fe&&!F&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),t.oauth&&r.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:We,children:["Connect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{D(!1),h({})},children:"Cancel"})]})]}),!V&&Ae==="running"&&s&&r.jsxs(r.Fragment,{children:[(Object.keys(w).length>0||Object.keys(N).length>0)&&r.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map(P=>{const ae=P.type==="password",me=N[P.key];return!ae&&w[P.key]==null||ae&&me==null?null:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:P.label}),r.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[ae?me.preview??"set":w[P.key],ae&&S&&r.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},P.key)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx(xt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(t.credentials.fields.length>0||t.oauth)&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{h({...w}),D(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:je,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),J&&ee!==void 0&&!b&&r.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),r.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ee===null?"window from your mandate":hi(ee).toLowerCase()}),ge&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),O&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:O})]}),r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>L(!0),children:"Edit"})]})}),J&&ee!==void 0&&b&&r.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),r.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>L(!1),children:"Done"})]}),r.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[$0.map(P=>{const ae=ee===P;return r.jsx("button",{className:`btn btn-sm ${ae?"btn-primary":"btn-secondary"}`,"aria-pressed":ae,disabled:ge,onClick:()=>xe(P),children:hi(P)},P)}),r.jsx("button",{className:`btn btn-sm ${ee===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ee===null,disabled:ge,onClick:()=>xe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:hi(null)})]}),r.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:O?r.jsx("span",{style:{color:"var(--danger)"},children:O}):ge?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ee===null?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ee===0?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):r.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ee," days is blocked, whoever it is from."]})})]}),r.jsx("div",{style:{display:"none"},children:r.jsx(xt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),Ae==="unconfigured"&&(()=>{const P=t.credentials.fields.every(Te=>Te.optional),ae=t.credentials.fields.some(Te=>!Te.optional),me=t.credentials.fields.some(Te=>{var ue;return(ue=u[Te.key])==null?void 0:ue.trim()});return r.jsxs(r.Fragment,{children:[v&&r.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",r.jsx("button",{onClick:()=>{p(!0),t.oauth&&R(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),t.oauth&&!v&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),t.setupHint&&!v&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:t.setupHint}),t.credentials.fields.map(Te=>r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:Te.label}),Te.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:ce[Te.key]?"text":"password",name:`${t.id}-${Te.key}-credential`,autoComplete:"new-password",placeholder:Te.placeholder,value:u[Te.key]||"",onChange:ue=>h(Oe=>({...Oe,[Te.key]:ue.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>re(ue=>({...ue,[Te.key]:!ue[Te.key]})),children:ce[Te.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${Te.key}-credential`,autoComplete:"off",placeholder:Te.placeholder,value:u[Te.key]||"",onChange:ue=>h(Oe=>({...Oe,[Te.key]:ue.target.value}))})]},Te.key)),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[me&&r.jsx("button",{className:"btn btn-primary",onClick:Ee,disabled:F||ae&&!t.credentials.fields.filter(Te=>!Te.optional).every(Te=>{var ue;return(ue=u[Te.key])==null?void 0:ue.trim()}),children:F?"Saving...":"Save & Encrypt"}),P&&!me&&r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":`Activate ${t.name}`})]})]})})(),Ae==="needs-oauth"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",t.name," account to authorize access."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsxs("button",{className:"btn btn-primary",onClick:We,children:["Connect ",t.name," Account"]}),r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),Ae==="ready"&&!s&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",t.oauth?`${t.name} account connected`:"Credentials configured"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":`Start ${t.name} Integration`}),!t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),R(!1)},children:"Change Credentials"})]})]}),Ae==="ready"&&s&&!s.running&&(dt.showStart?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[r.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:s.error}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:se,disabled:K,children:K?"Starting...":"Start"}),r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:je,children:"Disable"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),r.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:je,children:"Disable"})})]}))]})}function z0(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(h=>qs(h.manifest)),o=t.filter(h=>!qs(h.manifest)),c=o.filter(h=>h.state==="error"),u=o.filter(h=>h.state!=="error");return{grouped:!0,testSystems:a,realErrors:c,pausedReal:u,ungrouped:[]}}function F0({entry:t}){return r.jsxs("div",{className:"int-paused-row",children:[r.jsx("span",{"aria-hidden":"true",children:nm(t.manifest.icon)}),r.jsx("span",{className:"int-paused-name",children:t.manifest.name}),r.jsxs("span",{className:"int-chip int-chip-paused",children:[r.jsx("span",{className:"int-dot"}),"Paused"]})]})}function O0(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:c}=fc(),u=dc(),[h,g]=f.useState(""),p=f.useCallback(y=>{g(y),setTimeout(()=>g(""),5e3)},[]),v=z0(o,u);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Integrations"}),r.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),h&&r.jsx("div",{className:"alert alert-success",children:h}),t?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):v.grouped?r.jsxs(r.Fragment,{children:[v.testSystems.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Test systems"}),v.testSystems.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id))]}),(v.realErrors.length>0||v.pausedReal.length>0)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Real systems"}),v.realErrors.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id)),v.pausedReal.length>0&&r.jsxs("details",{className:"int-paused-group",open:!0,children:[r.jsxs("summary",{children:["Paused while simulation mode is on (",v.pausedReal.length,")"]}),r.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",r.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),v.pausedReal.map(y=>r.jsx(F0,{entry:y},y.id))]})]}),o.length===0&&r.jsx(Lf,{manifestsError:a})]}):r.jsxs(r.Fragment,{children:[o.map(y=>r.jsx(Pl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:c,onSuccess:p},y.id)),o.length===0&&r.jsx(Lf,{manifestsError:a})]})]})}function Lf({manifestsError:t}){return t?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",r.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):r.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function M0(){var D,ce,re;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=pt(),c=mn(),[u,h]=f.useState(null),[g,p]=f.useState(!1),[v,y]=f.useState(""),[w,j]=f.useState(""),[N,E]=f.useState(!1),[S,C]=f.useState(""),[T,R]=f.useState("");f.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{typeof Z.spUrl=="string"&&R(Z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!t){h(null);return}M.getGroupById(t.id).then(Z=>{const he=Z.group??Z,ge=Z.members??[],Y=Z.isAdmin??!1,O=ge.map(H=>{const b=H.userId||H.id||"",L=H.role||(Y&&b===he.createdBy?"admin":"member");return{id:b,name:H.name||b.slice(0,8)||"Member",email:H.email||"",domains:H.domains||[],role:L,isAdmin:L==="admin"||Y&&b===he.createdBy}});h({id:he.id,name:he.name,members:O})}).catch(()=>h(null))},[t==null?void 0:t.id]);const $=(u==null?void 0:u.members.filter(Z=>Z.isAdmin))??[],A=(t==null?void 0:t.isAdmin)===!0&&$.length<=1&&$.some(Z=>Z.id===(o==null?void 0:o.id)),F=(t==null?void 0:t.name)??"",G=S.trim()===F&&!g,q=()=>{C(""),E(!0)},de=()=>{E(!1),C("")},K=async()=>{if(!(!t||!G)){p(!0),y("");try{await M.leaveTeam(t.id),await a(),j("You have left the team."),h(null),de()}catch(Z){y(Z instanceof Error?Z.message:"Failed to leave team")}finally{p(!1)}}},oe=t&&T?`${T}/dashboard/groups/${t.id}`:void 0,V=T?`${T}/dashboard/groups`:void 0;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Team"}),r.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&r.jsx("div",{className:"error-message",children:v}),w&&r.jsx("div",{className:"alert alert-success",children:w}),t?r.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"card-title",children:t.name}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=u==null?void 0:u.members)==null?void 0:D.length)??0," ",(((ce=u==null?void 0:u.members)==null?void 0:ce.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),r.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(re=u==null?void 0:u.members)==null?void 0:re.map(Z=>r.jsxs("div",{className:"member-row",children:[r.jsx("div",{className:"member-avatar",children:Z.name.split(" ").map(he=>he[0]).join("").slice(0,2).toUpperCase()}),r.jsxs("div",{className:"member-info",children:[r.jsx("div",{className:"member-name",children:Z.name}),r.jsx("div",{className:"member-email",children:Z.email})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Z.role})]},Z.id)),r.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[oe&&r.jsx("a",{className:"btn btn-secondary btn-sm",href:oe,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),r.jsx("span",{title:A?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:q,disabled:g||A,children:"Leave team"})})]})]}):r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[r.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>c("/onboarding"),children:"Join or create a team"}),V&&r.jsx("a",{className:"btn btn-ghost btn-sm",href:V,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&t&&r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:de,children:r.jsxs("div",{className:"card",onClick:Z=>Z.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[r.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",F,"?"]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsx("li",{children:"Revoke all mandates you created in this team's context"}),r.jsx("li",{children:"Reject any pending action proposals you authored"}),r.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",r.jsx("strong",{children:"personal"})," mandates are not affected."]}),r.jsxs("div",{className:"form-group",children:[r.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",r.jsx("code",{children:F})," to confirm:"]}),r.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Z=>C(Z.target.value),placeholder:F,disabled:g,autoFocus:!0})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:de,disabled:g,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:K,disabled:!G,children:g?"Leaving...":"Leave team"})]})]})})]})}const B0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),D0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function U0(t){const s=t.lastIndexOf("/"),a=s>=0?t.slice(s+1):t,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function Nr(t,s){const a=U0(t),o=s!=null&&s.icon&&B0.has(s.icon)?s.icon:D0[a]??"help-circle",c=ut(t,s==null?void 0:s.name);return{icon:o,name:c,testSetup:a==="delegation"}}function zi(t){return t.startsWith("setup__")}const W0={mail:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),r.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),r.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),r.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),r.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),r.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),r.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),r.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),r.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),r.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),r.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),r.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),r.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),r.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),r.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),r.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),r.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),r.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),r.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),r.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M9 3h6"}),r.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),r.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),r.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),r.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),r.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),r.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),r.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),r.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function rm({icon:t,className:s}){return r.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:W0[t]})}function ea({profileId:t,declared:s}){const{icon:a,name:o}=Nr(t,s);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"id-rail",children:[r.jsx(rm,{icon:a,className:"id-rail-icon"}),r.jsx("span",{className:"id-rail-name",children:o})]}),r.jsx("div",{className:"id-sep"})]})}const Js=t=>t.replace(/@.*$/,"").split("/").pop()??t,zf=t=>t.split("@")[1]??"";function H0(t,s){const a=new Map;for(const o of t){const c=Js(o.id);if(!s.has(c))continue;const u=a.get(c);(!u||zf(o.id).localeCompare(zf(u.id),void 0,{numeric:!0})>0)&&a.set(c,o)}return a}function V0(t,s,a,o){var g;const c=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>Js(p.profile))]),u=H0(t,c),h=[];for(const p of s){const v=p.profile?u.get(p.profile):void 0;v&&h.push({key:`connector:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"connector",ready:((g=a.find(y=>y.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const v=u.get(Js(p.profile));v&&h.push({key:`builtin:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return h}function G0(t,s,a){if(s)return t.find(o=>Js(o.profile.id)===Js(s)&&o.ready&&a(o))}function K0({onDismiss:t,preselectProfileId:s}){const a=mn(),{group:o,groupId:c,domain:u,user:h}=pt(),[g,p]=f.useState([]),[v,y]=f.useState([]),[w,j]=f.useState([]),[N,E]=f.useState([]),[S,C]=f.useState(!0),[T,R]=f.useState({});f.useEffect(()=>{Promise.all([M.listProfiles().catch(()=>[]),M.getIntegrationManifests().then(K=>K.manifests??[]).catch(()=>[]),M.getMcpHealth().catch(()=>null)]).then(async([K,oe,V])=>{if(p(K),y(oe),j((V==null?void 0:V.integrations)??[]),E((V==null?void 0:V.builtins)??[]),c){const D=await Promise.all(K.map(re=>M.getTeamProfileConfig(c,re.id).catch(()=>null))),ce={};K.forEach((re,Z)=>{const he=D[Z];he&&(ce[re.id]=he)}),R(ce)}}).finally(()=>C(!1))},[c]);const $=V0(g,v,w,N),A=K=>{var oe;return Zh({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,approvers:(oe=T[K.id])==null?void 0:oe.approvers,userId:h==null?void 0:h.id,profileName:ut(K.id),teamName:o==null?void 0:o.name})},F=K=>K in T,G=(K,oe)=>{if(!c){console.error("No active group when creating authorization");return}const V=F(K);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:K,groupId:c,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:V,isPersonal:!!(o!=null&&o.isPersonal),...oe?{intentHint:oe}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},q=(K,oe)=>{c&&G(K,oe)},de=f.useRef(!1);return f.useEffect(()=>{if(S||!s||de.current)return;const K=G0($,s,oe=>A(oe.profile).can);K&&(de.current=!0,q(K.profile.id,K.intentHint))},[S,s]),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
75
75
|
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
76
76
|
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
77
77
|
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
78
78
|
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
79
|
-
`}),S?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.length===0?r.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[r.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),r.jsx(xt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>t==null?void 0:t(),children:"Go to Integrations"})]}):r.jsx("div",{className:"profile-grid",children:$.map(K=>{const oe=K.profile,V=F(oe.id),D=A(oe),ce=!K.ready||!D.can,{icon:re}=Nr(oe.id,{name:oe.name,icon:oe.icon});return r.jsxs("div",{className:"card",style:ce?{opacity:.7}:void 0,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[r.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[r.jsx(rm,{icon:re,className:"profile-chip-icon"}),K.name]}),V?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o!=null&&o.isPersonal?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:K.description}),D.can?K.ready?r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>q(oe.id,K.intentHint),children:"Give a mandate"}):K.kind==="builtin"?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:K.unavailableReason})]}):r.jsxs(xt,{to:`/integrations?setup=${K.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",K.name]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[D.reason," ",r.jsx("span",{style:{color:"var(--text-tertiary)"},children:D.fix})]})]})]},K.key)})})]})}const q0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Y0({status:t,label:s}){return r.jsx("span",{className:`status-badge status-${t}`,children:s||q0[t]})}function J0({domain:t,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return r.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:t})}const xr=86400,Vs=3600,mi=60,Q0=30*xr;function X0(t){if(t<=0)return"Expired";if(t>90*xr){const s=Math.floor(t/Q0);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*xr){const s=Math.floor(t/xr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*xr){const s=Math.floor(t/xr),a=Math.floor(t%xr/Vs);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*Vs){const s=Math.floor(t/Vs),a=Math.floor(t%Vs/mi);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=mi){const s=Math.floor(t/mi),a=Math.floor(t%mi);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function Z0({expiresAt:t}){const[s,a]=f.useState(()=>t-Date.now()/1e3),o=s<2*Vs;f.useEffect(()=>{const u=setInterval(()=>a(t-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[t,o]);const c=s<300;return r.jsx("span",{className:`ttl-badge ${c?"ttl-warn":"ttl-ok"}`,children:X0(s)})}function Zr({icon:t,title:s,text:a,children:o}){return r.jsxs("div",{className:"empty-state",children:[t&&r.jsx("div",{className:"empty-state-icon",children:t}),r.jsx("div",{className:"empty-state-title",children:s}),a&&r.jsx("div",{className:"empty-state-text",children:a}),o]})}function ew(t){const s=Math.floor(t/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(t/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(t/60);return`${o} minute${o===1?"":"s"}`}const tw=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function nw({item:t,onClose:s,onSuccess:a}){var $;const{user:o,activeDomain:c,groupId:u}=pt(),[h,g]=f.useState(null);f.useEffect(()=>{let A=!1;return M.getProfile(t.profile_id).then(F=>{var G;A||g(((G=F==null?void 0:F.ttl)==null?void 0:G.max)??null)}).catch(()=>{}),()=>{A=!0}},[t.profile_id]);const p=t.remaining_seconds??0,v=tw.filter(A=>A.seconds>p&&(h===null||A.seconds<=h)),y=(($=v[0])==null?void 0:$.seconds)??2592e3,[w,j]=f.useState(y);f.useEffect(()=>{var A;if(h!==null&&w>h){const F=(A=v[v.length-1])==null?void 0:A.seconds;F&&j(F)}},[h]);const[N,E]=f.useState(!1),[S,C]=f.useState(""),T=Object.entries(t.frame).filter(([A])=>A!=="profile"&&A!=="path"),R=async()=>{var A;if(o){E(!0),C("");try{const F=t.authorization_id,G=await M.getGateContent(F);if(!G)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const q=await M.getProfile(t.profile_id),de=t.frame,K=G.context??{},oe=t.attested_domains[0]||c||"owner",V=await xi(de,q),D=await Yh(K,q),[ce,re]=await Promise.all([Ni(G.gateContent.intent),Ni(JSON.stringify({profile:t.profile_id,path:t.path,domain:oe}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const Z=(((A=t.deferred_commitment_domains)==null?void 0:A.length)??0)>0?"review":"automatic",he=await Jh(q),ge=await M.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:he,supported_versions:["0.7"],bounds:de,bounds_hash:V,scope_hash:D,domain:oe,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ce},execution_context_hash:re,group_id:u,commitment_mode:Z,ttl:w});await M.pushGateContent(Qh(ge,{boundsHash:V,contextHash:D,context:K,path:t.path,gateContent:G.gateContent})),a()}catch(F){C(F instanceof Error?F.message:"Extension failed")}finally{E(!1)}}};return r.jsx("div",{className:"modal-backdrop",onClick:A=>A.target===A.currentTarget&&s(),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Extend mandate"}),r.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[ut(t.profile_id)," / ",t.path]}),T.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([A,F])=>`${A}=${F}`).join(" · ")})]}),r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),p>0&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",ew(p),". Only longer durations are shown."]}),r.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(A=>r.jsx("button",{className:`btn ${w===A.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(A.seconds),style:{minWidth:"3.5rem"},children:A.label},A.seconds))})]}),r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&r.jsx("div",{className:"error-message",children:S})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:N,children:"Cancel"}),r.jsx("button",{className:"btn btn-primary",onClick:R,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function Ff(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Of(t){return t.split("@")[1]??""}function rw(t,s){return Of(t).localeCompare(Of(s),void 0,{numeric:!0})>0}function sm(t,s){const a=Ff(t);let o;for(const c of s)Ff(c.id)===a&&(!o||rw(c.id,o.id))&&(o=c);return o}function am(t,s){var o;if(!s)return{};const a={};for(const c of s.keyOrder){if(c==="profile"||c==="path")continue;if(t[c]!==void 0){a[c]=t[c];continue}const u=(o=s.fields[c])==null?void 0:o.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[c]=u)}return a}function im(t,s){return am(t,s.boundsSchema)}function om(t,s){return am(t,s.scopeSchema)}function sw(t,s,a){return[...t].sort((o,c)=>{if(a){if(o.authorization_id===a&&c.authorization_id!==a)return-1;if(c.authorization_id===a&&o.authorization_id!==a)return 1}const u=bi(o,s),h=bi(c,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[u]!==g[h]?g[u]-g[h]:new Date(c.created_at).getTime()-new Date(o.created_at).getTime()})}function aw({item:t,newerProfile:s,revokedSet:a,expandedHash:o,gateCache:c,gateLoading:u,copiedHash:h,revokingHash:g,copyingHash:p,profileConfigCache:v,mode:y,ownerLabel:w,isAdmin:j,onExpand:N,onCopyHash:E,onCopy:S,onRevoke:C,onExtend:T,archivedSet:R,archivingHash:$,onArchive:A,highlightHash:F,needsReapprovalSet:G}){var Ae;const q=uc(t,{revokedSet:a}),de=q==="active"&&((G==null?void 0:G.has(t.authorization_id))??!1),K=Ih(t,{revokedSet:a,archivedSet:R}),oe=!w&&!!A&&Rh(q),V=o===t.authorization_id,D=c[t.authorization_id],ce=q==="active"||q==="pending"||q==="expired",re=Object.entries(t.frame).filter(([Ee])=>Ee!=="profile"&&Ee!=="path"),Z=v.get(t.profile_id)??null,he=(((Ae=Z==null?void 0:Z.approvers)==null?void 0:Ae.length)??0)>0,ge=new Map;if(Z!=null&&Z.caps&&y==="team")for(const[Ee,Le]of re){const fe=Z.caps[Ee];fe!==void 0&&Number(Le)>fe&&ge.set(Ee,{authorized:Number(Le),cap:fe})}const Y=ge.size>0,O=t.approvers_frozen??[],H=(Z==null?void 0:Z.approvers)??[],b=y==="team"&&O.length>0&&H.length>0&&(O.length!==H.length||O.some(Ee=>!H.includes(Ee))||H.some(Ee=>!O.includes(Ee))),L=Array.from(ge.entries()).map(([Ee,Le])=>`${Ee}: ${Le.authorized} (cap ${Le.cap})`).join(", "),J=Array.from(ge.entries()).map(([Ee,Le])=>`${Ee}: ${Le.authorized} → ${Le.cap}`).join(", "),W=Y?he?ge.size===1?`Above team cap: ${L} — actions require approval`:`Above team cap (${ge.size}): ${L} — actions require approval`:ge.size===1?`Reduced by hard cap: ${J}`:`Reduced by hard cap (${ge.size}): ${J}`:"",ee=Y?he?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,xe=Nr(t.profile_id),ke=xe.name,ve=s?r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem",padding:"0.4rem 0.6rem",border:"1px solid var(--border)",borderRadius:6},children:[r.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[ke,"@",s.version," available"]}),s.whatsNew?r.jsxs(r.Fragment,{children:[" — ",s.whatsNew]}):null,r.jsx("br",{}),r.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,ne=F!=null&&t.authorization_id===F;return r.jsxs("div",{className:`card id-card${ne?" card-highlight":""}`,style:{marginBottom:0},children:[r.jsx(ea,{profileId:t.profile_id}),r.jsxs("div",{className:"id-body",children:[ve,w&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",r.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:w})]}),r.jsxs("div",{className:"auth-card-header",children:[r.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:t.title||ke}),r.jsx(Y0,{status:q}),de&&r.jsx("span",{title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-on-warning, #7a4a00)",background:"var(--warning-bg, #fff3cd)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),xe.testSetup&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),q==="active"&&t.earliest_expiry&&r.jsx(Z0,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),q==="expired"&&(()=>{const Ee=Ev(t,q);return Ee?r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(Ee.iso).toLocaleString()}`,children:new Date(Ee.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[t.required_domains.map(Ee=>r.jsx(J0,{domain:Ee,attested:t.attested_domains.includes(Ee)},Ee)),t.deferred_commitment_domains.length>0&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),Y&&r.jsx("span",{title:ee,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:he?"var(--accent-subtle)":"var(--danger-subtle)",color:he?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:W}),b&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>S(t),disabled:p===t.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),re.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:re.map(([Ee,Le],fe)=>{const _e=ge.get(Ee);return r.jsxs("span",{children:[fe>0&&" · ",_e?he?r.jsxs("span",{title:`Team cap on ${Ee} is ${_e.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${_e.authorized}.`,children:[r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[Ee,"=",String(Le)]}),r.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",_e.cap]})]}):r.jsxs("span",{title:`Team cap on ${Ee} is ${_e.cap} with no approvers configured (hard cap). Authorized for ${_e.authorized}; effective ${_e.cap}.`,children:[r.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[Ee,"=",String(Le)]}),r.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",_e.cap]})]}):r.jsxs("span",{children:[Ee,"=",String(Le)]})]},Ee)})}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[oe&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>A(t.authorization_id,!K),disabled:$===t.authorization_id,title:K?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:$===t.authorization_id?K?"Unarchiving…":"Archiving…":K?"↩ Unarchive":"⊟ Archive"}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(t),children:V?"▲ Hide Details":"▼ Details"})]}),V&&r.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[re.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),r.jsx("dl",{className:"review-grid",children:re.map(([Ee,Le])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{children:String(Le)})]},Ee))})]}),(D==null?void 0:D.context)&&Object.keys(D.context).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("dl",{className:"review-grid",children:Object.entries(D.context).map(([Ee,Le])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{title:String(Le),children:Xh(Ee,Le,D.contextLabels)})]},Ee))})]}),r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),u===t.authorization_id?r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):D?r.jsx("div",{className:"gate-content-block",children:r.jsx("div",{className:"gate-content-item",children:r.jsx("div",{className:"gate-content-text",children:D.gateContent.intent})})}):r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(t.created_at).toLocaleString(),t.earliest_expiry&&` · Expires: ${new Date(t.earliest_expiry).toLocaleString()}`]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:t.authorization_id}),r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>E(t.authorization_id),children:h===t.authorization_id?"copied":"copy"})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!w&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>S(t),disabled:p===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===t.authorization_id?"Copying…":"⧉ Copy"}),!w&&(q==="active"||q==="pending")&&r.jsx("button",{className:de?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>S(t,{asEdit:!0}),disabled:p===t.authorization_id,title:de?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:de?"⚠ Re-approve":"✎ Edit"}),!w&&ce&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(t),children:"↻ Extend"}),w&&j&&q!=="revoked"?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id,w,ke),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):!w&&(q==="active"||q==="pending")?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},t.authorization_id)}function iw(){const[t,s]=f.useState([]),[a,o]=f.useState(!0),[c,u]=f.useState([]),[h,g]=f.useState(!1),[p,v]=f.useState(new Map),[y,w]=f.useState("mine"),[j,N]=f.useState("active"),[E,S]=f.useState(null),[C,T]=f.useState(null),[R,$]=oc(),[A,F]=f.useState(()=>R.get("new")==="1"),[G]=f.useState(()=>R.get("profile")),[q,de]=f.useState(()=>R.get("highlight")),[K,oe]=f.useState(null),[V,D]=f.useState({}),[ce,re]=f.useState(null),[Z,he]=f.useState(null),[ge,Y]=f.useState(null),[O,H]=f.useState(new Set),[b,L]=f.useState(null),[J,W]=f.useState(new Set),[ee,xe]=f.useState(null),[ke,ve]=f.useState(null),[ne,Ae]=f.useState(new Set),Ee=mn(),{group:Le,groupId:fe,domain:_e,mode:Ue,activeTeam:se}=pt(),je=(se==null?void 0:se.isAdmin)===!0,[$e,dt]=f.useState(()=>new Map),He=f.useCallback(()=>{o(!0),M.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),tt=f.useCallback(()=>{M.getArchivedMandates().then(ie=>W(new Set(ie))).catch(()=>{})},[]);f.useEffect(()=>{tt()},[tt]);const gt=f.useCallback(()=>{M.getEnrichedAuthorizations().then(ie=>Ae(new Set(ie.filter(Se=>Se.needsReapproval).map(Se=>Se.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{gt()},[gt]);const ft=async(ie,Se)=>{xe(ie);try{const pe=await M.setMandateArchived(ie,Se);W(new Set(pe)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(pe){alert(pe instanceof Error?pe.message:"Failed to update archive")}finally{xe(null)}},ze=f.useCallback(()=>{fe&&(g(!0),M.listTeamAuthorizations(fe).then(u).catch(()=>{}).finally(()=>g(!1)))},[fe]);Ge("attestation-changed",()=>{He(),je&&fe&&ze(),gt()}),f.useEffect(()=>{if(!q)return;R.get("highlight")&&(R.delete("highlight"),$(R,{replace:!0}));const ie=window.setTimeout(()=>de(null),3e3);return()=>window.clearTimeout(ie)},[]),nn(He,3e5),f.useEffect(()=>{y==="team"&&je&&fe&&c.length===0&&!h&&ze()},[y,je,fe,c.length,h,ze]),f.useEffect(()=>{let ie=!1;return M.listProfiles().then(Se=>{if(ie)return;const pe=Je=>Je.replace(/@.*$/,"").split("/").pop()??Je,Me=Je=>Je.split("@")[1]??"",Fe=new Map;for(const Je of Se){const Ut=pe(Je.id),er=Fe.get(Ut);(!er||Me(Je.id).localeCompare(Me(er.id),void 0,{numeric:!0})>0)&&Fe.set(Ut,Je)}v(Fe)}).catch(()=>{}),()=>{ie=!0}},[]);const P=f.useCallback(ie=>{const Se=Ut=>Ut.replace(/@.*$/,"").split("/").pop()??Ut,pe=Ut=>Ut.split("@")[1]??"",Me=p.get(Se(ie));if(!Me)return;const Fe=pe(ie),Je=pe(Me.id);if(!(!Fe||!Je))return Je.localeCompare(Fe,void 0,{numeric:!0})>0?Me:void 0},[p]);f.useEffect(()=>{if(Ue!=="team"||!fe)return;const ie=y==="mine"?t:c;if(ie.length===0)return;const Se=[...new Set(ie.map(pe=>pe.profile_id))].filter(pe=>!$e.has(pe));if(Se.length!==0){dt(pe=>{const Me=new Map(pe);for(const Fe of Se)Me.set(Fe,null);return Me});for(const pe of Se)M.getTeamProfileConfig(fe,pe).then(Me=>{dt(Fe=>new Map(Fe).set(pe,Me))}).catch(()=>{})}},[t,c,y,fe,Ue,$e]);const ae=async ie=>{if(K===ie.authorization_id){oe(null);return}oe(ie.authorization_id);const Se=ie.authorization_id;if(!(Se in V)){re(ie.authorization_id);try{const pe=await M.getGateContent(Se);D(Me=>({...Me,[Se]:pe}))}catch{D(pe=>({...pe,[Se]:null}))}finally{re(null)}}},me=ie=>{navigator.clipboard.writeText(ie).then(()=>{Y(ie),setTimeout(()=>Y(null),2e3)})},Te=async(ie,Se)=>{var pe;if(!fe){alert("No active group; cannot copy mandate.");return}ve(ie.authorization_id);try{const Me=ie.authorization_id;let Fe=V[Me]??null;Me in V||(Fe=await M.getGateContent(Me),D(bn=>({...bn,[Me]:Fe})));const Je=Object.fromEntries(Object.entries(ie.frame).filter(([bn])=>bn!=="profile"&&bn!=="path")),Ut=(Fe==null?void 0:Fe.context)??{},er=((pe=Fe==null?void 0:Fe.gateContent)==null?void 0:pe.intent)??"",rs=ie.deferred_commitment_domains.length>0?"review":"automatic",na=ie.attested_domains[0]||_e||"owner",Sn=Date.parse(ie.created_at),tr=ie.earliest_expiry?Date.parse(ie.earliest_expiry):NaN,nr=Number.isFinite(Sn)&&Number.isFinite(tr)&&tr>Sn?Math.round((tr-Sn)/1e3):void 0;let ra=ie.profile_id,$n=Je,rr=Ut,sr;const ss=await M.listProfiles(),Cr=sm(ie.profile_id,ss);if(Cr&&Cr.id!==ie.profile_id){const bn=await M.getProfile(Cr.id);ra=Cr.id,$n=im(Je,bn),rr=om(Ut,bn),sr=ie.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ra,groupId:fe,groupName:(Le==null?void 0:Le.name)??null,domain:na,isPersonal:!!(Le!=null&&Le.isPersonal),upgradedFromProfileId:sr})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:$n,context:rr,gateContent:{intent:er},templateMode:rs,templateTtl:nr})),Se!=null&&Se.asEdit?sessionStorage.setItem("agentEditReplaces",ie.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ee("/mandates/new/intent")}catch(Me){alert(Me instanceof Error?Me.message:"Failed to copy mandate")}finally{ve(null)}},ue=async(ie,Se,pe)=>{const Me=Se&&pe?`Revoke ${Se}'s ${pe} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Me)){L(ie);try{await M.revokeAttestation(ie),H(Fe=>new Set(Fe).add(ie)),M.resyncGates().catch(()=>{}),Se&&fe&&ze()}catch(Fe){alert(Fe instanceof Error?Fe.message:"Failed to revoke mandate")}finally{L(null)}}},Oe=y==="mine"?t:c,qe=y==="mine"?a:h,Ye=y==="mine"?{revokedSet:O,archivedSet:J}:{revokedSet:O},ht=ie=>bi(ie,Ye),pn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ie of Oe)pn[ht(ie)]+=1;const jn=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],nt=(()=>{const ie=new Map;for(const Se of Oe){if(ht(Se)!==j)continue;const pe=ie.get(Se.profile_id)??{count:0,review:!1};pe.count+=1,Se.deferred_commitment_domains.length>0&&(pe.review=!0),ie.set(Se.profile_id,pe)}return Array.from(ie.entries()).map(([Se,pe])=>({profileId:Se,...pe})).sort((Se,pe)=>ut(Se.profileId).localeCompare(ut(pe.profileId)))})(),kt=sw(Oe.filter(ie=>{if(ht(ie)!==j||E!==null&&ie.profile_id!==E)return!1;if(C!==null){const Se=ie.deferred_commitment_domains.length>0;if(C==="review"&&!Se||C==="auto"&&Se)return!1}return!0}),Ye,q),Et={revokedSet:O,expandedHash:K,gateCache:V,gateLoading:ce,copiedHash:ge,revokingHash:b,copyingHash:ke,profileConfigCache:$e,mode:Ue,activeDomain:_e,group:Le,groupId:fe,onExpand:ae,onCopyHash:me,onCopy:Te,onRevoke:ue,onExtend:he,highlightHash:q},wt={...Et,archivedSet:J,archivingHash:ee,onArchive:ft,needsReapprovalSet:ne};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Mandates"}),r.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),r.jsx("button",{className:"btn btn-primary",onClick:()=>F(!0),children:"+ New mandate"})]}),A&&r.jsx("div",{className:"modal-backdrop",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),$(R,{replace:!0}))},children:r.jsxs("div",{className:"modal",onClick:ie=>ie.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h2",{className:"modal-title",children:"New mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),$(R,{replace:!0}))},children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),r.jsx(K0,{onDismiss:()=>F(!1),preselectProfileId:G})]})]})}),je&&r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[r.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{w("mine"),N("active"),S(null),T(null),oe(null)},children:"Mine"}),r.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{w("team"),N("active"),S(null),T(null),oe(null)},children:"Team"})]}),r.jsx("div",{className:"nav-tabs",children:jn.map(ie=>r.jsxs("button",{className:`nav-tab${j===ie?" active":""}`,onClick:()=>{N(ie),S(null),T(null)},children:[ie.charAt(0).toUpperCase()+ie.slice(1)," (",pn[ie],")"]},ie))}),nt.length>0&&r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[nt.map(ie=>{const Se=E===ie.profileId;return r.jsx("button",{className:`btn btn-sm ${Se?"btn-primary":"btn-secondary"}`,onClick:()=>S(Se?null:ie.profileId),children:ut(ie.profileId)},ie.profileId)}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(ie=>{const Se=C===ie;return r.jsx("button",{className:`btn btn-sm ${Se?"btn-primary":"btn-secondary"}`,onClick:()=>T(Se?null:ie),children:ie==="auto"?"Auto":"Review"},ie)})]}),qe&&Oe.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):kt.length===0?r.jsx(Zr,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:kt.map(ie=>{const Se=y==="team"?ie:null,pe=Se!=null&&Se.owner?Se.owner.name??Se.owner.email??Se.owner.userId:void 0;return r.jsx(aw,{item:ie,newerProfile:P(ie.profile_id),ownerLabel:pe,isAdmin:je,...y==="mine"?wt:Et},ie.authorization_id)})}),Z&&r.jsx(nw,{item:Z,onClose:()=>he(null),onSuccess:()=>{he(null),He()}})]})}const ow=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Kt(t){const s=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Fi(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function lw(t){const{integrationId:s,toolName:a}=Fi(t);return s?`${s} · ${a}`:a}function jc(t,s){const a=s==null?void 0:s.find(o=>o.id===t);return a!=null&&a.name?a.name:t?t.toUpperCase():"the system"}function cw(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
|
|
79
|
+
`}),S?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.length===0?r.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[r.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),r.jsx(xt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>t==null?void 0:t(),children:"Go to Integrations"})]}):r.jsx("div",{className:"profile-grid",children:$.map(K=>{const oe=K.profile,V=F(oe.id),D=A(oe),ce=!K.ready||!D.can,{icon:re}=Nr(oe.id,{name:oe.name,icon:oe.icon});return r.jsxs("div",{className:"card",style:ce?{opacity:.7}:void 0,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[r.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[r.jsx(rm,{icon:re,className:"profile-chip-icon"}),K.name]}),V?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o!=null&&o.isPersonal?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:K.description}),D.can?K.ready?r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>q(oe.id,K.intentHint),children:"Give a mandate"}):K.kind==="builtin"?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:K.unavailableReason})]}):r.jsxs(xt,{to:`/integrations?setup=${K.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",K.name]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[D.reason," ",r.jsx("span",{style:{color:"var(--text-tertiary)"},children:D.fix})]})]})]},K.key)})})]})}const q0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Y0({status:t,label:s}){return r.jsx("span",{className:`status-badge status-${t}`,children:s||q0[t]})}function J0({domain:t,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return r.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:t})}const xr=86400,Vs=3600,mi=60,Q0=30*xr;function X0(t){if(t<=0)return"Expired";if(t>90*xr){const s=Math.floor(t/Q0);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*xr){const s=Math.floor(t/xr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*xr){const s=Math.floor(t/xr),a=Math.floor(t%xr/Vs);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*Vs){const s=Math.floor(t/Vs),a=Math.floor(t%Vs/mi);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=mi){const s=Math.floor(t/mi),a=Math.floor(t%mi);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function Z0({expiresAt:t}){const[s,a]=f.useState(()=>t-Date.now()/1e3),o=s<2*Vs;f.useEffect(()=>{const u=setInterval(()=>a(t-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[t,o]);const c=s<300;return r.jsx("span",{className:`ttl-badge ${c?"ttl-warn":"ttl-ok"}`,children:X0(s)})}function Zr({icon:t,title:s,text:a,children:o}){return r.jsxs("div",{className:"empty-state",children:[t&&r.jsx("div",{className:"empty-state-icon",children:t}),r.jsx("div",{className:"empty-state-title",children:s}),a&&r.jsx("div",{className:"empty-state-text",children:a}),o]})}function ew(t){const s=Math.floor(t/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(t/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(t/60);return`${o} minute${o===1?"":"s"}`}const tw=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function nw({item:t,onClose:s,onSuccess:a}){var $;const{user:o,activeDomain:c,groupId:u}=pt(),[h,g]=f.useState(null);f.useEffect(()=>{let A=!1;return M.getProfile(t.profile_id).then(F=>{var G;A||g(((G=F==null?void 0:F.ttl)==null?void 0:G.max)??null)}).catch(()=>{}),()=>{A=!0}},[t.profile_id]);const p=t.remaining_seconds??0,v=tw.filter(A=>A.seconds>p&&(h===null||A.seconds<=h)),y=(($=v[0])==null?void 0:$.seconds)??2592e3,[w,j]=f.useState(y);f.useEffect(()=>{var A;if(h!==null&&w>h){const F=(A=v[v.length-1])==null?void 0:A.seconds;F&&j(F)}},[h]);const[N,E]=f.useState(!1),[S,C]=f.useState(""),T=Object.entries(t.frame).filter(([A])=>A!=="profile"&&A!=="path"),R=async()=>{var A;if(o){E(!0),C("");try{const F=t.authorization_id,G=await M.getGateContent(F);if(!G)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const q=await M.getProfile(t.profile_id),de=t.frame,K=G.context??{},oe=t.attested_domains[0]||c||"owner",V=await xi(de,q),D=await Yh(K,q),[ce,re]=await Promise.all([Ni(G.gateContent.intent),Ni(JSON.stringify({profile:t.profile_id,path:t.path,domain:oe}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const Z=(((A=t.deferred_commitment_domains)==null?void 0:A.length)??0)>0?"review":"automatic",he=await Jh(q),ge=await M.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:he,supported_versions:["0.7"],bounds:de,bounds_hash:V,scope_hash:D,domain:oe,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ce},execution_context_hash:re,group_id:u,commitment_mode:Z,ttl:w});await M.pushGateContent(Qh(ge,{boundsHash:V,contextHash:D,context:K,path:t.path,gateContent:G.gateContent})),a()}catch(F){C(F instanceof Error?F.message:"Extension failed")}finally{E(!1)}}};return r.jsx("div",{className:"modal-backdrop",onClick:A=>A.target===A.currentTarget&&s(),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Extend mandate"}),r.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[ut(t.profile_id)," / ",t.path]}),T.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([A,F])=>`${A}=${F}`).join(" · ")})]}),r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),p>0&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",ew(p),". Only longer durations are shown."]}),r.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(A=>r.jsx("button",{className:`btn ${w===A.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(A.seconds),style:{minWidth:"3.5rem"},children:A.label},A.seconds))})]}),r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&r.jsx("div",{className:"error-message",children:S})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:N,children:"Cancel"}),r.jsx("button",{className:"btn btn-primary",onClick:R,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function Ff(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Of(t){return t.split("@")[1]??""}function rw(t,s){return Of(t).localeCompare(Of(s),void 0,{numeric:!0})>0}function sm(t,s){const a=Ff(t);let o;for(const c of s)Ff(c.id)===a&&(!o||rw(c.id,o.id))&&(o=c);return o}function am(t,s){var o;if(!s)return{};const a={};for(const c of s.keyOrder){if(c==="profile"||c==="path")continue;if(t[c]!==void 0){a[c]=t[c];continue}const u=(o=s.fields[c])==null?void 0:o.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[c]=u)}return a}function im(t,s){return am(t,s.boundsSchema)}function om(t,s){return am(t,s.scopeSchema)}function sw(t,s,a){return[...t].sort((o,c)=>{if(a){if(o.authorization_id===a&&c.authorization_id!==a)return-1;if(c.authorization_id===a&&o.authorization_id!==a)return 1}const u=bi(o,s),h=bi(c,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[u]!==g[h]?g[u]-g[h]:new Date(c.created_at).getTime()-new Date(o.created_at).getTime()})}function aw({item:t,newerProfile:s,revokedSet:a,expandedHash:o,gateCache:c,gateLoading:u,copiedHash:h,revokingHash:g,copyingHash:p,profileConfigCache:v,mode:y,ownerLabel:w,isAdmin:j,onExpand:N,onCopyHash:E,onCopy:S,onRevoke:C,onExtend:T,archivedSet:R,archivingHash:$,onArchive:A,highlightHash:F,needsReapprovalSet:G}){var Ae;const q=uc(t,{revokedSet:a}),de=q==="active"&&((G==null?void 0:G.has(t.authorization_id))??!1),K=Ih(t,{revokedSet:a,archivedSet:R}),oe=!w&&!!A&&Rh(q),V=o===t.authorization_id,D=c[t.authorization_id],ce=q==="active"||q==="pending"||q==="expired",re=Object.entries(t.frame).filter(([Ee])=>Ee!=="profile"&&Ee!=="path"),Z=v.get(t.profile_id)??null,he=(((Ae=Z==null?void 0:Z.approvers)==null?void 0:Ae.length)??0)>0,ge=new Map;if(Z!=null&&Z.caps&&y==="team")for(const[Ee,Le]of re){const fe=Z.caps[Ee];fe!==void 0&&Number(Le)>fe&&ge.set(Ee,{authorized:Number(Le),cap:fe})}const Y=ge.size>0,O=t.approvers_frozen??[],H=(Z==null?void 0:Z.approvers)??[],b=y==="team"&&O.length>0&&H.length>0&&(O.length!==H.length||O.some(Ee=>!H.includes(Ee))||H.some(Ee=>!O.includes(Ee))),L=Array.from(ge.entries()).map(([Ee,Le])=>`${Ee}: ${Le.authorized} (cap ${Le.cap})`).join(", "),J=Array.from(ge.entries()).map(([Ee,Le])=>`${Ee}: ${Le.authorized} → ${Le.cap}`).join(", "),W=Y?he?ge.size===1?`Above team cap: ${L} — actions require approval`:`Above team cap (${ge.size}): ${L} — actions require approval`:ge.size===1?`Reduced by hard cap: ${J}`:`Reduced by hard cap (${ge.size}): ${J}`:"",ee=Y?he?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,xe=Nr(t.profile_id),ke=xe.name,ve=s?r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem",padding:"0.4rem 0.6rem",border:"1px solid var(--border)",borderRadius:6},children:[r.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[ke,"@",s.version," available"]}),s.whatsNew?r.jsxs(r.Fragment,{children:[" — ",s.whatsNew]}):null,r.jsx("br",{}),r.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,ne=F!=null&&t.authorization_id===F;return r.jsxs("div",{className:`card id-card${ne?" card-highlight":""}`,style:{marginBottom:0},children:[r.jsx(ea,{profileId:t.profile_id}),r.jsxs("div",{className:"id-body",children:[ve,w&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",r.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:w})]}),r.jsxs("div",{className:"auth-card-header",children:[r.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:t.title||ke}),r.jsx(Y0,{status:q}),de&&r.jsx("span",{title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-on-warning, #7a4a00)",background:"var(--warning-bg, #fff3cd)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),xe.testSetup&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),q==="active"&&t.earliest_expiry&&r.jsx(Z0,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),q==="expired"&&(()=>{const Ee=Ev(t,q);return Ee?r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(Ee.iso).toLocaleString()}`,children:new Date(Ee.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[t.required_domains.map(Ee=>r.jsx(J0,{domain:Ee,attested:t.attested_domains.includes(Ee)},Ee)),t.deferred_commitment_domains.length>0&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),Y&&r.jsx("span",{title:ee,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:he?"var(--accent-subtle)":"var(--danger-subtle)",color:he?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:W}),b&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>S(t),disabled:p===t.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),re.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:re.map(([Ee,Le],fe)=>{const _e=ge.get(Ee);return r.jsxs("span",{children:[fe>0&&" · ",_e?he?r.jsxs("span",{title:`Team cap on ${Ee} is ${_e.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${_e.authorized}.`,children:[r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[Ee,"=",String(Le)]}),r.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",_e.cap]})]}):r.jsxs("span",{title:`Team cap on ${Ee} is ${_e.cap} with no approvers configured (hard cap). Authorized for ${_e.authorized}; effective ${_e.cap}.`,children:[r.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[Ee,"=",String(Le)]}),r.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",_e.cap]})]}):r.jsxs("span",{children:[Ee,"=",String(Le)]})]},Ee)})}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[oe&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>A(t.authorization_id,!K),disabled:$===t.authorization_id,title:K?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:$===t.authorization_id?K?"Unarchiving…":"Archiving…":K?"↩ Unarchive":"⊟ Archive"}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(t),children:V?"▲ Hide Details":"▼ Details"})]}),V&&r.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[re.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),r.jsx("dl",{className:"review-grid",children:re.map(([Ee,Le])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{children:String(Le)})]},Ee))})]}),(D==null?void 0:D.context)&&Object.keys(D.context).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("dl",{className:"review-grid",children:Object.entries(D.context).map(([Ee,Le])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{title:String(Le),children:Xh(Ee,Le,D.contextLabels)})]},Ee))})]}),r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),u===t.authorization_id?r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):D?r.jsx("div",{className:"gate-content-block",children:r.jsx("div",{className:"gate-content-item",children:r.jsx("div",{className:"gate-content-text",children:D.gateContent.intent})})}):r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(t.created_at).toLocaleString(),t.earliest_expiry&&` · Expires: ${new Date(t.earliest_expiry).toLocaleString()}`]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:t.authorization_id}),r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>E(t.authorization_id),children:h===t.authorization_id?"copied":"copy"})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!w&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>S(t),disabled:p===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===t.authorization_id?"Copying…":"⧉ Copy"}),!w&&(q==="active"||q==="pending")&&r.jsx("button",{className:de?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>S(t,{asEdit:!0}),disabled:p===t.authorization_id,title:de?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:de?"⚠ Re-approve":"✎ Edit"}),!w&&ce&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(t),children:"↻ Extend"}),w&&j&&q!=="revoked"?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id,w,ke),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):!w&&(q==="active"||q==="pending")?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},t.authorization_id)}function iw(){const[t,s]=f.useState([]),[a,o]=f.useState(!0),[c,u]=f.useState([]),[h,g]=f.useState(!1),[p,v]=f.useState(new Map),[y,w]=f.useState("mine"),[j,N]=f.useState("active"),[E,S]=f.useState(null),[C,T]=f.useState(null),[R,$]=oc(),[A,F]=f.useState(()=>R.get("new")==="1"),[G]=f.useState(()=>R.get("profile")),[q,de]=f.useState(()=>R.get("highlight")),[K,oe]=f.useState(null),[V,D]=f.useState({}),[ce,re]=f.useState(null),[Z,he]=f.useState(null),[ge,Y]=f.useState(null),[O,H]=f.useState(new Set),[b,L]=f.useState(null),[J,W]=f.useState(new Set),[ee,xe]=f.useState(null),[ke,ve]=f.useState(null),[ne,Ae]=f.useState(new Set),Ee=mn(),{group:Le,groupId:fe,domain:_e,mode:We,activeTeam:se}=pt(),je=(se==null?void 0:se.isAdmin)===!0,[$e,dt]=f.useState(()=>new Map),Ve=f.useCallback(()=>{o(!0),M.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),tt=f.useCallback(()=>{M.getArchivedMandates().then(ie=>W(new Set(ie))).catch(()=>{})},[]);f.useEffect(()=>{tt()},[tt]);const gt=f.useCallback(()=>{M.getEnrichedAuthorizations().then(ie=>Ae(new Set(ie.filter(Se=>Se.needsReapproval).map(Se=>Se.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{gt()},[gt]);const ft=async(ie,Se)=>{xe(ie);try{const pe=await M.setMandateArchived(ie,Se);W(new Set(pe)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(pe){alert(pe instanceof Error?pe.message:"Failed to update archive")}finally{xe(null)}},ze=f.useCallback(()=>{fe&&(g(!0),M.listTeamAuthorizations(fe).then(u).catch(()=>{}).finally(()=>g(!1)))},[fe]);Ue("attestation-changed",()=>{Ve(),je&&fe&&ze(),gt()}),f.useEffect(()=>{if(!q)return;R.get("highlight")&&(R.delete("highlight"),$(R,{replace:!0}));const ie=window.setTimeout(()=>de(null),3e3);return()=>window.clearTimeout(ie)},[]),nn(Ve,3e5),f.useEffect(()=>{y==="team"&&je&&fe&&c.length===0&&!h&&ze()},[y,je,fe,c.length,h,ze]),f.useEffect(()=>{let ie=!1;return M.listProfiles().then(Se=>{if(ie)return;const pe=Je=>Je.replace(/@.*$/,"").split("/").pop()??Je,Me=Je=>Je.split("@")[1]??"",Fe=new Map;for(const Je of Se){const Ut=pe(Je.id),er=Fe.get(Ut);(!er||Me(Je.id).localeCompare(Me(er.id),void 0,{numeric:!0})>0)&&Fe.set(Ut,Je)}v(Fe)}).catch(()=>{}),()=>{ie=!0}},[]);const P=f.useCallback(ie=>{const Se=Ut=>Ut.replace(/@.*$/,"").split("/").pop()??Ut,pe=Ut=>Ut.split("@")[1]??"",Me=p.get(Se(ie));if(!Me)return;const Fe=pe(ie),Je=pe(Me.id);if(!(!Fe||!Je))return Je.localeCompare(Fe,void 0,{numeric:!0})>0?Me:void 0},[p]);f.useEffect(()=>{if(We!=="team"||!fe)return;const ie=y==="mine"?t:c;if(ie.length===0)return;const Se=[...new Set(ie.map(pe=>pe.profile_id))].filter(pe=>!$e.has(pe));if(Se.length!==0){dt(pe=>{const Me=new Map(pe);for(const Fe of Se)Me.set(Fe,null);return Me});for(const pe of Se)M.getTeamProfileConfig(fe,pe).then(Me=>{dt(Fe=>new Map(Fe).set(pe,Me))}).catch(()=>{})}},[t,c,y,fe,We,$e]);const ae=async ie=>{if(K===ie.authorization_id){oe(null);return}oe(ie.authorization_id);const Se=ie.authorization_id;if(!(Se in V)){re(ie.authorization_id);try{const pe=await M.getGateContent(Se);D(Me=>({...Me,[Se]:pe}))}catch{D(pe=>({...pe,[Se]:null}))}finally{re(null)}}},me=ie=>{navigator.clipboard.writeText(ie).then(()=>{Y(ie),setTimeout(()=>Y(null),2e3)})},Te=async(ie,Se)=>{var pe;if(!fe){alert("No active group; cannot copy mandate.");return}ve(ie.authorization_id);try{const Me=ie.authorization_id;let Fe=V[Me]??null;Me in V||(Fe=await M.getGateContent(Me),D(bn=>({...bn,[Me]:Fe})));const Je=Object.fromEntries(Object.entries(ie.frame).filter(([bn])=>bn!=="profile"&&bn!=="path")),Ut=(Fe==null?void 0:Fe.context)??{},er=((pe=Fe==null?void 0:Fe.gateContent)==null?void 0:pe.intent)??"",rs=ie.deferred_commitment_domains.length>0?"review":"automatic",na=ie.attested_domains[0]||_e||"owner",Sn=Date.parse(ie.created_at),tr=ie.earliest_expiry?Date.parse(ie.earliest_expiry):NaN,nr=Number.isFinite(Sn)&&Number.isFinite(tr)&&tr>Sn?Math.round((tr-Sn)/1e3):void 0;let ra=ie.profile_id,$n=Je,rr=Ut,sr;const ss=await M.listProfiles(),Cr=sm(ie.profile_id,ss);if(Cr&&Cr.id!==ie.profile_id){const bn=await M.getProfile(Cr.id);ra=Cr.id,$n=im(Je,bn),rr=om(Ut,bn),sr=ie.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ra,groupId:fe,groupName:(Le==null?void 0:Le.name)??null,domain:na,isPersonal:!!(Le!=null&&Le.isPersonal),upgradedFromProfileId:sr})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:$n,context:rr,gateContent:{intent:er},templateMode:rs,templateTtl:nr})),Se!=null&&Se.asEdit?sessionStorage.setItem("agentEditReplaces",ie.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ee("/mandates/new/intent")}catch(Me){alert(Me instanceof Error?Me.message:"Failed to copy mandate")}finally{ve(null)}},ue=async(ie,Se,pe)=>{const Me=Se&&pe?`Revoke ${Se}'s ${pe} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Me)){L(ie);try{await M.revokeAttestation(ie),H(Fe=>new Set(Fe).add(ie)),M.resyncGates().catch(()=>{}),Se&&fe&&ze()}catch(Fe){alert(Fe instanceof Error?Fe.message:"Failed to revoke mandate")}finally{L(null)}}},Oe=y==="mine"?t:c,qe=y==="mine"?a:h,Ye=y==="mine"?{revokedSet:O,archivedSet:J}:{revokedSet:O},ht=ie=>bi(ie,Ye),pn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ie of Oe)pn[ht(ie)]+=1;const jn=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],nt=(()=>{const ie=new Map;for(const Se of Oe){if(ht(Se)!==j)continue;const pe=ie.get(Se.profile_id)??{count:0,review:!1};pe.count+=1,Se.deferred_commitment_domains.length>0&&(pe.review=!0),ie.set(Se.profile_id,pe)}return Array.from(ie.entries()).map(([Se,pe])=>({profileId:Se,...pe})).sort((Se,pe)=>ut(Se.profileId).localeCompare(ut(pe.profileId)))})(),kt=sw(Oe.filter(ie=>{if(ht(ie)!==j||E!==null&&ie.profile_id!==E)return!1;if(C!==null){const Se=ie.deferred_commitment_domains.length>0;if(C==="review"&&!Se||C==="auto"&&Se)return!1}return!0}),Ye,q),Et={revokedSet:O,expandedHash:K,gateCache:V,gateLoading:ce,copiedHash:ge,revokingHash:b,copyingHash:ke,profileConfigCache:$e,mode:We,activeDomain:_e,group:Le,groupId:fe,onExpand:ae,onCopyHash:me,onCopy:Te,onRevoke:ue,onExtend:he,highlightHash:q},wt={...Et,archivedSet:J,archivingHash:ee,onArchive:ft,needsReapprovalSet:ne};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Mandates"}),r.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),r.jsx("button",{className:"btn btn-primary",onClick:()=>F(!0),children:"+ New mandate"})]}),A&&r.jsx("div",{className:"modal-backdrop",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),$(R,{replace:!0}))},children:r.jsxs("div",{className:"modal",onClick:ie=>ie.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h2",{className:"modal-title",children:"New mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),$(R,{replace:!0}))},children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),r.jsx(K0,{onDismiss:()=>F(!1),preselectProfileId:G})]})]})}),je&&r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[r.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{w("mine"),N("active"),S(null),T(null),oe(null)},children:"Mine"}),r.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{w("team"),N("active"),S(null),T(null),oe(null)},children:"Team"})]}),r.jsx("div",{className:"nav-tabs",children:jn.map(ie=>r.jsxs("button",{className:`nav-tab${j===ie?" active":""}`,onClick:()=>{N(ie),S(null),T(null)},children:[ie.charAt(0).toUpperCase()+ie.slice(1)," (",pn[ie],")"]},ie))}),nt.length>0&&r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[nt.map(ie=>{const Se=E===ie.profileId;return r.jsx("button",{className:`btn btn-sm ${Se?"btn-primary":"btn-secondary"}`,onClick:()=>S(Se?null:ie.profileId),children:ut(ie.profileId)},ie.profileId)}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(ie=>{const Se=C===ie;return r.jsx("button",{className:`btn btn-sm ${Se?"btn-primary":"btn-secondary"}`,onClick:()=>T(Se?null:ie),children:ie==="auto"?"Auto":"Review"},ie)})]}),qe&&Oe.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):kt.length===0?r.jsx(Zr,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:kt.map(ie=>{const Se=y==="team"?ie:null,pe=Se!=null&&Se.owner?Se.owner.name??Se.owner.email??Se.owner.userId:void 0;return r.jsx(aw,{item:ie,newerProfile:P(ie.profile_id),ownerLabel:pe,isAdmin:je,...y==="mine"?wt:Et},ie.authorization_id)})}),Z&&r.jsx(nw,{item:Z,onClose:()=>he(null),onSuccess:()=>{he(null),Ve()}})]})}const ow=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Kt(t){const s=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Fi(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function lw(t){const{integrationId:s,toolName:a}=Fi(t);return s?`${s} · ${a}`:a}function jc(t,s){const a=s==null?void 0:s.find(o=>o.id===t);return a!=null&&a.name?a.name:t?t.toUpperCase():"the system"}function cw(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
|
|
80
80
|
`)||t.length>120)?"markdown":"text"}function uw(t,s){var h,g;const a=(s==null?void 0:s.approvalView)??{},o=((h=s==null?void 0:s.inputSchema)==null?void 0:h.properties)??{},c=[...new Set([...Object.keys(a),...Object.keys(o),...Object.keys(t)])],u=[];for(const p of c){if(!(p in t)||ow.has(p))continue;const v=t[p],y=a[p]??{},w=y.kind??cw(v),j={key:p,label:y.label??Kt(p),kind:w,value:v,hint:(g=o[p])==null?void 0:g.description};w==="money"&&y.currencyArg&&typeof t[y.currencyArg]=="string"&&(j.currency=t[y.currencyArg]),w==="profile"&&typeof v=="string"&&(j.profileRef=v),(w==="profile-limits"||w==="profile-scope")&&y.profileArg&&typeof t[y.profileArg]=="string"&&(j.profileRef=t[y.profileArg]),u.push(j)}return u}function lm(t,s){var o,c;const a=(c=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:c[t];return a?{label:a.displayName??t,hint:a.description}:{label:t}}function dw(t,s,a){if(!t||typeof t!="object"||Array.isArray(t))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,c=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(t)])],h=[];for(const g of u){if(g==="profile"||!(g in t))continue;const p=t[g],v=c[g],y=vc(v==null?void 0:v.unit),w=Array.isArray(p)?p.join(", "):String(p);h.push({key:g,label:(v==null?void 0:v.displayName)??Kt(g),value:y?`${w} ${y}`:w,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return h}function fw(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function hw(t,s){var p,v,y;const{integrationId:a,toolName:o}=fw(t.action),c=s.find(w=>w.id===a),u=(v=(p=c==null?void 0:c.toolGating)==null?void 0:p.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const h=ut(t.profileId),g=(y=t.executionContext)==null?void 0:y.action_type;return typeof g=="string"&&g?`${h} · ${g}`:`${h} · ${o}`}function mw(t,s){var c;const a=(c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields;if(!a)return"";const o=[];for(const[u,h]of Object.entries(t.executionContext??{})){if(!(u in a))continue;const g=String(h??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function pw(t,s){var c,u;if(!t)return"";const a=((c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields)??{},o=[];for(const[h,g]of Object.entries(t)){if(h==="action_type")continue;const p=String(g??"").trim();if(!p)continue;const v=((u=a[h])==null?void 0:u.displayName)??h;o.push(`${v} ${p.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function Mf(t){return t.appliesTo}function gw(t,s,a){var g,p,v,y;const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],c=t.actionType??(typeof((g=t.executionContext)==null?void 0:g.action_type)=="string"?t.executionContext.action_type:void 0),u=(p=a==null?void 0:a.boundsSchema)==null?void 0:p.fields,h=[];for(const{window:w,label:j}of o){const N=(v=t.cumulativeState)==null?void 0:v[w];if(!N)continue;let E;if(u&&s){const T=Object.entries(u).filter(([A,F])=>{if(!(A in s))return!1;const G=F.boundType;if(!G||G.kind!=="cumulative_sum"&&G.kind!=="cumulative_count"||G.window!==w)return!1;const q=Mf(F);return!q||!c||q.includes(c)}),$=(c?T.find(([,A])=>{var F;return(F=Mf(A))==null?void 0:F.includes(c)}):void 0)??(T.length===1?T[0]:void 0);$&&(E={key:$[0],isAmount:((y=$[1].boundType)==null?void 0:y.kind)==="cumulative_sum"})}const S=E?E.isAmount?N.amount:N.count:void 0,C=E?Number(s==null?void 0:s[E.key]):NaN;E&&Number.isFinite(C)?h.push(`${S} of ${C} ${j}`):h.push(`${N.count} ${N.count===1?"call":"calls"} ${j}`)}return h.join(" · ")}function yw(t,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!t||!s||!o)return[];const c=[];for(const[h,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const v=p.of;if(!(v in t)||!(h in s))continue;const y=Number(t[v]),w=Number(s[h]);if(!Number.isFinite(y)||!Number.isFinite(w))continue;const j=vc(g.unit),N=g.displayName??Kt(v),E=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();c.push({key:h,label:N,ok:y<=w,valueText:E(y),limitText:E(w)})}return c}function vw(t){return typeof t.proposalId=="string"&&t.proposalId.length>0}function xw(t){const s=ut(t),a=t.split("@")[1];return a?`${s}@${a}`:s}const Bf=new Map;function ww(t){let s=Bf.get(t);return s||(s=(async()=>{try{let a=t;if(!t.includes("@")){const o=await M.listProfiles(),c=h=>h.replace(/@.*$/,"").split("/").pop(),u=o.filter(h=>c(h.id)===t).sort((h,g)=>(g.id.split("@")[1]??"").localeCompare(h.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await M.getProfile(a)}catch{return null}})(),Bf.set(t,s)),s}function ta(t){const[s,a]=f.useState(null);return f.useEffect(()=>{let o=!0;return t&&ww(t).then(c=>{o&&a(c)}),()=>{o=!1}},[t]),s}async function Df(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function jw(t){return t.normalize("NFC").replace(/\r\n?/g,`
|
|
81
81
|
`).split(`
|
|
82
82
|
`).map(c=>c.replace(/[ \t]+$/,"")).join(`
|
|
@@ -84,7 +84,7 @@ Watch out — What should the agent avoid or be careful about?`;function f0(t,s,
|
|
|
84
84
|
`).map(s=>s.startsWith("+")&&!s.startsWith("+++")?{text:s,kind:"add"}:s.startsWith("-")&&!s.startsWith("---")?{text:s,kind:"remove"}:{text:s,kind:"context"})}function Nw(t,s){var c;if(Array.isArray(t)){if(t.length===0)return{value:"—"};if(t.every(y=>!tn(y)&&!Array.isArray(y))){if(t.every(j=>typeof j=="string"))return{lines:t};const y=t.map(j=>$t(j)).join(", "),w=t.map(j=>$t(j,!0)).join(", ");return w===y?{value:y}:{value:y,valueTitle:w}}const u=(c=s==null?void 0:s.items)==null?void 0:c.properties,h=t.map(y=>tn(y)?Sr(y,u,!1):$t(y)),g=t.map(y=>tn(y)?Sr(y,u,!0):$t(y,!0)),p=h.map((y,w)=>y===g[w]?void 0:g[w]),v=t.every(tn)?bw(t,u):void 0;return{lines:h,...p.some(y=>y!==void 0)?{lineTitles:p}:{},...v?{table:v}:{}}}if(tn(t)){const u=s==null?void 0:s.properties,h=u?Object.keys(u).filter(v=>v in t):Object.keys(t);if(h.length>0&&h.every(v=>!tn(t[v])&&!Array.isArray(t[v])))return{sublist:h.map(y=>{var S;const w=t[y],j=((S=u==null?void 0:u[y])==null?void 0:S.title)??Kt(y),N=$t(w),E=$t(w,!0);return E===N?{key:y,label:j,value:N}:{key:y,label:j,value:N,valueTitle:E}})};const g=Sr(t,u,!1),p=Sr(t,u,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof t=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:kw(t)};const a=$t(t),o=$t(t,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function Cw(t){let s;try{s=JSON.parse(t)}catch{return null}return tn(s)?s:null}function kr(t){const s=t!=null&&t.structured&&Object.keys(t.structured).length>0?t.structured:void 0;if(s)return{obj:s,schema:t==null?void 0:t.outputSchema};const a=t!=null&&t.text?Cw(t.text):null;return a?{obj:a}:null}function Ei(t){const s=kr(t);if(!s)return[];const{obj:a,schema:o}=s,c=(o==null?void 0:o.properties)??{},u=[...new Set([...Object.keys(c),...Object.keys(a)])],h=[];for(const g of u){if(!(g in a))continue;const p=c[g],v=(p==null?void 0:p.title)??Kt(g),y={key:g,label:v,...Nw(a[g],p)};p!=null&&p.description&&(y.description=p.description),h.push(y)}return h}function Ti(t,s){const a=kr(t);if(a){const c=Ei(t),u=s==null?void 0:s.fields;let h;if(u&&u.length>0){const v=new Map(c.map(y=>[y.key,y]));h=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else h=c.filter(v=>Sw(a.obj[v.key]));const g=new Set(h.map(v=>v.key)),p=c.filter(v=>!g.has(v.key));return{kind:"structured",fields:h,moreFields:p,totalFields:c.length}}const o=t==null?void 0:t.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Uf(t){return t?t.lines?`lines:${JSON.stringify(t.lines)}`:t.sublist?`sublist:${JSON.stringify(t.sublist.map(s=>[s.key,s.value]))}`:t.diffLines?`diffLines:${JSON.stringify(t.diffLines)}`:`value:${t.value??""}`:""}function pi(t){return{kind:t.length>0?"structured":"empty",fields:t,moreFields:[],totalFields:t.length}}function Ew(t,s,a){const o=kr(t),c=kr(s);if(!o&&!c){const j=(t==null?void 0:t.text)??"",N=(s==null?void 0:s.text)??"";return j===N?{approved:pi([]),current:pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const u=new Map(Ei(t).map(j=>[j.key,j])),h=new Map(Ei(s).map(j=>[j.key,j])),p=[...new Set([...u.keys(),...h.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:Uf(u.get(j))!==Uf(h.get(j))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(j=>p.includes(j)),...p.filter(j=>!a.fields.includes(j))]:p,y=v.map(j=>u.get(j)).filter(j=>j!==void 0),w=v.map(j=>h.get(j)).filter(j=>j!==void 0);return{approved:pi(y),current:pi(w),unchanged:p.length===0}}function Tw(t){const s=t==null?void 0:t.structured;if(Array.isArray(s)&&s.every(tn))return s;if(t!=null&&t.text){let a;try{a=JSON.parse(t.text)}catch{return null}if(Array.isArray(a)&&a.every(tn))return a}return null}function Oi(t){const s=$t(t),a=$t(t,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function um(t){return!t||t.status!=="ok"?[]:Ei(t.body)}function dm(t){if(!t)return"Not read.";switch(t.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function fm(t,s,a){var p;const o=um(t);if(o.length===0)return{rawId:$t(s),context:[],unresolved:dm(t)};const c=t&&t.status==="ok"?(p=kr(t.body))==null?void 0:p.obj:void 0,u=o.find(v=>["name","title","label"].includes(v.key))??o.find(v=>typeof(c==null?void 0:c[v.key])=="string"&&!v.lines&&!v.sublist&&!v.diffLines),h=a==null?void 0:a.pathPrefix,g=o.filter(v=>v.key!==(u==null?void 0:u.key)&&v.key!=="id").map(v=>{var E,S;if(!h)return v;const y=`${h}.${v.key}`,w=Ks(a==null?void 0:a.displayHints,y,v.label);if(!Qs((E=a==null?void 0:a.displayHints)==null?void 0:E.money,y)&&!Qs((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return w===v.label?v:{...v,label:w};const{value:j,valueTitle:N}=Ri(c==null?void 0:c[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:w,value:j,valueTitle:N}});return{name:u==null?void 0:u.value,rawId:$t(s),context:g}}const Rw=new Set(["id","name","title","label"]);function Qs(t,s){return!!(t!=null&&t.includes(s))}function Ks(t,s,a){var o;return((o=t==null?void 0:t.labels)==null?void 0:o[s])??a}function Iw(t,s){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:Oi(t)}function Aw(t){return typeof t!="number"&&typeof t!="string"?Oi(t):{value:`${t} %`}}function Ri(t,s,a,o){return Qs(s==null?void 0:s.money,a)?Iw(t,o):Qs(s==null?void 0:s.percent,a)?Aw(t):Oi(t)}function hm(t,s){return Qs(t==null?void 0:t.hidden,s)}function Pw(t,s,a){var h;const o=t==null?void 0:t.currencyField;if(!o)return;const c=o.indexOf(".");if(c<0){const g=s[o];return typeof g=="string"?g:void 0}const u=(h=a(o.slice(0,c)))==null?void 0:h[o.slice(c+1)];return typeof u=="string"?u:void 0}function _w(t,s,a,o){const c=t.forEach??"",u=t.attach,h=t.elements??[],g=Math.min(s.length,h.length),p=s.slice(0,g),v=h.slice(0,g),y=[...new Set(p.flatMap(S=>Object.keys(S)))].filter(S=>S!==t.sourceArg).filter(S=>!hm(a,`${c}[].${S}`)),w=new Map;if(u)for(const S of v)for(const C of um(S))w.has(C.key)||w.set(C.key,C.label);const j=u?[...w.keys()].filter(S=>!Rw.has(S)):[],N=[];u&&N.push({key:`__attach:${u}`,label:Ks(a,`${c}[].${u}`,Kt(t.sourceArg??u))});for(const S of y)N.push({key:`bound:${S}`,label:Ks(a,`${c}[].${S}`,Kt(S))});for(const S of j)N.push({key:`attached:${S}`,label:Ks(a,`${c}[].${u}.${S}`,w.get(S)??Kt(S))});const E=p.map((S,C)=>{var A;const T=v[C],R=[];if(u){const F=fm(T,t.sourceArg?S[t.sourceArg]:void 0),G=F.name?`${F.name} (${F.rawId})`:F.unresolved?`${F.rawId} — ${F.unresolved}`:F.rawId;R.push({value:G,sealed:!1})}for(const F of y){const{value:G,valueTitle:q}=Ri(S[F],a,`${c}[].${F}`,o);R.push({value:G,valueTitle:q,sealed:!0})}const $=T&&T.status==="ok"?(A=kr(T.body))==null?void 0:A.obj:void 0;for(const F of j){const G=$==null?void 0:$[F],{value:q,valueTitle:de}=G!==void 0?Ri(G,a,`${c}[].${u}.${F}`,o):{value:"—",valueTitle:void 0};R.push({value:q,valueTitle:de,sealed:!1})}return{cells:R}});return{columns:N,rows:E,...t.overflow?{overflowNote:`${t.overflow.total-t.overflow.shown} more not shown`}:{}}}function $w(t){return`${Kt(t)} — from the system`}function Lw(t){const s=$w(t.tool),a=t.result;if(!a||a.status!=="ok")return{heading:s,note:dm(a)};const o=Tw(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const c=[...new Set(o.flatMap(g=>Object.keys(g)))],u=c.map(g=>({key:g,label:Kt(g)})),h=o.map(g=>({cells:c.map(p=>({...Oi(g[p]),sealed:!1}))}));return{heading:s,table:{columns:u,rows:h}}}return{heading:s,body:Ti(a.body,{fields:t.fields})}}function zw(t,s,a){const o=new Map(s.filter(w=>w.attach&&!w.forEach).map(w=>[w.attach,w])),c=new Map(s.filter(w=>w.forEach).map(w=>[w.forEach,w])),u=s.filter(w=>!w.attach&&!w.forEach),g=Pw(a,t,w=>{var N,E;const j=(N=o.get(w))==null?void 0:N.result;return j&&j.status==="ok"?(E=kr(j.body))==null?void 0:E.obj:void 0}),p=(a==null?void 0:a.order)??[],v=[...new Set([...p,...Object.keys(t)])],y=[];for(const w of v){if(!(w in t)||hm(a,w))continue;const j=Ks(a,w,Kt(w)),N=c.get(w);if(N){const T=Array.isArray(t[w])?t[w]:[];y.push({kind:"table",key:w,label:j,table:_w(N,T,a,g)});continue}const E=o.get(w);if(E){const T=fm(E.result,t[w],{pathPrefix:w,displayHints:a,currency:g});y.push({kind:"identity",key:w,label:j,identity:T});continue}const{value:S,valueTitle:C}=Ri(t[w],a,w,g);y.push({kind:"scalar",key:w,label:j,value:S,valueTitle:C})}return{rows:y,sections:u.map(Lw)}}function Fw(t){return t.offDevice?"off-device":t.boundContent===void 0?"none":t.hasHashToCheck?t.hashVerified===!0?"verified":"mismatch":"unchecked"}function Ow(t,s){return t===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof t=="string"?Ti({text:t}):Ti({structured:t},{fields:s})}function Mw(t,s){return t?Object.entries(t).filter(([,a])=>a!=null&&a!=="").map(([a,o])=>({key:a,label:lm(a,s).label,value:String(o)})):[]}function Ii({table:t}){return t.columns.length===0?r.jsx("p",{className:"preview-note",children:"Nothing to show."}):r.jsxs(r.Fragment,{children:[r.jsxs("table",{className:"preview-table",children:[r.jsx("thead",{children:r.jsx("tr",{children:t.columns.map(s=>r.jsx("th",{children:s.label},s.key))})}),r.jsx("tbody",{children:t.rows.map((s,a)=>r.jsx("tr",{children:s.cells.map((o,c)=>r.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},c))},a))})]}),t.overflowNote&&r.jsx("p",{className:"preview-note",children:t.overflowNote})]})}function Wf({row:t}){return r.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[t.label,t.description&&r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:t.description})]})}function Bw({row:t}){return t.sublist?r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:t.sublist.map(s=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):t.diffLines?r.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:t.diffLines.map((s,a)=>r.jsx("div",{style:s.kind==="remove"?{color:"var(--danger)",textDecoration:"line-through"}:s.kind==="add"?{color:"var(--success)"}:void 0,children:s.text||" "},a))}):t.table?r.jsx(Ii,{table:t.table}):t.lines?r.jsx("div",{children:t.lines.map((s,a)=>{var o;return r.jsx("div",{title:(o=t.lineTitles)==null?void 0:o[a],children:s},a)})}):r.jsx("span",{title:t.valueTitle,children:t.value})}function Gl({rows:t}){return r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.map(s=>s.table?r.jsxs("div",{style:{gridColumn:"1 / -1"},children:[r.jsx(Wf,{row:s}),r.jsx(Ii,{table:s.table})]},s.key):r.jsxs(f.Fragment,{children:[r.jsx(Wf,{row:s}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r.jsx(Bw,{row:s})})]},s.key))})}function wi({rendered:t}){return t.kind==="empty"?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):t.kind==="text"?r.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.text}):r.jsxs(r.Fragment,{children:[r.jsx(Gl,{rows:t.fields}),t.moreFields.length>0&&r.jsxs("details",{style:{fontSize:"0.8rem"},children:[r.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",t.totalFields,")"]}),r.jsx(Gl,{rows:t.moreFields})]})]})}function mm({receipt:t,profile:s}){var j;const[a,o]=f.useState(void 0),[c,u]=f.useState(null),h=!!(t.contentHash&&t.contentBinding);if(f.useEffect(()=>{let N=!0;return o(void 0),u(null),(async()=>{let E;try{E=await M.getArchivedReceipt(t.id)}catch{N&&o(null);return}let S=null;const C=E==null?void 0:E.entry.boundContent;if(C!==void 0&&h)try{S=await cm(t.contentBinding.kind,C)===t.contentHash}catch{S=!1}N&&(u(S),o(E))})(),()=>{N=!1}},[t.id,t.contentHash,t.contentBinding,h]),a===void 0)return r.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const g=a===null,p=a==null?void 0:a.entry.boundContent,v=Fw({offDevice:g,boundContent:p,hasHashToCheck:h,hashVerified:c});if(v==="off-device")return r.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:r.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(v==="none"){const N=Mw(t.executionContext,s);return r.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[r.jsx("h4",{children:"What was done"}),N.length>0?r.jsx("dl",{className:"ticket-done-fields",children:N.map(E=>r.jsxs("div",{className:"ticket-done-field-row",children:[r.jsx("dt",{children:E.label}),r.jsx("dd",{children:E.value})]},E.key))}):r.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const y=Ow(p,(j=t.contentBinding)==null?void 0:j.fields),w=v==="verified"?"ticket-done-verified":v==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return r.jsxs("div",{className:`ticket-done-box ${w}`,"data-testid":"ticket-what-was-done","data-bound":v,children:[r.jsxs("h4",{children:["What was done",v!=="unchecked"&&r.jsxs(r.Fragment,{children:[" ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),r.jsx(wi,{rendered:y}),v==="verified"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ This exact content is bound by hash — any change after the fact would break the ticket."}),v==="mismatch"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This content does NOT match the ticket's signed hash — it may have been altered since archiving."}),v==="unchecked"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This content is kept on this device, but the ticket carries no content hash — it cannot be checked against the ticket."})]})}const Hf=500;function Kl(t){return t.length>Hf?`${t.slice(0,Hf)}…`:t}function Vf(t){return t.length?t[0].toUpperCase()+t.slice(1):t}function Dw(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function pm(t,s,a){switch(t.status){case"none":return t.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return t.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:t.message?`Preview not available — ${Kl(t.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:t.message?`Not found in your system — ${Kl(t.message)}`:"Not found in your system."};case"ok":{if("reads"in t)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${Dw(t.readAt)}.`,creation:zw(a??{},t.reads,t.display)};const o=Ti(t.body,{fields:t.fields}),c={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${t.tool} when you opened this card — the AI is not involved.`,rendered:o},u=t.version;if(u&&(c.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const h=Ew(t.body,u.currentBody,{fields:t.fields,excludeKey:u.field});c.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${Vf(u.field)} ${u.approved}`,currentLabel:`${Vf(u.field)} ${u.current}`,...h.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:h.approved,currentRendered:h.current}}}return c}}}function Uw(t,s){if(t.state!=="failed")return null;const a=t.detail?Kl(t.detail):void 0;return t.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function Ww(t){return t!==null&&t!=="loading"&&t!=="ok"&&t!=="stale"}function Hw({identity:t}){return t.unresolved?r.jsxs("span",{children:[r.jsx("span",{className:"id-raw",children:t.rawId})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",t.unresolved]})]}):r.jsxs("span",{children:[t.name&&r.jsx("span",{className:"src-tag-value src-tag-system-cell",children:t.name})," ",r.jsx("span",{className:"id-raw",children:t.rawId}),t.context.length>0&&r.jsx("span",{className:"creation-context",children:t.context.map(s=>r.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function Vw({view:t}){return r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.rows.map(s=>s.kind==="table"?null:r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:s.label}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:s.kind==="identity"?r.jsx(Hw,{identity:s.identity}):r.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:s.valueTitle,children:s.value})})]},s.key))}),t.rows.filter(s=>s.kind==="table").map(s=>r.jsxs("div",{style:{margin:"0.5rem 0"},children:[r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:s.label}),r.jsx(Ii,{table:s.table})]},s.key)),t.sections.map((s,a)=>r.jsxs("div",{className:"creation-own-section",children:[r.jsxs("h5",{children:[s.heading," ",r.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),s.table&&r.jsx(Ii,{table:s.table}),s.body&&r.jsx(Gl,{rows:s.body.fields}),s.note&&r.jsx("p",{className:"preview-note",children:s.note})]},a))]})}function gm({resp:t,systemName:s,toolArgs:a,sealed:o}){const c=pm(t,s,a??void 0),u=t.status==="ok"?c.stale?"stale":"ok":t.status;return u==="none"?r.jsx("p",{className:"preview-note","data-testid":"approval-preview","data-preview-status":"none",children:c.note}):r.jsxs("div",{className:`preview-box preview-box-${u}`,"data-testid":"approval-preview","data-preview-status":u,children:[r.jsxs("h4",{children:[c.heading,c.creation&&(o?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),c.creation&&r.jsx(Vw,{view:c.creation}),c.rendered&&r.jsx(wi,{rendered:c.rendered}),r.jsx("p",{className:"preview-note",children:c.note}),c.versionNote&&!c.stale&&r.jsx("p",{className:"preview-note",children:c.versionNote}),c.stale&&r.jsxs("div",{className:"preview-stale",children:[r.jsx("h5",{children:c.stale.heading}),c.stale.unchangedNote?r.jsx("p",{className:"preview-note",children:c.stale.unchangedNote}):r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[r.jsx("dt",{children:c.stale.approvedLabel}),r.jsx("dd",{children:r.jsx(wi,{rendered:c.stale.approvedRendered})}),r.jsx("dt",{children:c.stale.currentLabel}),r.jsx("dd",{children:r.jsx(wi,{rendered:c.stale.currentRendered})})]})]})]})}function Gw({proposalId:t,systemName:s,toolArgs:a,sealed:o,onTone:c,onData:u}){const[h,g]=f.useState(null),[p,v]=f.useState(!1);return f.useEffect(()=>{let y=!0;return g(null),v(!1),M.getProposalPreview(t).then(w=>{y&&g(w)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[t]),f.useEffect(()=>{if(p){c==null||c("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!h){u==null||u(null);return}const y=pm(h,s,a??void 0);c==null||c(h.status==="ok"?y.stale?"stale":"ok":h.status),u==null||u(h)},[h,p,s,c,u]),p?r.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[r.jsx("h4",{children:"Preview not available"}),r.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):h?r.jsx(gm,{resp:h,systemName:s,toolArgs:a,sealed:o}):r.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]})}const _l=6;function Ai(t){if(!t)return;const s=Date.parse(t);return Number.isNaN(s)?t:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Kw(t){if(!t)return{first:""};const s=t.split(`
|
|
85
85
|
`);return s.length<=_l?{first:t}:{first:s.slice(0,_l).join(`
|
|
86
86
|
`),more:s.slice(_l).join(`
|
|
87
|
-
`)}}const qw="Linked by the AI",Yw="linked automatically — this action already carried a reference to it";function Jw(t){if(t.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(t.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${t.reason}).`,chain:[]};if(t.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=Kw(t.body),o=[t.connector,t.kind,t.author?`from ${t.author}`:void 0,Ai(t.at)].filter(c=>!!c);return{state:"ok",implicit:t.implicit,tag:qw,...t.implicit?{implicitNote:Yw}:{},metaLine:o.join(" · "),title:t.title,bodyFirst:s,bodyMore:a,attribution:t.author?`— from ${t.author}, not checked`:void 0,chain:t.chain.map(c=>({...c,at:Ai(c.at)}))}}const Ds="Read by the gateway — same customer, not matched to this request";function Qw(t){const s=t.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${t.matchedKeyValue} (${s})`}function Xw(t){var c;const s=!!t.aiWritten,a=s?"Activity":t.type??t.kind??"Entry";let o;if(s){const u=((c=t.aiWritten)==null?void 0:c.at)!==void 0?Ai(new Date(t.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=t.author?`— from ${t.author}, not checked`:"— not checked";return{headLabel:a,at:Ai(t.at),title:t.title,body:t.body,attribution:o,aiWritten:s}}function Zw(t){if(t.status==="no_customer_link")return{state:"no_customer_link",label:Ds,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(t.status==="no_match")return{state:"no_match",label:Ds,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(t.status==="unreachable")return{state:"unreachable",label:Ds,note:`${t.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=t.matches.flatMap(c=>c.items.map(u=>({it:u,m:c}))).sort((c,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(c.it.at??"")||0)).map(({it:c})=>Xw(c)),a=t.matches.map(Qw),o=t.unreachableConnectorIds.length>0?`${t.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:Ds,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:Ds,note:"",matchNotes:a,items:s,unreachableNote:o}}function ym({resp:t}){const s=Jw(t.request),a=Zw(t.history);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":s.state,children:[r.jsxs("h4",{children:["Request",s.tag&&r.jsx("span",{className:"src-tag src-tag-ai",children:s.tag})]}),s.state!=="ok"?r.jsx("p",{className:"au10-req-state",children:s.note}):r.jsxs(r.Fragment,{children:[s.implicitNote&&r.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:s.implicitNote}),s.metaLine&&r.jsx("p",{className:"au10-req-meta",children:s.metaLine}),s.title&&r.jsx("p",{className:"au10-req-meta",children:r.jsx("b",{children:s.title})}),s.bodyFirst&&r.jsx("p",{className:"au10-req-quote",children:s.bodyFirst}),s.bodyMore&&r.jsxs("details",{children:[r.jsx("summary",{children:"Show more"}),r.jsx("p",{className:"au10-req-quote",children:s.bodyMore})]}),s.attribution&&r.jsx("p",{className:"au10-req-attrib",children:s.attribution}),s.chain.length>0&&r.jsxs("details",{className:"au10-chain",children:[r.jsxs("summary",{children:["Earlier in this thread (",s.chain.length,")"]}),s.chain.map((o,c)=>r.jsxs("div",{className:"au10-chain-item",children:[(o.author||o.at)&&r.jsxs("p",{className:"au10-req-meta",children:[o.author?r.jsxs(r.Fragment,{children:["from ",r.jsx("b",{children:o.author})]}):null,o.author&&o.at?" · ":"",o.at]}),o.title&&r.jsx("p",{className:"au10-req-meta",children:r.jsx("b",{children:o.title})}),o.body&&r.jsx("p",{className:"au10-req-quote",children:o.body}),o.author&&r.jsxs("p",{className:"au10-req-attrib",children:["— from ",o.author,", not checked"]})]},c))]})]})]}),r.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[r.jsxs("h4",{children:["History",r.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),a.state!=="ok"?r.jsx("p",{className:"au10-hist-state",children:a.note}):r.jsxs(r.Fragment,{children:[a.matchNotes.map((o,c)=>r.jsx("p",{className:"preview-note",style:{marginTop:0},children:o},c)),r.jsx("ul",{className:"au10-hist-list",children:a.items.map((o,c)=>r.jsxs("li",{className:"au10-hist-item",children:[r.jsxs("div",{className:"au10-hist-head",children:[r.jsxs("span",{children:[o.aiWritten&&r.jsx("span",{className:"au10-dot au10-dot-ai"}),o.headLabel]}),r.jsx("span",{children:o.at})]}),o.title&&r.jsx("div",{className:"au10-hist-title",children:o.title}),o.body&&r.jsx("div",{className:"au10-hist-body",children:o.body}),r.jsx("p",{className:"au10-hist-attrib",children:o.attribution})]},c))}),a.unreachableNote&&r.jsx("p",{className:"preview-note",children:a.unreachableNote})]})]})]})}function ej({proposalId:t,onData:s}){const[a,o]=f.useState(null),[c,u]=f.useState(!1);return f.useEffect(()=>{let h=!0;return o(null),u(!1),M.getProposalRequestContext(t).then(g=>{h&&o(g)}).catch(()=>{h&&u(!0)}),()=>{h=!1}},[t]),f.useEffect(()=>{s==null||s(c?null:a)},[a,c,s]),c||!a?null:r.jsx(ym,{resp:a})}function tj(t,s,a){const o=Object.entries(t??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,g])=>g.by===s)??(a?o.find(([g])=>g===`domain:${a}`):void 0),h=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:h}}function nj(t){return t.offDevice?"off-device":t.recordedHash?t.localHash===t.recordedHash?"verified":"mismatch":"unchecked"}function rj(t){if(!(t<=0))return`${t} other approver${t===1?"":"s"} recorded their own.`}function sj(t){return new Date(t).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function vm({proposalId:t,tool:s,manifests:a}){const{user:o,domain:c}=pt(),[u,h]=f.useState(null),[g,p]=f.useState(null),[v,y]=f.useState(!1);if(f.useEffect(()=>{let $=!0;return h(null),p(null),y(!1),Promise.all([M.getShownSnapshot(t),M.getProposal(t)]).then(([A,F])=>{$&&(h(A),p(F))}).catch(()=>{$&&y(!0)}),()=>{$=!1}},[t]),v||!u||!g)return null;const w=u.status==="off_device",{entry:j,otherCount:N}=tj(g.shownHashes,(o==null?void 0:o.id)??"",c),E=nj({offDevice:w,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=rj(N);if(w)return r.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[r.jsx("h4",{children:"What you saw"}),r.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:C}=u,{integrationId:T}=Fi(s),R=jc(T,a);return r.jsxs("div",{className:`ticket-box ticket-shown-${E}`,"data-testid":"au10-shown","data-shown-status":E,children:[r.jsxs("h4",{children:["What you saw (read ",sj(C.readAt),")",E==="verified"&&r.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),E==="mismatch"&&r.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),r.jsx(gm,{resp:C.preview,systemName:R,toolArgs:C.toolArgs,sealed:C.sealed}),r.jsx(ym,{resp:C.requestContext}),E==="verified"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),E==="mismatch"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),E==="unchecked"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),S&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral","data-testid":"au10-shown-others",children:S})]})}function Us({label:t,children:s}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{className:"receipt-row-label",children:t}),r.jsx("dd",{className:"receipt-row-value",children:s})]})}function aj({receipt:t,manifests:s,localAuth:a,localUnavailable:o,signature:c,grantTitle:u,ownerLabel:h,spUrl:g,formatDate:p,onOpenComplete:v}){var R;const y=ta(t.profileId),w=mw(t,y),j=pw(a==null?void 0:a.context,y),N=gw(t,(a==null?void 0:a.bounds)??t.limits,y),E=a==null?void 0:a.intent,S=Nr(t.profileId).testSetup||zi(t.action),[C,T]=f.useState(!1);return r.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{className:"receipt-head",children:[r.jsx("span",{className:"receipt-what",children:hw(t,s)}),r.jsx("span",{className:"receipt-tag",children:vw(t)?"review":"automatic"}),t.contentHash&&r.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(R=t.contentBinding)!=null&&R.fields?`The ticket binds: ${t.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),S&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsx("span",{className:"auth-card-time",children:p(t.timestamp)})]}),w&&r.jsx("div",{className:"receipt-scope",children:w}),r.jsx(mm,{receipt:t,profile:y}),t.proposalId&&r.jsx(vm,{proposalId:t.proposalId,tool:t.action,manifests:s}),r.jsxs("dl",{className:"receipt-rows",children:[r.jsxs(Us,{label:"mandate",children:[r.jsx("strong",{children:u||xw(t.profileId)})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),h&&r.jsx(Us,{label:"owner",children:h}),j&&r.jsxs(Us,{label:"allowed",children:[j," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),N&&r.jsxs(Us,{label:"used",children:[r.jsx("span",{className:"receipt-num",children:N})," ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),r.jsx(Us,{label:"intent",children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`intent-text${C?"":" intent-clamped"}`,children:E}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>T(!C),children:C?"Show less":"Show full intent"})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):r.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),r.jsxs("div",{className:"receipt-foot",children:[c==="valid"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),c==="valid-legacy"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),c==="invalid"&&r.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),r.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),g&&r.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",r.jsx("a",{className:"receipt-link",href:`${g}/r/${t.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),r.jsxs("details",{className:"receipt-more",children:[r.jsx("summary",{children:"Raw"}),r.jsxs("div",{className:"receipt-kv",children:[r.jsxs("div",{children:["ticket · ",t.id]}),r.jsxs("div",{children:["action · ",t.action]}),r.jsxs("div",{children:["profile · ",t.profileId]}),t.authorizationId&&r.jsxs("div",{children:["mandate · ",t.authorizationId]}),Object.keys(t.executionContext??{}).length>0&&r.jsxs("div",{children:["scope ·"," ",Object.entries(t.executionContext).map(([$,A])=>`${$}=${A}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&r.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&r.jsxs("div",{children:["scope hash · ",a.contextHash]}),t.contentHash&&r.jsxs("div",{children:["content · ",t.contentHash]}),t.proposalId&&r.jsxs("div",{children:["proposal · ",t.proposalId]}),r.jsxs("div",{children:["signature · ",t.signature]})]})]})]})]})}function ij({receipt:t,onClose:s}){const[a,o]=f.useState(null),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(!0),[y,w]=f.useState(!1);f.useEffect(()=>{let C=!1;return v(!0),M.getArchivedReceipt(t.id).then(T=>{C||(o(T),u(T?"local":"authority-server"),g((T==null?void 0:T.signature)??null))}).catch(()=>{C||u("authority-server")}).finally(()=>{C||v(!1)}),()=>{C=!0}},[t.id]);const j=a?a.entry:{receipt:t},N=JSON.stringify(j,null,2);function E(){const C=URL.createObjectURL(new Blob([N],{type:"application/json"})),T=document.createElement("a");T.href=C,T.download=`suveren-ticket-${t.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(C)}async function S(){try{await navigator.clipboard.writeText(N),w(!0),setTimeout(()=>w(!1),2e3)}catch{w(!1)}}return r.jsx("div",{className:"modal-backdrop",onClick:C=>C.target===C.currentTarget&&s(),children:r.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Complete ticket"}),r.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[h==="valid"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),h==="valid-legacy"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),h==="invalid"&&r.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:p?"Loading…":c==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),r.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:N})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Download"}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function oj(t){return new Date(t*1e3).toLocaleString()}function lj(t,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return t.timestamp>=o}function cj(t,s){if(!s)return!0;const a=s.toLowerCase();return t.profileId.toLowerCase().includes(a)||ut(t.profileId).toLowerCase().includes(a)||t.path.toLowerCase().includes(a)||t.action.toLowerCase().includes(a)||t.attestationHash.toLowerCase().includes(a)||t.id.toLowerCase().includes(a)||JSON.stringify(t.executionContext).toLowerCase().includes(a)}function Gf(t,s){const a=new Map(t.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,c)=>c.timestamp-o.timestamp)}function uj(){const{activeTeam:t,groupId:s}=pt(),a=(t==null?void 0:t.isAdmin)===!0,[o,c]=f.useState("mine"),[u,h]=f.useState([]),[g,p]=f.useState([]),[v,y]=f.useState(""),[w,j]=f.useState(!0),[N,E]=f.useState({}),[S,C]=f.useState(new Set),[T,R]=f.useState(""),[$,A]=f.useState(new Set),[F,G]=f.useState(new Set),[q,de]=f.useState("all"),[K,oe]=f.useState(!1),[V,D]=f.useState(!1),[ce,re]=f.useState(null),[Z,he]=f.useState({}),[ge,Y]=f.useState(!1),[O,H]=f.useState({}),[b,L]=f.useState({}),[J,W]=f.useState(null),[ee,xe]=f.useState(null),[ke,ve]=f.useState(!1),[ne,Ae]=f.useState(!1),Ee=f.useRef(""),Le=f.useCallback(P=>o==="team"&&a&&s?M.listTeamReceiptsPage(s,{before:P,limit:200}):M.getMyReceiptsPage({before:P,limit:200}),[o,a,s]),fe=f.useCallback(()=>{const P=o==="team"?`team:${s}`:"mine",ae=Ee.current!==P;Ee.current=P,j(!0),Ae(!1),Le().then(me=>{h(Te=>ae?me.receipts:Gf(Te,me.receipts)),xe(Te=>ae?me.nextBefore:Te??me.nextBefore)}).catch(()=>{ae&&h([]),Ae(!0)}).finally(()=>j(!1))},[Le,o,s]),_e=f.useCallback(()=>{!ee||ke||(ve(!0),Ae(!1),Le(ee).then(P=>{h(ae=>Gf(ae,P.receipts)),xe(P.nextBefore)}).catch(()=>Ae(!0)).finally(()=>ve(!1)))},[ee,ke,Le]);nn(fe,12e4),f.useEffect(()=>{M.getIntegrationManifests().then(({manifests:P})=>p(P)).catch(()=>{}),fetch("/health").then(P=>P.json()).then(P=>{typeof P.spUrl=="string"&&y(P.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{M.getLocalAuthorizations().then(({authorizations:P,signatures:ae})=>{he(P),H(ae),Y(!1)}).catch(()=>{he({}),H({}),Y(!0)}),M.getMyAttestations().then(P=>{const ae={};for(const me of P)me.authorization_id&&me.title&&(ae[me.authorization_id]=me.title);L(ae)}).catch(()=>{})},[]),f.useEffect(()=>{o!=="team"||Object.keys(N).length>0||M.listUsers().then(P=>{const ae={};for(const me of P)ae[me.id]={name:me.name,email:me.email};E(ae)}).catch(()=>{})},[o,N]);const Ue=f.useMemo(()=>{const P=new Set;for(const ae of u)P.add(ut(ae.profileId));return[...P].sort()},[u]),se=f.useMemo(()=>{const P=new Set;for(const ae of u)P.add(ae.action);return[...P].sort()},[u]),je=f.useMemo(()=>{if(o!=="team")return[];const P=new Set;for(const ae of u)ae.userId&&P.add(ae.userId);return[...P].map(ae=>{var me;return{id:ae,label:(me=N[ae])!=null&&me.name?`${N[ae].name} (${N[ae].email})`:ae}}).sort((ae,me)=>ae.label.localeCompare(me.label))},[o,u,N]),$e=f.useMemo(()=>u.filter(P=>!(!cj(P,T)||$.size>0&&!$.has(ut(P.profileId))||F.size>0&&!F.has(P.action)||S.size>0&&P.userId&&!S.has(P.userId)||!lj(P,q))),[u,T,$,F,S,q]),dt=$.size>0||F.size>0||S.size>0||q!=="all";function He(P){A(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function tt(P){G(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function gt(P){C(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function ft(){A(new Set),G(new Set),C(new Set),de("all"),R("")}async function ze(){D(!0),re(null);try{const{bundle:P,filename:ae}=await M.fetchEvidenceBundle(),me=URL.createObjectURL(new Blob([JSON.stringify(P,null,2)],{type:"application/json"})),Te=document.createElement("a");Te.href=me,Te.download=ae,Te.click(),URL.revokeObjectURL(me);const ue=P.sources??{};ue.authorityServer?ue.local||re(`Downloaded Authority Server history only — ${ue.localError??"local archive unavailable."}`):re(`Downloaded local evidence only — ${ue.asError??"Authority Server export unavailable."}`)}catch(P){re(`Export failed: ${P instanceof Error?P.message:String(P)}`)}finally{D(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Tickets"}),r.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),r.jsx("button",{className:"btn btn-secondary",onClick:ze,disabled:V,children:V?"Preparing…":"Download evidence"})]}),ce&&r.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:ce}),a&&r.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(P=>r.jsx("button",{onClick:()=>c(P),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===P?"2px solid var(--accent)":"2px solid transparent",color:o===P?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===P?600:500},children:P==="mine"?"Mine":"Team"},P))}),r.jsxs("div",{className:"search-filter-bar",children:[r.jsxs("div",{className:"search-input-wrap",children:[r.jsx("span",{className:"search-icon",children:"⌕"}),r.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:T,onChange:P=>R(P.target.value)}),T&&r.jsx("button",{className:"search-clear",onClick:()=>R(""),children:"×"})]}),r.jsxs("button",{className:`btn btn-sm btn-secondary${K?" active":""}`,onClick:()=>oe(!K),children:["Filters",dt?` (${$.size+F.size+(q!=="all"?1:0)})`:""]})]}),K&&r.jsxs("div",{className:"filter-panel",children:[Ue.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Profile"}),r.jsx("div",{className:"filter-chips",children:Ue.map(P=>r.jsx("button",{className:`filter-chip${$.has(P)?" selected":""}`,onClick:()=>He(P),children:P},P))})]}),se.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Action"}),r.jsx("div",{className:"filter-chips",children:se.map(P=>r.jsx("button",{className:`filter-chip${F.has(P)?" selected":""}`,onClick:()=>tt(P),children:P},P))})]}),o==="team"&&je.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Owner"}),r.jsx("div",{className:"filter-chips",children:je.map(P=>r.jsx("button",{className:`filter-chip${S.has(P.id)?" selected":""}`,onClick:()=>gt(P.id),children:P.label},P.id))})]}),r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Time range"}),r.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([P,ae])=>r.jsx("button",{className:`filter-chip${q===P?" selected":""}`,onClick:()=>de(P),children:ae},P))})]})]}),dt&&r.jsxs("div",{className:"active-filters",children:[[...$].map(P=>r.jsxs("span",{className:"active-chip",onClick:()=>He(P),children:[P," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)),[...F].map(P=>r.jsxs("span",{className:"active-chip",onClick:()=>tt(P),children:[P," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)),[...S].map(P=>{const ae=N[P],me=ae?ae.name:P;return r.jsxs("span",{className:"active-chip",onClick:()=>gt(P),children:[me," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)}),q!=="all"&&r.jsxs("span",{className:"active-chip",onClick:()=>de("all"),children:[q==="1d"?"Today":q==="7d"?"7 days":"30 days"," ",r.jsx("span",{className:"chip-remove",children:"×"})]}),r.jsx("button",{className:"clear-filters",onClick:ft,children:"Clear all"})]}),ne&&r.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:r.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),w&&u.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.length===0?r.jsx(Zr,{icon:"⌕",title:u.length===0?"No tickets in the last 30 days":"No matching tickets",text:u.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:$e.length===u.length?`${u.length} ticket${u.length!==1?"s":""}`:`${$e.length} of ${u.length} tickets`}),r.jsx("div",{className:"timeline",children:$e.map(P=>{const ae=P.userId?N[P.userId]:void 0;return r.jsx("div",{className:"timeline-event",children:r.jsx(aj,{receipt:P,manifests:g,localAuth:P.authorizationId?Z[P.authorizationId]:void 0,localUnavailable:ge,signature:O[P.id],grantTitle:P.authorizationId?b[P.authorizationId]:null,ownerLabel:o==="team"&&P.userId?ae?`${ae.name} (${ae.email})`:P.userId:null,spUrl:v,formatDate:oj,onOpenComplete:()=>W(P)})},P.id)})})]}),J&&r.jsx(ij,{receipt:J,onClose:()=>W(null)}),ee&&r.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:_e,disabled:ke,children:ke?"Loading…":"Load older"})})]})}function dj(){const[t,s]=f.useState(null),[a,o]=f.useState({}),[c,u]=f.useState(!1),h=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:p})=>{s(p),u(!1)}).catch(()=>u(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,6e4),f.useEffect(()=>{if(!t)return;const p=[...new Set(t.map(v=>v.profile).filter(v=>!!v))].filter(v=>!(v in a));p.length!==0&&Promise.all(p.map(v=>M.getProfile(v).catch(()=>null))).then(v=>{o(y=>{const w={...y};return p.forEach((j,N)=>{v[N]&&(w[j]=v[N])}),w})})},[t,a]),c)return r.jsx(Zr,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const g=$h(t,Date.now());return r.jsxs("div",{className:"blocked-page",children:[r.jsxs("div",{className:"page-header blocked-header",children:[r.jsx("h1",{className:"page-title",children:"Blocked actions"}),r.jsxs("span",{className:"blocked-today",children:[g," today · nothing ran"]})]}),t.length===0?r.jsx(Zr,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):r.jsx("div",{className:"blocked-list",children:t.map((p,v)=>{const y=Gv(p,p.profile?a[p.profile]:void 0);return r.jsxs("div",{className:"blocked-row","data-kind":Ys(p),children:[r.jsx("span",{className:`blocked-dot blocked-dot-${Ys(p)}`,"aria-hidden":"true"}),r.jsxs("div",{className:"blocked-row-main",children:[r.jsx("div",{className:"blocked-title",children:y.title}),r.jsx("div",{className:"blocked-sentence",children:y.sentence}),r.jsx("div",{className:"blocked-source",children:y.sourceLine}),r.jsxs("details",{children:[r.jsx("summary",{children:"What you can do"}),r.jsx("div",{className:"blocked-advice",children:y.whatYouCanDo})]})]}),r.jsx("div",{className:"blocked-when",children:new Date(p.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},`${p.ts}-${v}`)})})]})}const fj={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function hj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{s(await M.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),u(null);try{await M.setAutostart(!t.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await M.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[t,a,h]);if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read autostart state: ${c}`:"Checking…"})]});const p=fj[t.platform]??"a login service";return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:t.supported?r.jsxs(r.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):t.reason})]}),t.supported&&r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.installed,className:t.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":t.installed?"Turn off":"Turn on"})]}),t.supported&&r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",r.jsx("strong",{children:t.installed?"On — starts from your next login":"Off"})]}),t.supported&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",r.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:c})]})}function mj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{const p=await M.getGatewaySettings();s(p.desktopNotifications),u(null)}catch(p){u(p instanceof Error?p.message:"Could not read notification setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(t===null||a)){o(!0),u(null);try{const p=await M.setGatewaySettings({desktopNotifications:!t});s(p.desktopNotifications)}catch(p){u(p instanceof Error?p.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]);return t===null?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]}):r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t,className:t?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t?"Turn off":"Turn on"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const Kf={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function pj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{s(await M.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!t||a)){o(!0),u(null);try{s(await M.setIdentityDisclosure(!t.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]),p=r.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]});const v=t.verified&&t.name?`${t.name} — ${t.method==="as_vouched"?`${Kf.as_vouched} ${t.verifier}`:Kf[t.method??""]??t.method}`:null;return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[p,r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[t.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.always,className:t.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t.always?"Turn off":"Always show my name"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const gj={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function yj(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=lc();return t?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",r.jsx("strong",{children:t}),a&&s?r.jsxs(r.Fragment,{children:[" — ",r.jsx("strong",{children:s})," is available"]}):null]}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[gj[o]??"Update checking is unavailable",o==="dev"&&r.jsx(r.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function ql({title:t}){return r.jsxs("span",{className:"it-locked-badge",title:t,children:[r.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function qf(t){return t===!0}function vj(){const[t,s]=f.useState(null),[a,o]=f.useState(null);f.useEffect(()=>{let h=!1;return M.getAsPairing().then(g=>{h||s(g)}).catch(g=>{h||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{h=!0}},[]);const c=qf(t==null?void 0:t.asUrlLockedByPolicy),u=qf(t==null?void 0:t.pinTlsLockedByPolicy);return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),c&&r.jsx(ql,{})]}),!t&&!a&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&r.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:a}),t&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"URL:"})," ",r.jsx("code",{children:t.asUrl})]}),t.paired&&t.fingerprint?r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"Key fingerprint:"})," ",r.jsx("code",{children:t.fingerprint}),r.jsx("br",{}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(t.tlsPinFingerprint||t.pinTlsEnabled)&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"TLS certificate pin:"})," ",u&&r.jsx(ql,{title:"TLS pinning is set by your IT policy"})," ",t.tlsPinFingerprint?r.jsx("code",{children:t.tlsPinFingerprint}):r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",t.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),r.jsx("br",{}),r.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[t.pinTlsEnabled?r.jsxs(r.Fragment,{children:["TLS pinning is ON",u?r.jsx(r.Fragment,{children:", set by your organization's IT policy"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):r.jsxs(r.Fragment,{children:["Captured at sign-in; not currently enforced",u?r.jsx(r.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),c?r.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):r.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",r.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function xj(){const{simulation:t,locked:s}=Hh();return s?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',t!==null&&r.jsxs(r.Fragment,{children:[" ","Currently ",r.jsx("strong",{children:t?"ON":"OFF"}),t?" — real systems are not reachable from this gateway.":"."]})]})]}),r.jsx(ql,{})]}),r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",t!==null?` (currently ${t?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const wj={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},Ws=["AI Assistant","Authority Server","This computer","Security","Version"],Hs={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function jj(){const[t,s]=f.useState(""),[a,o]=f.useState("openrouter"),[c,u]=f.useState("openai-compatible"),[h,g]=f.useState("https://openrouter.ai/api/v1"),[p,v]=f.useState("google/gemma-4-31b-it"),[y,w]=f.useState(""),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=f.useState(!1),[R,$]=f.useState(null),[A,F]=f.useState([]),[G,q]=f.useState(!1),[de,K]=f.useState(null),[oe,V]=f.useState(""),D=f.useCallback(O=>{s(O),setTimeout(()=>s(""),3e3)},[]),ce=f.useCallback(async(O,H,b)=>{q(!0),K(null);try{const L=await M.aiModels({provider:O,endpoint:H,...b?{apiKey:b}:{}});L.ok&&L.models.length>0?(F(L.models),K(`${L.models.length} models available`)):(F([]),K(L.message||"No models returned — using defaults"))}catch(L){F([]),K(L instanceof Error?L.message:"Failed to load models")}finally{q(!1)}},[]),re=f.useCallback(async()=>{try{const O=await M.getCredential("ai-config");if(N(O.configured),O.configured&&O.fields){const H=O.fields.provider||"openai-compatible",b=O.fields.endpoint||"";O.fields.provider&&u(H),O.fields.endpoint&&g(b),O.fields.model&&v(O.fields.model),b.includes("openai.com")?o("openai"):b.includes("groq.com")?o("groq"):b.includes("together.xyz")?o("together"):b.includes("openrouter.ai")?o("openrouter"):o("ollama"),b&&ce(H,b)}}catch{}},[ce]);f.useEffect(()=>{re()},[re]);const Z=O=>{o(O),F([]),K(null),V("");const H=wj[O];H&&(u(H.provider),g(H.endpoint),v(""),ce(H.provider,H.endpoint,y||void 0))},he=()=>ce(c,h,y||void 0),ge=async()=>{S(!0);try{await M.setCredential("ai-config",{provider:c,endpoint:h,model:p,...y?{apiKey:y}:{}}),N(!0),D("AI configuration saved!")}catch{D("Failed to save AI config")}finally{S(!1)}},Y=async()=>{T(!0),$(null);try{const O=await M.aiTest({provider:c,endpoint:h,model:p,...y?{apiKey:y}:{}});$(O.ok?`OK: ${O.message}`:`Failed: ${O.message}`)}catch(O){$(`Error: ${O instanceof Error?O.message:"Unknown"}`)}finally{T(!1)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Settings"}),r.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),t&&r.jsx("div",{className:"alert alert-success",children:t}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[0]}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",children:"Configuration"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),j&&r.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[r.jsx("span",{className:"status-banner-icon",children:"✓"}),r.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:"Provider Preset"}),r.jsxs("select",{className:"form-input",value:a,onChange:O=>Z(O.target.value),children:[r.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),r.jsx("option",{value:"ollama",children:"Ollama (local)"}),r.jsx("option",{value:"openai",children:"OpenAI"}),r.jsx("option",{value:"groq",children:"Groq"}),r.jsx("option",{value:"together",children:"Together"})]})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("label",{className:"form-label",children:["API Key ",c==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),r.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:O=>w(O.target.value),onBlur:()=>{y.trim()&&ce(c,h,y.trim())},placeholder:j?"••••••••••••••••":"sk-... (not needed for Ollama)"}),r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsx("label",{className:"form-label",children:"Model"}),r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:he,disabled:G,title:"Re-fetch the model list from the provider",children:G?"Loading…":"↻ Refresh"})]}),A.length===0?r.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:G?"Loading models…":c==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const O=A,H=O.includes(p),b=O.length>12,L=oe.trim().toLowerCase();let J=L?O.filter(W=>W.toLowerCase().includes(L)):O;return H&&!J.includes(p)&&(J=[p,...J]),r.jsxs(r.Fragment,{children:[b&&r.jsx("input",{className:"form-input",value:oe,onChange:W=>V(W.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),r.jsxs("select",{className:"form-input",value:H?p:"__unset__",onChange:W=>v(W.target.value==="__unset__"?"":W.target.value),children:[r.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),J.map(W=>r.jsx("option",{value:W,children:W},W)),L&&J.length===0&&r.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",oe,"”"]})]})]})})(),de&&r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:de})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ge,disabled:E||!p.trim(),title:p.trim()?void 0:"Select a model first",children:E?"Saving...":"Save & Encrypt"}),j&&r.jsx("button",{className:"btn btn-ghost",onClick:Y,disabled:C,children:C?"Testing...":"Test Connection"})]}),R&&r.jsx("div",{className:`alert ${R.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:R})]}),r.jsx(Sj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[1]}),r.jsx(vj,{}),r.jsx(pj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[2]}),r.jsx(hj,{}),r.jsx(mj,{}),r.jsx(xj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[3]}),r.jsx("div",{className:"card",style:{padding:"1.5rem"},children:r.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"Every tool call verified against your mandate bounds"}),r.jsx("li",{children:"Credentials never exposed to agents through MCP"}),r.jsx("li",{children:"Every action produces a signed ticket"})]})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),r.jsx("li",{children:"For best security, run agents in sandboxed environments"}),r.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),r.jsxs("section",{children:[r.jsx("h2",{style:Hs,children:Ws[4]}),r.jsx(yj,{})]})]})}function Sj(){const[t,s]=f.useState(null),[a,o]=f.useState({intent:"",context:""}),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState(!1),j=f.useCallback(async()=>{if(!y)try{const S=await M.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){g(S instanceof Error?S.message:"Failed to load prompts")}},[y]),N=async S=>{if(t){u(S),g(null);try{const C=a[S],T=C.trim()===t[S].default.trim()?"":C;await M.setAIPrompt(S,T);const R=await M.getAIPrompts();s(R),o({intent:R.intent.current,context:R.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(C){g(C instanceof Error?C.message:"Save failed")}finally{u(null)}}},E=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await M.setAIPrompt(S,"");const C=await M.getAIPrompts();s(C),o({intent:C.intent.current,context:C.context.current})}catch(C){g(C instanceof Error?C.message:"Revert failed")}finally{u(null)}}};return r.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&j()},children:[r.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),h&&r.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:h}),!y&&!h&&r.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(Yf,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:t.intent,draft:a.intent,onChange:S=>o(C=>({...C,intent:S})),onSave:()=>N("intent"),onRevert:()=>E("intent"),saving:c==="intent",justSaved:p==="intent"}),r.jsx(Yf,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:t.context,draft:a.context,onChange:S=>o(C=>({...C,context:S})),onSave:()=>N("context"),onRevert:()=>E("context"),saving:c==="context",justSaved:p==="context"})]})]})}function Yf({kind:t,label:s,description:a,state:o,draft:c,onChange:u,onSave:h,onRevert:g,saving:p,justSaved:v}){const y=c!==o.current;return r.jsxs("section",{style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),r.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),r.jsx("textarea",{className:"form-textarea",value:c,onChange:w=>u(w.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:h,disabled:p||!y,children:p?"Saving…":"Save"}),o.overridden&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),y&&!p&&!v&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),r.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:o.default})]}),r.jsx("span",{style:{display:"none"},children:t})]})}function bj(t){return t.proposalId?"review":"automatic"}function Jf(t,s,a={}){const o=a.status??"pending",c=a.includeAutonomous??!1,u=[];for(const h of t)o==="pending"&&h.status!=="pending"||a.profile&&h.profileId!==a.profile||u.push({kind:"proposal",id:h.id,sortTimestamp:h.createdAt,commitmentMode:"review",profileId:h.profileId,proposal:h});if(o==="all")for(const h of s){const g=bj(h);!c&&g==="automatic"||a.profile&&h.profileId!==a.profile||u.push({kind:"receipt",id:h.id,sortTimestamp:h.timestamp,commitmentMode:g,profileId:h.profileId,receipt:h})}return u.sort((h,g)=>g.sortTimestamp-h.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const kj=["https://","http://"];function xm(t,s){return t!=null&&t.length?t.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(c,u)=>{const h=s[u];return typeof h=="string"||typeof h=="number"?String(h):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:kj.some(c=>o.toLowerCase().startsWith(c))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function wm(t,s){const a=t-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),c=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let h;return o>0?h=`expires in ${o}d ${c}h`:c>0?h=`expires in ${c}h ${u}m`:h=`expires in ${Math.max(1,u)}m`,{label:h,urgent:a<2*3600,expired:!1}}const Nj=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Cj(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:Nj.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Jr(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Qf({row:t,which:s}){const a=ta(t.profileRef),o=dw(t.value,a,s);return o.length===0?r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(c=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)"},title:c.hint,children:c.label}),r.jsxs("dd",{style:{margin:0,fontWeight:600},children:[c.value,c.unknown&&r.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},c.key))})}function Ej({row:t}){const s=ta(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return r.jsxs(r.Fragment,{children:[(s==null?void 0:s.name)??ut(a),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function Tj({row:t,altText:s}){switch(t.kind){case"profile":return r.jsx(Ej,{row:t});case"profile-limits":return r.jsx(Qf,{row:t,which:"limits"});case"profile-scope":return r.jsx(Qf,{row:t,which:"scope"});case"markdown":return r.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Jr(t.value)});case"list":return Array.isArray(t.value)?r.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:t.value.map((a,o)=>r.jsx("li",{children:Jr(a)},o))}):r.jsx(r.Fragment,{children:Jr(t.value)});case"money":return r.jsxs(r.Fragment,{children:[Jr(t.value),t.currency?` ${t.currency}`:""]});case"object":return r.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Jr(t.value)});default:return Cj(t.key,t.value)?r.jsx("img",{src:t.value,alt:s??t.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):r.jsx(r.Fragment,{children:Jr(t.value)})}}function jm({args:t,display:s,heading:a="Details"}){const o=uw(t,s);if(o.length===0)return null;const c=typeof t.altText=="string"?t.altText:void 0;return r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:o.map(u=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:u.hint,children:u.label}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:r.jsx(Tj,{row:u,altText:c})})]},u.key))})]})}function Rj({proposalId:t,systemName:s}){const[a,o]=f.useState(null);if(f.useEffect(()=>{let u=!0;return o(null),M.getProposalOutcome(t).then(h=>{u&&o(h)}).catch(()=>{}),()=>{u=!1}},[t]),!a)return null;const c=Uw(a,s);return c?r.jsxs("div",{className:"outcome-box",children:[r.jsx("h4",{children:c.heading}),r.jsx("p",{className:"outcome-note",children:c.note})]}):null}let $l=null;function Ij(){return $l||($l=M.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),$l}function Aj(t){const[s,a]=f.useState(void 0);return f.useEffect(()=>{let o=!0;if(t)return Ij().then(c=>{o&&a(c.get(t))}),()=>{o=!1}},[t]),s}function Pj(t,s){const[a,o]=f.useState(null),[c,u]=f.useState(!1),[h,g]=f.useState(null);return f.useEffect(()=>{let p=!0;return o(null),g(null),u(!0),(async()=>{var v;try{try{const j=await M.getGateContent(t);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){p&&o(j.gateContent.intent);return}}catch{}const y=await M.getAttestationIntent(t);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const w=await M.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});p&&o(w)}catch(y){p&&g(y instanceof Error?y.message:"Failed to decrypt intent")}finally{p&&u(!1)}})(),()=>{p=!1}},[t,s]),{intent:a,loading:c,error:h}}async function Sm(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await M.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function _j(t){if(!t.content)return[];const s=new Set([...t.createdBy?[t.createdBy]:[],...t.pendingApprovers??[]]),a=new Set(Object.keys(t.content.keys));return Array.from(s).filter(o=>!a.has(o))}function bm(t){return!t.loading&&t.readable}function km(t,s){const a=new Set;if(t.content)for(const o of Object.keys(t.content.keys))a.add(o);else{t.createdBy&&a.add(t.createdBy);for(const o of t.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function ji(t){const s=await Sm(t);if(s)return cm("jcs",s)}function $j(t){var o;const[s,a]=f.useState((t==null?void 0:t.note)??null);return f.useEffect(()=>{let c=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),M.decryptProposalContent(t.noteEncrypted).then(({plaintext:u})=>{c&&a(u)}).catch(()=>{c&&a(null)}),()=>{c=!1}},[t==null?void 0:t.note,(o=t==null?void 0:t.noteEncrypted)==null?void 0:o.ciphertext]),s}const Lj={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function Nm(t){var o;const[s,a]=f.useState(Lj);return f.useEffect(()=>{let c=!0;if(t.toolArgs){a({toolArgs:t.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!t.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Sm(t);c&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{c=!1}},[(o=t.content)==null?void 0:o.ciphertext,t.toolArgs]),s}function Xf(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[a,o]of Object.entries(t))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function zj(t){const s=Xf(t.limits),a=Xf(t.scope),o=typeof t.intent=="string"?t.intent:"",c={bounds:s,context:a,gateContent:{intent:o}};return(t.mode==="automatic"||t.mode==="review")&&(c.templateMode=t.mode),typeof t.duration_hours=="number"&&t.duration_hours>0&&(c.templateTtl=Math.round(t.duration_hours*3600)),c}function Cm(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>Cm(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Fj="setup__create_mandate";function Em({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:c,onContentState:u,onShownSnapshot:h}){const[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(null),N=mn(),{group:E,groupId:S,domain:C}=pt(),T=Object.entries(t.executionContext),R=ta(t.profileId),$=Aj(t.authorizationId),A=yw(t.executionContext,$,R),F=lw(t.tool),{integrationId:G}=Fi(t.tool),q=jc(G,c),{intent:de,loading:K,error:oe}=Pj(t.authorizationId,s),V=Nm(t),D=V.toolArgs!==null;f.useEffect(()=>{u==null||u({loading:V.loading,readable:D})},[V.loading,D]);const ce=_j(t),re=V.toolArgs?xm(a,V.toolArgs):[],Z=async()=>{if(!S){j("No active workspace; cannot open the mandate screen.");return}y(!0),j(null);try{if(!V.toolArgs){j("This content is not readable on this device yet.");return}const W=V.toolArgs,ee=typeof W.profile=="string"?W.profile:"",xe=await M.listProfiles(),ke=sm(ee,xe);if(!ke){j(`Unknown profile "${ee}".`);return}const ve=await M.getProfile(ke.id),ne=zj(W),Ae=im(ne.bounds,ve),Ee=om(ne.context,ve);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ke.id,groupId:S,groupName:(E==null?void 0:E.name)??null,domain:C,isPersonal:!!(E!=null&&E.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...ne,bounds:Ae,context:Ee})),sessionStorage.setItem("agentReplacesProposal",t.id),N("/mandates/new/intent")}catch(W){j(W instanceof Error?W.message:"Could not open the mandate screen.")}finally{y(!1)}},[he,ge]=f.useState(null),Y=Ww(he),[O,H]=f.useState(null),[b,L]=f.useState(null);f.useEffect(()=>{if(!O||!b){h==null||h(null);return}const W=O.status==="ok"?O.readAt:Date.now();h==null||h({readAt:W,preview:O,requestContext:b,...V.toolArgs?{toolArgs:V.toolArgs}:{},sealed:V.sealed})},[O,b,V.toolArgs,V.sealed,h]);const J=V.toolArgs?r.jsxs(r.Fragment,{children:[r.jsx(jm,{args:V.toolArgs,display:o,heading:""}),T.length>0&&r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([W,ee],xe)=>{const{label:ke,hint:ve}=lm(W,R);return r.jsxs("span",{children:[xe>0&&" · ",r.jsxs("span",{title:ve,children:[ke,"=",Cm(ee)]})]},W)})})]}):null;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"approval-headline",children:F}),V.sealed&&V.undecryptable&&r.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[r.jsx("strong",{children:"Encrypted for another device."}),r.jsx("p",{style:{margin:"0.35rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),V.sealed&&V.loading&&r.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),Y&&D&&r.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[r.jsxs("h4",{children:["What will be sent",V.sealed?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),J,V.sealed&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Decrypted on this device. suveren.ai stores only an unreadable copy and its fingerprint."})]}),ce.length>0&&r.jsxs("p",{"data-testid":"proposal-cannot-read",style:{margin:"0 0 0.5rem",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Cannot read this proposal yet: ",ce.join(", ")," — shared automatically once they sign in on a device."]}),D&&r.jsx(Gw,{proposalId:t.id,systemName:q,toolArgs:V.toolArgs,sealed:V.sealed,onTone:ge,onData:H}),D&&r.jsx(ej,{proposalId:t.id,onData:L}),D&&r.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]})]}),A.length>0&&r.jsxs("div",{className:"limit-checks",children:[r.jsx("h4",{children:"Within your limits"}),r.jsx("ul",{className:"limit-check-list",children:A.map(W=>r.jsxs("li",{className:W.ok?"ok":"bad",children:[r.jsx("span",{className:"limit-check-icon",children:W.ok?"✓":"✗"}),r.jsxs("span",{children:[W.label," ",W.valueText," — your limit ",W.limitText]})]},W.key))})]}),r.jsxs("div",{className:"mandate-intent",children:[r.jsxs("dl",{children:[r.jsx("dt",{children:"Mandate"}),r.jsxs("dd",{children:[r.jsx("strong",{children:(R==null?void 0:R.name)??ut(t.profileId)}),r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]})]}),r.jsxs("dl",{children:[r.jsx("dt",{children:"Intent"}),r.jsx("dd",{children:oe?r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:oe}):de!==null?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`intent-text${g?"":" intent-clamped"}`,children:de}),r.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>p(!g),children:g?"Show less":"Show full intent"})]}):K?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),D&&re.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:re.map(W=>r.jsxs("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:W.description??W.href,children:[W.label," ↗"]},W.label))}),!Y&&D&&r.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[r.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),r.jsx("div",{style:{marginTop:"0.5rem"},children:J})]}),D&&t.tool===Fj&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",margin:"0 0 0.4rem"},children:["The intent above is written by the AI, but it becomes ",r.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:Z,disabled:v,children:v?"Opening…":"Edit before signing"}),w&&r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:"0.4rem 0 0"},children:w})]})]})}function Tm({note:t,onNoteChange:s,onSend:a,onCancel:o,sending:c,error:u}){return r.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),r.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:b0.map(h=>r.jsx("button",{type:"button",className:`filter-chip${em(t,h)?" selected":""}`,onClick:()=>s(N0(t,h)),disabled:c,children:h},h))}),r.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:Ci,onChange:h=>s(h.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:c,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),r.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[t.length," / ",Ci]}),u&&r.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:u}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[r.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",style:{background:"var(--warning)",borderColor:"var(--warning)"},onClick:a,disabled:c,children:c?"Sending…":"Send back for change"}),r.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:c,children:"Cancel"})]}),r.jsx("p",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:"The AI is told: adjust and propose again — a new proposal you approve again. Nothing runs from this one."})]})}const Oj={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},Mj={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Zf={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function Ll(t){const s=Date.now()-t*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(t*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Bj(t){return t.split("__").pop()??t}function Dj(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function Rm(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>Rm(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function eh({item:t,onApprove:s,onReject:a,onChangeNeeded:o,resolving:c,proposalLinks:u,toolDisplay:h,manifests:g,currentUserId:p}){const v=t.kind==="proposal",y=v?t.proposal.status:"executed",w=v?t.proposal.tool:t.receipt.action,j=Bj(w),N=Dj(w),{integrationId:E}=Fi(w),S=jc(E,g),[C,T]=f.useState(!1),[R,$]=f.useState(""),[A,F]=f.useState(""),G=f.useRef(null),q=async()=>{const W=G.current;if(!(!W||!v))try{const{shownHash:ee}=await M.saveShownSnapshot(t.proposal.id,W);return ee}catch{return}},de=async()=>{const W=wc(R);if(!W.valid){F(W.error);return}F("");const ee=await q();o==null||o(t.id,W.trimmed,ee)},K=v&&y==="rejected"?R0(t.proposal,p??""):null,oe=v&&y==="refused"?I0(t.proposal):null,V=$j(v?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),D=ta(t.profileId),ce=Nm(v?t.proposal:{toolArgs:void 0,content:void 0}),re=v?ce.toolArgs:null,Z=v?t.proposal.executionContext:t.receipt.executionContext,he=v?null:t.receipt.cumulativeState,[ge,Y]=f.useState(!0),[O,H]=f.useState(!1),b=v&&ce.toolArgs?xm(u,ce.toolArgs):[],L=Object.entries(Z??{}),J=Nr(t.profileId).testSetup||zi(w);return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:j}),J&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),t.commitmentMode==="automatic"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[v&&y==="pending"&&(()=>{const W=wm(t.proposal.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:W.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:W.urgent?600:400,whiteSpace:"nowrap"},children:W.label})})(),r.jsx("span",{"data-testid":K||oe?"outcome-kind":void 0,className:`status-badge ${K?Zf[K.kind]:oe?Zf.REFUSED:Mj[y]}`,children:K?K.kind:oe?oe.kind:Oj[y]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ll(t.sortTimestamp)})]})]}),v&&t.proposal.status==="executed"&&r.jsx(Rj,{proposalId:t.proposal.id,systemName:S}),K&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By ",K.who,", ",Ll(K.at)]}),(V??K.note)&&r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[K.kind==="CHANGE NEEDED"?"Change: ":"Note: ",V??K.note]})]}),oe&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By the Authority Server, ",Ll(oe.at)]}),r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",oe.message]})]}),N&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[r.jsx("span",{children:"⚠"}),r.jsx("span",{children:"Irreversible action"})]}),v&&typeof(re==null?void 0:re._imagePreview)=="string"&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),r.jsx("img",{src:re._imagePreview,alt:typeof(re==null?void 0:re.altText)=="string"?re.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),v&&y==="pending"?r.jsx(Em,{proposal:t.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:h,manifests:g,onContentState:({loading:W,readable:ee})=>{H(W),Y(ee)},onShownSnapshot:W=>{G.current=W}}):r.jsxs(r.Fragment,{children:[b.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:b.map(W=>r.jsxs("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:W.description??W.href,children:[W.label," ↗"]},W.label))}),v?r.jsxs(r.Fragment,{children:[re&&r.jsx(jm,{args:re,display:h}),L.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:L.map(([W,ee])=>`${W}=${Rm(ee)}`).join(" · ")})]}):r.jsxs(r.Fragment,{children:[r.jsx(mm,{receipt:t.receipt,profile:D}),t.receipt.proposalId&&r.jsx(vm,{proposalId:t.receipt.proposalId,tool:t.receipt.action,manifests:g})]})]}),he&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",he.daily.count," action",he.daily.count===1?"":"s",he.daily.amount>0?`, ${he.daily.amount}`:""," · ","this month: ",he.monthly.count,he.monthly.amount>0?`, ${he.monthly.amount}`:""]}),v&&y==="pending"&&bm({loading:O,readable:ge})&&(C?r.jsx(Tm,{note:R,onNoteChange:$,onSend:de,onCancel:()=>{T(!1),$(""),F("")},sending:!!c,error:A}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:async()=>s==null?void 0:s(t.id,await q()),disabled:c,children:c?"Approving…":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>T(!0),disabled:c,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:async()=>a==null?void 0:a(t.id,await q()),disabled:c,children:"Reject"})]})),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[v?"Proposal":"Ticket",": ",t.id]})]})]})}function Uj(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Wj({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:c,toolDisplay:u,manifests:h}){const[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(!1),[N,E]=f.useState(""),[S,C]=f.useState(""),[T,R]=f.useState(!1),[$,A]=f.useState(!1),[F,G]=f.useState(!0),q=f.useRef(null),de=async()=>{const O=q.current;if(O)try{const{shownHash:H}=await M.saveShownSnapshot(t.id,O);return H}catch{return}},K=Nr(t.profileId).testSetup||zi(t.tool),oe=t.pendingApprovers??[],V=t.approvedBy??{},D=Object.keys(V).length,ce=oe.filter(O=>!(O in V)).length,re=s in V,Z=async()=>{if(pc()){o(gc);return}p(!0),o("");try{const O=await ji(t),H=await de();await M.approveProposal(t.id,O,H);try{const b=await M.getAttestationIntent(t.authorizationId);if(b){const L=await M.decryptIntent({intentCiphertext:b.intentCiphertext,encryptedKey:b.encryptedKey,approverId:s});await M.storeApprovedIntent(t.authorizationId,L)}}catch{}o(`Approved. ${ce-1>0?`${ce-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),a()}catch(O){o(O instanceof Error?O.message:"Approval failed")}finally{p(!1)}},he=async()=>{y(!0),o("");try{const O=await ji(t),H=await de();await M.rejectProposal(t.id,tm(),O,H),o("Action rejected."),a()}catch(O){o(O instanceof Error?O.message:"Rejection failed")}finally{y(!1)}},ge=async()=>{const O=wc(N);if(!O.valid){C(O.error);return}C(""),R(!0),o("");try{const{noteEncrypted:H}=await M.encryptProposalNote(O.trimmed,km(t,s)),b=await ji(t),L=await de();await M.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:H},b,L),o("Sent back for a change."),a()}catch(H){o(H instanceof Error?H.message:"Failed to send back")}finally{R(!1)}},Y=g||v||T;return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),K&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const O=wm(t.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:O.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:O.urgent?600:400,whiteSpace:"nowrap"},children:O.label})})(),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Uj(t.createdAt)})]})]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[D," of ",oe.length," approver",oe.length===1?"":"s"," signed off",oe.map(O=>{const H=O in V;return r.jsxs("span",{style:{marginLeft:"0.5rem",color:H?"var(--success, green)":"var(--text-tertiary)"},children:[H?"✓":"○"," ",O===s?"You":O]},O)})]}),r.jsx(Em,{proposal:t,currentUserId:s,proposalLinks:c,toolDisplay:u,manifests:h,onContentState:({loading:O,readable:H})=>{A(O),G(H)},onShownSnapshot:O=>{q.current=O}}),!re&&bm({loading:$,readable:F})&&(w?r.jsx(Tm,{note:N,onNoteChange:E,onSend:ge,onCancel:()=>{j(!1),E(""),C("")},sending:T,error:S}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:Y,children:g?"Approving...":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>j(!0),disabled:Y,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:he,disabled:Y,children:v?"Rejecting...":"Reject"})]})),re&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function Hj(){const{domain:t,user:s}=pt(),a=(s==null?void 0:s.id)??"",[o,c]=f.useState("awaiting-me"),[u,h]=f.useState([]),[g,p]=f.useState([]),[v,y]=f.useState({}),[w,j]=f.useState(!0),[N,E]=f.useState(""),S=f.useCallback(async()=>{try{const se=await M.getProposalsForApprover();h(se)}catch{}finally{j(!1)}},[]);Ge("proposal-added",S),Ge("proposal-approved",S),Ge("proposal-rejected",S),Ge("proposal-resolved",S),nn(S,3e4);const[C,T]=f.useState([]),R=f.useCallback(async()=>{try{const se=await M.getMyProposals(t);T(se)}catch{}},[t]);Ge("proposal-added",R),Ge("proposal-approved",R),Ge("proposal-rejected",R),Ge("proposal-resolved",R),nn(R,3e4,t);const $=f.useMemo(()=>C.filter(se=>{var je;return se.status==="pending"&&(((je=se.pendingApprovers)==null?void 0:je.length)??0)===0}),[C]),A=f.useMemo(()=>Jf($,[],{status:"pending"}),[$]),[F,G]=f.useState([]),q=f.useCallback(async()=>{if(a)try{const je=(await M.getMyProposals(t)).filter($e=>$e.status==="pending"&&$e.pendingApprovers&&$e.pendingApprovers.includes(a)&&$e.approvedBy&&a in $e.approvedBy);G(je)}catch{}},[a,t]);Ge("proposal-approved",q),Ge("proposal-rejected",q),nn(q,3e4,`${a}:${t}`),f.useEffect(()=>{M.getIntegrationManifests().then(se=>p(se.manifests??[])).catch(()=>{}),M.getToolDisplay().then(y).catch(()=>{})},[]);const de=se=>{var je;return(je=g.find($e=>$e.id===se.split("__")[0]))==null?void 0:je.proposalLinks};f.useEffect(()=>{S(),R(),q()},[]);const[K,oe]=f.useState([]),[V,D]=f.useState([]),[ce,re]=f.useState(!0),[Z,he]=f.useState(null),[ge,Y]=f.useState(""),[O,H]=f.useState("pending"),[b,L]=f.useState(null),[J,W]=f.useState(!1),ee=f.useCallback(async()=>{try{const{proposals:se,receipts:je}=await M.getThread({domain:t,status:O,sinceDays:7});oe(se),D(je)}catch{}finally{re(!1)}},[t,O]);nn(ee,3e4,`${t}:${O}`);const xe=async(se,je,$e,dt)=>{if(je==="commit"&&pc()){Y(gc);return}he(se),Y("");try{const He=K.find(P=>P.id===se)??C.find(P=>P.id===se),tt=gv(He,t),gt=He?await ji(He):void 0;let ft=$e??{};if(($e==null?void 0:$e.outcome)==="change_needed"&&$e.note){const P=He?km(He,a):[a],{noteEncrypted:ae}=await M.encryptProposalNote($e.note,P);ft={outcome:"change_needed",noteEncrypted:ae}}const ze=await M.resolveProposal(se,je,tt,{...ft,contentHash:gt,shownHash:dt});Y(je==="commit"?`Action approved. Status: ${ze.status}`:($e==null?void 0:$e.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ee(),R()])}catch(He){Y(He instanceof Error?He.message:"Failed")}finally{he(null)}},ke=(se,je)=>xe(se,"commit",void 0,je),ve=(se,je)=>xe(se,"reject",tm(),je),ne=(se,je,$e)=>xe(se,"reject",C0(je),$e),Ae=f.useMemo(()=>{const se=new Set;for(const je of K)se.add(je.profileId);for(const je of V)se.add(je.profileId);return Array.from(se).sort()},[K,V]),Ee=f.useMemo(()=>Jf(K,V,{status:O,profile:b??void 0,includeAutonomous:J}),[K,V,O,b,J]),Le=f.useCallback(()=>{S(),q()},[S,q]),fe=f.useMemo(()=>{const se=new Set,je=[];for(const $e of F)se.has($e.id)||(se.add($e.id),je.push($e));return je.sort(($e,dt)=>dt.createdAt-$e.createdAt)},[F]),_e=u.length+A.length,Ue=fe.length;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Pending Approvals"}),r.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),r.jsx(Uh,{what:"approve"})]}),r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[r.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>c("awaiting-me"),children:["Awaiting me ",_e>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:_e})]}),r.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>c("awaiting-others"),children:["Awaiting others ",Ue>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:Ue})]}),r.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{c("all"),ee()},children:"All"})]}),o==="awaiting-me"&&r.jsx(r.Fragment,{children:w&&_e===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(N||ge)&&r.jsx("div",{className:"alert alert-success",children:N||ge}),A.map(se=>r.jsx(eh,{proposalLinks:se.kind==="proposal"?de(se.proposal.tool):void 0,toolDisplay:se.kind==="proposal"?v[se.proposal.tool]:void 0,manifests:g,currentUserId:a,item:se,onApprove:ke,onReject:ve,onChangeNeeded:ne,resolving:Z===se.id},se.id)),u.map(se=>r.jsx(Wj,{proposal:se,currentUserId:a,onAction:Le,onMessage:E,proposalLinks:de(se.tool),toolDisplay:v[se.tool],manifests:g},se.id))]})}),o==="awaiting-others"&&r.jsx(r.Fragment,{children:fe.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:fe.map(se=>r.jsx(Gj,{proposal:se,currentUserId:a,onCancel:async()=>{try{await M.rejectProposal(se.id,{reason:"cancelled by creator"}),q(),R()}catch(je){alert(je instanceof Error?je.message:"Cancel failed")}}},se.id))})}),o==="all"&&r.jsxs(r.Fragment,{children:[ge&&r.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:ge}),r.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[r.jsx("button",{className:`filter-chip ${O==="pending"?"selected":""}`,onClick:()=>H("pending"),children:"Pending"}),r.jsx("button",{className:`filter-chip ${O==="all"?"selected":""}`,onClick:()=>H("all"),children:"All"}),Ae.length>0&&r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),Ae.map(se=>r.jsx("button",{className:`filter-chip ${b===se?"selected":""}`,onClick:()=>L(b===se?null:se),children:ut(se)},se)),O==="all"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),r.jsxs("button",{className:`filter-chip ${J?"selected":""}`,onClick:()=>W(!J),title:"Include actions executed without human review (automatic commitment mode)",children:[J?"✓ ":"","Autonomous actions"]})]})]}),ce&&Ee.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ee.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:O==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:O==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Ee.map(se=>r.jsx(eh,{proposalLinks:se.kind==="proposal"?de(se.proposal.tool):void 0,toolDisplay:se.kind==="proposal"?v[se.proposal.tool]:void 0,manifests:g,currentUserId:a,item:se,onApprove:ke,onReject:ve,onChangeNeeded:ne,resolving:Z===se.id},se.id))})]})]})}function Vj(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Gj({proposal:t,currentUserId:s,onCancel:a}){var y;const[o,c]=f.useState(!1),u=Object.keys(t.approvedBy??{}),h=(t.pendingApprovers??[]).filter(w=>!(w in(t.approvedBy??{}))),g=(((y=t.pendingApprovers)==null?void 0:y.length)??0)>0,p=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){c(!0);try{await a()}finally{c(!1)}}},v=Nr(t.profileId).testSetup||zi(t.tool);return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:t.tool.split("__").pop()??t.tool}),v&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),g&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Vj(t.createdAt)})]}),g&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[u.map(w=>r.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:w===s?"You approved":`${w} approved`},w)),h.map(w=>r.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",w===s?"you":w]},w))]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:p,disabled:o,children:o?"Cancelling...":"Cancel"})})]})]})}const Kj=`# Agent Brief
|
|
87
|
+
`)}}const qw="Linked by the AI",Yw="linked automatically — this action already carried a reference to it";function Jw(t){if(t.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(t.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${t.reason}).`,chain:[]};if(t.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=Kw(t.body),o=[t.connector,t.kind,t.author?`from ${t.author}`:void 0,Ai(t.at)].filter(c=>!!c);return{state:"ok",implicit:t.implicit,tag:qw,...t.implicit?{implicitNote:Yw}:{},metaLine:o.join(" · "),title:t.title,bodyFirst:s,bodyMore:a,attribution:t.author?`— from ${t.author}, not checked`:void 0,chain:t.chain.map(c=>({...c,at:Ai(c.at)}))}}const Ds="Read by the gateway — same customer, not matched to this request";function Qw(t){const s=t.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${t.matchedKeyValue} (${s})`}function Xw(t){var c;const s=!!t.aiWritten,a=s?"Activity":t.type??t.kind??"Entry";let o;if(s){const u=((c=t.aiWritten)==null?void 0:c.at)!==void 0?Ai(new Date(t.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=t.author?`— from ${t.author}, not checked`:"— not checked";return{headLabel:a,at:Ai(t.at),title:t.title,body:t.body,attribution:o,aiWritten:s}}function Zw(t){if(t.status==="no_customer_link")return{state:"no_customer_link",label:Ds,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(t.status==="no_match")return{state:"no_match",label:Ds,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(t.status==="unreachable")return{state:"unreachable",label:Ds,note:`${t.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=t.matches.flatMap(c=>c.items.map(u=>({it:u,m:c}))).sort((c,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(c.it.at??"")||0)).map(({it:c})=>Xw(c)),a=t.matches.map(Qw),o=t.unreachableConnectorIds.length>0?`${t.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:Ds,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:Ds,note:"",matchNotes:a,items:s,unreachableNote:o}}function ym({resp:t}){const s=Jw(t.request),a=Zw(t.history);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":s.state,children:[r.jsxs("h4",{children:["Request",s.tag&&r.jsx("span",{className:"src-tag src-tag-ai",children:s.tag})]}),s.state!=="ok"?r.jsx("p",{className:"au10-req-state",children:s.note}):r.jsxs(r.Fragment,{children:[s.implicitNote&&r.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:s.implicitNote}),s.metaLine&&r.jsx("p",{className:"au10-req-meta",children:s.metaLine}),s.title&&r.jsx("p",{className:"au10-req-meta",children:r.jsx("b",{children:s.title})}),s.bodyFirst&&r.jsx("p",{className:"au10-req-quote",children:s.bodyFirst}),s.bodyMore&&r.jsxs("details",{children:[r.jsx("summary",{children:"Show more"}),r.jsx("p",{className:"au10-req-quote",children:s.bodyMore})]}),s.attribution&&r.jsx("p",{className:"au10-req-attrib",children:s.attribution}),s.chain.length>0&&r.jsxs("details",{className:"au10-chain",children:[r.jsxs("summary",{children:["Earlier in this thread (",s.chain.length,")"]}),s.chain.map((o,c)=>r.jsxs("div",{className:"au10-chain-item",children:[(o.author||o.at)&&r.jsxs("p",{className:"au10-req-meta",children:[o.author?r.jsxs(r.Fragment,{children:["from ",r.jsx("b",{children:o.author})]}):null,o.author&&o.at?" · ":"",o.at]}),o.title&&r.jsx("p",{className:"au10-req-meta",children:r.jsx("b",{children:o.title})}),o.body&&r.jsx("p",{className:"au10-req-quote",children:o.body}),o.author&&r.jsxs("p",{className:"au10-req-attrib",children:["— from ",o.author,", not checked"]})]},c))]})]})]}),r.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[r.jsxs("h4",{children:["History",r.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),a.state!=="ok"?r.jsx("p",{className:"au10-hist-state",children:a.note}):r.jsxs(r.Fragment,{children:[a.matchNotes.map((o,c)=>r.jsx("p",{className:"preview-note",style:{marginTop:0},children:o},c)),r.jsx("ul",{className:"au10-hist-list",children:a.items.map((o,c)=>r.jsxs("li",{className:"au10-hist-item",children:[r.jsxs("div",{className:"au10-hist-head",children:[r.jsxs("span",{children:[o.aiWritten&&r.jsx("span",{className:"au10-dot au10-dot-ai"}),o.headLabel]}),r.jsx("span",{children:o.at})]}),o.title&&r.jsx("div",{className:"au10-hist-title",children:o.title}),o.body&&r.jsx("div",{className:"au10-hist-body",children:o.body}),r.jsx("p",{className:"au10-hist-attrib",children:o.attribution})]},c))}),a.unreachableNote&&r.jsx("p",{className:"preview-note",children:a.unreachableNote})]})]})]})}function ej({proposalId:t,onData:s}){const[a,o]=f.useState(null),[c,u]=f.useState(!1);return f.useEffect(()=>{let h=!0;return o(null),u(!1),M.getProposalRequestContext(t).then(g=>{h&&o(g)}).catch(()=>{h&&u(!0)}),()=>{h=!1}},[t]),f.useEffect(()=>{s==null||s(c?null:a)},[a,c,s]),c||!a?null:r.jsx(ym,{resp:a})}function tj(t,s,a){const o=Object.entries(t??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,g])=>g.by===s)??(a?o.find(([g])=>g===`domain:${a}`):void 0),h=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:h}}function nj(t){return t.offDevice?"off-device":t.recordedHash?t.localHash===t.recordedHash?"verified":"mismatch":"unchecked"}function rj(t){if(!(t<=0))return`${t} other approver${t===1?"":"s"} recorded their own.`}function sj(t){return new Date(t).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function vm({proposalId:t,tool:s,manifests:a}){const{user:o,domain:c}=pt(),[u,h]=f.useState(null),[g,p]=f.useState(null),[v,y]=f.useState(!1);if(f.useEffect(()=>{let $=!0;return h(null),p(null),y(!1),Promise.all([M.getShownSnapshot(t),M.getProposal(t)]).then(([A,F])=>{$&&(h(A),p(F))}).catch(()=>{$&&y(!0)}),()=>{$=!1}},[t]),v||!u||!g)return null;const w=u.status==="off_device",{entry:j,otherCount:N}=tj(g.shownHashes,(o==null?void 0:o.id)??"",c),E=nj({offDevice:w,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=rj(N);if(w)return r.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[r.jsx("h4",{children:"What you saw"}),r.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:C}=u,{integrationId:T}=Fi(s),R=jc(T,a);return r.jsxs("div",{className:`ticket-box ticket-shown-${E}`,"data-testid":"au10-shown","data-shown-status":E,children:[r.jsxs("h4",{children:["What you saw (read ",sj(C.readAt),")",E==="verified"&&r.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),E==="mismatch"&&r.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),r.jsx(gm,{resp:C.preview,systemName:R,toolArgs:C.toolArgs,sealed:C.sealed}),r.jsx(ym,{resp:C.requestContext}),E==="verified"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),E==="mismatch"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),E==="unchecked"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),S&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral","data-testid":"au10-shown-others",children:S})]})}function Us({label:t,children:s}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{className:"receipt-row-label",children:t}),r.jsx("dd",{className:"receipt-row-value",children:s})]})}function aj({receipt:t,manifests:s,localAuth:a,localUnavailable:o,signature:c,grantTitle:u,ownerLabel:h,spUrl:g,formatDate:p,onOpenComplete:v}){var R;const y=ta(t.profileId),w=mw(t,y),j=pw(a==null?void 0:a.context,y),N=gw(t,(a==null?void 0:a.bounds)??t.limits,y),E=a==null?void 0:a.intent,S=Nr(t.profileId).testSetup||zi(t.action),[C,T]=f.useState(!1);return r.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{className:"receipt-head",children:[r.jsx("span",{className:"receipt-what",children:hw(t,s)}),r.jsx("span",{className:"receipt-tag",children:vw(t)?"review":"automatic"}),t.contentHash&&r.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(R=t.contentBinding)!=null&&R.fields?`The ticket binds: ${t.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),S&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsx("span",{className:"auth-card-time",children:p(t.timestamp)})]}),w&&r.jsx("div",{className:"receipt-scope",children:w}),r.jsx(mm,{receipt:t,profile:y}),t.proposalId&&r.jsx(vm,{proposalId:t.proposalId,tool:t.action,manifests:s}),r.jsxs("dl",{className:"receipt-rows",children:[r.jsxs(Us,{label:"mandate",children:[r.jsx("strong",{children:u||xw(t.profileId)})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),h&&r.jsx(Us,{label:"owner",children:h}),j&&r.jsxs(Us,{label:"allowed",children:[j," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),N&&r.jsxs(Us,{label:"used",children:[r.jsx("span",{className:"receipt-num",children:N})," ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),r.jsx(Us,{label:"intent",children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`intent-text${C?"":" intent-clamped"}`,children:E}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>T(!C),children:C?"Show less":"Show full intent"})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):r.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),r.jsxs("div",{className:"receipt-foot",children:[c==="valid"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),c==="valid-legacy"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),c==="invalid"&&r.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),r.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),g&&r.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",r.jsx("a",{className:"receipt-link",href:`${g}/r/${t.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),r.jsxs("details",{className:"receipt-more",children:[r.jsx("summary",{children:"Raw"}),r.jsxs("div",{className:"receipt-kv",children:[r.jsxs("div",{children:["ticket · ",t.id]}),r.jsxs("div",{children:["action · ",t.action]}),r.jsxs("div",{children:["profile · ",t.profileId]}),t.authorizationId&&r.jsxs("div",{children:["mandate · ",t.authorizationId]}),Object.keys(t.executionContext??{}).length>0&&r.jsxs("div",{children:["scope ·"," ",Object.entries(t.executionContext).map(([$,A])=>`${$}=${A}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&r.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&r.jsxs("div",{children:["scope hash · ",a.contextHash]}),t.contentHash&&r.jsxs("div",{children:["content · ",t.contentHash]}),t.proposalId&&r.jsxs("div",{children:["proposal · ",t.proposalId]}),r.jsxs("div",{children:["signature · ",t.signature]})]})]})]})]})}function ij({receipt:t,onClose:s}){const[a,o]=f.useState(null),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(!0),[y,w]=f.useState(!1);f.useEffect(()=>{let C=!1;return v(!0),M.getArchivedReceipt(t.id).then(T=>{C||(o(T),u(T?"local":"authority-server"),g((T==null?void 0:T.signature)??null))}).catch(()=>{C||u("authority-server")}).finally(()=>{C||v(!1)}),()=>{C=!0}},[t.id]);const j=a?a.entry:{receipt:t},N=JSON.stringify(j,null,2);function E(){const C=URL.createObjectURL(new Blob([N],{type:"application/json"})),T=document.createElement("a");T.href=C,T.download=`suveren-ticket-${t.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(C)}async function S(){try{await navigator.clipboard.writeText(N),w(!0),setTimeout(()=>w(!1),2e3)}catch{w(!1)}}return r.jsx("div",{className:"modal-backdrop",onClick:C=>C.target===C.currentTarget&&s(),children:r.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Complete ticket"}),r.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[h==="valid"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),h==="valid-legacy"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),h==="invalid"&&r.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:p?"Loading…":c==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),r.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:N})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Download"}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function oj(t){return new Date(t*1e3).toLocaleString()}function lj(t,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return t.timestamp>=o}function cj(t,s){if(!s)return!0;const a=s.toLowerCase();return t.profileId.toLowerCase().includes(a)||ut(t.profileId).toLowerCase().includes(a)||t.path.toLowerCase().includes(a)||t.action.toLowerCase().includes(a)||t.attestationHash.toLowerCase().includes(a)||t.id.toLowerCase().includes(a)||JSON.stringify(t.executionContext).toLowerCase().includes(a)}function Gf(t,s){const a=new Map(t.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,c)=>c.timestamp-o.timestamp)}function uj(){const{activeTeam:t,groupId:s}=pt(),a=(t==null?void 0:t.isAdmin)===!0,[o,c]=f.useState("mine"),[u,h]=f.useState([]),[g,p]=f.useState([]),[v,y]=f.useState(""),[w,j]=f.useState(!0),[N,E]=f.useState({}),[S,C]=f.useState(new Set),[T,R]=f.useState(""),[$,A]=f.useState(new Set),[F,G]=f.useState(new Set),[q,de]=f.useState("all"),[K,oe]=f.useState(!1),[V,D]=f.useState(!1),[ce,re]=f.useState(null),[Z,he]=f.useState({}),[ge,Y]=f.useState(!1),[O,H]=f.useState({}),[b,L]=f.useState({}),[J,W]=f.useState(null),[ee,xe]=f.useState(null),[ke,ve]=f.useState(!1),[ne,Ae]=f.useState(!1),Ee=f.useRef(""),Le=f.useCallback(P=>o==="team"&&a&&s?M.listTeamReceiptsPage(s,{before:P,limit:200}):M.getMyReceiptsPage({before:P,limit:200}),[o,a,s]),fe=f.useCallback(()=>{const P=o==="team"?`team:${s}`:"mine",ae=Ee.current!==P;Ee.current=P,j(!0),Ae(!1),Le().then(me=>{h(Te=>ae?me.receipts:Gf(Te,me.receipts)),xe(Te=>ae?me.nextBefore:Te??me.nextBefore)}).catch(()=>{ae&&h([]),Ae(!0)}).finally(()=>j(!1))},[Le,o,s]),_e=f.useCallback(()=>{!ee||ke||(ve(!0),Ae(!1),Le(ee).then(P=>{h(ae=>Gf(ae,P.receipts)),xe(P.nextBefore)}).catch(()=>Ae(!0)).finally(()=>ve(!1)))},[ee,ke,Le]);nn(fe,12e4),f.useEffect(()=>{M.getIntegrationManifests().then(({manifests:P})=>p(P)).catch(()=>{}),fetch("/health").then(P=>P.json()).then(P=>{typeof P.spUrl=="string"&&y(P.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{M.getLocalAuthorizations().then(({authorizations:P,signatures:ae})=>{he(P),H(ae),Y(!1)}).catch(()=>{he({}),H({}),Y(!0)}),M.getMyAttestations().then(P=>{const ae={};for(const me of P)me.authorization_id&&me.title&&(ae[me.authorization_id]=me.title);L(ae)}).catch(()=>{})},[]),f.useEffect(()=>{o!=="team"||Object.keys(N).length>0||M.listUsers().then(P=>{const ae={};for(const me of P)ae[me.id]={name:me.name,email:me.email};E(ae)}).catch(()=>{})},[o,N]);const We=f.useMemo(()=>{const P=new Set;for(const ae of u)P.add(ut(ae.profileId));return[...P].sort()},[u]),se=f.useMemo(()=>{const P=new Set;for(const ae of u)P.add(ae.action);return[...P].sort()},[u]),je=f.useMemo(()=>{if(o!=="team")return[];const P=new Set;for(const ae of u)ae.userId&&P.add(ae.userId);return[...P].map(ae=>{var me;return{id:ae,label:(me=N[ae])!=null&&me.name?`${N[ae].name} (${N[ae].email})`:ae}}).sort((ae,me)=>ae.label.localeCompare(me.label))},[o,u,N]),$e=f.useMemo(()=>u.filter(P=>!(!cj(P,T)||$.size>0&&!$.has(ut(P.profileId))||F.size>0&&!F.has(P.action)||S.size>0&&P.userId&&!S.has(P.userId)||!lj(P,q))),[u,T,$,F,S,q]),dt=$.size>0||F.size>0||S.size>0||q!=="all";function Ve(P){A(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function tt(P){G(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function gt(P){C(ae=>{const me=new Set(ae);return me.has(P)?me.delete(P):me.add(P),me})}function ft(){A(new Set),G(new Set),C(new Set),de("all"),R("")}async function ze(){D(!0),re(null);try{const{bundle:P,filename:ae}=await M.fetchEvidenceBundle(),me=URL.createObjectURL(new Blob([JSON.stringify(P,null,2)],{type:"application/json"})),Te=document.createElement("a");Te.href=me,Te.download=ae,Te.click(),URL.revokeObjectURL(me);const ue=P.sources??{};ue.authorityServer?ue.local||re(`Downloaded Authority Server history only — ${ue.localError??"local archive unavailable."}`):re(`Downloaded local evidence only — ${ue.asError??"Authority Server export unavailable."}`)}catch(P){re(`Export failed: ${P instanceof Error?P.message:String(P)}`)}finally{D(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Tickets"}),r.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),r.jsx("button",{className:"btn btn-secondary",onClick:ze,disabled:V,children:V?"Preparing…":"Download evidence"})]}),ce&&r.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:ce}),a&&r.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(P=>r.jsx("button",{onClick:()=>c(P),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===P?"2px solid var(--accent)":"2px solid transparent",color:o===P?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===P?600:500},children:P==="mine"?"Mine":"Team"},P))}),r.jsxs("div",{className:"search-filter-bar",children:[r.jsxs("div",{className:"search-input-wrap",children:[r.jsx("span",{className:"search-icon",children:"⌕"}),r.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:T,onChange:P=>R(P.target.value)}),T&&r.jsx("button",{className:"search-clear",onClick:()=>R(""),children:"×"})]}),r.jsxs("button",{className:`btn btn-sm btn-secondary${K?" active":""}`,onClick:()=>oe(!K),children:["Filters",dt?` (${$.size+F.size+(q!=="all"?1:0)})`:""]})]}),K&&r.jsxs("div",{className:"filter-panel",children:[We.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Profile"}),r.jsx("div",{className:"filter-chips",children:We.map(P=>r.jsx("button",{className:`filter-chip${$.has(P)?" selected":""}`,onClick:()=>Ve(P),children:P},P))})]}),se.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Action"}),r.jsx("div",{className:"filter-chips",children:se.map(P=>r.jsx("button",{className:`filter-chip${F.has(P)?" selected":""}`,onClick:()=>tt(P),children:P},P))})]}),o==="team"&&je.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Owner"}),r.jsx("div",{className:"filter-chips",children:je.map(P=>r.jsx("button",{className:`filter-chip${S.has(P.id)?" selected":""}`,onClick:()=>gt(P.id),children:P.label},P.id))})]}),r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Time range"}),r.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([P,ae])=>r.jsx("button",{className:`filter-chip${q===P?" selected":""}`,onClick:()=>de(P),children:ae},P))})]})]}),dt&&r.jsxs("div",{className:"active-filters",children:[[...$].map(P=>r.jsxs("span",{className:"active-chip",onClick:()=>Ve(P),children:[P," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)),[...F].map(P=>r.jsxs("span",{className:"active-chip",onClick:()=>tt(P),children:[P," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)),[...S].map(P=>{const ae=N[P],me=ae?ae.name:P;return r.jsxs("span",{className:"active-chip",onClick:()=>gt(P),children:[me," ",r.jsx("span",{className:"chip-remove",children:"×"})]},P)}),q!=="all"&&r.jsxs("span",{className:"active-chip",onClick:()=>de("all"),children:[q==="1d"?"Today":q==="7d"?"7 days":"30 days"," ",r.jsx("span",{className:"chip-remove",children:"×"})]}),r.jsx("button",{className:"clear-filters",onClick:ft,children:"Clear all"})]}),ne&&r.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:r.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),w&&u.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.length===0?r.jsx(Zr,{icon:"⌕",title:u.length===0?"No tickets in the last 30 days":"No matching tickets",text:u.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:$e.length===u.length?`${u.length} ticket${u.length!==1?"s":""}`:`${$e.length} of ${u.length} tickets`}),r.jsx("div",{className:"timeline",children:$e.map(P=>{const ae=P.userId?N[P.userId]:void 0;return r.jsx("div",{className:"timeline-event",children:r.jsx(aj,{receipt:P,manifests:g,localAuth:P.authorizationId?Z[P.authorizationId]:void 0,localUnavailable:ge,signature:O[P.id],grantTitle:P.authorizationId?b[P.authorizationId]:null,ownerLabel:o==="team"&&P.userId?ae?`${ae.name} (${ae.email})`:P.userId:null,spUrl:v,formatDate:oj,onOpenComplete:()=>W(P)})},P.id)})})]}),J&&r.jsx(ij,{receipt:J,onClose:()=>W(null)}),ee&&r.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:_e,disabled:ke,children:ke?"Loading…":"Load older"})})]})}function dj(){const[t,s]=f.useState(null),[a,o]=f.useState({}),[c,u]=f.useState(!1),h=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:p})=>{s(p),u(!1)}).catch(()=>u(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,6e4),f.useEffect(()=>{if(!t)return;const p=[...new Set(t.map(v=>v.profile).filter(v=>!!v))].filter(v=>!(v in a));p.length!==0&&Promise.all(p.map(v=>M.getProfile(v).catch(()=>null))).then(v=>{o(y=>{const w={...y};return p.forEach((j,N)=>{v[N]&&(w[j]=v[N])}),w})})},[t,a]),c)return r.jsx(Zr,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const g=$h(t,Date.now());return r.jsxs("div",{className:"blocked-page",children:[r.jsxs("div",{className:"page-header blocked-header",children:[r.jsx("h1",{className:"page-title",children:"Blocked actions"}),r.jsxs("span",{className:"blocked-today",children:[g," today · nothing ran"]})]}),t.length===0?r.jsx(Zr,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):r.jsx("div",{className:"blocked-list",children:t.map((p,v)=>{const y=Gv(p,p.profile?a[p.profile]:void 0);return r.jsxs("div",{className:"blocked-row","data-kind":Ys(p),children:[r.jsx("span",{className:`blocked-dot blocked-dot-${Ys(p)}`,"aria-hidden":"true"}),r.jsxs("div",{className:"blocked-row-main",children:[r.jsx("div",{className:"blocked-title",children:y.title}),r.jsx("div",{className:"blocked-sentence",children:y.sentence}),r.jsx("div",{className:"blocked-source",children:y.sourceLine}),r.jsxs("details",{children:[r.jsx("summary",{children:"What you can do"}),r.jsx("div",{className:"blocked-advice",children:y.whatYouCanDo})]})]}),r.jsx("div",{className:"blocked-when",children:new Date(p.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},`${p.ts}-${v}`)})})]})}const fj={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function hj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{s(await M.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),u(null);try{await M.setAutostart(!t.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await M.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[t,a,h]);if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read autostart state: ${c}`:"Checking…"})]});const p=fj[t.platform]??"a login service";return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:t.supported?r.jsxs(r.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):t.reason})]}),t.supported&&r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.installed,className:t.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":t.installed?"Turn off":"Turn on"})]}),t.supported&&r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",r.jsx("strong",{children:t.installed?"On — starts from your next login":"Off"})]}),t.supported&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",r.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:c})]})}function mj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{const p=await M.getGatewaySettings();s(p.desktopNotifications),u(null)}catch(p){u(p instanceof Error?p.message:"Could not read notification setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(t===null||a)){o(!0),u(null);try{const p=await M.setGatewaySettings({desktopNotifications:!t});s(p.desktopNotifications)}catch(p){u(p instanceof Error?p.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]);return t===null?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]}):r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t,className:t?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t?"Turn off":"Turn on"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const Kf={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function pj(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,u]=f.useState(null),h=f.useCallback(async()=>{try{s(await M.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!t||a)){o(!0),u(null);try{s(await M.setIdentityDisclosure(!t.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]),p=r.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]});const v=t.verified&&t.name?`${t.name} — ${t.method==="as_vouched"?`${Kf.as_vouched} ${t.verifier}`:Kf[t.method??""]??t.method}`:null;return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[p,r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[t.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.always,className:t.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t.always?"Turn off":"Always show my name"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const gj={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function yj(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=lc();return t?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",r.jsx("strong",{children:t}),a&&s?r.jsxs(r.Fragment,{children:[" — ",r.jsx("strong",{children:s})," is available"]}):null]}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[gj[o]??"Update checking is unavailable",o==="dev"&&r.jsx(r.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function ql({title:t}){return r.jsxs("span",{className:"it-locked-badge",title:t,children:[r.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function qf(t){return t===!0}function vj(){const[t,s]=f.useState(null),[a,o]=f.useState(null);f.useEffect(()=>{let h=!1;return M.getAsPairing().then(g=>{h||s(g)}).catch(g=>{h||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{h=!0}},[]);const c=qf(t==null?void 0:t.asUrlLockedByPolicy),u=qf(t==null?void 0:t.pinTlsLockedByPolicy);return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),c&&r.jsx(ql,{})]}),!t&&!a&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&r.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:a}),t&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"URL:"})," ",r.jsx("code",{children:t.asUrl})]}),t.paired&&t.fingerprint?r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"Key fingerprint:"})," ",r.jsx("code",{children:t.fingerprint}),r.jsx("br",{}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(t.tlsPinFingerprint||t.pinTlsEnabled)&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"TLS certificate pin:"})," ",u&&r.jsx(ql,{title:"TLS pinning is set by your IT policy"})," ",t.tlsPinFingerprint?r.jsx("code",{children:t.tlsPinFingerprint}):r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",t.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),r.jsx("br",{}),r.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[t.pinTlsEnabled?r.jsxs(r.Fragment,{children:["TLS pinning is ON",u?r.jsx(r.Fragment,{children:", set by your organization's IT policy"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):r.jsxs(r.Fragment,{children:["Captured at sign-in; not currently enforced",u?r.jsx(r.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),c?r.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):r.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",r.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function xj(){const{simulation:t,locked:s}=Hh();return s?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',t!==null&&r.jsxs(r.Fragment,{children:[" ","Currently ",r.jsx("strong",{children:t?"ON":"OFF"}),t?" — real systems are not reachable from this gateway.":"."]})]})]}),r.jsx(ql,{})]}),r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",t!==null?` (currently ${t?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const wj={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},Ws=["AI Assistant","Authority Server","This computer","Security","Version"],Hs={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function jj(){const[t,s]=f.useState(""),[a,o]=f.useState("openrouter"),[c,u]=f.useState("openai-compatible"),[h,g]=f.useState("https://openrouter.ai/api/v1"),[p,v]=f.useState("google/gemma-4-31b-it"),[y,w]=f.useState(""),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=f.useState(!1),[R,$]=f.useState(null),[A,F]=f.useState([]),[G,q]=f.useState(!1),[de,K]=f.useState(null),[oe,V]=f.useState(""),D=f.useCallback(O=>{s(O),setTimeout(()=>s(""),3e3)},[]),ce=f.useCallback(async(O,H,b)=>{q(!0),K(null);try{const L=await M.aiModels({provider:O,endpoint:H,...b?{apiKey:b}:{}});L.ok&&L.models.length>0?(F(L.models),K(`${L.models.length} models available`)):(F([]),K(L.message||"No models returned — using defaults"))}catch(L){F([]),K(L instanceof Error?L.message:"Failed to load models")}finally{q(!1)}},[]),re=f.useCallback(async()=>{try{const O=await M.getCredential("ai-config");if(N(O.configured),O.configured&&O.fields){const H=O.fields.provider||"openai-compatible",b=O.fields.endpoint||"";O.fields.provider&&u(H),O.fields.endpoint&&g(b),O.fields.model&&v(O.fields.model),b.includes("openai.com")?o("openai"):b.includes("groq.com")?o("groq"):b.includes("together.xyz")?o("together"):b.includes("openrouter.ai")?o("openrouter"):o("ollama"),b&&ce(H,b)}}catch{}},[ce]);f.useEffect(()=>{re()},[re]);const Z=O=>{o(O),F([]),K(null),V("");const H=wj[O];H&&(u(H.provider),g(H.endpoint),v(""),ce(H.provider,H.endpoint,y||void 0))},he=()=>ce(c,h,y||void 0),ge=async()=>{S(!0);try{await M.setCredential("ai-config",{provider:c,endpoint:h,model:p,...y?{apiKey:y}:{}}),N(!0),D("AI configuration saved!")}catch{D("Failed to save AI config")}finally{S(!1)}},Y=async()=>{T(!0),$(null);try{const O=await M.aiTest({provider:c,endpoint:h,model:p,...y?{apiKey:y}:{}});$(O.ok?`OK: ${O.message}`:`Failed: ${O.message}`)}catch(O){$(`Error: ${O instanceof Error?O.message:"Unknown"}`)}finally{T(!1)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Settings"}),r.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),t&&r.jsx("div",{className:"alert alert-success",children:t}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[0]}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",children:"Configuration"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),j&&r.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[r.jsx("span",{className:"status-banner-icon",children:"✓"}),r.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:"Provider Preset"}),r.jsxs("select",{className:"form-input",value:a,onChange:O=>Z(O.target.value),children:[r.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),r.jsx("option",{value:"ollama",children:"Ollama (local)"}),r.jsx("option",{value:"openai",children:"OpenAI"}),r.jsx("option",{value:"groq",children:"Groq"}),r.jsx("option",{value:"together",children:"Together"})]})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("label",{className:"form-label",children:["API Key ",c==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),r.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:O=>w(O.target.value),onBlur:()=>{y.trim()&&ce(c,h,y.trim())},placeholder:j?"••••••••••••••••":"sk-... (not needed for Ollama)"}),r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsx("label",{className:"form-label",children:"Model"}),r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:he,disabled:G,title:"Re-fetch the model list from the provider",children:G?"Loading…":"↻ Refresh"})]}),A.length===0?r.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:G?"Loading models…":c==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const O=A,H=O.includes(p),b=O.length>12,L=oe.trim().toLowerCase();let J=L?O.filter(W=>W.toLowerCase().includes(L)):O;return H&&!J.includes(p)&&(J=[p,...J]),r.jsxs(r.Fragment,{children:[b&&r.jsx("input",{className:"form-input",value:oe,onChange:W=>V(W.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),r.jsxs("select",{className:"form-input",value:H?p:"__unset__",onChange:W=>v(W.target.value==="__unset__"?"":W.target.value),children:[r.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),J.map(W=>r.jsx("option",{value:W,children:W},W)),L&&J.length===0&&r.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",oe,"”"]})]})]})})(),de&&r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:de})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ge,disabled:E||!p.trim(),title:p.trim()?void 0:"Select a model first",children:E?"Saving...":"Save & Encrypt"}),j&&r.jsx("button",{className:"btn btn-ghost",onClick:Y,disabled:C,children:C?"Testing...":"Test Connection"})]}),R&&r.jsx("div",{className:`alert ${R.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:R})]}),r.jsx(Sj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[1]}),r.jsx(vj,{}),r.jsx(pj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[2]}),r.jsx(hj,{}),r.jsx(mj,{}),r.jsx(xj,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Hs,children:Ws[3]}),r.jsx("div",{className:"card",style:{padding:"1.5rem"},children:r.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"Every tool call verified against your mandate bounds"}),r.jsx("li",{children:"Credentials never exposed to agents through MCP"}),r.jsx("li",{children:"Every action produces a signed ticket"})]})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),r.jsx("li",{children:"For best security, run agents in sandboxed environments"}),r.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),r.jsxs("section",{children:[r.jsx("h2",{style:Hs,children:Ws[4]}),r.jsx(yj,{})]})]})}function Sj(){const[t,s]=f.useState(null),[a,o]=f.useState({intent:"",context:""}),[c,u]=f.useState(null),[h,g]=f.useState(null),[p,v]=f.useState(null),[y,w]=f.useState(!1),j=f.useCallback(async()=>{if(!y)try{const S=await M.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){g(S instanceof Error?S.message:"Failed to load prompts")}},[y]),N=async S=>{if(t){u(S),g(null);try{const C=a[S],T=C.trim()===t[S].default.trim()?"":C;await M.setAIPrompt(S,T);const R=await M.getAIPrompts();s(R),o({intent:R.intent.current,context:R.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(C){g(C instanceof Error?C.message:"Save failed")}finally{u(null)}}},E=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await M.setAIPrompt(S,"");const C=await M.getAIPrompts();s(C),o({intent:C.intent.current,context:C.context.current})}catch(C){g(C instanceof Error?C.message:"Revert failed")}finally{u(null)}}};return r.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&j()},children:[r.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),h&&r.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:h}),!y&&!h&&r.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(Yf,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:t.intent,draft:a.intent,onChange:S=>o(C=>({...C,intent:S})),onSave:()=>N("intent"),onRevert:()=>E("intent"),saving:c==="intent",justSaved:p==="intent"}),r.jsx(Yf,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:t.context,draft:a.context,onChange:S=>o(C=>({...C,context:S})),onSave:()=>N("context"),onRevert:()=>E("context"),saving:c==="context",justSaved:p==="context"})]})]})}function Yf({kind:t,label:s,description:a,state:o,draft:c,onChange:u,onSave:h,onRevert:g,saving:p,justSaved:v}){const y=c!==o.current;return r.jsxs("section",{style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),r.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),r.jsx("textarea",{className:"form-textarea",value:c,onChange:w=>u(w.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:h,disabled:p||!y,children:p?"Saving…":"Save"}),o.overridden&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),y&&!p&&!v&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),r.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:o.default})]}),r.jsx("span",{style:{display:"none"},children:t})]})}function bj(t){return t.proposalId?"review":"automatic"}function Jf(t,s,a={}){const o=a.status??"pending",c=a.includeAutonomous??!1,u=[];for(const h of t)o==="pending"&&h.status!=="pending"||a.profile&&h.profileId!==a.profile||u.push({kind:"proposal",id:h.id,sortTimestamp:h.createdAt,commitmentMode:"review",profileId:h.profileId,proposal:h});if(o==="all")for(const h of s){const g=bj(h);!c&&g==="automatic"||a.profile&&h.profileId!==a.profile||u.push({kind:"receipt",id:h.id,sortTimestamp:h.timestamp,commitmentMode:g,profileId:h.profileId,receipt:h})}return u.sort((h,g)=>g.sortTimestamp-h.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const kj=["https://","http://"];function xm(t,s){return t!=null&&t.length?t.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(c,u)=>{const h=s[u];return typeof h=="string"||typeof h=="number"?String(h):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:kj.some(c=>o.toLowerCase().startsWith(c))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function wm(t,s){const a=t-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),c=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let h;return o>0?h=`expires in ${o}d ${c}h`:c>0?h=`expires in ${c}h ${u}m`:h=`expires in ${Math.max(1,u)}m`,{label:h,urgent:a<2*3600,expired:!1}}const Nj=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Cj(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:Nj.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Jr(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Qf({row:t,which:s}){const a=ta(t.profileRef),o=dw(t.value,a,s);return o.length===0?r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(c=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)"},title:c.hint,children:c.label}),r.jsxs("dd",{style:{margin:0,fontWeight:600},children:[c.value,c.unknown&&r.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},c.key))})}function Ej({row:t}){const s=ta(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return r.jsxs(r.Fragment,{children:[(s==null?void 0:s.name)??ut(a),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function Tj({row:t,altText:s}){switch(t.kind){case"profile":return r.jsx(Ej,{row:t});case"profile-limits":return r.jsx(Qf,{row:t,which:"limits"});case"profile-scope":return r.jsx(Qf,{row:t,which:"scope"});case"markdown":return r.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Jr(t.value)});case"list":return Array.isArray(t.value)?r.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:t.value.map((a,o)=>r.jsx("li",{children:Jr(a)},o))}):r.jsx(r.Fragment,{children:Jr(t.value)});case"money":return r.jsxs(r.Fragment,{children:[Jr(t.value),t.currency?` ${t.currency}`:""]});case"object":return r.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Jr(t.value)});default:return Cj(t.key,t.value)?r.jsx("img",{src:t.value,alt:s??t.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):r.jsx(r.Fragment,{children:Jr(t.value)})}}function jm({args:t,display:s,heading:a="Details"}){const o=uw(t,s);if(o.length===0)return null;const c=typeof t.altText=="string"?t.altText:void 0;return r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:o.map(u=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:u.hint,children:u.label}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:r.jsx(Tj,{row:u,altText:c})})]},u.key))})]})}function Rj({proposalId:t,systemName:s}){const[a,o]=f.useState(null);if(f.useEffect(()=>{let u=!0;return o(null),M.getProposalOutcome(t).then(h=>{u&&o(h)}).catch(()=>{}),()=>{u=!1}},[t]),!a)return null;const c=Uw(a,s);return c?r.jsxs("div",{className:"outcome-box",children:[r.jsx("h4",{children:c.heading}),r.jsx("p",{className:"outcome-note",children:c.note})]}):null}let $l=null;function Ij(){return $l||($l=M.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),$l}function Aj(t){const[s,a]=f.useState(void 0);return f.useEffect(()=>{let o=!0;if(t)return Ij().then(c=>{o&&a(c.get(t))}),()=>{o=!1}},[t]),s}function Pj(t,s){const[a,o]=f.useState(null),[c,u]=f.useState(!1),[h,g]=f.useState(null);return f.useEffect(()=>{let p=!0;return o(null),g(null),u(!0),(async()=>{var v;try{try{const j=await M.getGateContent(t);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){p&&o(j.gateContent.intent);return}}catch{}const y=await M.getAttestationIntent(t);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const w=await M.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});p&&o(w)}catch(y){p&&g(y instanceof Error?y.message:"Failed to decrypt intent")}finally{p&&u(!1)}})(),()=>{p=!1}},[t,s]),{intent:a,loading:c,error:h}}async function Sm(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await M.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function _j(t){if(!t.content)return[];const s=new Set([...t.createdBy?[t.createdBy]:[],...t.pendingApprovers??[]]),a=new Set(Object.keys(t.content.keys));return Array.from(s).filter(o=>!a.has(o))}function bm(t){return!t.loading&&t.readable}function km(t,s){const a=new Set;if(t.content)for(const o of Object.keys(t.content.keys))a.add(o);else{t.createdBy&&a.add(t.createdBy);for(const o of t.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function ji(t){const s=await Sm(t);if(s)return cm("jcs",s)}function $j(t){var o;const[s,a]=f.useState((t==null?void 0:t.note)??null);return f.useEffect(()=>{let c=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),M.decryptProposalContent(t.noteEncrypted).then(({plaintext:u})=>{c&&a(u)}).catch(()=>{c&&a(null)}),()=>{c=!1}},[t==null?void 0:t.note,(o=t==null?void 0:t.noteEncrypted)==null?void 0:o.ciphertext]),s}const Lj={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function Nm(t){var o;const[s,a]=f.useState(Lj);return f.useEffect(()=>{let c=!0;if(t.toolArgs){a({toolArgs:t.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!t.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Sm(t);c&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{c=!1}},[(o=t.content)==null?void 0:o.ciphertext,t.toolArgs]),s}function Xf(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[a,o]of Object.entries(t))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function zj(t){const s=Xf(t.limits),a=Xf(t.scope),o=typeof t.intent=="string"?t.intent:"",c={bounds:s,context:a,gateContent:{intent:o}};return(t.mode==="automatic"||t.mode==="review")&&(c.templateMode=t.mode),typeof t.duration_hours=="number"&&t.duration_hours>0&&(c.templateTtl=Math.round(t.duration_hours*3600)),c}function Cm(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>Cm(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Fj="setup__create_mandate";function Em({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:c,onContentState:u,onShownSnapshot:h}){const[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(null),N=mn(),{group:E,groupId:S,domain:C}=pt(),T=Object.entries(t.executionContext),R=ta(t.profileId),$=Aj(t.authorizationId),A=yw(t.executionContext,$,R),F=lw(t.tool),{integrationId:G}=Fi(t.tool),q=jc(G,c),{intent:de,loading:K,error:oe}=Pj(t.authorizationId,s),V=Nm(t),D=V.toolArgs!==null;f.useEffect(()=>{u==null||u({loading:V.loading,readable:D})},[V.loading,D]);const ce=_j(t),re=V.toolArgs?xm(a,V.toolArgs):[],Z=async()=>{if(!S){j("No active workspace; cannot open the mandate screen.");return}y(!0),j(null);try{if(!V.toolArgs){j("This content is not readable on this device yet.");return}const W=V.toolArgs,ee=typeof W.profile=="string"?W.profile:"",xe=await M.listProfiles(),ke=sm(ee,xe);if(!ke){j(`Unknown profile "${ee}".`);return}const ve=await M.getProfile(ke.id),ne=zj(W),Ae=im(ne.bounds,ve),Ee=om(ne.context,ve);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ke.id,groupId:S,groupName:(E==null?void 0:E.name)??null,domain:C,isPersonal:!!(E!=null&&E.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...ne,bounds:Ae,context:Ee})),sessionStorage.setItem("agentReplacesProposal",t.id),N("/mandates/new/intent")}catch(W){j(W instanceof Error?W.message:"Could not open the mandate screen.")}finally{y(!1)}},[he,ge]=f.useState(null),Y=Ww(he),[O,H]=f.useState(null),[b,L]=f.useState(null);f.useEffect(()=>{if(!O||!b){h==null||h(null);return}const W=O.status==="ok"?O.readAt:Date.now();h==null||h({readAt:W,preview:O,requestContext:b,...V.toolArgs?{toolArgs:V.toolArgs}:{},sealed:V.sealed})},[O,b,V.toolArgs,V.sealed,h]);const J=V.toolArgs?r.jsxs(r.Fragment,{children:[r.jsx(jm,{args:V.toolArgs,display:o,heading:""}),T.length>0&&r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([W,ee],xe)=>{const{label:ke,hint:ve}=lm(W,R);return r.jsxs("span",{children:[xe>0&&" · ",r.jsxs("span",{title:ve,children:[ke,"=",Cm(ee)]})]},W)})})]}):null;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"approval-headline",children:F}),V.sealed&&V.undecryptable&&r.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[r.jsx("strong",{children:"Encrypted for another device."}),r.jsx("p",{style:{margin:"0.35rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),V.sealed&&V.loading&&r.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),Y&&D&&r.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[r.jsxs("h4",{children:["What will be sent",V.sealed?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),J,V.sealed&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Decrypted on this device. suveren.ai stores only an unreadable copy and its fingerprint."})]}),ce.length>0&&r.jsxs("p",{"data-testid":"proposal-cannot-read",style:{margin:"0 0 0.5rem",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Cannot read this proposal yet: ",ce.join(", ")," — shared automatically once they sign in on a device."]}),D&&r.jsx(Gw,{proposalId:t.id,systemName:q,toolArgs:V.toolArgs,sealed:V.sealed,onTone:ge,onData:H}),D&&r.jsx(ej,{proposalId:t.id,onData:L}),D&&r.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]})]}),A.length>0&&r.jsxs("div",{className:"limit-checks",children:[r.jsx("h4",{children:"Within your limits"}),r.jsx("ul",{className:"limit-check-list",children:A.map(W=>r.jsxs("li",{className:W.ok?"ok":"bad",children:[r.jsx("span",{className:"limit-check-icon",children:W.ok?"✓":"✗"}),r.jsxs("span",{children:[W.label," ",W.valueText," — your limit ",W.limitText]})]},W.key))})]}),r.jsxs("div",{className:"mandate-intent",children:[r.jsxs("dl",{children:[r.jsx("dt",{children:"Mandate"}),r.jsxs("dd",{children:[r.jsx("strong",{children:(R==null?void 0:R.name)??ut(t.profileId)}),r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]})]}),r.jsxs("dl",{children:[r.jsx("dt",{children:"Intent"}),r.jsx("dd",{children:oe?r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:oe}):de!==null?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`intent-text${g?"":" intent-clamped"}`,children:de}),r.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>p(!g),children:g?"Show less":"Show full intent"})]}):K?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),D&&re.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:re.map(W=>r.jsxs("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:W.description??W.href,children:[W.label," ↗"]},W.label))}),!Y&&D&&r.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[r.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),r.jsx("div",{style:{marginTop:"0.5rem"},children:J})]}),D&&t.tool===Fj&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",margin:"0 0 0.4rem"},children:["The intent above is written by the AI, but it becomes ",r.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:Z,disabled:v,children:v?"Opening…":"Edit before signing"}),w&&r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:"0.4rem 0 0"},children:w})]})]})}function Tm({note:t,onNoteChange:s,onSend:a,onCancel:o,sending:c,error:u}){return r.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),r.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:b0.map(h=>r.jsx("button",{type:"button",className:`filter-chip${em(t,h)?" selected":""}`,onClick:()=>s(N0(t,h)),disabled:c,children:h},h))}),r.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:Ci,onChange:h=>s(h.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:c,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),r.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[t.length," / ",Ci]}),u&&r.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:u}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[r.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",style:{background:"var(--warning)",borderColor:"var(--warning)"},onClick:a,disabled:c,children:c?"Sending…":"Send back for change"}),r.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:c,children:"Cancel"})]}),r.jsx("p",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:"The AI is told: adjust and propose again — a new proposal you approve again. Nothing runs from this one."})]})}const Oj={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},Mj={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Zf={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function Ll(t){const s=Date.now()-t*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(t*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Bj(t){return t.split("__").pop()??t}function Dj(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function Rm(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>Rm(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function eh({item:t,onApprove:s,onReject:a,onChangeNeeded:o,resolving:c,proposalLinks:u,toolDisplay:h,manifests:g,currentUserId:p}){const v=t.kind==="proposal",y=v?t.proposal.status:"executed",w=v?t.proposal.tool:t.receipt.action,j=Bj(w),N=Dj(w),{integrationId:E}=Fi(w),S=jc(E,g),[C,T]=f.useState(!1),[R,$]=f.useState(""),[A,F]=f.useState(""),G=f.useRef(null),q=async()=>{const W=G.current;if(!(!W||!v))try{const{shownHash:ee}=await M.saveShownSnapshot(t.proposal.id,W);return ee}catch{return}},de=async()=>{const W=wc(R);if(!W.valid){F(W.error);return}F("");const ee=await q();o==null||o(t.id,W.trimmed,ee)},K=v&&y==="rejected"?R0(t.proposal,p??""):null,oe=v&&y==="refused"?I0(t.proposal):null,V=$j(v?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),D=ta(t.profileId),ce=Nm(v?t.proposal:{toolArgs:void 0,content:void 0}),re=v?ce.toolArgs:null,Z=v?t.proposal.executionContext:t.receipt.executionContext,he=v?null:t.receipt.cumulativeState,[ge,Y]=f.useState(!0),[O,H]=f.useState(!1),b=v&&ce.toolArgs?xm(u,ce.toolArgs):[],L=Object.entries(Z??{}),J=Nr(t.profileId).testSetup||zi(w);return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:j}),J&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),t.commitmentMode==="automatic"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[v&&y==="pending"&&(()=>{const W=wm(t.proposal.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:W.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:W.urgent?600:400,whiteSpace:"nowrap"},children:W.label})})(),r.jsx("span",{"data-testid":K||oe?"outcome-kind":void 0,className:`status-badge ${K?Zf[K.kind]:oe?Zf.REFUSED:Mj[y]}`,children:K?K.kind:oe?oe.kind:Oj[y]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ll(t.sortTimestamp)})]})]}),v&&t.proposal.status==="executed"&&r.jsx(Rj,{proposalId:t.proposal.id,systemName:S}),K&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By ",K.who,", ",Ll(K.at)]}),(V??K.note)&&r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[K.kind==="CHANGE NEEDED"?"Change: ":"Note: ",V??K.note]})]}),oe&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By the Authority Server, ",Ll(oe.at)]}),r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",oe.message]})]}),N&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[r.jsx("span",{children:"⚠"}),r.jsx("span",{children:"Irreversible action"})]}),v&&typeof(re==null?void 0:re._imagePreview)=="string"&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),r.jsx("img",{src:re._imagePreview,alt:typeof(re==null?void 0:re.altText)=="string"?re.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),v&&y==="pending"?r.jsx(Em,{proposal:t.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:h,manifests:g,onContentState:({loading:W,readable:ee})=>{H(W),Y(ee)},onShownSnapshot:W=>{G.current=W}}):r.jsxs(r.Fragment,{children:[b.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:b.map(W=>r.jsxs("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:W.description??W.href,children:[W.label," ↗"]},W.label))}),v?r.jsxs(r.Fragment,{children:[re&&r.jsx(jm,{args:re,display:h}),L.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:L.map(([W,ee])=>`${W}=${Rm(ee)}`).join(" · ")})]}):r.jsxs(r.Fragment,{children:[r.jsx(mm,{receipt:t.receipt,profile:D}),t.receipt.proposalId&&r.jsx(vm,{proposalId:t.receipt.proposalId,tool:t.receipt.action,manifests:g})]})]}),he&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",he.daily.count," action",he.daily.count===1?"":"s",he.daily.amount>0?`, ${he.daily.amount}`:""," · ","this month: ",he.monthly.count,he.monthly.amount>0?`, ${he.monthly.amount}`:""]}),v&&y==="pending"&&bm({loading:O,readable:ge})&&(C?r.jsx(Tm,{note:R,onNoteChange:$,onSend:de,onCancel:()=>{T(!1),$(""),F("")},sending:!!c,error:A}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:async()=>s==null?void 0:s(t.id,await q()),disabled:c,children:c?"Approving…":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>T(!0),disabled:c,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:async()=>a==null?void 0:a(t.id,await q()),disabled:c,children:"Reject"})]})),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[v?"Proposal":"Ticket",": ",t.id]})]})]})}function Uj(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Wj({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:c,toolDisplay:u,manifests:h}){const[g,p]=f.useState(!1),[v,y]=f.useState(!1),[w,j]=f.useState(!1),[N,E]=f.useState(""),[S,C]=f.useState(""),[T,R]=f.useState(!1),[$,A]=f.useState(!1),[F,G]=f.useState(!0),q=f.useRef(null),de=async()=>{const O=q.current;if(O)try{const{shownHash:H}=await M.saveShownSnapshot(t.id,O);return H}catch{return}},K=Nr(t.profileId).testSetup||zi(t.tool),oe=t.pendingApprovers??[],V=t.approvedBy??{},D=Object.keys(V).length,ce=oe.filter(O=>!(O in V)).length,re=s in V,Z=async()=>{if(pc()){o(gc);return}p(!0),o("");try{const O=await ji(t),H=await de();await M.approveProposal(t.id,O,H);try{const b=await M.getAttestationIntent(t.authorizationId);if(b){const L=await M.decryptIntent({intentCiphertext:b.intentCiphertext,encryptedKey:b.encryptedKey,approverId:s});await M.storeApprovedIntent(t.authorizationId,L)}}catch{}o(`Approved. ${ce-1>0?`${ce-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),a()}catch(O){o(O instanceof Error?O.message:"Approval failed")}finally{p(!1)}},he=async()=>{y(!0),o("");try{const O=await ji(t),H=await de();await M.rejectProposal(t.id,tm(),O,H),o("Action rejected."),a()}catch(O){o(O instanceof Error?O.message:"Rejection failed")}finally{y(!1)}},ge=async()=>{const O=wc(N);if(!O.valid){C(O.error);return}C(""),R(!0),o("");try{const{noteEncrypted:H}=await M.encryptProposalNote(O.trimmed,km(t,s)),b=await ji(t),L=await de();await M.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:H},b,L),o("Sent back for a change."),a()}catch(H){o(H instanceof Error?H.message:"Failed to send back")}finally{R(!1)}},Y=g||v||T;return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),K&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const O=wm(t.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:O.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:O.urgent?600:400,whiteSpace:"nowrap"},children:O.label})})(),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Uj(t.createdAt)})]})]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[D," of ",oe.length," approver",oe.length===1?"":"s"," signed off",oe.map(O=>{const H=O in V;return r.jsxs("span",{style:{marginLeft:"0.5rem",color:H?"var(--success, green)":"var(--text-tertiary)"},children:[H?"✓":"○"," ",O===s?"You":O]},O)})]}),r.jsx(Em,{proposal:t,currentUserId:s,proposalLinks:c,toolDisplay:u,manifests:h,onContentState:({loading:O,readable:H})=>{A(O),G(H)},onShownSnapshot:O=>{q.current=O}}),!re&&bm({loading:$,readable:F})&&(w?r.jsx(Tm,{note:N,onNoteChange:E,onSend:ge,onCancel:()=>{j(!1),E(""),C("")},sending:T,error:S}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:Y,children:g?"Approving...":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>j(!0),disabled:Y,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:he,disabled:Y,children:v?"Rejecting...":"Reject"})]})),re&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function Hj(){const{domain:t,user:s}=pt(),a=(s==null?void 0:s.id)??"",[o,c]=f.useState("awaiting-me"),[u,h]=f.useState([]),[g,p]=f.useState([]),[v,y]=f.useState({}),[w,j]=f.useState(!0),[N,E]=f.useState(""),S=f.useCallback(async()=>{try{const se=await M.getProposalsForApprover();h(se)}catch{}finally{j(!1)}},[]);Ue("proposal-added",S),Ue("proposal-approved",S),Ue("proposal-rejected",S),Ue("proposal-resolved",S),nn(S,3e4);const[C,T]=f.useState([]),R=f.useCallback(async()=>{try{const se=await M.getMyProposals(t);T(se)}catch{}},[t]);Ue("proposal-added",R),Ue("proposal-approved",R),Ue("proposal-rejected",R),Ue("proposal-resolved",R),Ue("execution-failed",R),nn(R,3e4,t);const $=f.useMemo(()=>C.filter(se=>{var je;return se.status==="pending"&&(((je=se.pendingApprovers)==null?void 0:je.length)??0)===0}),[C]),A=f.useMemo(()=>Jf($,[],{status:"pending"}),[$]),[F,G]=f.useState([]),q=f.useCallback(async()=>{if(a)try{const je=(await M.getMyProposals(t)).filter($e=>$e.status==="pending"&&$e.pendingApprovers&&$e.pendingApprovers.includes(a)&&$e.approvedBy&&a in $e.approvedBy);G(je)}catch{}},[a,t]);Ue("proposal-approved",q),Ue("proposal-rejected",q),nn(q,3e4,`${a}:${t}`),f.useEffect(()=>{M.getIntegrationManifests().then(se=>p(se.manifests??[])).catch(()=>{}),M.getToolDisplay().then(y).catch(()=>{})},[]);const de=se=>{var je;return(je=g.find($e=>$e.id===se.split("__")[0]))==null?void 0:je.proposalLinks};f.useEffect(()=>{S(),R(),q()},[]);const[K,oe]=f.useState([]),[V,D]=f.useState([]),[ce,re]=f.useState(!0),[Z,he]=f.useState(null),[ge,Y]=f.useState(""),[O,H]=f.useState("pending"),[b,L]=f.useState(null),[J,W]=f.useState(!1),ee=f.useCallback(async()=>{try{const{proposals:se,receipts:je}=await M.getThread({domain:t,status:O,sinceDays:7});oe(se),D(je)}catch{}finally{re(!1)}},[t,O]);nn(ee,3e4,`${t}:${O}`);const xe=async(se,je,$e,dt)=>{if(je==="commit"&&pc()){Y(gc);return}he(se),Y("");try{const Ve=K.find(P=>P.id===se)??C.find(P=>P.id===se),tt=gv(Ve,t),gt=Ve?await ji(Ve):void 0;let ft=$e??{};if(($e==null?void 0:$e.outcome)==="change_needed"&&$e.note){const P=Ve?km(Ve,a):[a],{noteEncrypted:ae}=await M.encryptProposalNote($e.note,P);ft={outcome:"change_needed",noteEncrypted:ae}}const ze=await M.resolveProposal(se,je,tt,{...ft,contentHash:gt,shownHash:dt});Y(je==="commit"?`Action approved. Status: ${ze.status}`:($e==null?void 0:$e.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ee(),R()])}catch(Ve){Y(Ve instanceof Error?Ve.message:"Failed")}finally{he(null)}},ke=(se,je)=>xe(se,"commit",void 0,je),ve=(se,je)=>xe(se,"reject",tm(),je),ne=(se,je,$e)=>xe(se,"reject",C0(je),$e),Ae=f.useMemo(()=>{const se=new Set;for(const je of K)se.add(je.profileId);for(const je of V)se.add(je.profileId);return Array.from(se).sort()},[K,V]),Ee=f.useMemo(()=>Jf(K,V,{status:O,profile:b??void 0,includeAutonomous:J}),[K,V,O,b,J]),Le=f.useCallback(()=>{S(),q()},[S,q]),fe=f.useMemo(()=>{const se=new Set,je=[];for(const $e of F)se.has($e.id)||(se.add($e.id),je.push($e));return je.sort(($e,dt)=>dt.createdAt-$e.createdAt)},[F]),_e=u.length+A.length,We=fe.length;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Pending Approvals"}),r.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),r.jsx(Uh,{what:"approve"})]}),r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[r.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>c("awaiting-me"),children:["Awaiting me ",_e>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:_e})]}),r.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>c("awaiting-others"),children:["Awaiting others ",We>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:We})]}),r.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{c("all"),ee()},children:"All"})]}),o==="awaiting-me"&&r.jsx(r.Fragment,{children:w&&_e===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(N||ge)&&r.jsx("div",{className:"alert alert-success",children:N||ge}),A.map(se=>r.jsx(eh,{proposalLinks:se.kind==="proposal"?de(se.proposal.tool):void 0,toolDisplay:se.kind==="proposal"?v[se.proposal.tool]:void 0,manifests:g,currentUserId:a,item:se,onApprove:ke,onReject:ve,onChangeNeeded:ne,resolving:Z===se.id},se.id)),u.map(se=>r.jsx(Wj,{proposal:se,currentUserId:a,onAction:Le,onMessage:E,proposalLinks:de(se.tool),toolDisplay:v[se.tool],manifests:g},se.id))]})}),o==="awaiting-others"&&r.jsx(r.Fragment,{children:fe.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:fe.map(se=>r.jsx(Gj,{proposal:se,currentUserId:a,onCancel:async()=>{try{await M.rejectProposal(se.id,{reason:"cancelled by creator"}),q(),R()}catch(je){alert(je instanceof Error?je.message:"Cancel failed")}}},se.id))})}),o==="all"&&r.jsxs(r.Fragment,{children:[ge&&r.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:ge}),r.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[r.jsx("button",{className:`filter-chip ${O==="pending"?"selected":""}`,onClick:()=>H("pending"),children:"Pending"}),r.jsx("button",{className:`filter-chip ${O==="all"?"selected":""}`,onClick:()=>H("all"),children:"All"}),Ae.length>0&&r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),Ae.map(se=>r.jsx("button",{className:`filter-chip ${b===se?"selected":""}`,onClick:()=>L(b===se?null:se),children:ut(se)},se)),O==="all"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),r.jsxs("button",{className:`filter-chip ${J?"selected":""}`,onClick:()=>W(!J),title:"Include actions executed without human review (automatic commitment mode)",children:[J?"✓ ":"","Autonomous actions"]})]})]}),ce&&Ee.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ee.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:O==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:O==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Ee.map(se=>r.jsx(eh,{proposalLinks:se.kind==="proposal"?de(se.proposal.tool):void 0,toolDisplay:se.kind==="proposal"?v[se.proposal.tool]:void 0,manifests:g,currentUserId:a,item:se,onApprove:ke,onReject:ve,onChangeNeeded:ne,resolving:Z===se.id},se.id))})]})]})}function Vj(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Gj({proposal:t,currentUserId:s,onCancel:a}){var y;const[o,c]=f.useState(!1),u=Object.keys(t.approvedBy??{}),h=(t.pendingApprovers??[]).filter(w=>!(w in(t.approvedBy??{}))),g=(((y=t.pendingApprovers)==null?void 0:y.length)??0)>0,p=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){c(!0);try{await a()}finally{c(!1)}}},v=Nr(t.profileId).testSetup||zi(t.tool);return r.jsxs("div",{className:"card id-card",children:[r.jsx(ea,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:t.tool.split("__").pop()??t.tool}),v&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),g&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Vj(t.createdAt)})]}),g&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[u.map(w=>r.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:w===s?"You approved":`${w} approved`},w)),h.map(w=>r.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",w===s?"you":w]},w))]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:p,disabled:o,children:o?"Cancelling...":"Cancel"})})]})]})}const Kj=`# Agent Brief
|
|
88
88
|
|
|
89
89
|
You act on my behalf through Suveren — the gateway that gates every
|
|
90
90
|
privileged tool call you make. Suveren implements the bounded-authority
|
|
@@ -120,4 +120,4 @@ executes. When you propose an action:
|
|
|
120
120
|
next.
|
|
121
121
|
- Never email anyone outside the company without asking first.
|
|
122
122
|
- When drafting posts, prefer plain language over marketing copy.
|
|
123
|
-
`;function qj(){const[t,s]=f.useState(""),[a,o]=f.useState(""),[c,u]=f.useState(!0),[h,g]=f.useState(!1),[p,v]=f.useState(null),[y,w]=f.useState(!1),j=t!==a,N=new Blob([t]).size,E=16*1024;f.useEffect(()=>{if(!j)return;const R=A=>{A.preventDefault(),A.returnValue=""},$=A=>{var q,de;if(A.defaultPrevented||A.button!==0||A.metaKey||A.ctrlKey||A.shiftKey||A.altKey)return;const F=(de=(q=A.target)==null?void 0:q.closest)==null?void 0:de.call(q,"a");if(!F||!F.href)return;let G;try{G=new URL(F.href)}catch{return}G.origin===window.location.origin&&G.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(A.preventDefault(),A.stopPropagation()))};return window.addEventListener("beforeunload",R),document.addEventListener("click",$,!0),()=>{window.removeEventListener("beforeunload",R),document.removeEventListener("click",$,!0)}},[j]),f.useEffect(()=>{let R=!1;return M.getAgentContext().then($=>{R||(s($),o($))}).catch($=>{R||v({kind:"error",text:$ instanceof Error?$.message:"Failed to load context"})}).finally(()=>{R||u(!1)}),()=>{R=!0}},[]);const S=async()=>{g(!0),v(null);try{await M.saveAgentContext(t),o(t),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(R){v({kind:"error",text:R instanceof Error?R.message:"Save failed"})}finally{g(!1)}},C=()=>{s(a),v(null)},T=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(Kj)};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Agent Brief"}),r.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!t.trim()&&!c&&r.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,disabled:h,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),p&&r.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),r.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[r.jsx("div",{className:"card intent-pane chat",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||s(R)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[r.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),r.jsxs("span",{style:{fontSize:"0.75rem",color:N>E?"var(--danger)":"var(--text-muted)"},children:[N.toLocaleString()," / ",E.toLocaleString()," bytes"]})]}),r.jsx("textarea",{className:"form-textarea",value:t,onChange:R=>s(R.target.value),placeholder:c?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:c,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),r.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:h||!j,children:"Revert"}),r.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:h||!j||N>E||c,children:h?"Saving…":"Save"})]})]}),r.jsx("button",{type:"button",className:"floating-help",onClick:()=>w(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),r.jsx(Kh,{open:y,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||(s(R),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Yj(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Jj(t){const s=t.find(c=>{var u;return c.kind==="sv-mandate"&&c.status!=="unverifiable"&&typeof((u=c.data)==null?void 0:u.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function Qj(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Xj(t,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${t.signaturesValid>0?`${t.signaturesValid} ✓ tickets`:`${t.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function Zj(t){return t.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:t.emailExportError}:{kind:"ok",text:`${t.coveredCases.length} of ${t.loadedCases.length}`}}function eS(t){return t.periodStart!==null?null:t.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:t.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function th(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function tS(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function nS(t,s){const a=s[t];return a==null||a===""||tS(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function rS(t){const s=[];return t.missingCases.length>0&&s.push(`cases ${t.missingCases.join(", ")}`),t.ticketsNotReferenced.length>0&&s.push(`${t.ticketsNotReferenced.length} ticket${t.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function sS(t,s){var a;if(s)return s;if(!t)return null;if(t.kind==="sv-ticket")return t.attrs.ref||null;if(t.kind==="sv-approval"||t.kind==="sv-mandate")return t.attrs.ticket||null;if(t.kind==="sv-case"){const o=(a=t.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const aS="allow-popups allow-popups-to-escape-sandbox",iS="AI analysis — not verified",oS="Green = verified by the gateway — raw signed fields only",lS="Grey dashed = the AI's own analysis, not verified",cS="= translation by the AI, not verified",uS="Übersetzung anzeigen / show translation";function nh(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function dS(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function fS(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const hS={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function mS(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${hS[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function pS(t){if(!t||t.kind!=="sv-case"||!t.data)return[];const s=Array.isArray(t.data.steps)?t.data.steps:[],a=t.data.goal,o=[...s.map(c=>({n:c,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(c=>typeof c.n.ticketId=="string"&&c.n.ticketId);return o.sort((c,u)=>(c.n.time??0)-(u.n.time??0)),o.map(({n:c,isGoal:u})=>({ticketId:c.ticketId,label:String(c.action??c.ticketId),isGoal:u}))}function gS(t){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${t}</body></html>`}const Sc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},yS={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function vS(t,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[t].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function xS(t,s){const a=yS[t].filter(o=>s[o]!==void 0);return a.length===0?null:r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),r.jsx("dl",{style:{...Sc,marginTop:"0.5rem"},children:a.map(o=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function zl(t,s){return s?r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:t}),s.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:Sc,children:vS(t,s.data??{}).map(({label:a,value:o})=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),xS(t,s.data??{})]})]}):null}function wS({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:c}){var w;const u=t.elements.find(j=>j.id===s),h=sS(u,a),g=h?t.ticketDetails[h]:void 0,p=pS(u),v=(w=t.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:w.summary,y=f.useRef(null);return f.useEffect(()=>{const j=y.current;if(!j||typeof j.getBoundingClientRect!="function")return;const N=j.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),r.jsxs("div",{className:"card reports-detail",ref:y,children:[r.jsxs("div",{className:"card-header",children:[r.jsx("div",{className:"card-title",children:"Details"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&r.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),p.length>0&&r.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(j=>r.jsxs("button",{type:"button",className:`btn btn-sm ${j.ticketId===h?"btn-secondary":"btn-ghost"}`,"aria-pressed":j.ticketId===h,onClick:()=>c(j.ticketId),children:[j.isGoal?"Goal: ":"",j.label]},j.ticketId))}),!u&&r.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!h&&(u.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):r.jsx("dl",{style:Sc,children:Object.keys(u.data??{}).map(j=>{const N=nS(j,u.data??{});return N===null?null:r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},j)})})),g&&r.jsxs(r.Fragment,{children:[zl("Ticket",g.ticket),zl("Mandate",g.mandate),zl("Approval",g.approval)]}),h&&!g&&r.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",h,"."]})]})}async function jS(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function rh({detail:t}){return t?r.jsxs("details",{style:{marginTop:"0.25rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),r.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:t})]}):null}function SS({report:t,open:s,selectedId:a,onOpenElement:o,detail:c}){const{proof:u,coverage:h}=t,g=mS(t.elements),p=rS(h),v=Zj(h),y=eS(h),w=th(u.signaturesValid),j=th(u.recordsChecked);return r.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[c,r.jsxs("div",{className:"card",children:[r.jsx("div",{className:"card-title",children:"Proof"}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets referenced"}),r.jsx("b",{children:u.ticketsReferenced.length})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Signatures valid"}),r.jsx("b",{style:w.kind==="ok"?{color:"var(--success)"}:void 0,children:w.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Records checked"}),r.jsx("b",{style:j.kind==="ok"?{color:"var(--success)"}:void 0,children:j.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Not verifiable"}),r.jsx("b",{children:u.unverifiableCount})]}),g.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[r.jsx("span",{children:N.text}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]}),r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"reports-error",role:"alert",children:v.text}),r.jsx(rh,{detail:v.detail})]}):r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Cases"}),r.jsx("b",{children:v.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets in test period"}),r.jsxs("b",{children:[h.ticketsReferenced.length," of ",h.ticketsInPeriod.length]})]}),y&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:y.detail?"reports-error":"reports-note",role:y.detail?"alert":void 0,children:y.text}),r.jsx(rh,{detail:y.detail})]}),p&&r.jsx("p",{className:"reports-missing",children:p})]}),u.verifiedValues.length>0&&r.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[r.jsx("span",{children:N.summary}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function bS(){const[t,s]=f.useState(null),[a,o]=f.useState(!0),[c,u]=f.useState(null),[h,g]=f.useState(!1),[p,v]=f.useState(!1),[y,w]=f.useState(null),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=oc(),R=f.useCallback(()=>M.getReport().then(({report:D})=>s(D)).catch(D=>u(D instanceof Error?D.message:String(D))),[]),$=f.useCallback(()=>{o(!0),u(null),R().finally(()=>o(!1))},[R]);f.useEffect(()=>{$()},[$]);const A=f.useCallback(()=>{g(!0),M.recheckReport().then(({report:D})=>s(D)).catch(D=>u(D instanceof Error?D.message:String(D))).finally(()=>g(!1))},[]),F=f.useCallback(async()=>{v(!0),w(null);try{await jS({exportReport:()=>M.exportReportWithProof(),download:(D,ce)=>{const re=URL.createObjectURL(new Blob([D],{type:"text/html"})),Z=document.createElement("a");Z.href=re,Z.download=ce,Z.click(),URL.revokeObjectURL(re)},refresh:R})}catch(D){w(D instanceof Error?D.message:String(D))}finally{v(!1)}},[R]),G=C.get("element"),q=C.get("ticket"),de=f.useCallback((D,ce)=>{T(fS(C,D,ce))},[C,T]),K=f.useCallback(()=>{const D=new URLSearchParams(C);D.delete("element"),D.delete("ticket"),T(D,{replace:!0})},[C,T]);if(a)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(c)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"⚠",title:"Report unavailable",text:c})]});if(!t)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const oe=Yj(t.renderedHtml),V=Jj(t.elements);return r.jsx("div",{className:"page-inner reports-page",children:r.jsxs("div",{className:"reports-layout",children:[r.jsxs("div",{className:"reports-bar",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:oe}),r.jsxs("p",{className:"page-subtitle",children:[V?`written by the AI under mandate ${V} · `:"","checked ",Qj(t.checkedAt)]})]}),r.jsxs("div",{className:"reports-bar-actions",children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:A,disabled:h,children:h?"Checking…":"Check again"}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:F,disabled:p,children:p?"Exporting…":"Export with proof"})]})]}),y&&r.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),r.jsxs("div",{className:"reports-summary-chip",children:[r.jsx("span",{children:Xj(t.proof,t.coverage)}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(D=>!D),children:j?"hide":"details"})]}),r.jsxs("div",{className:"reports-grid",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"reports-legend",role:"note",children:[r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-v"}),oS]}),r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-a"}),lS," (“",iS,"”)"]}),t.renderedHtmlGloss&&r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",cS]})]}),nh(t)&&r.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:nh(t)}),t.renderedHtmlGloss&&r.jsxs("label",{className:"reports-gloss-switch",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:E,onChange:D=>S(D.target.checked)}),r.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:r.jsx("span",{className:"reports-gloss-thumb"})}),r.jsx("span",{children:uS})]}),r.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),r.jsx("iframe",{title:"Report",sandbox:aS,srcDoc:gS(dS(t,E)),className:"reports-iframe"})]}),r.jsx(SS,{report:t,open:j||!!G,selectedId:G,onOpenElement:D=>de(D),detail:G?r.jsx(wS,{report:t,elementId:G,ticketParam:q,onClose:K,onSelectTicket:D=>de(G,D)}):void 0})]})]})})}function Qr({to:t}){const{search:s,hash:a}=Dt();return r.jsx(Pn,{to:`${t}${s}${a}`,replace:!0})}function kS({children:t}){const{user:s,mode:a,domain:o}=pt();return s?a==="team"&&!o?r.jsx(Pn,{to:"/onboarding",replace:!0}):r.jsx(r.Fragment,{children:t}):r.jsx(Pn,{to:"/login",replace:!0})}function NS(){const{user:t,handleSessionLocked:s,refreshGroups:a}=pt();return Ge("session-locked",o=>{const c=o==null?void 0:o.message;s(c)}),Ge("team-membership-changed",()=>{a()}),r.jsxs(_y,{children:[r.jsx(Xe,{path:"/login",element:t?r.jsx(Pn,{to:"/",replace:!0}):r.jsx(jx,{})}),r.jsx(Xe,{path:"/onboarding",element:t?r.jsx(Ex,{}):r.jsx(Pn,{to:"/login",replace:!0})}),r.jsxs(Xe,{element:r.jsx(kS,{children:r.jsx(wx,{})}),children:[r.jsx(Xe,{path:"/",element:r.jsx(Ux,{})}),r.jsx(Xe,{path:"/mandates",element:r.jsx(iw,{})}),r.jsx(Xe,{path:"/mandates/new/intent",element:r.jsx(h0,{})}),r.jsx(Xe,{path:"/mandates/new/sign",element:r.jsx(A0,{})}),r.jsx(Xe,{path:"/integrations",element:r.jsx(O0,{})}),r.jsx(Xe,{path:"/team",element:r.jsx(M0,{})}),r.jsx(Xe,{path:"/tickets",element:r.jsx(uj,{})}),r.jsx(Xe,{path:"/blocked",element:r.jsx(dj,{})}),r.jsx(Xe,{path:"/approvals",element:r.jsx(Hj,{})}),r.jsx(Xe,{path:"/reports",element:r.jsx(bS,{})}),r.jsx(Xe,{path:"/agent/new",element:r.jsx(Pn,{to:"/mandates?new=1",replace:!0})}),r.jsx(Xe,{path:"/agent/gate",element:r.jsx(Qr,{to:"/mandates/new/intent"})}),r.jsx(Xe,{path:"/agent/review",element:r.jsx(Qr,{to:"/mandates/new/sign"})}),r.jsx(Xe,{path:"/authorizations",element:r.jsx(Qr,{to:"/mandates"})}),r.jsx(Xe,{path:"/groups",element:r.jsx(Qr,{to:"/team"})}),r.jsx(Xe,{path:"/audit",element:r.jsx(Qr,{to:"/tickets"})}),r.jsx(Xe,{path:"/proposals",element:r.jsx(Qr,{to:"/approvals"})}),r.jsx(Xe,{path:"/agent-brief",element:r.jsx(qj,{})}),r.jsx(Xe,{path:"/settings",element:r.jsx(jj,{})}),r.jsx(Xe,{path:"/settings/services",element:r.jsx(Pn,{to:"/settings",replace:!0})}),r.jsx(Xe,{path:"/deploy",element:r.jsx(Pn,{to:"/integrations",replace:!0})})]}),r.jsx(Xe,{path:"*",element:r.jsx(Pn,{to:"/",replace:!0})})]})}function CS(){return r.jsx(sv,{children:r.jsx(xv,{children:r.jsx(wv,{children:r.jsx(NS,{})})})})}Ig.createRoot(document.getElementById("root")).render(r.jsx(f.StrictMode,{children:r.jsx(CS,{})}));
|
|
123
|
+
`;function qj(){const[t,s]=f.useState(""),[a,o]=f.useState(""),[c,u]=f.useState(!0),[h,g]=f.useState(!1),[p,v]=f.useState(null),[y,w]=f.useState(!1),j=t!==a,N=new Blob([t]).size,E=16*1024;f.useEffect(()=>{if(!j)return;const R=A=>{A.preventDefault(),A.returnValue=""},$=A=>{var q,de;if(A.defaultPrevented||A.button!==0||A.metaKey||A.ctrlKey||A.shiftKey||A.altKey)return;const F=(de=(q=A.target)==null?void 0:q.closest)==null?void 0:de.call(q,"a");if(!F||!F.href)return;let G;try{G=new URL(F.href)}catch{return}G.origin===window.location.origin&&G.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(A.preventDefault(),A.stopPropagation()))};return window.addEventListener("beforeunload",R),document.addEventListener("click",$,!0),()=>{window.removeEventListener("beforeunload",R),document.removeEventListener("click",$,!0)}},[j]),f.useEffect(()=>{let R=!1;return M.getAgentContext().then($=>{R||(s($),o($))}).catch($=>{R||v({kind:"error",text:$ instanceof Error?$.message:"Failed to load context"})}).finally(()=>{R||u(!1)}),()=>{R=!0}},[]);const S=async()=>{g(!0),v(null);try{await M.saveAgentContext(t),o(t),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(R){v({kind:"error",text:R instanceof Error?R.message:"Save failed"})}finally{g(!1)}},C=()=>{s(a),v(null)},T=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(Kj)};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Agent Brief"}),r.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!t.trim()&&!c&&r.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,disabled:h,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),p&&r.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),r.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[r.jsx("div",{className:"card intent-pane chat",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||s(R)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[r.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),r.jsxs("span",{style:{fontSize:"0.75rem",color:N>E?"var(--danger)":"var(--text-muted)"},children:[N.toLocaleString()," / ",E.toLocaleString()," bytes"]})]}),r.jsx("textarea",{className:"form-textarea",value:t,onChange:R=>s(R.target.value),placeholder:c?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:c,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),r.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:h||!j,children:"Revert"}),r.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:h||!j||N>E||c,children:h?"Saving…":"Save"})]})]}),r.jsx("button",{type:"button",className:"floating-help",onClick:()=>w(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),r.jsx(Kh,{open:y,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||(s(R),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Yj(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Jj(t){const s=t.find(c=>{var u;return c.kind==="sv-mandate"&&c.status!=="unverifiable"&&typeof((u=c.data)==null?void 0:u.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function Qj(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Xj(t,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${t.signaturesValid>0?`${t.signaturesValid} ✓ tickets`:`${t.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function Zj(t){return t.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:t.emailExportError}:{kind:"ok",text:`${t.coveredCases.length} of ${t.loadedCases.length}`}}function eS(t){return t.periodStart!==null?null:t.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:t.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function th(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function tS(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function nS(t,s){const a=s[t];return a==null||a===""||tS(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function rS(t){const s=[];return t.missingCases.length>0&&s.push(`cases ${t.missingCases.join(", ")}`),t.ticketsNotReferenced.length>0&&s.push(`${t.ticketsNotReferenced.length} ticket${t.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function sS(t,s){var a;if(s)return s;if(!t)return null;if(t.kind==="sv-ticket")return t.attrs.ref||null;if(t.kind==="sv-approval"||t.kind==="sv-mandate")return t.attrs.ticket||null;if(t.kind==="sv-case"){const o=(a=t.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const aS="allow-popups allow-popups-to-escape-sandbox",iS="AI analysis — not verified",oS="Green = verified by the gateway — raw signed fields only",lS="Grey dashed = the AI's own analysis, not verified",cS="= translation by the AI, not verified",uS="Übersetzung anzeigen / show translation";function nh(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function dS(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function fS(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const hS={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function mS(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${hS[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function pS(t){if(!t||t.kind!=="sv-case"||!t.data)return[];const s=Array.isArray(t.data.steps)?t.data.steps:[],a=t.data.goal,o=[...s.map(c=>({n:c,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(c=>typeof c.n.ticketId=="string"&&c.n.ticketId);return o.sort((c,u)=>(c.n.time??0)-(u.n.time??0)),o.map(({n:c,isGoal:u})=>({ticketId:c.ticketId,label:String(c.action??c.ticketId),isGoal:u}))}function gS(t){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${t}</body></html>`}const Sc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},yS={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function vS(t,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[t].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function xS(t,s){const a=yS[t].filter(o=>s[o]!==void 0);return a.length===0?null:r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),r.jsx("dl",{style:{...Sc,marginTop:"0.5rem"},children:a.map(o=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function zl(t,s){return s?r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:t}),s.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:Sc,children:vS(t,s.data??{}).map(({label:a,value:o})=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),xS(t,s.data??{})]})]}):null}function wS({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:c}){var w;const u=t.elements.find(j=>j.id===s),h=sS(u,a),g=h?t.ticketDetails[h]:void 0,p=pS(u),v=(w=t.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:w.summary,y=f.useRef(null);return f.useEffect(()=>{const j=y.current;if(!j||typeof j.getBoundingClientRect!="function")return;const N=j.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),r.jsxs("div",{className:"card reports-detail",ref:y,children:[r.jsxs("div",{className:"card-header",children:[r.jsx("div",{className:"card-title",children:"Details"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&r.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),p.length>0&&r.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(j=>r.jsxs("button",{type:"button",className:`btn btn-sm ${j.ticketId===h?"btn-secondary":"btn-ghost"}`,"aria-pressed":j.ticketId===h,onClick:()=>c(j.ticketId),children:[j.isGoal?"Goal: ":"",j.label]},j.ticketId))}),!u&&r.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!h&&(u.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):r.jsx("dl",{style:Sc,children:Object.keys(u.data??{}).map(j=>{const N=nS(j,u.data??{});return N===null?null:r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},j)})})),g&&r.jsxs(r.Fragment,{children:[zl("Ticket",g.ticket),zl("Mandate",g.mandate),zl("Approval",g.approval)]}),h&&!g&&r.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",h,"."]})]})}async function jS(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function rh({detail:t}){return t?r.jsxs("details",{style:{marginTop:"0.25rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),r.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:t})]}):null}function SS({report:t,open:s,selectedId:a,onOpenElement:o,detail:c}){const{proof:u,coverage:h}=t,g=mS(t.elements),p=rS(h),v=Zj(h),y=eS(h),w=th(u.signaturesValid),j=th(u.recordsChecked);return r.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[c,r.jsxs("div",{className:"card",children:[r.jsx("div",{className:"card-title",children:"Proof"}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets referenced"}),r.jsx("b",{children:u.ticketsReferenced.length})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Signatures valid"}),r.jsx("b",{style:w.kind==="ok"?{color:"var(--success)"}:void 0,children:w.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Records checked"}),r.jsx("b",{style:j.kind==="ok"?{color:"var(--success)"}:void 0,children:j.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Not verifiable"}),r.jsx("b",{children:u.unverifiableCount})]}),g.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[r.jsx("span",{children:N.text}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]}),r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"reports-error",role:"alert",children:v.text}),r.jsx(rh,{detail:v.detail})]}):r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Cases"}),r.jsx("b",{children:v.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets in test period"}),r.jsxs("b",{children:[h.ticketsReferenced.length," of ",h.ticketsInPeriod.length]})]}),y&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:y.detail?"reports-error":"reports-note",role:y.detail?"alert":void 0,children:y.text}),r.jsx(rh,{detail:y.detail})]}),p&&r.jsx("p",{className:"reports-missing",children:p})]}),u.verifiedValues.length>0&&r.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[r.jsx("span",{children:N.summary}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function bS(){const[t,s]=f.useState(null),[a,o]=f.useState(!0),[c,u]=f.useState(null),[h,g]=f.useState(!1),[p,v]=f.useState(!1),[y,w]=f.useState(null),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=oc(),R=f.useCallback(()=>M.getReport().then(({report:D})=>s(D)).catch(D=>u(D instanceof Error?D.message:String(D))),[]),$=f.useCallback(()=>{o(!0),u(null),R().finally(()=>o(!1))},[R]);f.useEffect(()=>{$()},[$]);const A=f.useCallback(()=>{g(!0),M.recheckReport().then(({report:D})=>s(D)).catch(D=>u(D instanceof Error?D.message:String(D))).finally(()=>g(!1))},[]),F=f.useCallback(async()=>{v(!0),w(null);try{await jS({exportReport:()=>M.exportReportWithProof(),download:(D,ce)=>{const re=URL.createObjectURL(new Blob([D],{type:"text/html"})),Z=document.createElement("a");Z.href=re,Z.download=ce,Z.click(),URL.revokeObjectURL(re)},refresh:R})}catch(D){w(D instanceof Error?D.message:String(D))}finally{v(!1)}},[R]),G=C.get("element"),q=C.get("ticket"),de=f.useCallback((D,ce)=>{T(fS(C,D,ce))},[C,T]),K=f.useCallback(()=>{const D=new URLSearchParams(C);D.delete("element"),D.delete("ticket"),T(D,{replace:!0})},[C,T]);if(a)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(c)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"⚠",title:"Report unavailable",text:c})]});if(!t)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const oe=Yj(t.renderedHtml),V=Jj(t.elements);return r.jsx("div",{className:"page-inner reports-page",children:r.jsxs("div",{className:"reports-layout",children:[r.jsxs("div",{className:"reports-bar",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:oe}),r.jsxs("p",{className:"page-subtitle",children:[V?`written by the AI under mandate ${V} · `:"","checked ",Qj(t.checkedAt)]})]}),r.jsxs("div",{className:"reports-bar-actions",children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:A,disabled:h,children:h?"Checking…":"Check again"}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:F,disabled:p,children:p?"Exporting…":"Export with proof"})]})]}),y&&r.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),r.jsxs("div",{className:"reports-summary-chip",children:[r.jsx("span",{children:Xj(t.proof,t.coverage)}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(D=>!D),children:j?"hide":"details"})]}),r.jsxs("div",{className:"reports-grid",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"reports-legend",role:"note",children:[r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-v"}),oS]}),r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-a"}),lS," (“",iS,"”)"]}),t.renderedHtmlGloss&&r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",cS]})]}),nh(t)&&r.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:nh(t)}),t.renderedHtmlGloss&&r.jsxs("label",{className:"reports-gloss-switch",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:E,onChange:D=>S(D.target.checked)}),r.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:r.jsx("span",{className:"reports-gloss-thumb"})}),r.jsx("span",{children:uS})]}),r.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),r.jsx("iframe",{title:"Report",sandbox:aS,srcDoc:gS(dS(t,E)),className:"reports-iframe"})]}),r.jsx(SS,{report:t,open:j||!!G,selectedId:G,onOpenElement:D=>de(D),detail:G?r.jsx(wS,{report:t,elementId:G,ticketParam:q,onClose:K,onSelectTicket:D=>de(G,D)}):void 0})]})]})})}function Qr({to:t}){const{search:s,hash:a}=Dt();return r.jsx(Pn,{to:`${t}${s}${a}`,replace:!0})}function kS({children:t}){const{user:s,mode:a,domain:o}=pt();return s?a==="team"&&!o?r.jsx(Pn,{to:"/onboarding",replace:!0}):r.jsx(r.Fragment,{children:t}):r.jsx(Pn,{to:"/login",replace:!0})}function NS(){const{user:t,handleSessionLocked:s,refreshGroups:a}=pt();return Ue("session-locked",o=>{const c=o==null?void 0:o.message;s(c)}),Ue("team-membership-changed",()=>{a()}),r.jsxs(_y,{children:[r.jsx(Xe,{path:"/login",element:t?r.jsx(Pn,{to:"/",replace:!0}):r.jsx(jx,{})}),r.jsx(Xe,{path:"/onboarding",element:t?r.jsx(Ex,{}):r.jsx(Pn,{to:"/login",replace:!0})}),r.jsxs(Xe,{element:r.jsx(kS,{children:r.jsx(wx,{})}),children:[r.jsx(Xe,{path:"/",element:r.jsx(Ux,{})}),r.jsx(Xe,{path:"/mandates",element:r.jsx(iw,{})}),r.jsx(Xe,{path:"/mandates/new/intent",element:r.jsx(h0,{})}),r.jsx(Xe,{path:"/mandates/new/sign",element:r.jsx(A0,{})}),r.jsx(Xe,{path:"/integrations",element:r.jsx(O0,{})}),r.jsx(Xe,{path:"/team",element:r.jsx(M0,{})}),r.jsx(Xe,{path:"/tickets",element:r.jsx(uj,{})}),r.jsx(Xe,{path:"/blocked",element:r.jsx(dj,{})}),r.jsx(Xe,{path:"/approvals",element:r.jsx(Hj,{})}),r.jsx(Xe,{path:"/reports",element:r.jsx(bS,{})}),r.jsx(Xe,{path:"/agent/new",element:r.jsx(Pn,{to:"/mandates?new=1",replace:!0})}),r.jsx(Xe,{path:"/agent/gate",element:r.jsx(Qr,{to:"/mandates/new/intent"})}),r.jsx(Xe,{path:"/agent/review",element:r.jsx(Qr,{to:"/mandates/new/sign"})}),r.jsx(Xe,{path:"/authorizations",element:r.jsx(Qr,{to:"/mandates"})}),r.jsx(Xe,{path:"/groups",element:r.jsx(Qr,{to:"/team"})}),r.jsx(Xe,{path:"/audit",element:r.jsx(Qr,{to:"/tickets"})}),r.jsx(Xe,{path:"/proposals",element:r.jsx(Qr,{to:"/approvals"})}),r.jsx(Xe,{path:"/agent-brief",element:r.jsx(qj,{})}),r.jsx(Xe,{path:"/settings",element:r.jsx(jj,{})}),r.jsx(Xe,{path:"/settings/services",element:r.jsx(Pn,{to:"/settings",replace:!0})}),r.jsx(Xe,{path:"/deploy",element:r.jsx(Pn,{to:"/integrations",replace:!0})})]}),r.jsx(Xe,{path:"*",element:r.jsx(Pn,{to:"/",replace:!0})})]})}function CS(){return r.jsx(sv,{children:r.jsx(xv,{children:r.jsx(wv,{children:r.jsx(NS,{})})})})}Ig.createRoot(document.getElementById("root")).render(r.jsx(f.StrictMode,{children:r.jsx(CS,{})}));
|