@prooflane/inspector-beta 0.1.0-beta.11 → 0.1.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +17 -0
- package/dist/server.mjs +27 -3
- package/dist/ui/assets/index-BV5kQQPQ.js +81 -0
- package/dist/ui/index.html +1 -1
- package/package.json +2 -2
- package/dist/ui/assets/index-DuZ7dgSo.js +0 -81
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var bT=Object.defineProperty;var wT=(e,t,n)=>t in e?bT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var vt=(e,t,n)=>wT(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function ST(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var HN={exports:{}},wp={},BN={exports:{}},ut={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var _d=Symbol.for("react.element"),NT=Symbol.for("react.portal"),kT=Symbol.for("react.fragment"),ET=Symbol.for("react.strict_mode"),_T=Symbol.for("react.profiler"),CT=Symbol.for("react.provider"),TT=Symbol.for("react.context"),RT=Symbol.for("react.forward_ref"),IT=Symbol.for("react.suspense"),AT=Symbol.for("react.memo"),PT=Symbol.for("react.lazy"),vj=Symbol.iterator;function $T(e){return e===null||typeof e!="object"?null:(e=vj&&e[vj]||e["@@iterator"],typeof e=="function"?e:null)}var VN={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qN=Object.assign,KN={};function yl(e,t,n){this.props=e,this.context=t,this.refs=KN,this.updater=n||VN}yl.prototype.isReactComponent={};yl.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};yl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function JN(){}JN.prototype=yl.prototype;function dy(e,t,n){this.props=e,this.context=t,this.refs=KN,this.updater=n||VN}var uy=dy.prototype=new JN;uy.constructor=dy;qN(uy,yl.prototype);uy.isPureReactComponent=!0;var yj=Array.isArray,YN=Object.prototype.hasOwnProperty,hy={current:null},ZN={key:!0,ref:!0,__self:!0,__source:!0};function XN(e,t,n){var a,r={},i=null,o=null;if(t!=null)for(a in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)YN.call(t,a)&&!ZN.hasOwnProperty(a)&&(r[a]=t[a]);var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}if(e&&e.defaultProps)for(a in l=e.defaultProps,l)r[a]===void 0&&(r[a]=l[a]);return{$$typeof:_d,type:e,key:i,ref:o,props:r,_owner:hy.current}}function OT(e,t){return{$$typeof:_d,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function py(e){return typeof e=="object"&&e!==null&&e.$$typeof===_d}function LT(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var xj=/\/+/g;function sm(e,t){return typeof e=="object"&&e!==null&&e.key!=null?LT(""+e.key):t.toString(36)}function Yu(e,t,n,a,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case _d:case NT:o=!0}}if(o)return o=e,r=r(o),e=a===""?"."+sm(o,0):a,yj(r)?(n="",e!=null&&(n=e.replace(xj,"$&/")+"/"),Yu(r,t,n,"",function(u){return u})):r!=null&&(py(r)&&(r=OT(r,n+(!r.key||o&&o.key===r.key?"":(""+r.key).replace(xj,"$&/")+"/")+e)),t.push(r)),1;if(o=0,a=a===""?".":a+":",yj(e))for(var l=0;l<e.length;l++){i=e[l];var c=a+sm(i,l);o+=Yu(i,t,n,c,r)}else if(c=$T(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=a+sm(i,l++),o+=Yu(i,t,n,c,r);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Hd(e,t,n){if(e==null)return e;var a=[],r=0;return Yu(e,a,"","",function(i){return t.call(n,i,r++)}),a}function MT(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var qs={current:null},Zu={transition:null},DT={ReactCurrentDispatcher:qs,ReactCurrentBatchConfig:Zu,ReactCurrentOwner:hy};function QN(){throw Error("act(...) is not supported in production builds of React.")}ut.Children={map:Hd,forEach:function(e,t,n){Hd(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Hd(e,function(){t++}),t},toArray:function(e){return Hd(e,function(t){return t})||[]},only:function(e){if(!py(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ut.Component=yl;ut.Fragment=kT;ut.Profiler=_T;ut.PureComponent=dy;ut.StrictMode=ET;ut.Suspense=IT;ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=DT;ut.act=QN;ut.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var a=qN({},e.props),r=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=hy.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)YN.call(t,c)&&!ZN.hasOwnProperty(c)&&(a[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)a.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}return{$$typeof:_d,type:e.type,key:r,ref:i,props:a,_owner:o}};ut.createContext=function(e){return e={$$typeof:TT,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:CT,_context:e},e.Consumer=e};ut.createElement=XN;ut.createFactory=function(e){var t=XN.bind(null,e);return t.type=e,t};ut.createRef=function(){return{current:null}};ut.forwardRef=function(e){return{$$typeof:RT,render:e}};ut.isValidElement=py;ut.lazy=function(e){return{$$typeof:PT,_payload:{_status:-1,_result:e},_init:MT}};ut.memo=function(e,t){return{$$typeof:AT,type:e,compare:t===void 0?null:t}};ut.startTransition=function(e){var t=Zu.transition;Zu.transition={};try{e()}finally{Zu.transition=t}};ut.unstable_act=QN;ut.useCallback=function(e,t){return qs.current.useCallback(e,t)};ut.useContext=function(e){return qs.current.useContext(e)};ut.useDebugValue=function(){};ut.useDeferredValue=function(e){return qs.current.useDeferredValue(e)};ut.useEffect=function(e,t){return qs.current.useEffect(e,t)};ut.useId=function(){return qs.current.useId()};ut.useImperativeHandle=function(e,t,n){return qs.current.useImperativeHandle(e,t,n)};ut.useInsertionEffect=function(e,t){return qs.current.useInsertionEffect(e,t)};ut.useLayoutEffect=function(e,t){return qs.current.useLayoutEffect(e,t)};ut.useMemo=function(e,t){return qs.current.useMemo(e,t)};ut.useReducer=function(e,t,n){return qs.current.useReducer(e,t,n)};ut.useRef=function(e){return qs.current.useRef(e)};ut.useState=function(e){return qs.current.useState(e)};ut.useSyncExternalStore=function(e,t,n){return qs.current.useSyncExternalStore(e,t,n)};ut.useTransition=function(){return qs.current.useTransition()};ut.version="18.3.1";BN.exports=ut;var p=BN.exports;const zT=ST(p);/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var UT=p,FT=Symbol.for("react.element"),GT=Symbol.for("react.fragment"),WT=Object.prototype.hasOwnProperty,HT=UT.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,BT={key:!0,ref:!0,__self:!0,__source:!0};function e0(e,t,n){var a,r={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(a in t)WT.call(t,a)&&!BT.hasOwnProperty(a)&&(r[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps,t)r[a]===void 0&&(r[a]=t[a]);return{$$typeof:FT,type:e,key:i,ref:o,props:r,_owner:HT.current}}wp.Fragment=GT;wp.jsx=e0;wp.jsxs=e0;HN.exports=wp;var s=HN.exports,t0={exports:{}},Cn={},s0={exports:{}},n0={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(K,ce){var F=K.length;K.push(ce);e:for(;0<F;){var ie=F-1>>>1,ue=K[ie];if(0<r(ue,ce))K[ie]=ce,K[F]=ue,F=ie;else break e}}function n(K){return K.length===0?null:K[0]}function a(K){if(K.length===0)return null;var ce=K[0],F=K.pop();if(F!==ce){K[0]=F;e:for(var ie=0,ue=K.length,oe=ue>>>1;ie<oe;){var B=2*(ie+1)-1,Q=K[B],X=B+1,me=K[X];if(0>r(Q,F))X<ue&&0>r(me,Q)?(K[ie]=me,K[X]=F,ie=X):(K[ie]=Q,K[B]=F,ie=B);else if(X<ue&&0>r(me,F))K[ie]=me,K[X]=F,ie=X;else break e}}return ce}function r(K,ce){var F=K.sortIndex-ce.sortIndex;return F!==0?F:K.id-ce.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,g=3,v=!1,f=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(K){for(var ce=n(u);ce!==null;){if(ce.callback===null)a(u);else if(ce.startTime<=K)a(u),ce.sortIndex=ce.expirationTime,t(c,ce);else break;ce=n(u)}}function S(K){if(y=!1,j(K),!f)if(n(c)!==null)f=!0,H(w);else{var ce=n(u);ce!==null&&Y(S,ce.startTime-K)}}function w(K,ce){f=!1,y&&(y=!1,m(N),N=-1),v=!0;var F=g;try{for(j(ce),h=n(c);h!==null&&(!(h.expirationTime>ce)||K&&!E());){var ie=h.callback;if(typeof ie=="function"){h.callback=null,g=h.priorityLevel;var ue=ie(h.expirationTime<=ce);ce=e.unstable_now(),typeof ue=="function"?h.callback=ue:h===n(c)&&a(c),j(ce)}else a(c);h=n(c)}if(h!==null)var oe=!0;else{var B=n(u);B!==null&&Y(S,B.startTime-ce),oe=!1}return oe}finally{h=null,g=F,v=!1}}var C=!1,k=null,N=-1,L=5,_=-1;function E(){return!(e.unstable_now()-_<L)}function I(){if(k!==null){var K=e.unstable_now();_=K;var ce=!0;try{ce=k(!0,K)}finally{ce?$():(C=!1,k=null)}}else C=!1}var $;if(typeof x=="function")$=function(){x(I)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,R=W.port2;W.port1.onmessage=I,$=function(){R.postMessage(null)}}else $=function(){b(I,0)};function H(K){k=K,C||(C=!0,$())}function Y(K,ce){N=b(function(){K(e.unstable_now())},ce)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){f||v||(f=!0,H(w))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(K){switch(g){case 1:case 2:case 3:var ce=3;break;default:ce=g}var F=g;g=ce;try{return K()}finally{g=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,ce){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var F=g;g=K;try{return ce()}finally{g=F}},e.unstable_scheduleCallback=function(K,ce,F){var ie=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?ie+F:ie):F=ie,K){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=F+ue,K={id:d++,callback:ce,priorityLevel:K,startTime:F,expirationTime:ue,sortIndex:-1},F>ie?(K.sortIndex=F,t(u,K),n(c)===null&&K===n(u)&&(y?(m(N),N=-1):y=!0,Y(S,F-ie))):(K.sortIndex=ue,t(c,K),f||v||(f=!0,H(w))),K},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(K){var ce=g;return function(){var F=g;g=ce;try{return K.apply(this,arguments)}finally{g=F}}}})(n0);s0.exports=n0;var VT=s0.exports;/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var qT=p,_n=VT;function Ie(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a0=new Set,ed={};function Ji(e,t){el(e,t),el(e+"Capture",t)}function el(e,t){for(ed[e]=t,e=0;e<t.length;e++)a0.add(t[e])}var ir=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sg=Object.prototype.hasOwnProperty,KT=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,jj={},bj={};function JT(e){return sg.call(bj,e)?!0:sg.call(jj,e)?!1:KT.test(e)?bj[e]=!0:(jj[e]=!0,!1)}function YT(e,t,n,a){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return a?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ZT(e,t,n,a){if(t===null||typeof t>"u"||YT(e,t,n,a))return!0;if(a)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ks(e,t,n,a,r,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=a,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var _s={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){_s[e]=new Ks(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];_s[t]=new Ks(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){_s[e]=new Ks(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){_s[e]=new Ks(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){_s[e]=new Ks(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){_s[e]=new Ks(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){_s[e]=new Ks(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){_s[e]=new Ks(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){_s[e]=new Ks(e,5,!1,e.toLowerCase(),null,!1,!1)});var my=/[\-:]([a-z])/g;function fy(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(my,fy);_s[t]=new Ks(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(my,fy);_s[t]=new Ks(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(my,fy);_s[t]=new Ks(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){_s[e]=new Ks(e,1,!1,e.toLowerCase(),null,!1,!1)});_s.xlinkHref=new Ks("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){_s[e]=new Ks(e,1,!1,e.toLowerCase(),null,!0,!0)});function gy(e,t,n,a){var r=_s.hasOwnProperty(t)?_s[t]:null;(r!==null?r.type!==0:a||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(ZT(t,n,r,a)&&(n=null),a||r===null?JT(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):r.mustUseProperty?e[r.propertyName]=n===null?r.type===3?!1:"":n:(t=r.attributeName,a=r.attributeNamespace,n===null?e.removeAttribute(t):(r=r.type,n=r===3||r===4&&n===!0?"":""+n,a?e.setAttributeNS(a,t,n):e.setAttribute(t,n))))}var pr=qT.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Bd=Symbol.for("react.element"),So=Symbol.for("react.portal"),No=Symbol.for("react.fragment"),vy=Symbol.for("react.strict_mode"),ng=Symbol.for("react.profiler"),r0=Symbol.for("react.provider"),i0=Symbol.for("react.context"),yy=Symbol.for("react.forward_ref"),ag=Symbol.for("react.suspense"),rg=Symbol.for("react.suspense_list"),xy=Symbol.for("react.memo"),Er=Symbol.for("react.lazy"),o0=Symbol.for("react.offscreen"),wj=Symbol.iterator;function Il(e){return e===null||typeof e!="object"?null:(e=wj&&e[wj]||e["@@iterator"],typeof e=="function"?e:null)}var Zt=Object.assign,nm;function hc(e){if(nm===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);nm=t&&t[1]||""}return`
|
|
34
|
-
`+nm+e}var am=!1;function rm(e,t){if(!e||am)return"";am=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var a=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){a=u}e.call(t.prototype)}else{try{throw Error()}catch(u){a=u}e()}}catch(u){if(u&&a&&typeof u.stack=="string"){for(var r=u.stack.split(`
|
|
35
|
-
`),i=a.stack.split(`
|
|
36
|
-
`),o=r.length-1,l=i.length-1;1<=o&&0<=l&&r[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(r[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||r[o]!==i[l]){var c=`
|
|
37
|
-
`+r[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{am=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?hc(e):""}function XT(e){switch(e.tag){case 5:return hc(e.type);case 16:return hc("Lazy");case 13:return hc("Suspense");case 19:return hc("SuspenseList");case 0:case 2:case 15:return e=rm(e.type,!1),e;case 11:return e=rm(e.type.render,!1),e;case 1:return e=rm(e.type,!0),e;default:return""}}function ig(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 No:return"Fragment";case So:return"Portal";case ng:return"Profiler";case vy:return"StrictMode";case ag:return"Suspense";case rg:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case i0:return(e.displayName||"Context")+".Consumer";case r0:return(e._context.displayName||"Context")+".Provider";case yy:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case xy:return t=e.displayName||null,t!==null?t:ig(e.type)||"Memo";case Er:t=e._payload,e=e._init;try{return ig(e(t))}catch{}}return null}function QT(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ig(t);case 8:return t===vy?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Zr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function l0(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function eR(e){var t=l0(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),a=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(o){a=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(o){a=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Vd(e){e._valueTracker||(e._valueTracker=eR(e))}function c0(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=l0(e)?e.checked?"true":"false":e.value),e=a,e!==n?(t.setValue(e),!0):!1}function kh(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 og(e,t){var n=t.checked;return Zt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Sj(e,t){var n=t.defaultValue==null?"":t.defaultValue,a=t.checked!=null?t.checked:t.defaultChecked;n=Zr(t.value!=null?t.value:n),e._wrapperState={initialChecked:a,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function d0(e,t){t=t.checked,t!=null&&gy(e,"checked",t,!1)}function lg(e,t){d0(e,t);var n=Zr(t.value),a=t.type;if(n!=null)a==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(a==="submit"||a==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?cg(e,t.type,n):t.hasOwnProperty("defaultValue")&&cg(e,t.type,Zr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Nj(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var a=t.type;if(!(a!=="submit"&&a!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function cg(e,t,n){(t!=="number"||kh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var pc=Array.isArray;function Go(e,t,n,a){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&a&&(e[n].defaultSelected=!0)}else{for(n=""+Zr(n),t=null,r=0;r<e.length;r++){if(e[r].value===n){e[r].selected=!0,a&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function dg(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ie(91));return Zt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function kj(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ie(92));if(pc(n)){if(1<n.length)throw Error(Ie(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Zr(n)}}function u0(e,t){var n=Zr(t.value),a=Zr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),a!=null&&(e.defaultValue=""+a)}function Ej(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function h0(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 ug(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?h0(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var qd,p0=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,a,r){MSApp.execUnsafeLocalFunction(function(){return e(t,n,a,r)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(qd=qd||document.createElement("div"),qd.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=qd.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function td(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ec={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},tR=["Webkit","ms","Moz","O"];Object.keys(Ec).forEach(function(e){tR.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ec[t]=Ec[e]})});function m0(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ec.hasOwnProperty(e)&&Ec[e]?(""+t).trim():t+"px"}function f0(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var a=n.indexOf("--")===0,r=m0(n,t[n],a);n==="float"&&(n="cssFloat"),a?e.setProperty(n,r):e[n]=r}}var sR=Zt({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 hg(e,t){if(t){if(sR[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ie(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ie(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ie(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ie(62))}}function pg(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var mg=null;function jy(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var fg=null,Wo=null,Ho=null;function _j(e){if(e=Rd(e)){if(typeof fg!="function")throw Error(Ie(280));var t=e.stateNode;t&&(t=_p(t),fg(e.stateNode,e.type,t))}}function g0(e){Wo?Ho?Ho.push(e):Ho=[e]:Wo=e}function v0(){if(Wo){var e=Wo,t=Ho;if(Ho=Wo=null,_j(e),t)for(e=0;e<t.length;e++)_j(t[e])}}function y0(e,t){return e(t)}function x0(){}var im=!1;function j0(e,t,n){if(im)return e(t,n);im=!0;try{return y0(e,t,n)}finally{im=!1,(Wo!==null||Ho!==null)&&(x0(),v0())}}function sd(e,t){var n=e.stateNode;if(n===null)return null;var a=_p(n);if(a===null)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Ie(231,t,typeof n));return n}var gg=!1;if(ir)try{var Al={};Object.defineProperty(Al,"passive",{get:function(){gg=!0}}),window.addEventListener("test",Al,Al),window.removeEventListener("test",Al,Al)}catch{gg=!1}function nR(e,t,n,a,r,i,o,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var _c=!1,Eh=null,_h=!1,vg=null,aR={onError:function(e){_c=!0,Eh=e}};function rR(e,t,n,a,r,i,o,l,c){_c=!1,Eh=null,nR.apply(aR,arguments)}function iR(e,t,n,a,r,i,o,l,c){if(rR.apply(this,arguments),_c){if(_c){var u=Eh;_c=!1,Eh=null}else throw Error(Ie(198));_h||(_h=!0,vg=u)}}function Yi(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function b0(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Cj(e){if(Yi(e)!==e)throw Error(Ie(188))}function oR(e){var t=e.alternate;if(!t){if(t=Yi(e),t===null)throw Error(Ie(188));return t!==e?null:e}for(var n=e,a=t;;){var r=n.return;if(r===null)break;var i=r.alternate;if(i===null){if(a=r.return,a!==null){n=a;continue}break}if(r.child===i.child){for(i=r.child;i;){if(i===n)return Cj(r),e;if(i===a)return Cj(r),t;i=i.sibling}throw Error(Ie(188))}if(n.return!==a.return)n=r,a=i;else{for(var o=!1,l=r.child;l;){if(l===n){o=!0,n=r,a=i;break}if(l===a){o=!0,a=r,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,a=r;break}if(l===a){o=!0,a=i,n=r;break}l=l.sibling}if(!o)throw Error(Ie(189))}}if(n.alternate!==a)throw Error(Ie(190))}if(n.tag!==3)throw Error(Ie(188));return n.stateNode.current===n?e:t}function w0(e){return e=oR(e),e!==null?S0(e):null}function S0(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=S0(e);if(t!==null)return t;e=e.sibling}return null}var N0=_n.unstable_scheduleCallback,Tj=_n.unstable_cancelCallback,lR=_n.unstable_shouldYield,cR=_n.unstable_requestPaint,ns=_n.unstable_now,dR=_n.unstable_getCurrentPriorityLevel,by=_n.unstable_ImmediatePriority,k0=_n.unstable_UserBlockingPriority,Ch=_n.unstable_NormalPriority,uR=_n.unstable_LowPriority,E0=_n.unstable_IdlePriority,Sp=null,Ra=null;function hR(e){if(Ra&&typeof Ra.onCommitFiberRoot=="function")try{Ra.onCommitFiberRoot(Sp,e,void 0,(e.current.flags&128)===128)}catch{}}var ha=Math.clz32?Math.clz32:fR,pR=Math.log,mR=Math.LN2;function fR(e){return e>>>=0,e===0?32:31-(pR(e)/mR|0)|0}var Kd=64,Jd=4194304;function mc(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 Th(e,t){var n=e.pendingLanes;if(n===0)return 0;var a=0,r=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~r;l!==0?a=mc(l):(i&=o,i!==0&&(a=mc(i)))}else o=n&~r,o!==0?a=mc(o):i!==0&&(a=mc(i));if(a===0)return 0;if(t!==0&&t!==a&&!(t&r)&&(r=a&-a,i=t&-t,r>=i||r===16&&(i&4194240)!==0))return t;if(a&4&&(a|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=a;0<t;)n=31-ha(t),r=1<<n,a|=e[n],t&=~r;return a}function gR(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 vR(e,t){for(var n=e.suspendedLanes,a=e.pingedLanes,r=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-ha(i),l=1<<o,c=r[o];c===-1?(!(l&n)||l&a)&&(r[o]=gR(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function yg(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function _0(){var e=Kd;return Kd<<=1,!(Kd&4194240)&&(Kd=64),e}function om(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Cd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ha(t),e[t]=n}function yR(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var a=e.eventTimes;for(e=e.expirationTimes;0<n;){var r=31-ha(n),i=1<<r;t[r]=0,a[r]=-1,e[r]=-1,n&=~i}}function wy(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var a=31-ha(n),r=1<<a;r&t|e[a]&t&&(e[a]|=t),n&=~r}}var Rt=0;function C0(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var T0,Sy,R0,I0,A0,xg=!1,Yd=[],Ur=null,Fr=null,Gr=null,nd=new Map,ad=new Map,Tr=[],xR="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 Rj(e,t){switch(e){case"focusin":case"focusout":Ur=null;break;case"dragenter":case"dragleave":Fr=null;break;case"mouseover":case"mouseout":Gr=null;break;case"pointerover":case"pointerout":nd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ad.delete(t.pointerId)}}function Pl(e,t,n,a,r,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:a,nativeEvent:i,targetContainers:[r]},t!==null&&(t=Rd(t),t!==null&&Sy(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function jR(e,t,n,a,r){switch(t){case"focusin":return Ur=Pl(Ur,e,t,n,a,r),!0;case"dragenter":return Fr=Pl(Fr,e,t,n,a,r),!0;case"mouseover":return Gr=Pl(Gr,e,t,n,a,r),!0;case"pointerover":var i=r.pointerId;return nd.set(i,Pl(nd.get(i)||null,e,t,n,a,r)),!0;case"gotpointercapture":return i=r.pointerId,ad.set(i,Pl(ad.get(i)||null,e,t,n,a,r)),!0}return!1}function P0(e){var t=_i(e.target);if(t!==null){var n=Yi(t);if(n!==null){if(t=n.tag,t===13){if(t=b0(n),t!==null){e.blockedOn=t,A0(e.priority,function(){R0(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Xu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=jg(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var a=new n.constructor(n.type,n);mg=a,n.target.dispatchEvent(a),mg=null}else return t=Rd(n),t!==null&&Sy(t),e.blockedOn=n,!1;t.shift()}return!0}function Ij(e,t,n){Xu(e)&&n.delete(t)}function bR(){xg=!1,Ur!==null&&Xu(Ur)&&(Ur=null),Fr!==null&&Xu(Fr)&&(Fr=null),Gr!==null&&Xu(Gr)&&(Gr=null),nd.forEach(Ij),ad.forEach(Ij)}function $l(e,t){e.blockedOn===t&&(e.blockedOn=null,xg||(xg=!0,_n.unstable_scheduleCallback(_n.unstable_NormalPriority,bR)))}function rd(e){function t(r){return $l(r,e)}if(0<Yd.length){$l(Yd[0],e);for(var n=1;n<Yd.length;n++){var a=Yd[n];a.blockedOn===e&&(a.blockedOn=null)}}for(Ur!==null&&$l(Ur,e),Fr!==null&&$l(Fr,e),Gr!==null&&$l(Gr,e),nd.forEach(t),ad.forEach(t),n=0;n<Tr.length;n++)a=Tr[n],a.blockedOn===e&&(a.blockedOn=null);for(;0<Tr.length&&(n=Tr[0],n.blockedOn===null);)P0(n),n.blockedOn===null&&Tr.shift()}var Bo=pr.ReactCurrentBatchConfig,Rh=!0;function wR(e,t,n,a){var r=Rt,i=Bo.transition;Bo.transition=null;try{Rt=1,Ny(e,t,n,a)}finally{Rt=r,Bo.transition=i}}function SR(e,t,n,a){var r=Rt,i=Bo.transition;Bo.transition=null;try{Rt=4,Ny(e,t,n,a)}finally{Rt=r,Bo.transition=i}}function Ny(e,t,n,a){if(Rh){var r=jg(e,t,n,a);if(r===null)vm(e,t,a,Ih,n),Rj(e,a);else if(jR(r,e,t,n,a))a.stopPropagation();else if(Rj(e,a),t&4&&-1<xR.indexOf(e)){for(;r!==null;){var i=Rd(r);if(i!==null&&T0(i),i=jg(e,t,n,a),i===null&&vm(e,t,a,Ih,n),i===r)break;r=i}r!==null&&a.stopPropagation()}else vm(e,t,a,null,n)}}var Ih=null;function jg(e,t,n,a){if(Ih=null,e=jy(a),e=_i(e),e!==null)if(t=Yi(e),t===null)e=null;else if(n=t.tag,n===13){if(e=b0(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Ih=e,null}function $0(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(dR()){case by:return 1;case k0:return 4;case Ch:case uR:return 16;case E0:return 536870912;default:return 16}default:return 16}}var Or=null,ky=null,Qu=null;function O0(){if(Qu)return Qu;var e,t=ky,n=t.length,a,r="value"in Or?Or.value:Or.textContent,i=r.length;for(e=0;e<n&&t[e]===r[e];e++);var o=n-e;for(a=1;a<=o&&t[n-a]===r[i-a];a++);return Qu=r.slice(e,1<a?1-a:void 0)}function eh(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Zd(){return!0}function Aj(){return!1}function Tn(e){function t(n,a,r,i,o){this._reactName=n,this._targetInst=r,this.type=a,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Zd:Aj,this.isPropagationStopped=Aj,this}return Zt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Zd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Zd)},persist:function(){},isPersistent:Zd}),t}var xl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ey=Tn(xl),Td=Zt({},xl,{view:0,detail:0}),NR=Tn(Td),lm,cm,Ol,Np=Zt({},Td,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_y,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!==Ol&&(Ol&&e.type==="mousemove"?(lm=e.screenX-Ol.screenX,cm=e.screenY-Ol.screenY):cm=lm=0,Ol=e),lm)},movementY:function(e){return"movementY"in e?e.movementY:cm}}),Pj=Tn(Np),kR=Zt({},Np,{dataTransfer:0}),ER=Tn(kR),_R=Zt({},Td,{relatedTarget:0}),dm=Tn(_R),CR=Zt({},xl,{animationName:0,elapsedTime:0,pseudoElement:0}),TR=Tn(CR),RR=Zt({},xl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),IR=Tn(RR),AR=Zt({},xl,{data:0}),$j=Tn(AR),PR={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$R={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"},OR={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function LR(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=OR[e])?!!t[e]:!1}function _y(){return LR}var MR=Zt({},Td,{key:function(e){if(e.key){var t=PR[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=eh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?$R[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_y,charCode:function(e){return e.type==="keypress"?eh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?eh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),DR=Tn(MR),zR=Zt({},Np,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Oj=Tn(zR),UR=Zt({},Td,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_y}),FR=Tn(UR),GR=Zt({},xl,{propertyName:0,elapsedTime:0,pseudoElement:0}),WR=Tn(GR),HR=Zt({},Np,{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}),BR=Tn(HR),VR=[9,13,27,32],Cy=ir&&"CompositionEvent"in window,Cc=null;ir&&"documentMode"in document&&(Cc=document.documentMode);var qR=ir&&"TextEvent"in window&&!Cc,L0=ir&&(!Cy||Cc&&8<Cc&&11>=Cc),Lj=" ",Mj=!1;function M0(e,t){switch(e){case"keyup":return VR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function D0(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ko=!1;function KR(e,t){switch(e){case"compositionend":return D0(t);case"keypress":return t.which!==32?null:(Mj=!0,Lj);case"textInput":return e=t.data,e===Lj&&Mj?null:e;default:return null}}function JR(e,t){if(ko)return e==="compositionend"||!Cy&&M0(e,t)?(e=O0(),Qu=ky=Or=null,ko=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return L0&&t.locale!=="ko"?null:t.data;default:return null}}var YR={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 Dj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!YR[e.type]:t==="textarea"}function z0(e,t,n,a){g0(a),t=Ah(t,"onChange"),0<t.length&&(n=new Ey("onChange","change",null,n,a),e.push({event:n,listeners:t}))}var Tc=null,id=null;function ZR(e){Y0(e,0)}function kp(e){var t=Co(e);if(c0(t))return e}function XR(e,t){if(e==="change")return t}var U0=!1;if(ir){var um;if(ir){var hm="oninput"in document;if(!hm){var zj=document.createElement("div");zj.setAttribute("oninput","return;"),hm=typeof zj.oninput=="function"}um=hm}else um=!1;U0=um&&(!document.documentMode||9<document.documentMode)}function Uj(){Tc&&(Tc.detachEvent("onpropertychange",F0),id=Tc=null)}function F0(e){if(e.propertyName==="value"&&kp(id)){var t=[];z0(t,id,e,jy(e)),j0(ZR,t)}}function QR(e,t,n){e==="focusin"?(Uj(),Tc=t,id=n,Tc.attachEvent("onpropertychange",F0)):e==="focusout"&&Uj()}function eI(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return kp(id)}function tI(e,t){if(e==="click")return kp(t)}function sI(e,t){if(e==="input"||e==="change")return kp(t)}function nI(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ga=typeof Object.is=="function"?Object.is:nI;function od(e,t){if(ga(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var r=n[a];if(!sg.call(t,r)||!ga(e[r],t[r]))return!1}return!0}function Fj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gj(e,t){var n=Fj(e);e=0;for(var a;n;){if(n.nodeType===3){if(a=e+n.textContent.length,e<=t&&a>=t)return{node:n,offset:t-e};e=a}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Fj(n)}}function G0(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?G0(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function W0(){for(var e=window,t=kh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=kh(e.document)}return t}function Ty(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function aI(e){var t=W0(),n=e.focusedElem,a=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&G0(n.ownerDocument.documentElement,n)){if(a!==null&&Ty(n)){if(t=a.start,e=a.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var r=n.textContent.length,i=Math.min(a.start,r);a=a.end===void 0?i:Math.min(a.end,r),!e.extend&&i>a&&(r=a,a=i,i=r),r=Gj(n,i);var o=Gj(n,a);r&&o&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(r.node,r.offset),e.removeAllRanges(),i>a?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var rI=ir&&"documentMode"in document&&11>=document.documentMode,Eo=null,bg=null,Rc=null,wg=!1;function Wj(e,t,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;wg||Eo==null||Eo!==kh(a)||(a=Eo,"selectionStart"in a&&Ty(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Rc&&od(Rc,a)||(Rc=a,a=Ah(bg,"onSelect"),0<a.length&&(t=new Ey("onSelect","select",null,t,n),e.push({event:t,listeners:a}),t.target=Eo)))}function Xd(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var _o={animationend:Xd("Animation","AnimationEnd"),animationiteration:Xd("Animation","AnimationIteration"),animationstart:Xd("Animation","AnimationStart"),transitionend:Xd("Transition","TransitionEnd")},pm={},H0={};ir&&(H0=document.createElement("div").style,"AnimationEvent"in window||(delete _o.animationend.animation,delete _o.animationiteration.animation,delete _o.animationstart.animation),"TransitionEvent"in window||delete _o.transitionend.transition);function Ep(e){if(pm[e])return pm[e];if(!_o[e])return e;var t=_o[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in H0)return pm[e]=t[n];return e}var B0=Ep("animationend"),V0=Ep("animationiteration"),q0=Ep("animationstart"),K0=Ep("transitionend"),J0=new Map,Hj="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 ti(e,t){J0.set(e,t),Ji(t,[e])}for(var mm=0;mm<Hj.length;mm++){var fm=Hj[mm],iI=fm.toLowerCase(),oI=fm[0].toUpperCase()+fm.slice(1);ti(iI,"on"+oI)}ti(B0,"onAnimationEnd");ti(V0,"onAnimationIteration");ti(q0,"onAnimationStart");ti("dblclick","onDoubleClick");ti("focusin","onFocus");ti("focusout","onBlur");ti(K0,"onTransitionEnd");el("onMouseEnter",["mouseout","mouseover"]);el("onMouseLeave",["mouseout","mouseover"]);el("onPointerEnter",["pointerout","pointerover"]);el("onPointerLeave",["pointerout","pointerover"]);Ji("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ji("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ji("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ji("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ji("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ji("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fc="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(" "),lI=new Set("cancel close invalid load scroll toggle".split(" ").concat(fc));function Bj(e,t,n){var a=e.type||"unknown-event";e.currentTarget=n,iR(a,t,void 0,e),e.currentTarget=null}function Y0(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var a=e[n],r=a.event;a=a.listeners;e:{var i=void 0;if(t)for(var o=a.length-1;0<=o;o--){var l=a[o],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==i&&r.isPropagationStopped())break e;Bj(r,l,u),i=c}else for(o=0;o<a.length;o++){if(l=a[o],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&r.isPropagationStopped())break e;Bj(r,l,u),i=c}}}if(_h)throw e=vg,_h=!1,vg=null,e}function Ft(e,t){var n=t[_g];n===void 0&&(n=t[_g]=new Set);var a=e+"__bubble";n.has(a)||(Z0(t,e,2,!1),n.add(a))}function gm(e,t,n){var a=0;t&&(a|=4),Z0(n,e,a,t)}var Qd="_reactListening"+Math.random().toString(36).slice(2);function ld(e){if(!e[Qd]){e[Qd]=!0,a0.forEach(function(n){n!=="selectionchange"&&(lI.has(n)||gm(n,!1,e),gm(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Qd]||(t[Qd]=!0,gm("selectionchange",!1,t))}}function Z0(e,t,n,a){switch($0(t)){case 1:var r=wR;break;case 4:r=SR;break;default:r=Ny}n=r.bind(null,t,n,e),r=void 0,!gg||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(r=!0),a?r!==void 0?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):r!==void 0?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function vm(e,t,n,a,r){var i=a;if(!(t&1)&&!(t&2)&&a!==null)e:for(;;){if(a===null)return;var o=a.tag;if(o===3||o===4){var l=a.stateNode.containerInfo;if(l===r||l.nodeType===8&&l.parentNode===r)break;if(o===4)for(o=a.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===r||c.nodeType===8&&c.parentNode===r))return;o=o.return}for(;l!==null;){if(o=_i(l),o===null)return;if(c=o.tag,c===5||c===6){a=i=o;continue e}l=l.parentNode}}a=a.return}j0(function(){var u=i,d=jy(n),h=[];e:{var g=J0.get(e);if(g!==void 0){var v=Ey,f=e;switch(e){case"keypress":if(eh(n)===0)break e;case"keydown":case"keyup":v=DR;break;case"focusin":f="focus",v=dm;break;case"focusout":f="blur",v=dm;break;case"beforeblur":case"afterblur":v=dm;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":v=Pj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=ER;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=FR;break;case B0:case V0:case q0:v=TR;break;case K0:v=WR;break;case"scroll":v=NR;break;case"wheel":v=BR;break;case"copy":case"cut":case"paste":v=IR;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=Oj}var y=(t&4)!==0,b=!y&&e==="scroll",m=y?g!==null?g+"Capture":null:g;y=[];for(var x=u,j;x!==null;){j=x;var S=j.stateNode;if(j.tag===5&&S!==null&&(j=S,m!==null&&(S=sd(x,m),S!=null&&y.push(cd(x,S,j)))),b)break;x=x.return}0<y.length&&(g=new v(g,f,null,n,d),h.push({event:g,listeners:y}))}}if(!(t&7)){e:{if(g=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",g&&n!==mg&&(f=n.relatedTarget||n.fromElement)&&(_i(f)||f[or]))break e;if((v||g)&&(g=d.window===d?d:(g=d.ownerDocument)?g.defaultView||g.parentWindow:window,v?(f=n.relatedTarget||n.toElement,v=u,f=f?_i(f):null,f!==null&&(b=Yi(f),f!==b||f.tag!==5&&f.tag!==6)&&(f=null)):(v=null,f=u),v!==f)){if(y=Pj,S="onMouseLeave",m="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(y=Oj,S="onPointerLeave",m="onPointerEnter",x="pointer"),b=v==null?g:Co(v),j=f==null?g:Co(f),g=new y(S,x+"leave",v,n,d),g.target=b,g.relatedTarget=j,S=null,_i(d)===u&&(y=new y(m,x+"enter",f,n,d),y.target=j,y.relatedTarget=b,S=y),b=S,v&&f)t:{for(y=v,m=f,x=0,j=y;j;j=Qi(j))x++;for(j=0,S=m;S;S=Qi(S))j++;for(;0<x-j;)y=Qi(y),x--;for(;0<j-x;)m=Qi(m),j--;for(;x--;){if(y===m||m!==null&&y===m.alternate)break t;y=Qi(y),m=Qi(m)}y=null}else y=null;v!==null&&Vj(h,g,v,y,!1),f!==null&&b!==null&&Vj(h,b,f,y,!0)}}e:{if(g=u?Co(u):window,v=g.nodeName&&g.nodeName.toLowerCase(),v==="select"||v==="input"&&g.type==="file")var w=XR;else if(Dj(g))if(U0)w=sI;else{w=eI;var C=QR}else(v=g.nodeName)&&v.toLowerCase()==="input"&&(g.type==="checkbox"||g.type==="radio")&&(w=tI);if(w&&(w=w(e,u))){z0(h,w,n,d);break e}C&&C(e,g,u),e==="focusout"&&(C=g._wrapperState)&&C.controlled&&g.type==="number"&&cg(g,"number",g.value)}switch(C=u?Co(u):window,e){case"focusin":(Dj(C)||C.contentEditable==="true")&&(Eo=C,bg=u,Rc=null);break;case"focusout":Rc=bg=Eo=null;break;case"mousedown":wg=!0;break;case"contextmenu":case"mouseup":case"dragend":wg=!1,Wj(h,n,d);break;case"selectionchange":if(rI)break;case"keydown":case"keyup":Wj(h,n,d)}var k;if(Cy)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else ko?M0(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(L0&&n.locale!=="ko"&&(ko||N!=="onCompositionStart"?N==="onCompositionEnd"&&ko&&(k=O0()):(Or=d,ky="value"in Or?Or.value:Or.textContent,ko=!0)),C=Ah(u,N),0<C.length&&(N=new $j(N,e,null,n,d),h.push({event:N,listeners:C}),k?N.data=k:(k=D0(n),k!==null&&(N.data=k)))),(k=qR?KR(e,n):JR(e,n))&&(u=Ah(u,"onBeforeInput"),0<u.length&&(d=new $j("onBeforeInput","beforeinput",null,n,d),h.push({event:d,listeners:u}),d.data=k))}Y0(h,t)})}function cd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ah(e,t){for(var n=t+"Capture",a=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=sd(e,n),i!=null&&a.unshift(cd(e,i,r)),i=sd(e,t),i!=null&&a.push(cd(e,i,r))),e=e.return}return a}function Qi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Vj(e,t,n,a,r){for(var i=t._reactName,o=[];n!==null&&n!==a;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===a)break;l.tag===5&&u!==null&&(l=u,r?(c=sd(n,i),c!=null&&o.unshift(cd(n,c,l))):r||(c=sd(n,i),c!=null&&o.push(cd(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var cI=/\r\n?/g,dI=/\u0000|\uFFFD/g;function qj(e){return(typeof e=="string"?e:""+e).replace(cI,`
|
|
38
|
-
`).replace(dI,"")}function eu(e,t,n){if(t=qj(t),qj(e)!==t&&n)throw Error(Ie(425))}function Ph(){}var Sg=null,Ng=null;function kg(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Eg=typeof setTimeout=="function"?setTimeout:void 0,uI=typeof clearTimeout=="function"?clearTimeout:void 0,Kj=typeof Promise=="function"?Promise:void 0,hI=typeof queueMicrotask=="function"?queueMicrotask:typeof Kj<"u"?function(e){return Kj.resolve(null).then(e).catch(pI)}:Eg;function pI(e){setTimeout(function(){throw e})}function ym(e,t){var n=t,a=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(a===0){e.removeChild(r),rd(t);return}a--}else n!=="$"&&n!=="$?"&&n!=="$!"||a++;n=r}while(n);rd(t)}function Wr(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Jj(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var jl=Math.random().toString(36).slice(2),Ca="__reactFiber$"+jl,dd="__reactProps$"+jl,or="__reactContainer$"+jl,_g="__reactEvents$"+jl,mI="__reactListeners$"+jl,fI="__reactHandles$"+jl;function _i(e){var t=e[Ca];if(t)return t;for(var n=e.parentNode;n;){if(t=n[or]||n[Ca]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Jj(e);e!==null;){if(n=e[Ca])return n;e=Jj(e)}return t}e=n,n=e.parentNode}return null}function Rd(e){return e=e[Ca]||e[or],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Co(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ie(33))}function _p(e){return e[dd]||null}var Cg=[],To=-1;function si(e){return{current:e}}function Wt(e){0>To||(e.current=Cg[To],Cg[To]=null,To--)}function Mt(e,t){To++,Cg[To]=e.current,e.current=t}var Xr={},Ms=si(Xr),an=si(!1),Gi=Xr;function tl(e,t){var n=e.type.contextTypes;if(!n)return Xr;var a=e.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===t)return a.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in n)r[i]=t[i];return a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function rn(e){return e=e.childContextTypes,e!=null}function $h(){Wt(an),Wt(Ms)}function Yj(e,t,n){if(Ms.current!==Xr)throw Error(Ie(168));Mt(Ms,t),Mt(an,n)}function X0(e,t,n){var a=e.stateNode;if(t=t.childContextTypes,typeof a.getChildContext!="function")return n;a=a.getChildContext();for(var r in a)if(!(r in t))throw Error(Ie(108,QT(e)||"Unknown",r));return Zt({},n,a)}function Oh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Xr,Gi=Ms.current,Mt(Ms,e),Mt(an,an.current),!0}function Zj(e,t,n){var a=e.stateNode;if(!a)throw Error(Ie(169));n?(e=X0(e,t,Gi),a.__reactInternalMemoizedMergedChildContext=e,Wt(an),Wt(Ms),Mt(Ms,e)):Wt(an),Mt(an,n)}var qa=null,Cp=!1,xm=!1;function Q0(e){qa===null?qa=[e]:qa.push(e)}function gI(e){Cp=!0,Q0(e)}function ni(){if(!xm&&qa!==null){xm=!0;var e=0,t=Rt;try{var n=qa;for(Rt=1;e<n.length;e++){var a=n[e];do a=a(!0);while(a!==null)}qa=null,Cp=!1}catch(r){throw qa!==null&&(qa=qa.slice(e+1)),N0(by,ni),r}finally{Rt=t,xm=!1}}return null}var Ro=[],Io=0,Lh=null,Mh=0,On=[],Ln=0,Wi=null,Xa=1,Qa="";function gi(e,t){Ro[Io++]=Mh,Ro[Io++]=Lh,Lh=e,Mh=t}function ek(e,t,n){On[Ln++]=Xa,On[Ln++]=Qa,On[Ln++]=Wi,Wi=e;var a=Xa;e=Qa;var r=32-ha(a)-1;a&=~(1<<r),n+=1;var i=32-ha(t)+r;if(30<i){var o=r-r%5;i=(a&(1<<o)-1).toString(32),a>>=o,r-=o,Xa=1<<32-ha(t)+r|n<<r|a,Qa=i+e}else Xa=1<<i|n<<r|a,Qa=e}function Ry(e){e.return!==null&&(gi(e,1),ek(e,1,0))}function Iy(e){for(;e===Lh;)Lh=Ro[--Io],Ro[Io]=null,Mh=Ro[--Io],Ro[Io]=null;for(;e===Wi;)Wi=On[--Ln],On[Ln]=null,Qa=On[--Ln],On[Ln]=null,Xa=On[--Ln],On[Ln]=null}var Nn=null,jn=null,Vt=!1,ra=null;function tk(e,t){var n=Dn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Xj(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Nn=e,jn=Wr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Nn=e,jn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Wi!==null?{id:Xa,overflow:Qa}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Dn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Nn=e,jn=null,!0):!1;default:return!1}}function Tg(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Rg(e){if(Vt){var t=jn;if(t){var n=t;if(!Xj(e,t)){if(Tg(e))throw Error(Ie(418));t=Wr(n.nextSibling);var a=Nn;t&&Xj(e,t)?tk(a,n):(e.flags=e.flags&-4097|2,Vt=!1,Nn=e)}}else{if(Tg(e))throw Error(Ie(418));e.flags=e.flags&-4097|2,Vt=!1,Nn=e}}}function Qj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Nn=e}function tu(e){if(e!==Nn)return!1;if(!Vt)return Qj(e),Vt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!kg(e.type,e.memoizedProps)),t&&(t=jn)){if(Tg(e))throw sk(),Error(Ie(418));for(;t;)tk(e,t),t=Wr(t.nextSibling)}if(Qj(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ie(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){jn=Wr(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}jn=null}}else jn=Nn?Wr(e.stateNode.nextSibling):null;return!0}function sk(){for(var e=jn;e;)e=Wr(e.nextSibling)}function sl(){jn=Nn=null,Vt=!1}function Ay(e){ra===null?ra=[e]:ra.push(e)}var vI=pr.ReactCurrentBatchConfig;function Ll(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ie(309));var a=n.stateNode}if(!a)throw Error(Ie(147,e));var r=a,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=r.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(Ie(284));if(!n._owner)throw Error(Ie(290,e))}return e}function su(e,t){throw e=Object.prototype.toString.call(t),Error(Ie(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function eb(e){var t=e._init;return t(e._payload)}function nk(e){function t(m,x){if(e){var j=m.deletions;j===null?(m.deletions=[x],m.flags|=16):j.push(x)}}function n(m,x){if(!e)return null;for(;x!==null;)t(m,x),x=x.sibling;return null}function a(m,x){for(m=new Map;x!==null;)x.key!==null?m.set(x.key,x):m.set(x.index,x),x=x.sibling;return m}function r(m,x){return m=qr(m,x),m.index=0,m.sibling=null,m}function i(m,x,j){return m.index=j,e?(j=m.alternate,j!==null?(j=j.index,j<x?(m.flags|=2,x):j):(m.flags|=2,x)):(m.flags|=1048576,x)}function o(m){return e&&m.alternate===null&&(m.flags|=2),m}function l(m,x,j,S){return x===null||x.tag!==6?(x=Em(j,m.mode,S),x.return=m,x):(x=r(x,j),x.return=m,x)}function c(m,x,j,S){var w=j.type;return w===No?d(m,x,j.props.children,S,j.key):x!==null&&(x.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===Er&&eb(w)===x.type)?(S=r(x,j.props),S.ref=Ll(m,x,j),S.return=m,S):(S=oh(j.type,j.key,j.props,null,m.mode,S),S.ref=Ll(m,x,j),S.return=m,S)}function u(m,x,j,S){return x===null||x.tag!==4||x.stateNode.containerInfo!==j.containerInfo||x.stateNode.implementation!==j.implementation?(x=_m(j,m.mode,S),x.return=m,x):(x=r(x,j.children||[]),x.return=m,x)}function d(m,x,j,S,w){return x===null||x.tag!==7?(x=Li(j,m.mode,S,w),x.return=m,x):(x=r(x,j),x.return=m,x)}function h(m,x,j){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Em(""+x,m.mode,j),x.return=m,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Bd:return j=oh(x.type,x.key,x.props,null,m.mode,j),j.ref=Ll(m,null,x),j.return=m,j;case So:return x=_m(x,m.mode,j),x.return=m,x;case Er:var S=x._init;return h(m,S(x._payload),j)}if(pc(x)||Il(x))return x=Li(x,m.mode,j,null),x.return=m,x;su(m,x)}return null}function g(m,x,j,S){var w=x!==null?x.key:null;if(typeof j=="string"&&j!==""||typeof j=="number")return w!==null?null:l(m,x,""+j,S);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Bd:return j.key===w?c(m,x,j,S):null;case So:return j.key===w?u(m,x,j,S):null;case Er:return w=j._init,g(m,x,w(j._payload),S)}if(pc(j)||Il(j))return w!==null?null:d(m,x,j,S,null);su(m,j)}return null}function v(m,x,j,S,w){if(typeof S=="string"&&S!==""||typeof S=="number")return m=m.get(j)||null,l(x,m,""+S,w);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case Bd:return m=m.get(S.key===null?j:S.key)||null,c(x,m,S,w);case So:return m=m.get(S.key===null?j:S.key)||null,u(x,m,S,w);case Er:var C=S._init;return v(m,x,j,C(S._payload),w)}if(pc(S)||Il(S))return m=m.get(j)||null,d(x,m,S,w,null);su(x,S)}return null}function f(m,x,j,S){for(var w=null,C=null,k=x,N=x=0,L=null;k!==null&&N<j.length;N++){k.index>N?(L=k,k=null):L=k.sibling;var _=g(m,k,j[N],S);if(_===null){k===null&&(k=L);break}e&&k&&_.alternate===null&&t(m,k),x=i(_,x,N),C===null?w=_:C.sibling=_,C=_,k=L}if(N===j.length)return n(m,k),Vt&&gi(m,N),w;if(k===null){for(;N<j.length;N++)k=h(m,j[N],S),k!==null&&(x=i(k,x,N),C===null?w=k:C.sibling=k,C=k);return Vt&&gi(m,N),w}for(k=a(m,k);N<j.length;N++)L=v(k,m,N,j[N],S),L!==null&&(e&&L.alternate!==null&&k.delete(L.key===null?N:L.key),x=i(L,x,N),C===null?w=L:C.sibling=L,C=L);return e&&k.forEach(function(E){return t(m,E)}),Vt&&gi(m,N),w}function y(m,x,j,S){var w=Il(j);if(typeof w!="function")throw Error(Ie(150));if(j=w.call(j),j==null)throw Error(Ie(151));for(var C=w=null,k=x,N=x=0,L=null,_=j.next();k!==null&&!_.done;N++,_=j.next()){k.index>N?(L=k,k=null):L=k.sibling;var E=g(m,k,_.value,S);if(E===null){k===null&&(k=L);break}e&&k&&E.alternate===null&&t(m,k),x=i(E,x,N),C===null?w=E:C.sibling=E,C=E,k=L}if(_.done)return n(m,k),Vt&&gi(m,N),w;if(k===null){for(;!_.done;N++,_=j.next())_=h(m,_.value,S),_!==null&&(x=i(_,x,N),C===null?w=_:C.sibling=_,C=_);return Vt&&gi(m,N),w}for(k=a(m,k);!_.done;N++,_=j.next())_=v(k,m,N,_.value,S),_!==null&&(e&&_.alternate!==null&&k.delete(_.key===null?N:_.key),x=i(_,x,N),C===null?w=_:C.sibling=_,C=_);return e&&k.forEach(function(I){return t(m,I)}),Vt&&gi(m,N),w}function b(m,x,j,S){if(typeof j=="object"&&j!==null&&j.type===No&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case Bd:e:{for(var w=j.key,C=x;C!==null;){if(C.key===w){if(w=j.type,w===No){if(C.tag===7){n(m,C.sibling),x=r(C,j.props.children),x.return=m,m=x;break e}}else if(C.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===Er&&eb(w)===C.type){n(m,C.sibling),x=r(C,j.props),x.ref=Ll(m,C,j),x.return=m,m=x;break e}n(m,C);break}else t(m,C);C=C.sibling}j.type===No?(x=Li(j.props.children,m.mode,S,j.key),x.return=m,m=x):(S=oh(j.type,j.key,j.props,null,m.mode,S),S.ref=Ll(m,x,j),S.return=m,m=S)}return o(m);case So:e:{for(C=j.key;x!==null;){if(x.key===C)if(x.tag===4&&x.stateNode.containerInfo===j.containerInfo&&x.stateNode.implementation===j.implementation){n(m,x.sibling),x=r(x,j.children||[]),x.return=m,m=x;break e}else{n(m,x);break}else t(m,x);x=x.sibling}x=_m(j,m.mode,S),x.return=m,m=x}return o(m);case Er:return C=j._init,b(m,x,C(j._payload),S)}if(pc(j))return f(m,x,j,S);if(Il(j))return y(m,x,j,S);su(m,j)}return typeof j=="string"&&j!==""||typeof j=="number"?(j=""+j,x!==null&&x.tag===6?(n(m,x.sibling),x=r(x,j),x.return=m,m=x):(n(m,x),x=Em(j,m.mode,S),x.return=m,m=x),o(m)):n(m,x)}return b}var nl=nk(!0),ak=nk(!1),Dh=si(null),zh=null,Ao=null,Py=null;function $y(){Py=Ao=zh=null}function Oy(e){var t=Dh.current;Wt(Dh),e._currentValue=t}function Ig(e,t,n){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function Vo(e,t){zh=e,Py=Ao=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(tn=!0),e.firstContext=null)}function Fn(e){var t=e._currentValue;if(Py!==e)if(e={context:e,memoizedValue:t,next:null},Ao===null){if(zh===null)throw Error(Ie(308));Ao=e,zh.dependencies={lanes:0,firstContext:e}}else Ao=Ao.next=e;return t}var Ci=null;function Ly(e){Ci===null?Ci=[e]:Ci.push(e)}function rk(e,t,n,a){var r=t.interleaved;return r===null?(n.next=n,Ly(t)):(n.next=r.next,r.next=n),t.interleaved=n,lr(e,a)}function lr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var _r=!1;function My(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ik(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function nr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Hr(e,t,n){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,bt&2){var r=a.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),a.pending=t,lr(e,n)}return r=a.interleaved,r===null?(t.next=t,Ly(a)):(t.next=r.next,r.next=t),a.interleaved=t,lr(e,n)}function th(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,wy(e,n)}}function tb(e,t){var n=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var r=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?r=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?r=i=t:i=i.next=t}else r=i=t;n={baseState:a.baseState,firstBaseUpdate:r,lastBaseUpdate:i,shared:a.shared,effects:a.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Uh(e,t,n,a){var r=e.updateQueue;_r=!1;var i=r.firstBaseUpdate,o=r.lastBaseUpdate,l=r.shared.pending;if(l!==null){r.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?i=u:o.next=u,o=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==o&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(i!==null){var h=r.baseState;o=0,d=u=c=null,l=i;do{var g=l.lane,v=l.eventTime;if((a&g)===g){d!==null&&(d=d.next={eventTime:v,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var f=e,y=l;switch(g=t,v=n,y.tag){case 1:if(f=y.payload,typeof f=="function"){h=f.call(v,h,g);break e}h=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=y.payload,g=typeof f=="function"?f.call(v,h,g):f,g==null)break e;h=Zt({},h,g);break e;case 2:_r=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,g=r.effects,g===null?r.effects=[l]:g.push(l))}else v={eventTime:v,lane:g,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=v,c=h):d=d.next=v,o|=g;if(l=l.next,l===null){if(l=r.shared.pending,l===null)break;g=l,l=g.next,g.next=null,r.lastBaseUpdate=g,r.shared.pending=null}}while(!0);if(d===null&&(c=h),r.baseState=c,r.firstBaseUpdate=u,r.lastBaseUpdate=d,t=r.shared.interleaved,t!==null){r=t;do o|=r.lane,r=r.next;while(r!==t)}else i===null&&(r.shared.lanes=0);Bi|=o,e.lanes=o,e.memoizedState=h}}function sb(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var a=e[t],r=a.callback;if(r!==null){if(a.callback=null,a=n,typeof r!="function")throw Error(Ie(191,r));r.call(a)}}}var Id={},Ia=si(Id),ud=si(Id),hd=si(Id);function Ti(e){if(e===Id)throw Error(Ie(174));return e}function Dy(e,t){switch(Mt(hd,t),Mt(ud,e),Mt(Ia,Id),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ug(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ug(t,e)}Wt(Ia),Mt(Ia,t)}function al(){Wt(Ia),Wt(ud),Wt(hd)}function ok(e){Ti(hd.current);var t=Ti(Ia.current),n=ug(t,e.type);t!==n&&(Mt(ud,e),Mt(Ia,n))}function zy(e){ud.current===e&&(Wt(Ia),Wt(ud))}var Jt=si(0);function Fh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var jm=[];function Uy(){for(var e=0;e<jm.length;e++)jm[e]._workInProgressVersionPrimary=null;jm.length=0}var sh=pr.ReactCurrentDispatcher,bm=pr.ReactCurrentBatchConfig,Hi=0,Yt=null,ps=null,gs=null,Gh=!1,Ic=!1,pd=0,yI=0;function Rs(){throw Error(Ie(321))}function Fy(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ga(e[n],t[n]))return!1;return!0}function Gy(e,t,n,a,r,i){if(Hi=i,Yt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,sh.current=e===null||e.memoizedState===null?wI:SI,e=n(a,r),Ic){i=0;do{if(Ic=!1,pd=0,25<=i)throw Error(Ie(301));i+=1,gs=ps=null,t.updateQueue=null,sh.current=NI,e=n(a,r)}while(Ic)}if(sh.current=Wh,t=ps!==null&&ps.next!==null,Hi=0,gs=ps=Yt=null,Gh=!1,t)throw Error(Ie(300));return e}function Wy(){var e=pd!==0;return pd=0,e}function Sa(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gs===null?Yt.memoizedState=gs=e:gs=gs.next=e,gs}function Gn(){if(ps===null){var e=Yt.alternate;e=e!==null?e.memoizedState:null}else e=ps.next;var t=gs===null?Yt.memoizedState:gs.next;if(t!==null)gs=t,ps=e;else{if(e===null)throw Error(Ie(310));ps=e,e={memoizedState:ps.memoizedState,baseState:ps.baseState,baseQueue:ps.baseQueue,queue:ps.queue,next:null},gs===null?Yt.memoizedState=gs=e:gs=gs.next=e}return gs}function md(e,t){return typeof t=="function"?t(e):t}function wm(e){var t=Gn(),n=t.queue;if(n===null)throw Error(Ie(311));n.lastRenderedReducer=e;var a=ps,r=a.baseQueue,i=n.pending;if(i!==null){if(r!==null){var o=r.next;r.next=i.next,i.next=o}a.baseQueue=r=i,n.pending=null}if(r!==null){i=r.next,a=a.baseState;var l=o=null,c=null,u=i;do{var d=u.lane;if((Hi&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),a=u.hasEagerState?u.eagerState:e(a,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=h,o=a):c=c.next=h,Yt.lanes|=d,Bi|=d}u=u.next}while(u!==null&&u!==i);c===null?o=a:c.next=l,ga(a,t.memoizedState)||(tn=!0),t.memoizedState=a,t.baseState=o,t.baseQueue=c,n.lastRenderedState=a}if(e=n.interleaved,e!==null){r=e;do i=r.lane,Yt.lanes|=i,Bi|=i,r=r.next;while(r!==e)}else r===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Sm(e){var t=Gn(),n=t.queue;if(n===null)throw Error(Ie(311));n.lastRenderedReducer=e;var a=n.dispatch,r=n.pending,i=t.memoizedState;if(r!==null){n.pending=null;var o=r=r.next;do i=e(i,o.action),o=o.next;while(o!==r);ga(i,t.memoizedState)||(tn=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,a]}function lk(){}function ck(e,t){var n=Yt,a=Gn(),r=t(),i=!ga(a.memoizedState,r);if(i&&(a.memoizedState=r,tn=!0),a=a.queue,Hy(hk.bind(null,n,a,e),[e]),a.getSnapshot!==t||i||gs!==null&&gs.memoizedState.tag&1){if(n.flags|=2048,fd(9,uk.bind(null,n,a,r,t),void 0,null),ys===null)throw Error(Ie(349));Hi&30||dk(n,t,r)}return r}function dk(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Yt.updateQueue,t===null?(t={lastEffect:null,stores:null},Yt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function uk(e,t,n,a){t.value=n,t.getSnapshot=a,pk(t)&&mk(e)}function hk(e,t,n){return n(function(){pk(t)&&mk(e)})}function pk(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ga(e,n)}catch{return!0}}function mk(e){var t=lr(e,1);t!==null&&pa(t,e,1,-1)}function nb(e){var t=Sa();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:md,lastRenderedState:e},t.queue=e,e=e.dispatch=bI.bind(null,Yt,e),[t.memoizedState,e]}function fd(e,t,n,a){return e={tag:e,create:t,destroy:n,deps:a,next:null},t=Yt.updateQueue,t===null?(t={lastEffect:null,stores:null},Yt.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(a=n.next,n.next=e,e.next=a,t.lastEffect=e)),e}function fk(){return Gn().memoizedState}function nh(e,t,n,a){var r=Sa();Yt.flags|=e,r.memoizedState=fd(1|t,n,void 0,a===void 0?null:a)}function Tp(e,t,n,a){var r=Gn();a=a===void 0?null:a;var i=void 0;if(ps!==null){var o=ps.memoizedState;if(i=o.destroy,a!==null&&Fy(a,o.deps)){r.memoizedState=fd(t,n,i,a);return}}Yt.flags|=e,r.memoizedState=fd(1|t,n,i,a)}function ab(e,t){return nh(8390656,8,e,t)}function Hy(e,t){return Tp(2048,8,e,t)}function gk(e,t){return Tp(4,2,e,t)}function vk(e,t){return Tp(4,4,e,t)}function yk(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function xk(e,t,n){return n=n!=null?n.concat([e]):null,Tp(4,4,yk.bind(null,t,e),n)}function By(){}function jk(e,t){var n=Gn();t=t===void 0?null:t;var a=n.memoizedState;return a!==null&&t!==null&&Fy(t,a[1])?a[0]:(n.memoizedState=[e,t],e)}function bk(e,t){var n=Gn();t=t===void 0?null:t;var a=n.memoizedState;return a!==null&&t!==null&&Fy(t,a[1])?a[0]:(e=e(),n.memoizedState=[e,t],e)}function wk(e,t,n){return Hi&21?(ga(n,t)||(n=_0(),Yt.lanes|=n,Bi|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,tn=!0),e.memoizedState=n)}function xI(e,t){var n=Rt;Rt=n!==0&&4>n?n:4,e(!0);var a=bm.transition;bm.transition={};try{e(!1),t()}finally{Rt=n,bm.transition=a}}function Sk(){return Gn().memoizedState}function jI(e,t,n){var a=Vr(e);if(n={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null},Nk(e))kk(t,n);else if(n=rk(e,t,n,a),n!==null){var r=Hs();pa(n,e,a,r),Ek(n,t,a)}}function bI(e,t,n){var a=Vr(e),r={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null};if(Nk(e))kk(t,r);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,n);if(r.hasEagerState=!0,r.eagerState=l,ga(l,o)){var c=t.interleaved;c===null?(r.next=r,Ly(t)):(r.next=c.next,c.next=r),t.interleaved=r;return}}catch{}finally{}n=rk(e,t,r,a),n!==null&&(r=Hs(),pa(n,e,a,r),Ek(n,t,a))}}function Nk(e){var t=e.alternate;return e===Yt||t!==null&&t===Yt}function kk(e,t){Ic=Gh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ek(e,t,n){if(n&4194240){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,wy(e,n)}}var Wh={readContext:Fn,useCallback:Rs,useContext:Rs,useEffect:Rs,useImperativeHandle:Rs,useInsertionEffect:Rs,useLayoutEffect:Rs,useMemo:Rs,useReducer:Rs,useRef:Rs,useState:Rs,useDebugValue:Rs,useDeferredValue:Rs,useTransition:Rs,useMutableSource:Rs,useSyncExternalStore:Rs,useId:Rs,unstable_isNewReconciler:!1},wI={readContext:Fn,useCallback:function(e,t){return Sa().memoizedState=[e,t===void 0?null:t],e},useContext:Fn,useEffect:ab,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,nh(4194308,4,yk.bind(null,t,e),n)},useLayoutEffect:function(e,t){return nh(4194308,4,e,t)},useInsertionEffect:function(e,t){return nh(4,2,e,t)},useMemo:function(e,t){var n=Sa();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var a=Sa();return t=n!==void 0?n(t):t,a.memoizedState=a.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},a.queue=e,e=e.dispatch=jI.bind(null,Yt,e),[a.memoizedState,e]},useRef:function(e){var t=Sa();return e={current:e},t.memoizedState=e},useState:nb,useDebugValue:By,useDeferredValue:function(e){return Sa().memoizedState=e},useTransition:function(){var e=nb(!1),t=e[0];return e=xI.bind(null,e[1]),Sa().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var a=Yt,r=Sa();if(Vt){if(n===void 0)throw Error(Ie(407));n=n()}else{if(n=t(),ys===null)throw Error(Ie(349));Hi&30||dk(a,t,n)}r.memoizedState=n;var i={value:n,getSnapshot:t};return r.queue=i,ab(hk.bind(null,a,i,e),[e]),a.flags|=2048,fd(9,uk.bind(null,a,i,n,t),void 0,null),n},useId:function(){var e=Sa(),t=ys.identifierPrefix;if(Vt){var n=Qa,a=Xa;n=(a&~(1<<32-ha(a)-1)).toString(32)+n,t=":"+t+"R"+n,n=pd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=yI++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},SI={readContext:Fn,useCallback:jk,useContext:Fn,useEffect:Hy,useImperativeHandle:xk,useInsertionEffect:gk,useLayoutEffect:vk,useMemo:bk,useReducer:wm,useRef:fk,useState:function(){return wm(md)},useDebugValue:By,useDeferredValue:function(e){var t=Gn();return wk(t,ps.memoizedState,e)},useTransition:function(){var e=wm(md)[0],t=Gn().memoizedState;return[e,t]},useMutableSource:lk,useSyncExternalStore:ck,useId:Sk,unstable_isNewReconciler:!1},NI={readContext:Fn,useCallback:jk,useContext:Fn,useEffect:Hy,useImperativeHandle:xk,useInsertionEffect:gk,useLayoutEffect:vk,useMemo:bk,useReducer:Sm,useRef:fk,useState:function(){return Sm(md)},useDebugValue:By,useDeferredValue:function(e){var t=Gn();return ps===null?t.memoizedState=e:wk(t,ps.memoizedState,e)},useTransition:function(){var e=Sm(md)[0],t=Gn().memoizedState;return[e,t]},useMutableSource:lk,useSyncExternalStore:ck,useId:Sk,unstable_isNewReconciler:!1};function sa(e,t){if(e&&e.defaultProps){t=Zt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Ag(e,t,n,a){t=e.memoizedState,n=n(a,t),n=n==null?t:Zt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Rp={isMounted:function(e){return(e=e._reactInternals)?Yi(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var a=Hs(),r=Vr(e),i=nr(a,r);i.payload=t,n!=null&&(i.callback=n),t=Hr(e,i,r),t!==null&&(pa(t,e,r,a),th(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var a=Hs(),r=Vr(e),i=nr(a,r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Hr(e,i,r),t!==null&&(pa(t,e,r,a),th(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Hs(),a=Vr(e),r=nr(n,a);r.tag=2,t!=null&&(r.callback=t),t=Hr(e,r,a),t!==null&&(pa(t,e,a,n),th(t,e,a))}};function rb(e,t,n,a,r,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,i,o):t.prototype&&t.prototype.isPureReactComponent?!od(n,a)||!od(r,i):!0}function _k(e,t,n){var a=!1,r=Xr,i=t.contextType;return typeof i=="object"&&i!==null?i=Fn(i):(r=rn(t)?Gi:Ms.current,a=t.contextTypes,i=(a=a!=null)?tl(e,r):Xr),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Rp,e.stateNode=t,t._reactInternals=e,a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),t}function ib(e,t,n,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,a),t.state!==e&&Rp.enqueueReplaceState(t,t.state,null)}function Pg(e,t,n,a){var r=e.stateNode;r.props=n,r.state=e.memoizedState,r.refs={},My(e);var i=t.contextType;typeof i=="object"&&i!==null?r.context=Fn(i):(i=rn(t)?Gi:Ms.current,r.context=tl(e,i)),r.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Ag(e,t,i,n),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&Rp.enqueueReplaceState(r,r.state,null),Uh(e,n,r,a),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function rl(e,t){try{var n="",a=t;do n+=XT(a),a=a.return;while(a);var r=n}catch(i){r=`
|
|
39
|
-
Error generating stack: `+i.message+`
|
|
40
|
-
`+i.stack}return{value:e,source:t,stack:r,digest:null}}function Nm(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function $g(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var kI=typeof WeakMap=="function"?WeakMap:Map;function Ck(e,t,n){n=nr(-1,n),n.tag=3,n.payload={element:null};var a=t.value;return n.callback=function(){Bh||(Bh=!0,Hg=a),$g(e,t)},n}function Tk(e,t,n){n=nr(-1,n),n.tag=3;var a=e.type.getDerivedStateFromError;if(typeof a=="function"){var r=t.value;n.payload=function(){return a(r)},n.callback=function(){$g(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){$g(e,t),typeof a!="function"&&(Br===null?Br=new Set([this]):Br.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function ob(e,t,n){var a=e.pingCache;if(a===null){a=e.pingCache=new kI;var r=new Set;a.set(t,r)}else r=a.get(t),r===void 0&&(r=new Set,a.set(t,r));r.has(n)||(r.add(n),e=zI.bind(null,e,t,n),t.then(e,e))}function lb(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function cb(e,t,n,a,r){return e.mode&1?(e.flags|=65536,e.lanes=r,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=nr(-1,1),t.tag=2,Hr(n,t,1))),n.lanes|=1),e)}var EI=pr.ReactCurrentOwner,tn=!1;function Gs(e,t,n,a){t.child=e===null?ak(t,null,n,a):nl(t,e.child,n,a)}function db(e,t,n,a,r){n=n.render;var i=t.ref;return Vo(t,r),a=Gy(e,t,n,a,i,r),n=Wy(),e!==null&&!tn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,cr(e,t,r)):(Vt&&n&&Ry(t),t.flags|=1,Gs(e,t,a,r),t.child)}function ub(e,t,n,a,r){if(e===null){var i=n.type;return typeof i=="function"&&!Qy(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Rk(e,t,i,a,r)):(e=oh(n.type,null,a,t,t.mode,r),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&r)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:od,n(o,a)&&e.ref===t.ref)return cr(e,t,r)}return t.flags|=1,e=qr(i,a),e.ref=t.ref,e.return=t,t.child=e}function Rk(e,t,n,a,r){if(e!==null){var i=e.memoizedProps;if(od(i,a)&&e.ref===t.ref)if(tn=!1,t.pendingProps=a=i,(e.lanes&r)!==0)e.flags&131072&&(tn=!0);else return t.lanes=e.lanes,cr(e,t,r)}return Og(e,t,n,a,r)}function Ik(e,t,n){var a=t.pendingProps,r=a.children,i=e!==null?e.memoizedState:null;if(a.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Mt($o,pn),pn|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Mt($o,pn),pn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},a=i!==null?i.baseLanes:n,Mt($o,pn),pn|=a}else i!==null?(a=i.baseLanes|n,t.memoizedState=null):a=n,Mt($o,pn),pn|=a;return Gs(e,t,r,n),t.child}function Ak(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Og(e,t,n,a,r){var i=rn(n)?Gi:Ms.current;return i=tl(t,i),Vo(t,r),n=Gy(e,t,n,a,i,r),a=Wy(),e!==null&&!tn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,cr(e,t,r)):(Vt&&a&&Ry(t),t.flags|=1,Gs(e,t,n,r),t.child)}function hb(e,t,n,a,r){if(rn(n)){var i=!0;Oh(t)}else i=!1;if(Vo(t,r),t.stateNode===null)ah(e,t),_k(t,n,a),Pg(t,n,a,r),a=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Fn(u):(u=rn(n)?Gi:Ms.current,u=tl(t,u));var d=n.getDerivedStateFromProps,h=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==a||c!==u)&&ib(t,o,a,u),_r=!1;var g=t.memoizedState;o.state=g,Uh(t,a,o,r),c=t.memoizedState,l!==a||g!==c||an.current||_r?(typeof d=="function"&&(Ag(t,n,d,a),c=t.memoizedState),(l=_r||rb(t,n,l,a,g,c,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=c),o.props=a,o.state=c,o.context=u,a=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{o=t.stateNode,ik(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:sa(t.type,l),o.props=u,h=t.pendingProps,g=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=Fn(c):(c=rn(n)?Gi:Ms.current,c=tl(t,c));var v=n.getDerivedStateFromProps;(d=typeof v=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||g!==c)&&ib(t,o,a,c),_r=!1,g=t.memoizedState,o.state=g,Uh(t,a,o,r);var f=t.memoizedState;l!==h||g!==f||an.current||_r?(typeof v=="function"&&(Ag(t,n,v,a),f=t.memoizedState),(u=_r||rb(t,n,u,a,g,f,c)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(a,f,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(a,f,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=f),o.props=a,o.state=f,o.context=c,a=u):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),a=!1)}return Lg(e,t,n,a,i,r)}function Lg(e,t,n,a,r,i){Ak(e,t);var o=(t.flags&128)!==0;if(!a&&!o)return r&&Zj(t,n,!1),cr(e,t,i);a=t.stateNode,EI.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:a.render();return t.flags|=1,e!==null&&o?(t.child=nl(t,e.child,null,i),t.child=nl(t,null,l,i)):Gs(e,t,l,i),t.memoizedState=a.state,r&&Zj(t,n,!0),t.child}function Pk(e){var t=e.stateNode;t.pendingContext?Yj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Yj(e,t.context,!1),Dy(e,t.containerInfo)}function pb(e,t,n,a,r){return sl(),Ay(r),t.flags|=256,Gs(e,t,n,a),t.child}var Mg={dehydrated:null,treeContext:null,retryLane:0};function Dg(e){return{baseLanes:e,cachePool:null,transitions:null}}function $k(e,t,n){var a=t.pendingProps,r=Jt.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(r&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),Mt(Jt,r&1),e===null)return Rg(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=a.children,e=a.fallback,i?(a=t.mode,i=t.child,o={mode:"hidden",children:o},!(a&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Pp(o,a,0,null),e=Li(e,a,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Dg(n),t.memoizedState=Mg,e):Vy(t,o));if(r=e.memoizedState,r!==null&&(l=r.dehydrated,l!==null))return _I(e,t,o,a,l,r,n);if(i){i=a.fallback,o=t.mode,r=e.child,l=r.sibling;var c={mode:"hidden",children:a.children};return!(o&1)&&t.child!==r?(a=t.child,a.childLanes=0,a.pendingProps=c,t.deletions=null):(a=qr(r,c),a.subtreeFlags=r.subtreeFlags&14680064),l!==null?i=qr(l,i):(i=Li(i,o,n,null),i.flags|=2),i.return=t,a.return=t,a.sibling=i,t.child=a,a=i,i=t.child,o=e.child.memoizedState,o=o===null?Dg(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Mg,a}return i=e.child,e=i.sibling,a=qr(i,{mode:"visible",children:a.children}),!(t.mode&1)&&(a.lanes=n),a.return=t,a.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=a,t.memoizedState=null,a}function Vy(e,t){return t=Pp({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function nu(e,t,n,a){return a!==null&&Ay(a),nl(t,e.child,null,n),e=Vy(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _I(e,t,n,a,r,i,o){if(n)return t.flags&256?(t.flags&=-257,a=Nm(Error(Ie(422))),nu(e,t,o,a)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=a.fallback,r=t.mode,a=Pp({mode:"visible",children:a.children},r,0,null),i=Li(i,r,o,null),i.flags|=2,a.return=t,i.return=t,a.sibling=i,t.child=a,t.mode&1&&nl(t,e.child,null,o),t.child.memoizedState=Dg(o),t.memoizedState=Mg,i);if(!(t.mode&1))return nu(e,t,o,null);if(r.data==="$!"){if(a=r.nextSibling&&r.nextSibling.dataset,a)var l=a.dgst;return a=l,i=Error(Ie(419)),a=Nm(i,a,void 0),nu(e,t,o,a)}if(l=(o&e.childLanes)!==0,tn||l){if(a=ys,a!==null){switch(o&-o){case 4:r=2;break;case 16:r=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:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(a.suspendedLanes|o)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,lr(e,r),pa(a,e,r,-1))}return Xy(),a=Nm(Error(Ie(421))),nu(e,t,o,a)}return r.data==="$?"?(t.flags|=128,t.child=e.child,t=UI.bind(null,e),r._reactRetry=t,null):(e=i.treeContext,jn=Wr(r.nextSibling),Nn=t,Vt=!0,ra=null,e!==null&&(On[Ln++]=Xa,On[Ln++]=Qa,On[Ln++]=Wi,Xa=e.id,Qa=e.overflow,Wi=t),t=Vy(t,a.children),t.flags|=4096,t)}function mb(e,t,n){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Ig(e.return,t,n)}function km(e,t,n,a,r){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=a,i.tail=n,i.tailMode=r)}function Ok(e,t,n){var a=t.pendingProps,r=a.revealOrder,i=a.tail;if(Gs(e,t,a.children,n),a=Jt.current,a&2)a=a&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&mb(e,n,t);else if(e.tag===19)mb(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}a&=1}if(Mt(Jt,a),!(t.mode&1))t.memoizedState=null;else switch(r){case"forwards":for(n=t.child,r=null;n!==null;)e=n.alternate,e!==null&&Fh(e)===null&&(r=n),n=n.sibling;n=r,n===null?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),km(t,!1,r,n,i);break;case"backwards":for(n=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&Fh(e)===null){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}km(t,!0,n,null,i);break;case"together":km(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ah(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function cr(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Bi|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ie(153));if(t.child!==null){for(e=t.child,n=qr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=qr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function CI(e,t,n){switch(t.tag){case 3:Pk(t),sl();break;case 5:ok(t);break;case 1:rn(t.type)&&Oh(t);break;case 4:Dy(t,t.stateNode.containerInfo);break;case 10:var a=t.type._context,r=t.memoizedProps.value;Mt(Dh,a._currentValue),a._currentValue=r;break;case 13:if(a=t.memoizedState,a!==null)return a.dehydrated!==null?(Mt(Jt,Jt.current&1),t.flags|=128,null):n&t.child.childLanes?$k(e,t,n):(Mt(Jt,Jt.current&1),e=cr(e,t,n),e!==null?e.sibling:null);Mt(Jt,Jt.current&1);break;case 19:if(a=(n&t.childLanes)!==0,e.flags&128){if(a)return Ok(e,t,n);t.flags|=128}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),Mt(Jt,Jt.current),a)break;return null;case 22:case 23:return t.lanes=0,Ik(e,t,n)}return cr(e,t,n)}var Lk,zg,Mk,Dk;Lk=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};zg=function(){};Mk=function(e,t,n,a){var r=e.memoizedProps;if(r!==a){e=t.stateNode,Ti(Ia.current);var i=null;switch(n){case"input":r=og(e,r),a=og(e,a),i=[];break;case"select":r=Zt({},r,{value:void 0}),a=Zt({},a,{value:void 0}),i=[];break;case"textarea":r=dg(e,r),a=dg(e,a),i=[];break;default:typeof r.onClick!="function"&&typeof a.onClick=="function"&&(e.onclick=Ph)}hg(n,a);var o;n=null;for(u in r)if(!a.hasOwnProperty(u)&&r.hasOwnProperty(u)&&r[u]!=null)if(u==="style"){var l=r[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ed.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in a){var c=a[u];if(l=r!=null?r[u]:void 0,a.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ed.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Ft("scroll",e),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};Dk=function(e,t,n,a){n!==a&&(t.flags|=4)};function Ml(e,t){if(!Vt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Is(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,a=0;if(t)for(var r=e.child;r!==null;)n|=r.lanes|r.childLanes,a|=r.subtreeFlags&14680064,a|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)n|=r.lanes|r.childLanes,a|=r.subtreeFlags,a|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=a,e.childLanes=n,t}function TI(e,t,n){var a=t.pendingProps;switch(Iy(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Is(t),null;case 1:return rn(t.type)&&$h(),Is(t),null;case 3:return a=t.stateNode,al(),Wt(an),Wt(Ms),Uy(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(tu(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ra!==null&&(qg(ra),ra=null))),zg(e,t),Is(t),null;case 5:zy(t);var r=Ti(hd.current);if(n=t.type,e!==null&&t.stateNode!=null)Mk(e,t,n,a,r),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!a){if(t.stateNode===null)throw Error(Ie(166));return Is(t),null}if(e=Ti(Ia.current),tu(t)){a=t.stateNode,n=t.type;var i=t.memoizedProps;switch(a[Ca]=t,a[dd]=i,e=(t.mode&1)!==0,n){case"dialog":Ft("cancel",a),Ft("close",a);break;case"iframe":case"object":case"embed":Ft("load",a);break;case"video":case"audio":for(r=0;r<fc.length;r++)Ft(fc[r],a);break;case"source":Ft("error",a);break;case"img":case"image":case"link":Ft("error",a),Ft("load",a);break;case"details":Ft("toggle",a);break;case"input":Sj(a,i),Ft("invalid",a);break;case"select":a._wrapperState={wasMultiple:!!i.multiple},Ft("invalid",a);break;case"textarea":kj(a,i),Ft("invalid",a)}hg(n,i),r=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?a.textContent!==l&&(i.suppressHydrationWarning!==!0&&eu(a.textContent,l,e),r=["children",l]):typeof l=="number"&&a.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&eu(a.textContent,l,e),r=["children",""+l]):ed.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&Ft("scroll",a)}switch(n){case"input":Vd(a),Nj(a,i,!0);break;case"textarea":Vd(a),Ej(a);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(a.onclick=Ph)}a=r,t.updateQueue=a,a!==null&&(t.flags|=4)}else{o=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=h0(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof a.is=="string"?e=o.createElement(n,{is:a.is}):(e=o.createElement(n),n==="select"&&(o=e,a.multiple?o.multiple=!0:a.size&&(o.size=a.size))):e=o.createElementNS(e,n),e[Ca]=t,e[dd]=a,Lk(e,t,!1,!1),t.stateNode=e;e:{switch(o=pg(n,a),n){case"dialog":Ft("cancel",e),Ft("close",e),r=a;break;case"iframe":case"object":case"embed":Ft("load",e),r=a;break;case"video":case"audio":for(r=0;r<fc.length;r++)Ft(fc[r],e);r=a;break;case"source":Ft("error",e),r=a;break;case"img":case"image":case"link":Ft("error",e),Ft("load",e),r=a;break;case"details":Ft("toggle",e),r=a;break;case"input":Sj(e,a),r=og(e,a),Ft("invalid",e);break;case"option":r=a;break;case"select":e._wrapperState={wasMultiple:!!a.multiple},r=Zt({},a,{value:void 0}),Ft("invalid",e);break;case"textarea":kj(e,a),r=dg(e,a),Ft("invalid",e);break;default:r=a}hg(n,r),l=r;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?f0(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&p0(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&td(e,c):typeof c=="number"&&td(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ed.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Ft("scroll",e):c!=null&&gy(e,i,c,o))}switch(n){case"input":Vd(e),Nj(e,a,!1);break;case"textarea":Vd(e),Ej(e);break;case"option":a.value!=null&&e.setAttribute("value",""+Zr(a.value));break;case"select":e.multiple=!!a.multiple,i=a.value,i!=null?Go(e,!!a.multiple,i,!1):a.defaultValue!=null&&Go(e,!!a.multiple,a.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=Ph)}switch(n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}}a&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Is(t),null;case 6:if(e&&t.stateNode!=null)Dk(e,t,e.memoizedProps,a);else{if(typeof a!="string"&&t.stateNode===null)throw Error(Ie(166));if(n=Ti(hd.current),Ti(Ia.current),tu(t)){if(a=t.stateNode,n=t.memoizedProps,a[Ca]=t,(i=a.nodeValue!==n)&&(e=Nn,e!==null))switch(e.tag){case 3:eu(a.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&eu(a.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else a=(n.nodeType===9?n:n.ownerDocument).createTextNode(a),a[Ca]=t,t.stateNode=a}return Is(t),null;case 13:if(Wt(Jt),a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Vt&&jn!==null&&t.mode&1&&!(t.flags&128))sk(),sl(),t.flags|=98560,i=!1;else if(i=tu(t),a!==null&&a.dehydrated!==null){if(e===null){if(!i)throw Error(Ie(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ie(317));i[Ca]=t}else sl(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Is(t),i=!1}else ra!==null&&(qg(ra),ra=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(a=a!==null,a!==(e!==null&&e.memoizedState!==null)&&a&&(t.child.flags|=8192,t.mode&1&&(e===null||Jt.current&1?ms===0&&(ms=3):Xy())),t.updateQueue!==null&&(t.flags|=4),Is(t),null);case 4:return al(),zg(e,t),e===null&&ld(t.stateNode.containerInfo),Is(t),null;case 10:return Oy(t.type._context),Is(t),null;case 17:return rn(t.type)&&$h(),Is(t),null;case 19:if(Wt(Jt),i=t.memoizedState,i===null)return Is(t),null;if(a=(t.flags&128)!==0,o=i.rendering,o===null)if(a)Ml(i,!1);else{if(ms!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Fh(e),o!==null){for(t.flags|=128,Ml(i,!1),a=o.updateQueue,a!==null&&(t.updateQueue=a,t.flags|=4),t.subtreeFlags=0,a=n,n=t.child;n!==null;)i=n,e=a,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Mt(Jt,Jt.current&1|2),t.child}e=e.sibling}i.tail!==null&&ns()>il&&(t.flags|=128,a=!0,Ml(i,!1),t.lanes=4194304)}else{if(!a)if(e=Fh(o),e!==null){if(t.flags|=128,a=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ml(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Vt)return Is(t),null}else 2*ns()-i.renderingStartTime>il&&n!==1073741824&&(t.flags|=128,a=!0,Ml(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ns(),t.sibling=null,n=Jt.current,Mt(Jt,a?n&1|2:n&1),t):(Is(t),null);case 22:case 23:return Zy(),a=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==a&&(t.flags|=8192),a&&t.mode&1?pn&1073741824&&(Is(t),t.subtreeFlags&6&&(t.flags|=8192)):Is(t),null;case 24:return null;case 25:return null}throw Error(Ie(156,t.tag))}function RI(e,t){switch(Iy(t),t.tag){case 1:return rn(t.type)&&$h(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return al(),Wt(an),Wt(Ms),Uy(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return zy(t),null;case 13:if(Wt(Jt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ie(340));sl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Wt(Jt),null;case 4:return al(),null;case 10:return Oy(t.type._context),null;case 22:case 23:return Zy(),null;case 24:return null;default:return null}}var au=!1,Ps=!1,II=typeof WeakSet=="function"?WeakSet:Set,We=null;function Po(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(a){Qt(e,t,a)}else n.current=null}function Ug(e,t,n){try{n()}catch(a){Qt(e,t,a)}}var fb=!1;function AI(e,t){if(Sg=Rh,e=W0(),Ty(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var a=n.getSelection&&n.getSelection();if(a&&a.rangeCount!==0){n=a.anchorNode;var r=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,h=e,g=null;t:for(;;){for(var v;h!==n||r!==0&&h.nodeType!==3||(l=o+r),h!==i||a!==0&&h.nodeType!==3||(c=o+a),h.nodeType===3&&(o+=h.nodeValue.length),(v=h.firstChild)!==null;)g=h,h=v;for(;;){if(h===e)break t;if(g===n&&++u===r&&(l=o),g===i&&++d===a&&(c=o),(v=h.nextSibling)!==null)break;h=g,g=h.parentNode}h=v}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ng={focusedElem:e,selectionRange:n},Rh=!1,We=t;We!==null;)if(t=We,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,We=e;else for(;We!==null;){t=We;try{var f=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(f!==null){var y=f.memoizedProps,b=f.memoizedState,m=t.stateNode,x=m.getSnapshotBeforeUpdate(t.elementType===t.type?y:sa(t.type,y),b);m.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var j=t.stateNode.containerInfo;j.nodeType===1?j.textContent="":j.nodeType===9&&j.documentElement&&j.removeChild(j.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ie(163))}}catch(S){Qt(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,We=e;break}We=t.return}return f=fb,fb=!1,f}function Ac(e,t,n){var a=t.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var r=a=a.next;do{if((r.tag&e)===e){var i=r.destroy;r.destroy=void 0,i!==void 0&&Ug(t,n,i)}r=r.next}while(r!==a)}}function Ip(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var a=n.create;n.destroy=a()}n=n.next}while(n!==t)}}function Fg(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function zk(e){var t=e.alternate;t!==null&&(e.alternate=null,zk(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ca],delete t[dd],delete t[_g],delete t[mI],delete t[fI])),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 Uk(e){return e.tag===5||e.tag===3||e.tag===4}function gb(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Uk(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 Gg(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ph));else if(a!==4&&(e=e.child,e!==null))for(Gg(e,t,n),e=e.sibling;e!==null;)Gg(e,t,n),e=e.sibling}function Wg(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(a!==4&&(e=e.child,e!==null))for(Wg(e,t,n),e=e.sibling;e!==null;)Wg(e,t,n),e=e.sibling}var ws=null,na=!1;function gr(e,t,n){for(n=n.child;n!==null;)Fk(e,t,n),n=n.sibling}function Fk(e,t,n){if(Ra&&typeof Ra.onCommitFiberUnmount=="function")try{Ra.onCommitFiberUnmount(Sp,n)}catch{}switch(n.tag){case 5:Ps||Po(n,t);case 6:var a=ws,r=na;ws=null,gr(e,t,n),ws=a,na=r,ws!==null&&(na?(e=ws,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ws.removeChild(n.stateNode));break;case 18:ws!==null&&(na?(e=ws,n=n.stateNode,e.nodeType===8?ym(e.parentNode,n):e.nodeType===1&&ym(e,n),rd(e)):ym(ws,n.stateNode));break;case 4:a=ws,r=na,ws=n.stateNode.containerInfo,na=!0,gr(e,t,n),ws=a,na=r;break;case 0:case 11:case 14:case 15:if(!Ps&&(a=n.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){r=a=a.next;do{var i=r,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Ug(n,t,o),r=r.next}while(r!==a)}gr(e,t,n);break;case 1:if(!Ps&&(Po(n,t),a=n.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=n.memoizedProps,a.state=n.memoizedState,a.componentWillUnmount()}catch(l){Qt(n,t,l)}gr(e,t,n);break;case 21:gr(e,t,n);break;case 22:n.mode&1?(Ps=(a=Ps)||n.memoizedState!==null,gr(e,t,n),Ps=a):gr(e,t,n);break;default:gr(e,t,n)}}function vb(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new II),t.forEach(function(a){var r=FI.bind(null,e,a);n.has(a)||(n.add(a),a.then(r,r))})}}function Kn(e,t){var n=t.deletions;if(n!==null)for(var a=0;a<n.length;a++){var r=n[a];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:ws=l.stateNode,na=!1;break e;case 3:ws=l.stateNode.containerInfo,na=!0;break e;case 4:ws=l.stateNode.containerInfo,na=!0;break e}l=l.return}if(ws===null)throw Error(Ie(160));Fk(i,o,r),ws=null,na=!1;var c=r.alternate;c!==null&&(c.return=null),r.return=null}catch(u){Qt(r,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Gk(t,e),t=t.sibling}function Gk(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Kn(t,e),ja(e),a&4){try{Ac(3,e,e.return),Ip(3,e)}catch(y){Qt(e,e.return,y)}try{Ac(5,e,e.return)}catch(y){Qt(e,e.return,y)}}break;case 1:Kn(t,e),ja(e),a&512&&n!==null&&Po(n,n.return);break;case 5:if(Kn(t,e),ja(e),a&512&&n!==null&&Po(n,n.return),e.flags&32){var r=e.stateNode;try{td(r,"")}catch(y){Qt(e,e.return,y)}}if(a&4&&(r=e.stateNode,r!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&d0(r,i),pg(l,o);var u=pg(l,i);for(o=0;o<c.length;o+=2){var d=c[o],h=c[o+1];d==="style"?f0(r,h):d==="dangerouslySetInnerHTML"?p0(r,h):d==="children"?td(r,h):gy(r,d,h,u)}switch(l){case"input":lg(r,i);break;case"textarea":u0(r,i);break;case"select":var g=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var v=i.value;v!=null?Go(r,!!i.multiple,v,!1):g!==!!i.multiple&&(i.defaultValue!=null?Go(r,!!i.multiple,i.defaultValue,!0):Go(r,!!i.multiple,i.multiple?[]:"",!1))}r[dd]=i}catch(y){Qt(e,e.return,y)}}break;case 6:if(Kn(t,e),ja(e),a&4){if(e.stateNode===null)throw Error(Ie(162));r=e.stateNode,i=e.memoizedProps;try{r.nodeValue=i}catch(y){Qt(e,e.return,y)}}break;case 3:if(Kn(t,e),ja(e),a&4&&n!==null&&n.memoizedState.isDehydrated)try{rd(t.containerInfo)}catch(y){Qt(e,e.return,y)}break;case 4:Kn(t,e),ja(e);break;case 13:Kn(t,e),ja(e),r=e.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(Jy=ns())),a&4&&vb(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Ps=(u=Ps)||d,Kn(t,e),Ps=u):Kn(t,e),ja(e),a&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(We=e,d=e.child;d!==null;){for(h=We=d;We!==null;){switch(g=We,v=g.child,g.tag){case 0:case 11:case 14:case 15:Ac(4,g,g.return);break;case 1:Po(g,g.return);var f=g.stateNode;if(typeof f.componentWillUnmount=="function"){a=g,n=g.return;try{t=a,f.props=t.memoizedProps,f.state=t.memoizedState,f.componentWillUnmount()}catch(y){Qt(a,n,y)}}break;case 5:Po(g,g.return);break;case 22:if(g.memoizedState!==null){xb(h);continue}}v!==null?(v.return=g,We=v):xb(h)}d=d.sibling}e:for(d=null,h=e;;){if(h.tag===5){if(d===null){d=h;try{r=h.stateNode,u?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=h.stateNode,c=h.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=m0("display",o))}catch(y){Qt(e,e.return,y)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(y){Qt(e,e.return,y)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Kn(t,e),ja(e),a&4&&vb(e);break;case 21:break;default:Kn(t,e),ja(e)}}function ja(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Uk(n)){var a=n;break e}n=n.return}throw Error(Ie(160))}switch(a.tag){case 5:var r=a.stateNode;a.flags&32&&(td(r,""),a.flags&=-33);var i=gb(e);Wg(e,i,r);break;case 3:case 4:var o=a.stateNode.containerInfo,l=gb(e);Gg(e,l,o);break;default:throw Error(Ie(161))}}catch(c){Qt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function PI(e,t,n){We=e,Wk(e)}function Wk(e,t,n){for(var a=(e.mode&1)!==0;We!==null;){var r=We,i=r.child;if(r.tag===22&&a){var o=r.memoizedState!==null||au;if(!o){var l=r.alternate,c=l!==null&&l.memoizedState!==null||Ps;l=au;var u=Ps;if(au=o,(Ps=c)&&!u)for(We=r;We!==null;)o=We,c=o.child,o.tag===22&&o.memoizedState!==null?jb(r):c!==null?(c.return=o,We=c):jb(r);for(;i!==null;)We=i,Wk(i),i=i.sibling;We=r,au=l,Ps=u}yb(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,We=i):yb(e)}}function yb(e){for(;We!==null;){var t=We;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ps||Ip(5,t);break;case 1:var a=t.stateNode;if(t.flags&4&&!Ps)if(n===null)a.componentDidMount();else{var r=t.elementType===t.type?n.memoizedProps:sa(t.type,n.memoizedProps);a.componentDidUpdate(r,n.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&sb(t,i,a);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}sb(t,o,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var h=d.dehydrated;h!==null&&rd(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ie(163))}Ps||t.flags&512&&Fg(t)}catch(g){Qt(t,t.return,g)}}if(t===e){We=null;break}if(n=t.sibling,n!==null){n.return=t.return,We=n;break}We=t.return}}function xb(e){for(;We!==null;){var t=We;if(t===e){We=null;break}var n=t.sibling;if(n!==null){n.return=t.return,We=n;break}We=t.return}}function jb(e){for(;We!==null;){var t=We;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ip(4,t)}catch(c){Qt(t,n,c)}break;case 1:var a=t.stateNode;if(typeof a.componentDidMount=="function"){var r=t.return;try{a.componentDidMount()}catch(c){Qt(t,r,c)}}var i=t.return;try{Fg(t)}catch(c){Qt(t,i,c)}break;case 5:var o=t.return;try{Fg(t)}catch(c){Qt(t,o,c)}}}catch(c){Qt(t,t.return,c)}if(t===e){We=null;break}var l=t.sibling;if(l!==null){l.return=t.return,We=l;break}We=t.return}}var $I=Math.ceil,Hh=pr.ReactCurrentDispatcher,qy=pr.ReactCurrentOwner,zn=pr.ReactCurrentBatchConfig,bt=0,ys=null,ds=null,Ns=0,pn=0,$o=si(0),ms=0,gd=null,Bi=0,Ap=0,Ky=0,Pc=null,en=null,Jy=0,il=1/0,Ba=null,Bh=!1,Hg=null,Br=null,ru=!1,Lr=null,Vh=0,$c=0,Bg=null,rh=-1,ih=0;function Hs(){return bt&6?ns():rh!==-1?rh:rh=ns()}function Vr(e){return e.mode&1?bt&2&&Ns!==0?Ns&-Ns:vI.transition!==null?(ih===0&&(ih=_0()),ih):(e=Rt,e!==0||(e=window.event,e=e===void 0?16:$0(e.type)),e):1}function pa(e,t,n,a){if(50<$c)throw $c=0,Bg=null,Error(Ie(185));Cd(e,n,a),(!(bt&2)||e!==ys)&&(e===ys&&(!(bt&2)&&(Ap|=n),ms===4&&Rr(e,Ns)),on(e,a),n===1&&bt===0&&!(t.mode&1)&&(il=ns()+500,Cp&&ni()))}function on(e,t){var n=e.callbackNode;vR(e,t);var a=Th(e,e===ys?Ns:0);if(a===0)n!==null&&Tj(n),e.callbackNode=null,e.callbackPriority=0;else if(t=a&-a,e.callbackPriority!==t){if(n!=null&&Tj(n),t===1)e.tag===0?gI(bb.bind(null,e)):Q0(bb.bind(null,e)),hI(function(){!(bt&6)&&ni()}),n=null;else{switch(C0(a)){case 1:n=by;break;case 4:n=k0;break;case 16:n=Ch;break;case 536870912:n=E0;break;default:n=Ch}n=Zk(n,Hk.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Hk(e,t){if(rh=-1,ih=0,bt&6)throw Error(Ie(327));var n=e.callbackNode;if(qo()&&e.callbackNode!==n)return null;var a=Th(e,e===ys?Ns:0);if(a===0)return null;if(a&30||a&e.expiredLanes||t)t=qh(e,a);else{t=a;var r=bt;bt|=2;var i=Vk();(ys!==e||Ns!==t)&&(Ba=null,il=ns()+500,Oi(e,t));do try{MI();break}catch(l){Bk(e,l)}while(!0);$y(),Hh.current=i,bt=r,ds!==null?t=0:(ys=null,Ns=0,t=ms)}if(t!==0){if(t===2&&(r=yg(e),r!==0&&(a=r,t=Vg(e,r))),t===1)throw n=gd,Oi(e,0),Rr(e,a),on(e,ns()),n;if(t===6)Rr(e,a);else{if(r=e.current.alternate,!(a&30)&&!OI(r)&&(t=qh(e,a),t===2&&(i=yg(e),i!==0&&(a=i,t=Vg(e,i))),t===1))throw n=gd,Oi(e,0),Rr(e,a),on(e,ns()),n;switch(e.finishedWork=r,e.finishedLanes=a,t){case 0:case 1:throw Error(Ie(345));case 2:vi(e,en,Ba);break;case 3:if(Rr(e,a),(a&130023424)===a&&(t=Jy+500-ns(),10<t)){if(Th(e,0)!==0)break;if(r=e.suspendedLanes,(r&a)!==a){Hs(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=Eg(vi.bind(null,e,en,Ba),t);break}vi(e,en,Ba);break;case 4:if(Rr(e,a),(a&4194240)===a)break;for(t=e.eventTimes,r=-1;0<a;){var o=31-ha(a);i=1<<o,o=t[o],o>r&&(r=o),a&=~i}if(a=r,a=ns()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*$I(a/1960))-a,10<a){e.timeoutHandle=Eg(vi.bind(null,e,en,Ba),a);break}vi(e,en,Ba);break;case 5:vi(e,en,Ba);break;default:throw Error(Ie(329))}}}return on(e,ns()),e.callbackNode===n?Hk.bind(null,e):null}function Vg(e,t){var n=Pc;return e.current.memoizedState.isDehydrated&&(Oi(e,t).flags|=256),e=qh(e,t),e!==2&&(t=en,en=n,t!==null&&qg(t)),e}function qg(e){en===null?en=e:en.push.apply(en,e)}function OI(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var a=0;a<n.length;a++){var r=n[a],i=r.getSnapshot;r=r.value;try{if(!ga(i(),r))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Rr(e,t){for(t&=~Ky,t&=~Ap,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-ha(t),a=1<<n;e[n]=-1,t&=~a}}function bb(e){if(bt&6)throw Error(Ie(327));qo();var t=Th(e,0);if(!(t&1))return on(e,ns()),null;var n=qh(e,t);if(e.tag!==0&&n===2){var a=yg(e);a!==0&&(t=a,n=Vg(e,a))}if(n===1)throw n=gd,Oi(e,0),Rr(e,t),on(e,ns()),n;if(n===6)throw Error(Ie(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,vi(e,en,Ba),on(e,ns()),null}function Yy(e,t){var n=bt;bt|=1;try{return e(t)}finally{bt=n,bt===0&&(il=ns()+500,Cp&&ni())}}function Vi(e){Lr!==null&&Lr.tag===0&&!(bt&6)&&qo();var t=bt;bt|=1;var n=zn.transition,a=Rt;try{if(zn.transition=null,Rt=1,e)return e()}finally{Rt=a,zn.transition=n,bt=t,!(bt&6)&&ni()}}function Zy(){pn=$o.current,Wt($o)}function Oi(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,uI(n)),ds!==null)for(n=ds.return;n!==null;){var a=n;switch(Iy(a),a.tag){case 1:a=a.type.childContextTypes,a!=null&&$h();break;case 3:al(),Wt(an),Wt(Ms),Uy();break;case 5:zy(a);break;case 4:al();break;case 13:Wt(Jt);break;case 19:Wt(Jt);break;case 10:Oy(a.type._context);break;case 22:case 23:Zy()}n=n.return}if(ys=e,ds=e=qr(e.current,null),Ns=pn=t,ms=0,gd=null,Ky=Ap=Bi=0,en=Pc=null,Ci!==null){for(t=0;t<Ci.length;t++)if(n=Ci[t],a=n.interleaved,a!==null){n.interleaved=null;var r=a.next,i=n.pending;if(i!==null){var o=i.next;i.next=r,a.next=o}n.pending=a}Ci=null}return e}function Bk(e,t){do{var n=ds;try{if($y(),sh.current=Wh,Gh){for(var a=Yt.memoizedState;a!==null;){var r=a.queue;r!==null&&(r.pending=null),a=a.next}Gh=!1}if(Hi=0,gs=ps=Yt=null,Ic=!1,pd=0,qy.current=null,n===null||n.return===null){ms=1,gd=t,ds=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=Ns,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,h=d.tag;if(!(d.mode&1)&&(h===0||h===11||h===15)){var g=d.alternate;g?(d.updateQueue=g.updateQueue,d.memoizedState=g.memoizedState,d.lanes=g.lanes):(d.updateQueue=null,d.memoizedState=null)}var v=lb(o);if(v!==null){v.flags&=-257,cb(v,o,l,i,t),v.mode&1&&ob(i,u,t),t=v,c=u;var f=t.updateQueue;if(f===null){var y=new Set;y.add(c),t.updateQueue=y}else f.add(c);break e}else{if(!(t&1)){ob(i,u,t),Xy();break e}c=Error(Ie(426))}}else if(Vt&&l.mode&1){var b=lb(o);if(b!==null){!(b.flags&65536)&&(b.flags|=256),cb(b,o,l,i,t),Ay(rl(c,l));break e}}i=c=rl(c,l),ms!==4&&(ms=2),Pc===null?Pc=[i]:Pc.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var m=Ck(i,c,t);tb(i,m);break e;case 1:l=c;var x=i.type,j=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(Br===null||!Br.has(j)))){i.flags|=65536,t&=-t,i.lanes|=t;var S=Tk(i,l,t);tb(i,S);break e}}i=i.return}while(i!==null)}Kk(n)}catch(w){t=w,ds===n&&n!==null&&(ds=n=n.return);continue}break}while(!0)}function Vk(){var e=Hh.current;return Hh.current=Wh,e===null?Wh:e}function Xy(){(ms===0||ms===3||ms===2)&&(ms=4),ys===null||!(Bi&268435455)&&!(Ap&268435455)||Rr(ys,Ns)}function qh(e,t){var n=bt;bt|=2;var a=Vk();(ys!==e||Ns!==t)&&(Ba=null,Oi(e,t));do try{LI();break}catch(r){Bk(e,r)}while(!0);if($y(),bt=n,Hh.current=a,ds!==null)throw Error(Ie(261));return ys=null,Ns=0,ms}function LI(){for(;ds!==null;)qk(ds)}function MI(){for(;ds!==null&&!lR();)qk(ds)}function qk(e){var t=Yk(e.alternate,e,pn);e.memoizedProps=e.pendingProps,t===null?Kk(e):ds=t,qy.current=null}function Kk(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=RI(n,t),n!==null){n.flags&=32767,ds=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ms=6,ds=null;return}}else if(n=TI(n,t,pn),n!==null){ds=n;return}if(t=t.sibling,t!==null){ds=t;return}ds=t=e}while(t!==null);ms===0&&(ms=5)}function vi(e,t,n){var a=Rt,r=zn.transition;try{zn.transition=null,Rt=1,DI(e,t,n,a)}finally{zn.transition=r,Rt=a}return null}function DI(e,t,n,a){do qo();while(Lr!==null);if(bt&6)throw Error(Ie(327));n=e.finishedWork;var r=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Ie(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(yR(e,i),e===ys&&(ds=ys=null,Ns=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ru||(ru=!0,Zk(Ch,function(){return qo(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=zn.transition,zn.transition=null;var o=Rt;Rt=1;var l=bt;bt|=4,qy.current=null,AI(e,n),Gk(n,e),aI(Ng),Rh=!!Sg,Ng=Sg=null,e.current=n,PI(n),cR(),bt=l,Rt=o,zn.transition=i}else e.current=n;if(ru&&(ru=!1,Lr=e,Vh=r),i=e.pendingLanes,i===0&&(Br=null),hR(n.stateNode),on(e,ns()),t!==null)for(a=e.onRecoverableError,n=0;n<t.length;n++)r=t[n],a(r.value,{componentStack:r.stack,digest:r.digest});if(Bh)throw Bh=!1,e=Hg,Hg=null,e;return Vh&1&&e.tag!==0&&qo(),i=e.pendingLanes,i&1?e===Bg?$c++:($c=0,Bg=e):$c=0,ni(),null}function qo(){if(Lr!==null){var e=C0(Vh),t=zn.transition,n=Rt;try{if(zn.transition=null,Rt=16>e?16:e,Lr===null)var a=!1;else{if(e=Lr,Lr=null,Vh=0,bt&6)throw Error(Ie(331));var r=bt;for(bt|=4,We=e.current;We!==null;){var i=We,o=i.child;if(We.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(We=u;We!==null;){var d=We;switch(d.tag){case 0:case 11:case 15:Ac(8,d,i)}var h=d.child;if(h!==null)h.return=d,We=h;else for(;We!==null;){d=We;var g=d.sibling,v=d.return;if(zk(d),d===u){We=null;break}if(g!==null){g.return=v,We=g;break}We=v}}}var f=i.alternate;if(f!==null){var y=f.child;if(y!==null){f.child=null;do{var b=y.sibling;y.sibling=null,y=b}while(y!==null)}}We=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,We=o;else e:for(;We!==null;){if(i=We,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Ac(9,i,i.return)}var m=i.sibling;if(m!==null){m.return=i.return,We=m;break e}We=i.return}}var x=e.current;for(We=x;We!==null;){o=We;var j=o.child;if(o.subtreeFlags&2064&&j!==null)j.return=o,We=j;else e:for(o=x;We!==null;){if(l=We,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Ip(9,l)}}catch(w){Qt(l,l.return,w)}if(l===o){We=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,We=S;break e}We=l.return}}if(bt=r,ni(),Ra&&typeof Ra.onPostCommitFiberRoot=="function")try{Ra.onPostCommitFiberRoot(Sp,e)}catch{}a=!0}return a}finally{Rt=n,zn.transition=t}}return!1}function wb(e,t,n){t=rl(n,t),t=Ck(e,t,1),e=Hr(e,t,1),t=Hs(),e!==null&&(Cd(e,1,t),on(e,t))}function Qt(e,t,n){if(e.tag===3)wb(e,e,n);else for(;t!==null;){if(t.tag===3){wb(t,e,n);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Br===null||!Br.has(a))){e=rl(n,e),e=Tk(t,e,1),t=Hr(t,e,1),e=Hs(),t!==null&&(Cd(t,1,e),on(t,e));break}}t=t.return}}function zI(e,t,n){var a=e.pingCache;a!==null&&a.delete(t),t=Hs(),e.pingedLanes|=e.suspendedLanes&n,ys===e&&(Ns&n)===n&&(ms===4||ms===3&&(Ns&130023424)===Ns&&500>ns()-Jy?Oi(e,0):Ky|=n),on(e,t)}function Jk(e,t){t===0&&(e.mode&1?(t=Jd,Jd<<=1,!(Jd&130023424)&&(Jd=4194304)):t=1);var n=Hs();e=lr(e,t),e!==null&&(Cd(e,t,n),on(e,n))}function UI(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Jk(e,n)}function FI(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,r=e.memoizedState;r!==null&&(n=r.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(Ie(314))}a!==null&&a.delete(t),Jk(e,n)}var Yk;Yk=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||an.current)tn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return tn=!1,CI(e,t,n);tn=!!(e.flags&131072)}else tn=!1,Vt&&t.flags&1048576&&ek(t,Mh,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;ah(e,t),e=t.pendingProps;var r=tl(t,Ms.current);Vo(t,n),r=Gy(null,t,a,e,r,n);var i=Wy();return t.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,rn(a)?(i=!0,Oh(t)):i=!1,t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,My(t),r.updater=Rp,t.stateNode=r,r._reactInternals=t,Pg(t,a,e,n),t=Lg(null,t,a,!0,i,n)):(t.tag=0,Vt&&i&&Ry(t),Gs(null,t,r,n),t=t.child),t;case 16:a=t.elementType;e:{switch(ah(e,t),e=t.pendingProps,r=a._init,a=r(a._payload),t.type=a,r=t.tag=WI(a),e=sa(a,e),r){case 0:t=Og(null,t,a,e,n);break e;case 1:t=hb(null,t,a,e,n);break e;case 11:t=db(null,t,a,e,n);break e;case 14:t=ub(null,t,a,sa(a.type,e),n);break e}throw Error(Ie(306,a,""))}return t;case 0:return a=t.type,r=t.pendingProps,r=t.elementType===a?r:sa(a,r),Og(e,t,a,r,n);case 1:return a=t.type,r=t.pendingProps,r=t.elementType===a?r:sa(a,r),hb(e,t,a,r,n);case 3:e:{if(Pk(t),e===null)throw Error(Ie(387));a=t.pendingProps,i=t.memoizedState,r=i.element,ik(e,t),Uh(t,a,null,n);var o=t.memoizedState;if(a=o.element,i.isDehydrated)if(i={element:a,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){r=rl(Error(Ie(423)),t),t=pb(e,t,a,n,r);break e}else if(a!==r){r=rl(Error(Ie(424)),t),t=pb(e,t,a,n,r);break e}else for(jn=Wr(t.stateNode.containerInfo.firstChild),Nn=t,Vt=!0,ra=null,n=ak(t,null,a,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(sl(),a===r){t=cr(e,t,n);break e}Gs(e,t,a,n)}t=t.child}return t;case 5:return ok(t),e===null&&Rg(t),a=t.type,r=t.pendingProps,i=e!==null?e.memoizedProps:null,o=r.children,kg(a,r)?o=null:i!==null&&kg(a,i)&&(t.flags|=32),Ak(e,t),Gs(e,t,o,n),t.child;case 6:return e===null&&Rg(t),null;case 13:return $k(e,t,n);case 4:return Dy(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=nl(t,null,a,n):Gs(e,t,a,n),t.child;case 11:return a=t.type,r=t.pendingProps,r=t.elementType===a?r:sa(a,r),db(e,t,a,r,n);case 7:return Gs(e,t,t.pendingProps,n),t.child;case 8:return Gs(e,t,t.pendingProps.children,n),t.child;case 12:return Gs(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(a=t.type._context,r=t.pendingProps,i=t.memoizedProps,o=r.value,Mt(Dh,a._currentValue),a._currentValue=o,i!==null)if(ga(i.value,o)){if(i.children===r.children&&!an.current){t=cr(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===a){if(i.tag===1){c=nr(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Ig(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(Ie(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ig(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Gs(e,t,r.children,n),t=t.child}return t;case 9:return r=t.type,a=t.pendingProps.children,Vo(t,n),r=Fn(r),a=a(r),t.flags|=1,Gs(e,t,a,n),t.child;case 14:return a=t.type,r=sa(a,t.pendingProps),r=sa(a.type,r),ub(e,t,a,r,n);case 15:return Rk(e,t,t.type,t.pendingProps,n);case 17:return a=t.type,r=t.pendingProps,r=t.elementType===a?r:sa(a,r),ah(e,t),t.tag=1,rn(a)?(e=!0,Oh(t)):e=!1,Vo(t,n),_k(t,a,r),Pg(t,a,r,n),Lg(null,t,a,!0,e,n);case 19:return Ok(e,t,n);case 22:return Ik(e,t,n)}throw Error(Ie(156,t.tag))};function Zk(e,t){return N0(e,t)}function GI(e,t,n,a){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Dn(e,t,n,a){return new GI(e,t,n,a)}function Qy(e){return e=e.prototype,!(!e||!e.isReactComponent)}function WI(e){if(typeof e=="function")return Qy(e)?1:0;if(e!=null){if(e=e.$$typeof,e===yy)return 11;if(e===xy)return 14}return 2}function qr(e,t){var n=e.alternate;return n===null?(n=Dn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function oh(e,t,n,a,r,i){var o=2;if(a=e,typeof e=="function")Qy(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case No:return Li(n.children,r,i,t);case vy:o=8,r|=8;break;case ng:return e=Dn(12,n,t,r|2),e.elementType=ng,e.lanes=i,e;case ag:return e=Dn(13,n,t,r),e.elementType=ag,e.lanes=i,e;case rg:return e=Dn(19,n,t,r),e.elementType=rg,e.lanes=i,e;case o0:return Pp(n,r,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case r0:o=10;break e;case i0:o=9;break e;case yy:o=11;break e;case xy:o=14;break e;case Er:o=16,a=null;break e}throw Error(Ie(130,e==null?e:typeof e,""))}return t=Dn(o,n,t,r),t.elementType=e,t.type=a,t.lanes=i,t}function Li(e,t,n,a){return e=Dn(7,e,a,t),e.lanes=n,e}function Pp(e,t,n,a){return e=Dn(22,e,a,t),e.elementType=o0,e.lanes=n,e.stateNode={isHidden:!1},e}function Em(e,t,n){return e=Dn(6,e,null,t),e.lanes=n,e}function _m(e,t,n){return t=Dn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function HI(e,t,n,a,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=om(0),this.expirationTimes=om(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=om(0),this.identifierPrefix=a,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function ex(e,t,n,a,r,i,o,l,c){return e=new HI(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Dn(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:a,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},My(i),e}function BI(e,t,n){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:So,key:a==null?null:""+a,children:e,containerInfo:t,implementation:n}}function Xk(e){if(!e)return Xr;e=e._reactInternals;e:{if(Yi(e)!==e||e.tag!==1)throw Error(Ie(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(rn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ie(171))}if(e.tag===1){var n=e.type;if(rn(n))return X0(e,n,t)}return t}function Qk(e,t,n,a,r,i,o,l,c){return e=ex(n,a,!0,e,r,i,o,l,c),e.context=Xk(null),n=e.current,a=Hs(),r=Vr(n),i=nr(a,r),i.callback=t??null,Hr(n,i,r),e.current.lanes=r,Cd(e,r,a),on(e,a),e}function $p(e,t,n,a){var r=t.current,i=Hs(),o=Vr(r);return n=Xk(n),t.context===null?t.context=n:t.pendingContext=n,t=nr(i,o),t.payload={element:e},a=a===void 0?null:a,a!==null&&(t.callback=a),e=Hr(r,t,o),e!==null&&(pa(e,r,o,i),th(e,r,o)),o}function Kh(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 Sb(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function tx(e,t){Sb(e,t),(e=e.alternate)&&Sb(e,t)}function VI(){return null}var e1=typeof reportError=="function"?reportError:function(e){console.error(e)};function sx(e){this._internalRoot=e}Op.prototype.render=sx.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ie(409));$p(e,t,null,null)};Op.prototype.unmount=sx.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vi(function(){$p(null,e,null,null)}),t[or]=null}};function Op(e){this._internalRoot=e}Op.prototype.unstable_scheduleHydration=function(e){if(e){var t=I0();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tr.length&&t!==0&&t<Tr[n].priority;n++);Tr.splice(n,0,e),n===0&&P0(e)}};function nx(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Lp(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Nb(){}function qI(e,t,n,a,r){if(r){if(typeof a=="function"){var i=a;a=function(){var u=Kh(o);i.call(u)}}var o=Qk(t,a,e,0,null,!1,!1,"",Nb);return e._reactRootContainer=o,e[or]=o.current,ld(e.nodeType===8?e.parentNode:e),Vi(),o}for(;r=e.lastChild;)e.removeChild(r);if(typeof a=="function"){var l=a;a=function(){var u=Kh(c);l.call(u)}}var c=ex(e,0,!1,null,null,!1,!1,"",Nb);return e._reactRootContainer=c,e[or]=c.current,ld(e.nodeType===8?e.parentNode:e),Vi(function(){$p(t,c,n,a)}),c}function Mp(e,t,n,a,r){var i=n._reactRootContainer;if(i){var o=i;if(typeof r=="function"){var l=r;r=function(){var c=Kh(o);l.call(c)}}$p(t,o,e,r)}else o=qI(n,t,e,r,a);return Kh(o)}T0=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=mc(t.pendingLanes);n!==0&&(wy(t,n|1),on(t,ns()),!(bt&6)&&(il=ns()+500,ni()))}break;case 13:Vi(function(){var a=lr(e,1);if(a!==null){var r=Hs();pa(a,e,1,r)}}),tx(e,1)}};Sy=function(e){if(e.tag===13){var t=lr(e,134217728);if(t!==null){var n=Hs();pa(t,e,134217728,n)}tx(e,134217728)}};R0=function(e){if(e.tag===13){var t=Vr(e),n=lr(e,t);if(n!==null){var a=Hs();pa(n,e,t,a)}tx(e,t)}};I0=function(){return Rt};A0=function(e,t){var n=Rt;try{return Rt=e,t()}finally{Rt=n}};fg=function(e,t,n){switch(t){case"input":if(lg(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var r=_p(a);if(!r)throw Error(Ie(90));c0(a),lg(a,r)}}}break;case"textarea":u0(e,n);break;case"select":t=n.value,t!=null&&Go(e,!!n.multiple,t,!1)}};y0=Yy;x0=Vi;var KI={usingClientEntryPoint:!1,Events:[Rd,Co,_p,g0,v0,Yy]},Dl={findFiberByHostInstance:_i,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},JI={bundleType:Dl.bundleType,version:Dl.version,rendererPackageName:Dl.rendererPackageName,rendererConfig:Dl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:pr.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=w0(e),e===null?null:e.stateNode},findFiberByHostInstance:Dl.findFiberByHostInstance||VI,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 iu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iu.isDisabled&&iu.supportsFiber)try{Sp=iu.inject(JI),Ra=iu}catch{}}Cn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=KI;Cn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!nx(t))throw Error(Ie(200));return BI(e,t,null,n)};Cn.createRoot=function(e,t){if(!nx(e))throw Error(Ie(299));var n=!1,a="",r=e1;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onRecoverableError!==void 0&&(r=t.onRecoverableError)),t=ex(e,1,!1,null,null,n,!1,a,r),e[or]=t.current,ld(e.nodeType===8?e.parentNode:e),new sx(t)};Cn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Ie(188)):(e=Object.keys(e).join(","),Error(Ie(268,e)));return e=w0(t),e=e===null?null:e.stateNode,e};Cn.flushSync=function(e){return Vi(e)};Cn.hydrate=function(e,t,n){if(!Lp(t))throw Error(Ie(200));return Mp(null,e,t,!0,n)};Cn.hydrateRoot=function(e,t,n){if(!nx(e))throw Error(Ie(405));var a=n!=null&&n.hydratedSources||null,r=!1,i="",o=e1;if(n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Qk(t,null,e,1,n??null,r,!1,i,o),e[or]=t.current,ld(e),a)for(e=0;e<a.length;e++)n=a[e],r=n._getVersion,r=r(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,r]:t.mutableSourceEagerHydrationData.push(n,r);return new Op(t)};Cn.render=function(e,t,n){if(!Lp(t))throw Error(Ie(200));return Mp(null,e,t,!1,n)};Cn.unmountComponentAtNode=function(e){if(!Lp(e))throw Error(Ie(40));return e._reactRootContainer?(Vi(function(){Mp(null,null,e,!1,function(){e._reactRootContainer=null,e[or]=null})}),!0):!1};Cn.unstable_batchedUpdates=Yy;Cn.unstable_renderSubtreeIntoContainer=function(e,t,n,a){if(!Lp(n))throw Error(Ie(200));if(e==null||e._reactInternals===void 0)throw Error(Ie(38));return Mp(e,t,n,!1,a)};Cn.version="18.3.1-next-f1338f8080-20240426";function t1(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t1)}catch(e){console.error(e)}}t1(),t0.exports=Cn;var ax=t0.exports,s1,kb=ax;s1=kb.createRoot,kb.hydrateRoot;function Qs(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}function oi(e,t,n,a){if(typeof t=="function"?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?a:n==="a"?a.call(e):a?a.value:t.get(e)}function Eb(e,t,n,a,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}function n1(e,t){this.v=e,this.k=t}function _b(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function at(e,t,n){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function YI(e){return new n1(e,0)}function a1(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function J(e,t){return e.get(at(e,t))}function tt(e,t,n){a1(e,t),t.set(e,n)}function Je(e,t,n){return e.set(at(e,t),n),n}function Dp(e,t){a1(e,t),t.add(e)}function Pe(e,t,n){return(t=function(a){var r=function(i,o){if(typeof i!="object"||!i)return i;var l=i[Symbol.toPrimitive];if(l!==void 0){var c=l.call(i,o);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}(a,"string");return typeof r=="symbol"?r:r+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,a)}return n}function Le(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Cb(Object(n),!0).forEach(function(a){Pe(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cb(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Tb(e,t){if(e==null)return{};var n,a,r=function(o,l){if(o==null)return{};var c={};for(var u in o)if({}.hasOwnProperty.call(o,u)){if(l.indexOf(u)!==-1)continue;c[u]=o[u]}return c}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function kn(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,a){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var i,o,l,c,u=[],d=!0,h=!1;try{if(l=(r=r.call(n)).next,a===0){if(Object(r)!==r)return;d=!1}else for(;!(d=(i=l.call(r)).done)&&(u.push(i.value),u.length!==a);d=!0);}catch(g){h=!0,o=g}finally{try{if(!d&&r.return!=null&&(c=r.return(),Object(c)!==c))return}finally{if(h)throw o}}return u}}(e,t)||function(n,a){if(n){if(typeof n=="string")return _b(n,a);var r={}.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_b(n,a):void 0}}(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
41
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ZI(e){return function(){return new gc(e.apply(this,arguments))}}function gc(e){var t,n;function a(i,o){try{var l=e[i](o),c=l.value,u=c instanceof n1;Promise.resolve(u?c.v:c).then(function(d){if(u){var h=i==="return"&&c.k?i:"next";if(!c.k||d.done)return a(h,d);d=e[h](d).value}r(!!l.done,d)},function(d){a("throw",d)})}catch(d){r(2,d)}}function r(i,o){i===2?t.reject(o):t.resolve({value:o,done:i}),(t=t.next)?a(t.key,t.arg):n=null}this._invoke=function(i,o){return new Promise(function(l,c){var u={key:i,arg:o,resolve:l,reject:c,next:null};n?n=n.next=u:(t=n=u,a(i,o))})},typeof e.return!="function"&&(this.return=void 0)}typeof SuppressedError=="function"&&SuppressedError,gc.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},gc.prototype.next=function(e){return this._invoke("next",e)},gc.prototype.throw=function(e){return this._invoke("throw",e)},gc.prototype.return=function(e){return this._invoke("return",e)};const XI={timeoutInSeconds:60},Kg=1e4,Rb="memory",r1="online_access",Jg={name:"auth0-spa-js",version:"2.24.0"},i1=()=>Date.now(),bs="default";let Ct=class Yg extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,Yg.prototype)}static fromPayload(t){let n=t.error,a=t.error_description;return new Yg(n,a)}},Ib=class o1 extends Ct{constructor(t,n){super("invalid_configuration","".concat(t," ").concat(n)),this.suggestion=n,Object.setPrototypeOf(this,o1.prototype)}},QI=class l1 extends Ct{constructor(t,n,a){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=a,this.appState=r,Object.setPrototypeOf(this,l1.prototype)}},eA=class c1 extends Ct{constructor(t,n,a,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=a,this.state=r,this.appState=i,Object.setPrototypeOf(this,c1.prototype)}},zp=class d1 extends Ct{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,d1.prototype)}},tA=class u1 extends zp{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,u1.prototype)}},sA=class h1 extends Ct{constructor(t){super("cancelled","Popup closed"),this.popup=t,Object.setPrototypeOf(this,h1.prototype)}},nA=class p1 extends Ct{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,p1.prototype)}},Zg=class m1 extends Ct{constructor(t,n,a,r){super(t,n),this.mfa_token=a,this.mfa_requirements=r,Object.setPrototypeOf(this,m1.prototype)}},f1=class g1 extends Ct{constructor(t,n){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(Jh(t,["default"]),"', scope: '").concat(Jh(n),"')")),this.audience=t,this.scope=n,Object.setPrototypeOf(this,g1.prototype)}},aA=class v1 extends Ct{constructor(t,n){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(Jh(t,["default"]),"', missing scope: '").concat(Jh(n),"')")),this.audience=t,this.scope=n,Object.setPrototypeOf(this,v1.prototype)}},y1=class x1 extends Ct{constructor(t){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=t,Object.setPrototypeOf(this,x1.prototype)}};function Jh(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:""}const Yh=()=>window.crypto,zl=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";for(;t.length<43;){const n=Yh().getRandomValues(new Uint8Array(43-t.length));for(const a of n)t.length<43&&a<198&&(t+=e[a%66])}return t},Cm=e=>btoa(e),rA=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],Xg=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,a)=>{if(t&&a==="env")return n;const r=rA.find(i=>i.key===a);return r&&r.type.includes(typeof e[a])&&(n[a]=e[a]),n},{})},vc=e=>{var t=e.clientId,n=Qs(e,["clientId"]);return new URLSearchParams((a=>Object.keys(a).filter(r=>a[r]!==void 0).reduce((r,i)=>Object.assign(Object.assign({},r),{[i]:a[i]}),{}))(Object.assign({client_id:t},n))).toString()},Ab=async e=>await Yh().subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),Pb=e=>(t=>decodeURIComponent(atob(t).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),$b=e=>{const t=new Uint8Array(e);return(n=>{const a={"+":"-","/":"_","=":""};return n.replace(/[+/=]/g,r=>a[r])})(window.btoa(String.fromCharCode(...Array.from(t))))};var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},j1={},rx={};Object.defineProperty(rx,"__esModule",{value:!0});var iA=function(){function e(){var t=this;this.locked=new Map,this.addToLocked=function(n,a){var r=t.locked.get(n);r===void 0?a===void 0?t.locked.set(n,[]):t.locked.set(n,[a]):a!==void 0&&(r.unshift(a),t.locked.set(n,r))},this.isLocked=function(n){return t.locked.has(n)},this.lock=function(n){return new Promise(function(a,r){t.isLocked(n)?t.addToLocked(n,a):(t.addToLocked(n),a())})},this.unlock=function(n){var a=t.locked.get(n);if(a!==void 0&&a.length!==0){var r=a.pop();t.locked.set(n,a),r!==void 0&&setTimeout(r,0)}else t.locked.delete(n)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();rx.default=function(){return iA.getInstance()};var ia=qi&&qi.__awaiter||function(e,t,n,a){return new(n||(n=Promise))(function(r,i){function o(u){try{c(a.next(u))}catch(d){i(d)}}function l(u){try{c(a.throw(u))}catch(d){i(d)}}function c(u){u.done?r(u.value):new n(function(d){d(u.value)}).then(o,l)}c((a=a.apply(e,t||[])).next())})},oa=qi&&qi.__generator||function(e,t){var n,a,r,i,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(c){return function(u){return function(d){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,a&&(r=2&d[0]?a.return:d[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,d[1])).done)return r;switch(a=0,r&&(d=[2&d[0],r.value]),d[0]){case 0:case 1:r=d;break;case 4:return o.label++,{value:d[1],done:!1};case 5:o.label++,a=d[1],d=[0];continue;case 7:d=o.ops.pop(),o.trys.pop();continue;default:if(r=o.trys,!((r=r.length>0&&r[r.length-1])||d[0]!==6&&d[0]!==2)){o=0;continue}if(d[0]===3&&(!r||d[1]>r[0]&&d[1]<r[3])){o.label=d[1];break}if(d[0]===6&&o.label<r[1]){o.label=r[1],r=d;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(d);break}r[2]&&o.ops.pop(),o.trys.pop();continue}d=t.call(e,o)}catch(h){d=[6,h],a=0}finally{n=r=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}([c,u])}}},Ul=qi;Object.defineProperty(j1,"__esModule",{value:!0});var eo=rx,Tm="browser-tabs-lock-key",ou={key:function(e){return ia(Ul,void 0,void 0,function(){return oa(this,function(t){throw new Error("Unsupported")})})},getItem:function(e){return ia(Ul,void 0,void 0,function(){return oa(this,function(t){throw new Error("Unsupported")})})},clear:function(){return ia(Ul,void 0,void 0,function(){return oa(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return ia(Ul,void 0,void 0,function(){return oa(this,function(t){throw new Error("Unsupported")})})},setItem:function(e,t){return ia(Ul,void 0,void 0,function(){return oa(this,function(n){throw new Error("Unsupported")})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function Rm(e){return new Promise(function(t){return setTimeout(t,e)})}function Im(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",a=0;a<e;a++)n+=t[Math.floor(61*Math.random())];return n}var oA=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+Im(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),ia(this,void 0,void 0,function(){var a,r,i,o,l,c,u;return oa(this,function(d){switch(d.label){case 0:a=Date.now()+Im(4),r=Date.now()+n,i=Tm+"-"+t,o=this.storageHandler===void 0?ou:this.storageHandler,d.label=1;case 1:return Date.now()<r?[4,Rm(30)]:[3,8];case 2:return d.sent(),o.getItemSync(i)!==null?[3,5]:(l=this.id+"-"+t+"-"+a,[4,Rm(Math.floor(25*Math.random()))]);case 3:return d.sent(),o.setItemSync(i,JSON.stringify({id:this.id,iat:a,timeoutKey:l,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,Rm(30)];case 4:return d.sent(),(c=o.getItemSync(i))!==null&&(u=JSON.parse(c)).id===this.id&&u.iat===a?(this.acquiredIatSet.add(a),this.refreshLockWhileAcquired(i,a),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?ou:this.storageHandler),[4,this.waitForSomethingToChange(r)];case 6:d.sent(),d.label=7;case 7:return a=Date.now()+Im(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(t,n){return ia(this,void 0,void 0,function(){var a=this;return oa(this,function(r){return setTimeout(function(){return ia(a,void 0,void 0,function(){var i,o,l;return oa(this,function(c){switch(c.label){case 0:return[4,eo.default().lock(n)];case 1:return c.sent(),this.acquiredIatSet.has(n)?(i=this.storageHandler===void 0?ou:this.storageHandler,(o=i.getItemSync(t))===null?(eo.default().unlock(n),[2]):((l=JSON.parse(o)).timeRefreshed=Date.now(),i.setItemSync(t,JSON.stringify(l)),eo.default().unlock(n),this.refreshLockWhileAcquired(t,n),[2])):(eo.default().unlock(n),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return ia(this,void 0,void 0,function(){return oa(this,function(n){switch(n.label){case 0:return[4,new Promise(function(a){var r=!1,i=Date.now(),o=!1;function l(){if(o||(window.removeEventListener("storage",l),e.removeFromWaiting(l),clearTimeout(c),o=!0),!r){r=!0;var u=50-(Date.now()-i);u>0?setTimeout(a,u):a(null)}}window.addEventListener("storage",l),e.addToWaiting(l);var c=setTimeout(l,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(n){return n!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(t){return t()})},e.prototype.releaseLock=function(t){return ia(this,void 0,void 0,function(){return oa(this,function(n){switch(n.label){case 0:return[4,this.releaseLock__private__(t)];case 1:return[2,n.sent()]}})})},e.prototype.releaseLock__private__=function(t){return ia(this,void 0,void 0,function(){var n,a,r,i;return oa(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?ou:this.storageHandler,a=Tm+"-"+t,(r=n.getItemSync(a))===null?[2]:(i=JSON.parse(r)).id!==this.id?[3,2]:[4,eo.default().lock(i.iat)];case 1:o.sent(),this.acquiredIatSet.delete(i.iat),n.removeItemSync(a),eo.default().unlock(i.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,a=t,r=[],i=0;;){var o=a.keySync(i);if(o===null)break;r.push(o),i++}for(var l=!1,c=0;c<r.length;c++){var u=r[c];if(u.includes(Tm)){var d=a.getItemSync(u);if(d!==null){var h=JSON.parse(d);(h.timeRefreshed===void 0&&h.timeAcquired<n||h.timeRefreshed!==void 0&&h.timeRefreshed<n)&&(a.removeItemSync(u),l=!0)}}}l&&e.notifyWaiters()},e.waiters=void 0,e}(),lA=j1.default=oA;let cA=class{async runWithLock(t,n,a){const r=new AbortController,i=setTimeout(()=>r.abort(),n);try{return await navigator.locks.request(t,{mode:"exclusive",signal:r.signal},async o=>{if(clearTimeout(i),!o)throw new Error("Lock not available");return await a()})}catch(o){throw clearTimeout(i),(o==null?void 0:o.name)==="AbortError"?new zp:o}}},dA=class{constructor(){this.activeLocks=new Set,this.lock=new lA,this.pagehideHandler=()=>{this.activeLocks.forEach(t=>this.lock.releaseLock(t)),this.activeLocks.clear()}}async runWithLock(t,n,a){let r=!1;for(let i=0;i<10&&!r;i++)r=await this.lock.acquireLock(t,n);if(!r)throw new zp;this.activeLocks.add(t),this.activeLocks.size===1&&typeof window<"u"&&window.addEventListener("pagehide",this.pagehideHandler);try{return await a()}finally{this.activeLocks.delete(t),await this.lock.releaseLock(t),this.activeLocks.size===0&&typeof window<"u"&&window.removeEventListener("pagehide",this.pagehideHandler)}}};function uA(){return typeof navigator<"u"&&typeof((e=navigator.locks)===null||e===void 0?void 0:e.request)=="function"?new cA:new dA;var e}let Am=null;const hA=new TextEncoder,pA=new TextDecoder;function Oc(e){return typeof e=="string"?hA.encode(e):pA.decode(e)}function Ob(e){if(typeof e.modulusLength!="number"||e.modulusLength<2048)throw new fA(`${e.name} modulusLength must be at least 2048 bits`)}async function mA(e,t,n){if(n.usages.includes("sign")===!1)throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');const a=`${Lc(Oc(JSON.stringify(e)))}.${Lc(Oc(JSON.stringify(t)))}`;return`${a}.${Lc(await crypto.subtle.sign(function(r){switch(r.algorithm.name){case"ECDSA":return{name:r.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return Ob(r.algorithm),{name:r.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return Ob(r.algorithm),{name:r.algorithm.name};case"Ed25519":return{name:r.algorithm.name}}throw new Ri}(n),n,Oc(a)))}`}let Qg;Uint8Array.prototype.toBase64?Qg=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):Qg=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let a=0;a<t.byteLength;a+=32768)n.push(String.fromCharCode.apply(null,t.subarray(a,a+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};function Lc(e){return Qg(e)}let Ri=class extends Error{constructor(t){var n;super(t??"operation not supported"),this.name=this.constructor.name,(n=Error.captureStackTrace)===null||n===void 0||n.call(Error,this,this.constructor)}},fA=class extends Error{constructor(t){var n;super(t),this.name=this.constructor.name,(n=Error.captureStackTrace)===null||n===void 0||n.call(Error,this,this.constructor)}};function gA(e){switch(e.algorithm.name){case"RSA-PSS":return function(t){if(t.algorithm.hash.name==="SHA-256")return"PS256";throw new Ri("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(t){if(t.algorithm.hash.name==="SHA-256")return"RS256";throw new Ri("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(t){if(t.algorithm.namedCurve==="P-256")return"ES256";throw new Ri("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return"Ed25519";default:throw new Ri("unsupported CryptoKey algorithm name")}}function b1(e){return e instanceof CryptoKey}function w1(e){return b1(e)&&e.type==="public"}async function vA(e,t,n,a,r,i){const o=e==null?void 0:e.privateKey,l=e==null?void 0:e.publicKey;if(!b1(c=o)||c.type!=="private")throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!w1(l))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(l.extractable!==!0)throw new TypeError('"keypair.publicKey.extractable" must be true');if(typeof t!="string")throw new TypeError('"htu" must be a string');if(typeof n!="string")throw new TypeError('"htm" must be a string');if(a!==void 0&&typeof a!="string")throw new TypeError('"nonce" must be a string or undefined');if(r!==void 0&&typeof r!="string")throw new TypeError('"accessToken" must be a string or undefined');return mA({alg:gA(o),typ:"dpop+jwt",jwk:await S1(l)},Object.assign(Object.assign({},i),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:a,htu:t,ath:r?Lc(await crypto.subtle.digest("SHA-256",Oc(r))):void 0}),o)}async function S1(e){const{kty:t,e:n,n:a,x:r,y:i,crv:o}=await crypto.subtle.exportKey("jwk",e);return{kty:t,crv:o,e:n,n:a,x:r,y:i}}const N1="dpop-nonce",yA=["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:token-exchange","urn:okta:params:oauth:grant-type:webauthn","http://auth0.com/oauth/grant-type/mfa-oob","http://auth0.com/oauth/grant-type/mfa-otp","http://auth0.com/oauth/grant-type/mfa-recovery-code"];function xA(){return async function(e,t){var n;let a;if(e.length===0)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":a={name:"RSA-PSS",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":a={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":a={name:"ECDSA",namedCurve:"P-256"};break;case"Ed25519":a={name:"Ed25519"};break;default:throw new Ri}return crypto.subtle.generateKey(a,(n=t==null?void 0:t.extractable)!==null&&n!==void 0&&n,["sign","verify"])}("ES256",{extractable:!1})}function jA(e){return async function(t){if(!w1(t))throw new TypeError('"publicKey" must be a public CryptoKey');if(t.extractable!==!0)throw new TypeError('"publicKey.extractable" must be true');const n=await S1(t);let a;switch(n.kty){case"EC":a={crv:n.crv,kty:n.kty,x:n.x,y:n.y};break;case"OKP":a={crv:n.crv,kty:n.kty,x:n.x};break;case"RSA":a={e:n.e,kty:n.kty,n:n.n};break;default:throw new Ri("unsupported JWK kty")}return Lc(await crypto.subtle.digest({name:"SHA-256"},Oc(JSON.stringify(a))))}(e.publicKey)}function bA(e){let t=e.keyPair,n=e.url,a=e.method,r=e.nonce,i=e.accessToken;const o=function(l){const c=new URL(l);return c.search="",c.hash="",c.href}(n);return vA(t,o,a,r,i)}const ev=(e,t)=>new Promise(function(n,a){const r=new MessageChannel;r.port1.onmessage=function(i){i.data.error?a(new Error(i.data.error)):n(i.data),r.port1.close()},t.postMessage(e,[r.port2])}),k1=(e,t,n)=>{const a=new AbortController;let r;return t.signal=a.signal,Promise.race([fetch(e,t),new Promise((i,o)=>{r=setTimeout(()=>{a.abort(),o(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(r)})},wA=async function(e,t,n,a,r,i){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Kg;return r?(async(l,c,u,d,h,g,v,f,y,b)=>ev({type:"refresh",auth:{audience:c,scope:u},timeout:h,fetchUrl:l,fetchOptions:d,useFormData:v,useMrrt:f,skipTokenStorage:y,preserveRefreshToken:b},g))(e,t,n,a,o,r,i,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0,arguments.length>9?arguments[9]:void 0):(async(l,c,u)=>{const d=await k1(l,c,u);return{ok:d.ok,json:await d.json(),headers:(h=d.headers,[...h].reduce((g,v)=>{let f=kn(v,2),y=f[0],b=f[1];return g[y]=b,g},{}))};var h})(e,a,o)};async function E1(e,t,n,a,r,i,o,l,c,u,d,h){if(c){const C=await c.generateProof({url:e,method:r.method||"GET",nonce:await c.getNonce()});r.headers=Object.assign(Object.assign({},r.headers),{dpop:C})}let g,v=null;for(let C=0;C<3;C++)try{g=await wA(e,n,a,r,i,o,t,l,d,h),v=null;break}catch(k){v=k}if(v)throw v;const f=g.json,y=f.error,b=f.error_description,m=Qs(f,["error","error_description"]),x=g,j=x.headers,S=x.ok;let w;if(c&&(w=j[N1],w&&await c.setNonce(w)),!S){const C=b||"HTTP error. Unable to fetch ".concat(e);if(y==="mfa_required")throw new Zg(y,C,m.mfa_token,m.mfa_requirements);if(y==="missing_refresh_token")throw new f1(n,a);if(y==="use_dpop_nonce"){if(!c||!w||u)throw new y1(w);return E1(e,t,n,a,r,i,o,l,c,!0,d,h)}throw new Ct(y||"request_error",C)}return m}async function Lb(e,t,n){var a=e.baseUrl,r=e.timeout,i=e.audience,o=e.scope,l=e.auth0Client,c=e.useFormData,u=e.useMrrt,d=e.dpop,h=e.preserveRefreshToken,g=Qs(e,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop","preserveRefreshToken"]);const v=g.grant_type==="urn:ietf:params:oauth:grant-type:token-exchange",f=g.grant_type==="urn:okta:params:oauth:grant-type:webauthn",y=g.grant_type==="refresh_token"&&u,b=v||f||y,m=Object.assign(Object.assign(Object.assign({},g),b&&i&&{audience:i}),b&&o&&{scope:o}),x=f||!c,j=x?JSON.stringify(m):vc(m),S=(w=g.grant_type,yA.includes(w));var w;return await E1("".concat(a,"/oauth/token"),r,i||bs,o,{method:"POST",body:j,headers:{"Content-Type":x?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(Xg(l||Jg)))}},t,c,u,S?d:void 0,void 0,n,h)}const lh=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(a=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(a))).join(" ");var a},Fl=(e,t,n)=>{let a;return n&&(a=e[n]),a||(a=e[bs]),lh(a,t)},Ii="@@auth0spajs@@",yi="@@user@@";let mn=class tv{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ii,a=arguments.length>2?arguments[2]:void 0;this.prefix=n,this.suffix=a,this.clientId=t.clientId,this.scope=t.scope,this.audience=t.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(t){const n=kn(t.split("::"),4),a=n[0],r=n[1],i=n[2],o=n[3];return new tv({clientId:r,scope:o,audience:i},a)}static fromCacheEntry(t){const n=t.scope,a=t.audience,r=t.client_id;return new tv({scope:n,audience:a,clientId:r})}},SA=class{set(t,n){localStorage.setItem(t,JSON.stringify(n))}get(t){const n=window.localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch{return}}remove(t){localStorage.removeItem(t)}allKeys(){return Object.keys(window.localStorage).filter(t=>t.startsWith(Ii))}},_1=class{constructor(){this.enclosedCache=function(){let t={};return{set(n,a){t[n]=a},get(n){const a=t[n];if(a)return a},remove(n){delete t[n]},allKeys:()=>Object.keys(t)}}()}},NA=class{constructor(t,n,a){this.cache=t,this.keyManifest=n,this.nowProvider=a||i1}async setIdToken(t,n,a){var r;const i=this.getIdTokenCacheKey(t);await this.cache.set(i,{id_token:n,decodedToken:a}),await((r=this.keyManifest)===null||r===void 0?void 0:r.add(i))}async getIdToken(t){const n=await this.cache.get(this.getIdTokenCacheKey(t.clientId));if(!n&&t.scope&&t.audience){const a=await this.get(t);return!a||!a.id_token||!a.decodedToken?void 0:{id_token:a.id_token,decodedToken:a.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0;var i;let o=await this.cache.get(t.toKey()),l=t;if(!o){const d=await this.getCacheKeys();if(!d)return;const h=this.matchExistingCacheKey(t,d);if(h&&(o=await this.cache.get(h),l=mn.fromKey(h)),!o&&a&&r!=="cache-only")return this.getEntryWithRefreshToken(t,d)}if(!o)return;const c=await this.nowProvider(),u=Math.floor(c/1e3);return o.expiresAt-n<u?o.body.refresh_token?this.modifiedCachedEntry(o,l):(await this.cache.remove(l.toKey()),void await((i=this.keyManifest)===null||i===void 0?void 0:i.remove(l.toKey()))):o.body}async modifiedCachedEntry(t,n){const a={refresh_token:t.body.refresh_token,audience:t.body.audience,scope:t.body.scope},r={body:a,expiresAt:t.expiresAt};return await this.cache.set(n.toKey(),r),{refresh_token:a.refresh_token,audience:a.audience,scope:a.scope}}async set(t){var n;const a=new mn({clientId:t.client_id,scope:t.scope,audience:t.audience}),r=await this.wrapCacheEntry(t);await this.cache.set(a.toKey(),r),await((n=this.keyManifest)===null||n===void 0?void 0:n.add(a.toKey()))}async remove(t,n,a){const r=new mn({clientId:t,scope:a,audience:n});await this.cache.remove(r.toKey())}async stripRefreshToken(t){var n;const a=await this.getCacheKeys();if(a)for(const r of a){const i=await this.cache.get(r);((n=i==null?void 0:i.body)===null||n===void 0?void 0:n.refresh_token)===t&&(delete i.body.refresh_token,await this.cache.set(r,i))}}async clear(t){var n;const a=await this.getCacheKeys();a&&(await a.filter(r=>!t||r.includes(t)).reduce(async(r,i)=>{await r,await this.cache.remove(i)},Promise.resolve()),await((n=this.keyManifest)===null||n===void 0?void 0:n.clear()))}async wrapCacheEntry(t){const n=await this.nowProvider();return{body:t,expiresAt:Math.floor(n/1e3)+t.expires_in}}async getCacheKeys(){var t;return this.keyManifest?(t=await this.keyManifest.get())===null||t===void 0?void 0:t.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(t){return new mn({clientId:t},Ii,yi).toKey()}matchExistingCacheKey(t,n){return n.filter(a=>{var r;const i=mn.fromKey(a),o=new Set(i.scope&&i.scope.split(" ")),l=((r=t.scope)===null||r===void 0?void 0:r.split(" "))||[],c=i.scope&&l.reduce((u,d)=>u&&o.has(d),!0);return i.prefix===Ii&&i.clientId===t.clientId&&i.audience===t.audience&&c})[0]}async getEntryWithRefreshToken(t,n){var a;for(const r of n){const i=mn.fromKey(r);if(i.prefix===Ii&&i.clientId===t.clientId){const o=await this.cache.get(r);if(!((a=o==null?void 0:o.body)===null||a===void 0)&&a.refresh_token)return{refresh_token:o.body.refresh_token,audience:o.body.audience,scope:o.body.scope}}}}async getRefreshTokensByAudience(t,n){var a;const r=await this.getCacheKeys();if(!r)return[];const i=new Set;for(const o of r){const l=mn.fromKey(o);if(l.prefix===Ii&&l.clientId===n&&l.audience===t){const c=await this.cache.get(o);!((a=c==null?void 0:c.body)===null||a===void 0)&&a.refresh_token&&i.add(c.body.refresh_token)}}return Array.from(i)}async updateEntry(t,n){var a;const r=await this.getCacheKeys();if(r)for(const i of r){const o=await this.cache.get(i);((a=o==null?void 0:o.body)===null||a===void 0?void 0:a.refresh_token)===t&&(o.body.refresh_token=n,await this.cache.set(i,o))}}},kA=class{constructor(t,n,a){this.storage=t,this.clientId=n,this.cookieDomain=a,this.storageKey="".concat("a0.spajs.txs",".").concat(this.clientId)}create(t){this.storage.save(this.storageKey,t,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}};const Gl=e=>typeof e=="number",EA=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],_A=e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(i=>{const o=i.split("."),l=kn(o,3),c=l[0],u=l[1],d=l[2];if(o.length!==3||!c||!u||!d)throw new Error("ID token could not be decoded");const h=JSON.parse(Pb(u)),g={__raw:i},v={};return Object.keys(h).forEach(f=>{g[f]=h[f],EA.includes(f)||(v[f]=h[f])}),{encoded:{header:c,payload:u,signature:d},header:JSON.parse(Pb(c)),claims:g,user:v}})(e.id_token);if(!t.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(t.claims.iss!==e.iss)throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(t.header.alg!=="RS256")throw new Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||typeof t.claims.aud!="string"&&!Array.isArray(t.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but was not one of "').concat(t.claims.aud.join(", "),'"'));if(t.claims.aud.length>1){if(!t.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(t.claims.azp!==e.aud)throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(t.claims.aud,'"'));if(e.nonce){if(!t.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(t.claims.nonce!==e.nonce)throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!Gl(t.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(t.claims.exp==null||!Gl(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Gl(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=e.leeway||60,a=new Date(e.now||Date.now()),r=new Date(0);if(r.setUTCSeconds(t.claims.exp+n),a>r)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(a,") is after expiration time (").concat(r,")"));if(t.claims.nbf!=null&&Gl(t.claims.nbf)){const i=new Date(0);if(i.setUTCSeconds(t.claims.nbf-n),a<i)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(a,") is before ").concat(i))}if(t.claims.auth_time!=null&&Gl(t.claims.auth_time)){const i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),a>i)throw new Error("Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (".concat(a,") is after last auth at ").concat(i))}if(e.organization){const i=e.organization.trim();if(i.startsWith("org_")){const o=i;if(!t.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(o!==t.claims.org_id)throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(o,'", found "').concat(t.claims.org_id,'"'))}else{const o=i.toLowerCase();if(!t.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(o!==t.claims.org_name)throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(o,'", found "').concat(t.claims.org_name,'"'))}}return t};var vd=qi&&qi.__assign||function(){return vd=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},vd.apply(this,arguments)};function Wl(e,t){if(!t)return"";var n="; "+e;return t===!0?n:n+"="+t}function CA(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(a){if(typeof a.expires=="number"){var r=new Date;r.setMilliseconds(r.getMilliseconds()+864e5*a.expires),a.expires=r}return Wl("Expires",a.expires?a.expires.toUTCString():"")+Wl("Domain",a.domain)+Wl("Path",a.path)+Wl("Secure",a.secure)+Wl("SameSite",a.sameSite)}(n)}function TA(){return function(e){for(var t={},n=e?e.split("; "):[],a=/(%[\dA-F]{2})+/gi,r=0;r<n.length;r++){var i=n[r].split("="),o=i.slice(1).join("=");o.charAt(0)==='"'&&(o=o.slice(1,-1));try{t[i[0].replace(a,decodeURIComponent)]=o.replace(a,decodeURIComponent)}catch{}}return t}(document.cookie)}var RA=function(e){return TA()[e]};function C1(e,t,n){document.cookie=CA(e,t,vd({path:"/"},n))}var T1=C1,R1=function(e,t){C1(e,"",vd(vd({},t),{expires:-1}))};const yo={get(e){const t=RA(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let a={};window.location.protocol==="https:"&&(a={secure:!0,sameSite:"none"}),n!=null&&n.daysUntilExpire&&(a.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(a.domain=n.cookieDomain),T1(e,JSON.stringify(t),a)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),R1(e,n)}},Pm="_legacy_",IA={get(e){return yo.get(e)||yo.get("".concat(Pm).concat(e))},save(e,t,n){let a={};window.location.protocol==="https:"&&(a={secure:!0}),n!=null&&n.daysUntilExpire&&(a.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(a.domain=n.cookieDomain),T1("".concat(Pm).concat(e),JSON.stringify(t),a),yo.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),R1(e,n),yo.remove(e,t),yo.remove("".concat(Pm).concat(e),t)}},AA={get(e){if(typeof sessionStorage>"u")return;const t=sessionStorage.getItem(e);return t!=null?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}};var Ei;(function(e){e.Code="code",e.ConnectCode="connect_code"})(Ei||(Ei={}));function PA(e,t,n){var a=t===void 0?null:t,r=function(c,u){var d=atob(c);if(u){for(var h=new Uint8Array(d.length),g=0,v=d.length;g<v;++g)h[g]=d.charCodeAt(g);return String.fromCharCode.apply(null,new Uint16Array(h.buffer))}return d}(e,n!==void 0&&n),i=r.indexOf(`
|
|
42
|
-
`,10)+1,o=r.substring(i)+(a?"//# sourceMappingURL="+a:""),l=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(l)}var Mb,Db,zb,$m,$A=(Mb="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxpLGE9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihhLnB1c2goby52YWx1ZSksYS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoaT1yLnJldHVybigpLE9iamVjdChpKSE9PWkpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGF9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGk9e30sYT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PWU9PntPYmplY3QuZW50cmllcyhpKS5mb3JFYWNoKHI9PntsZXQgbz10KHIsMiksbj1vWzBdO29bMV09PT1lJiZkZWxldGUgaVtuXX0pfSxmPWU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKChlLHQpPT57clt0XT1lfSkscn0saD1hc3luYyBlPT57bGV0IHIsbixhPWUuZGF0YSx1PWEudGltZW91dCxoPWEuYXV0aCxkPWEuZmV0Y2hVcmwscD1hLmZldGNoT3B0aW9ucyx5PWEudXNlRm9ybURhdGEsZz1hLnVzZU1ycnQsYj1hLnNraXBUb2tlblN0b3JhZ2UsTz1hLnByZXNlcnZlUmVmcmVzaFRva2VuLGs9dChlLnBvcnRzLDEpWzBdLG09e307Y29uc3Qgaj1ofHx7fSx2PWouYXVkaWVuY2UsXz1qLnNjb3BlO3RyeXtjb25zdCBlPXk/ZihwLmJvZHkpOkpTT04ucGFyc2UocC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKG49KChlLHQpPT5pW2MoZSx0KV0pKHYsXyksIW4mJmcpe2NvbnN0IGU9aS5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+ISFPYmplY3Qua2V5cyhpKS5maW5kKHI9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09cil7Y29uc3Qgbz1sKHQsciksbj1yLnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKSxzPWUuc3BsaXQoIiAiKS5ldmVyeShlPT5uLmluY2x1ZGVzKGUpKTtyZXR1cm4gbyYmc319KSkoXyx2KTtlJiYhdCYmKG49ZSl9aWYoIW4pdGhyb3cgbmV3IG8odixfKTtwLmJvZHk9eT9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpfWxldCBhLGg7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixwLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2g9YXdhaXQgUHJvbWlzZS5yYWNlKFsoVT11LG5ldyBQcm9taXNlKGU9PnNldFRpbWVvdXQoZSxVKSkpLGZldGNoKGQsT2JqZWN0LmFzc2lnbih7fSxwKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBrLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighaClyZXR1cm4gYSYmYS5hYm9ydCgpLHZvaWQgay5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZihNPWguaGVhZGVycyxtPVsuLi5NXS5yZWR1Y2UoKGUscik9PntsZXQgbz10KHIsMiksbj1vWzBdLHM9b1sxXTtyZXR1cm4gZVtuXT1zLGV9LHt9KSxyPWF3YWl0IGguanNvbigpLGIpcmV0dXJuIGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4sdm9pZCBrLnBvc3RNZXNzYWdlKHtvazpoLm9rLGpzb246cixoZWFkZXJzOm19KTtyLnJlZnJlc2hfdG9rZW4/KGcmJihpLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbix3PW4sUz1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMoaSkuZm9yRWFjaChlPT57bGV0IHI9dChlLDIpLG89clswXTtyWzFdPT09dyYmKGlbb109Uyl9KSksKChlLHQscik9PntpW2ModCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbix2LF8pLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOk98fCgoZSx0KT0+e2RlbGV0ZSBpW2MoZSx0KV19KSh2LF8pLGsucG9zdE1lc3NhZ2Uoe29rOmgub2ssanNvbjpyLGhlYWRlcnM6bX0pfWNhdGNoKGUpe2sucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOm19KX12YXIgdyxTLE0sVX0sZD1hc3luYyBlPT57bGV0IHI9ZS5kYXRhLG89ci50aW1lb3V0LG49ci5hdXRoLGE9ci5mZXRjaFVybCxjPXIuZmV0Y2hPcHRpb25zLGg9ci51c2VGb3JtRGF0YSxkPXQoZS5wb3J0cywxKVswXTtjb25zdCBwPShufHx7fSkuYXVkaWVuY2U7dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCByPW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKGkpLmZvckVhY2gobz0+e2xldCBuPXQobywyKSxzPW5bMF0saT1uWzFdO2woZSxzKSYmci5hZGQoaSl9KSxBcnJheS5mcm9tKHIpfSkocCk7aWYoMD09PWUubGVuZ3RoKXJldHVybiB2b2lkIGQucG9zdE1lc3NhZ2Uoe29rOiEwfSk7Y29uc3Qgcj1oP2YoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7Zm9yKGNvbnN0IHQgb2YgZSl7Y29uc3QgZT1oP3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7dG9rZW46dH0pKTtsZXQgbixpLGwsZjsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYobj1uZXcgQWJvcnRDb250cm9sbGVyLGk9bi5zaWduYWwpO3RyeXtmPWF3YWl0IFByb21pc2UucmFjZShbbmV3IFByb21pc2UoZT0+e2w9c2V0VGltZW91dChlLG8pfSksZmV0Y2goYSxPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sYykse2JvZHk6ZSxzaWduYWw6aX0pKV0pLmZpbmFsbHkoKCk9PmNsZWFyVGltZW91dChsKSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIWYpcmV0dXJuIG4mJm4uYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7aWYoIWYub2spe2xldCBlO3RyeXtjb25zdCB0PUpTT04ucGFyc2UoYXdhaXQgZi50ZXh0KCkpO2U9dC5lcnJvcl9kZXNjcmlwdGlvbn1jYXRjaChlKXt9cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoZi5zdGF0dXMpfSl9dSh0KX1kLnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe2QucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSxwPShlLHQpPT57aWYoIWEpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChhKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0IHI9ZS5kYXRhLG89dChlLnBvcnRzLDEpWzBdO2lmKCEoInR5cGUiaW4gcil8fCJpbml0IiE9PXIudHlwZSlyZXR1cm4idHlwZSJpbiByJiYiY2xlYXIiPT09ci50eXBlPyhpPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHImJiJyZXZva2UiPT09ci50eXBlP3AociwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgZChlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHImJnAociwiL29hdXRoL3Rva2VuIik/aChlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09YSl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxhPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK",Db=null,zb=!1,function(e){return $m=$m||PA(Mb,Db,zb),new Worker($m,e)});const Om={};let OA=class{constructor(t,n){this.cache=t,this.clientId=n,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var n;const a=new Set(((n=await this.cache.get(this.manifestKey))===null||n===void 0?void 0:n.keys)||[]);a.add(t),await this.cache.set(this.manifestKey,{keys:[...a]})}async remove(t){const n=await this.cache.get(this.manifestKey);if(n){const a=new Set(n.keys);return a.delete(t),a.size>0?await this.cache.set(this.manifestKey,{keys:[...a]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(t){return"".concat(Ii,"::").concat(t)}};const Ub="auth0.is.authenticated",LA={memory:()=>new _1().enclosedCache,localstorage:()=>new SA},Fb=e=>LA[e],Gb=e=>{const t=e.openUrl,n=e.onRedirect,a=Qs(e,["openUrl","onRedirect"]);return Object.assign(Object.assign({},a),{openUrl:t===!1||t?t:n})},MA=(e,t,n)=>{const a=(e==null?void 0:e.split(" "))||[],r=n?a.filter(o=>o!==r1):a,i=(t==null?void 0:t.split(" "))||[];return r.filter(o=>i.indexOf(o)==-1).join(",")},li={NONCE:"nonce",KEYPAIR:"keypair"};let DA=class{constructor(t){this.clientId=t}getVersion(){return 1}createDbHandle(){const t=window.indexedDB.open("auth0-spa-js",this.getVersion());return new Promise((n,a)=>{t.onupgradeneeded=()=>Object.values(li).forEach(r=>t.result.createObjectStore(r)),t.onerror=()=>a(t.error),t.onsuccess=()=>n(t.result)})}async getDbHandle(){return this.dbHandle||(this.dbHandle=await this.createDbHandle()),this.dbHandle}async executeDbRequest(t,n,a){const r=a((await this.getDbHandle()).transaction(t,n).objectStore(t));return new Promise((i,o)=>{r.onsuccess=()=>i(r.result),r.onerror=()=>o(r.error)})}buildKey(t){const n=t?"_".concat(t):"auth0";return"".concat(this.clientId,"::").concat(n)}setNonce(t,n){return this.save(li.NONCE,this.buildKey(n),t)}setKeyPair(t){return this.save(li.KEYPAIR,this.buildKey(),t)}async save(t,n,a){await this.executeDbRequest(t,"readwrite",r=>r.put(a,n))}findNonce(t){return this.find(li.NONCE,this.buildKey(t))}findKeyPair(){return this.find(li.KEYPAIR,this.buildKey())}find(t,n){return this.executeDbRequest(t,"readonly",a=>a.get(n))}async deleteBy(t,n){const a=await this.executeDbRequest(t,"readonly",r=>r.getAllKeys());await Promise.all((a==null?void 0:a.filter(n).map(r=>this.executeDbRequest(t,"readwrite",i=>i.delete(r))))||[])}deleteByClientId(t,n){return this.deleteBy(t,a=>typeof a=="string"&&a.startsWith("".concat(n,"::")))}clearNonces(){return this.deleteByClientId(li.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(li.KEYPAIR,this.clientId)}},zA=class{constructor(t){this.storage=new DA(t)}getNonce(t){return this.storage.findNonce(t)}setNonce(t,n){return this.storage.setNonce(t,n)}async getOrGenerateKeyPair(){let t=await this.storage.findKeyPair();return t||(t=await xA(),await this.storage.setKeyPair(t)),t}async generateProof(t){const n=await this.getOrGenerateKeyPair();return bA(Object.assign({keyPair:n},t))}async calculateThumbprint(){return jA(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}};var Oo;(function(e){e.Bearer="Bearer",e.DPoP="DPoP"})(Oo||(Oo={}));let UA=class{constructor(t,n){this.hooks=n,this.config=Object.assign(Object.assign({},t),{fetch:t.fetch||(typeof window>"u"?fetch:window.fetch.bind(window))})}isAbsoluteUrl(t){return/^(https?:)?\/\//i.test(t)}buildUrl(t,n){if(n){if(this.isAbsoluteUrl(n))return n;if(t)return"".concat(t.replace(/\/?\/$/,""),"/").concat(n.replace(/^\/+/,""))}throw new TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(t){return this.config.getAccessToken?this.config.getAccessToken(t):this.hooks.getAccessToken(t)}extractUrl(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url}buildBaseRequest(t,n){if(!this.config.baseUrl)return new Request(t,n);const a=this.buildUrl(this.config.baseUrl,this.extractUrl(t)),r=t instanceof Request?new Request(a,t):a;return new Request(r,n)}setAuthorizationHeader(t,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Oo.Bearer;t.headers.set("authorization","".concat(a," ").concat(n))}async setDpopProofHeader(t,n){if(!this.config.dpopNonceId)return;const a=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:n,method:t.method,nonce:a,url:t.url});t.headers.set("dpop",r)}async prepareRequest(t,n){const a=await this.getAccessToken(n);let r,i;typeof a=="string"?(r=this.config.dpopNonceId?Oo.DPoP:Oo.Bearer,i=a):(r=a.token_type,i=a.access_token),this.setAuthorizationHeader(t,i,r),r===Oo.DPoP&&await this.setDpopProofHeader(t,i)}getHeader(t,n){return Array.isArray(t)?new Headers(t).get(n)||"":typeof t.get=="function"?t.get(n)||"":t[n]||""}hasUseDpopNonceError(t){if(t.status!==401)return!1;const n=this.getHeader(t.headers,"www-authenticate");return n.includes("invalid_dpop_nonce")||n.includes("use_dpop_nonce")}async handleResponse(t,n){const a=this.getHeader(t.headers,N1);if(a&&await this.hooks.setDpopNonce(a),!this.hasUseDpopNonceError(t))return t;if(!a||!n.onUseDpopNonceError)throw new y1(a);return n.onUseDpopNonceError()}async internalFetchWithAuth(t,n,a,r){const i=this.buildBaseRequest(t,n);await this.prepareRequest(i,r);const o=await this.config.fetch(i);return this.handleResponse(o,a)}fetchWithAuth(t,n,a){const r={onUseDpopNonceError:()=>this.internalFetchWithAuth(t,n,Object.assign(Object.assign({},r),{onUseDpopNonceError:void 0}),a)};return this.internalFetchWithAuth(t,n,r,a)}},FA=class{constructor(t,n){this.myAccountFetcher=t,this.apiBase=n}async connectAccount(t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["create:me:connected_accounts"]});return this._handleResponse(n)}async completeAccount(t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/complete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["create:me:connected_accounts"]});return this._handleResponse(n)}async getFactors(){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return(await this._handleResponse(t)).factors}async getAuthenticationMethods(t){const n=t?"?".concat(new URLSearchParams({type:t})):"",a=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(n),{method:"GET"},{scope:["read:me:authentication_methods"]});return(await this._handleResponse(a)).authentication_methods}async getAuthenticationMethod(t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(t)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(n)}async deleteAuthenticationMethod(t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(t)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});n.ok||await this._handleResponse(n)}async updateAuthenticationMethod(t,n){const a=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},{scope:["update:me:authentication_methods"]});return this._handleResponse(a)}async enrollmentChallenge(t){var n;const a=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["create:me:authentication_methods"]}),r=await this._handleResponse(a),i=(n=a.headers.get("location"))!==null&&n!==void 0?n:"",o=decodeURIComponent(i.split("/").pop()||"");return Object.assign(Object.assign({},r),{id:o,location:i})}async enrollmentVerify(t){const n=t,a=n.location;n.type;const r=Qs(n,["location","type"]),i=await this.myAccountFetcher.fetchWithAuth("".concat(a,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},{scope:["create:me:authentication_methods"]});return this._handleResponse(i)}async _handleResponse(t){let n;try{n=await t.text(),n=JSON.parse(n)}catch(a){throw new Wb({type:"invalid_json",status:t.status,title:"Invalid JSON response",detail:n||String(a)})}if(t.ok)return n;throw new Wb(n)}},Wb=class I1 extends Error{constructor(t){let n=t.type,a=t.status,r=t.title,i=t.detail,o=t.validation_errors;super(i),this.name="MyAccountApiError",this.type=n,this.status=a,this.title=r,this.detail=i,this.validation_errors=o,Object.setPrototypeOf(this,I1.prototype)}};const GA={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}},WA="http://auth0.com/oauth/grant-type/mfa-otp",HA="http://auth0.com/oauth/grant-type/mfa-oob",BA="http://auth0.com/oauth/grant-type/mfa-recovery-code";var lu,Lm;let sv;(typeof navigator>"u"||(lu=navigator.userAgent)===null||lu===void 0||(Lm=lu.startsWith)===null||Lm===void 0||!Lm.call(lu,"Mozilla/5.0 "))&&(sv="".concat("oauth4webapi","/").concat("v3.8.6"));function Zi(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}const Os="ERR_INVALID_ARG_VALUE",Bs="ERR_INVALID_ARG_TYPE";function Nt(e,t,n){const a=new TypeError(e,{cause:n});return Object.assign(a,{code:t}),a}const ln=Symbol(),nv=Symbol(),av=Symbol(),Bn=Symbol(),dr=Symbol(),VA=new TextEncoder,qA=new TextDecoder;function Ko(e){return typeof e=="string"?VA.encode(e):qA.decode(e)}let rv,A1;Uint8Array.prototype.toBase64?rv=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):rv=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let a=0;a<t.byteLength;a+=32768)n.push(String.fromCharCode.apply(null,t.subarray(a,a+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};function Mi(e){return typeof e=="string"?A1(e):rv(e)}A1=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(t){throw Nt("The input to be decoded is not correctly encoded.",Os,t)}}:e=>{try{const t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}catch(t){throw Nt("The input to be decoded is not correctly encoded.",Os,t)}};let bn=class extends Error{constructor(t,n){var a;super(t,n),Pe(this,"code",void 0),this.name=this.constructor.name,this.code=lv,(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}},ix=class extends Error{constructor(t,n){var a;super(t,n),Pe(this,"code",void 0),this.name=this.constructor.name,n!=null&&n.code&&(this.code=n==null?void 0:n.code),(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}};function nt(e,t,n){return new ix(e,{code:t,cause:n})}function KA(e,t){if(function(n,a){if(!(n instanceof CryptoKey))throw Nt("".concat(a," must be a CryptoKey"),Bs)}(e,t),e.type!=="private")throw Nt("".concat(t," must be a private CryptoKey"),Os)}function Zh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ad(e){Zi(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(e??{});if(sv&&!t.has("user-agent")&&t.set("user-agent",sv),t.has("authorization"))throw Nt('"options.headers" must not include the "authorization" header name',Os);return t}function P1(e,t){if(t!==void 0){if(typeof t=="function"&&(t=t(e.href)),!(t instanceof AbortSignal))throw Nt('"options.signal" must return or be an instance of AbortSignal',Bs);return t}}function Hb(e){return e.includes("//")?e.replace("//","/"):e}async function JA(e,t){return async function(n,a,r,i){if(!(n instanceof URL))throw Nt('"'.concat(a,'" must be an instance of URL'),Bs);ox(n,(i==null?void 0:i[ln])!==!0);const o=r(new URL(n.href)),l=Ad(i==null?void 0:i.headers);return l.set("accept","application/json"),((i==null?void 0:i[Bn])||fetch)(o.href,{body:void 0,headers:Object.fromEntries(l.entries()),method:"GET",redirect:"manual",signal:P1(o,i==null?void 0:i.signal)})}(e,"issuerIdentifier",n=>{switch(t==null?void 0:t.algorithm){case void 0:case"oidc":(function(a,r){a.pathname=Hb("".concat(a.pathname,"/").concat(r))})(n,".well-known/openid-configuration");break;case"oauth2":(function(a,r){let i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];a.pathname==="/"?a.pathname=r:a.pathname=Hb("".concat(r,"/").concat(i?a.pathname:a.pathname.replace(/(\/)$/,"")))})(n,".well-known/oauth-authorization-server");break;default:throw Nt('"options.algorithm" must be "oidc" (default), or "oauth2"',Os)}return n},t)}function Kr(e,t,n,a,r){try{if(typeof e!="number"||!Number.isFinite(e))throw Nt("".concat(n," must be a number"),Bs,r);if(e>0)return;if(t){if(e!==0)throw Nt("".concat(n," must be a non-negative number"),Os,r);return}throw Nt("".concat(n," must be a positive number"),Os,r)}catch(i){throw a?nt(i.message,a,r):i}}function as(e,t,n,a){try{if(typeof e!="string")throw Nt("".concat(t," must be a string"),Bs,a);if(e.length===0)throw Nt("".concat(t," must not be empty"),Os,a)}catch(r){throw n?nt(r.message,n,a):r}}function $1(e){(function(t,n){if(D1(t)!==n)throw function(a){let r='"response" content-type must be ';for(var i=arguments.length,o=new Array(i>1?i-1:0),l=1;l<i;l++)o[l-1]=arguments[l];if(o.length>2){const c=o.pop();r+="".concat(o.join(", "),", or ").concat(c)}else o.length===2?r+="".concat(o[0]," or ").concat(o[1]):r+=o[0];return nt(r,U1,a)}(t,n)})(e,"application/json")}function O1(){return Mi(crypto.getRandomValues(new Uint8Array(32)))}function YA(e){switch(e.algorithm.name){case"RSA-PSS":return function(t){switch(t.algorithm.hash.name){case"SHA-256":return"PS256";case"SHA-384":return"PS384";case"SHA-512":return"PS512";default:throw new bn("unsupported RsaHashedKeyAlgorithm hash name",{cause:t})}}(e);case"RSASSA-PKCS1-v1_5":return function(t){switch(t.algorithm.hash.name){case"SHA-256":return"RS256";case"SHA-384":return"RS384";case"SHA-512":return"RS512";default:throw new bn("unsupported RsaHashedKeyAlgorithm hash name",{cause:t})}}(e);case"ECDSA":return function(t){switch(t.algorithm.namedCurve){case"P-256":return"ES256";case"P-384":return"ES384";case"P-521":return"ES512";default:throw new bn("unsupported EcKeyAlgorithm namedCurve",{cause:t})}}(e);case"Ed25519":case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return e.algorithm.name;case"EdDSA":return"Ed25519";default:throw new bn("unsupported CryptoKey algorithm name",{cause:e})}}function Xh(e){const t=e==null?void 0:e[nv];return typeof t=="number"&&Number.isFinite(t)?t:0}function iv(e){const t=e==null?void 0:e[av];return typeof t=="number"&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function Qh(){return Math.floor(Date.now()/1e3)}function Wn(e){if(typeof e!="object"||e===null)throw Nt('"as" must be an object',Bs);as(e.issuer,'"as.issuer"')}function Hn(e){if(typeof e!="object"||e===null)throw Nt('"client" must be an object',Bs);as(e.client_id,'"client.client_id"')}function Bb(e){return as(e,'"clientSecret"'),(t,n,a,r)=>{a.set("client_id",n.client_id),a.set("client_secret",e)}}function ZA(e,t){const n=(i=e)instanceof CryptoKey?{key:i}:(i==null?void 0:i.key)instanceof CryptoKey?(i.kid!==void 0&&as(i.kid,'"kid"'),{key:i.key,kid:i.kid}):{},a=n.key,r=n.kid;var i;return KA(a,'"clientPrivateKey.key"'),async(o,l,c,u)=>{const d={alg:YA(a),kid:r},h=function(g,v){const f=Qh()+Xh(v);return{jti:O1(),aud:g.issuer,exp:f+60,iat:f,nbf:f,iss:v.client_id,sub:v.client_id}}(o,l);c.set("client_id",l.client_id),c.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),c.set("client_assertion",await async function(g,v,f){if(!f.usages.includes("sign"))throw Nt('CryptoKey instances used for signing assertions must include "sign" in their "usages"',Os);const y="".concat(Mi(Ko(JSON.stringify(g))),".").concat(Mi(Ko(JSON.stringify(v)))),b=Mi(await crypto.subtle.sign(function(m){switch(m.algorithm.name){case"ECDSA":return{name:m.algorithm.name,hash:vP(m)};case"RSA-PSS":switch(Kb(m),m.algorithm.hash.name){case"SHA-256":case"SHA-384":case"SHA-512":return{name:m.algorithm.name,saltLength:parseInt(m.algorithm.hash.name.slice(-3),10)>>3};default:throw new bn("unsupported RSA-PSS hash name",{cause:m})}case"RSASSA-PKCS1-v1_5":return Kb(m),m.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return m.algorithm.name}throw new bn("unsupported CryptoKey algorithm name",{cause:m})}(f),f,Ko(y)));return"".concat(y,".").concat(b)}(d,h,a))}}const XA=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function ox(e,t){if(t&&e.protocol!=="https:")throw nt("only requests to HTTPS are allowed",F1,e);if(e.protocol!=="https:"&&e.protocol!=="http:")throw nt("only HTTP and HTTPS requests are allowed",G1,e)}function Vb(e,t,n,a){let r;if(typeof e!="string"||!(r=XA(e)))throw nt("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),e===void 0?mP:fP,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return ox(r,a),r}function bl(e,t,n,a){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?Vb(e.mtls_endpoint_aliases[t],t,n,a):Vb(e[t],t,n,a)}let Up=class extends Error{constructor(t,n){var a;super(t,n),Pe(this,"cause",void 0),Pe(this,"code",void 0),Pe(this,"error",void 0),Pe(this,"status",void 0),Pe(this,"error_description",void 0),Pe(this,"response",void 0),this.name=this.constructor.name,this.code=hP,this.cause=n.cause,this.error=n.cause.error,this.status=n.response.status,this.error_description=n.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}};class L1 extends Error{constructor(t,n){var a,r;super(t,n),Pe(this,"cause",void 0),Pe(this,"code",void 0),Pe(this,"error",void 0),Pe(this,"error_description",void 0),this.name=this.constructor.name,this.code=pP,this.cause=n.cause,this.error=n.cause.get("error"),this.error_description=(a=n.cause.get("error_description"))!==null&&a!==void 0?a:void 0,(r=Error.captureStackTrace)===null||r===void 0||r.call(Error,this,this.constructor)}}let lx=class extends Error{constructor(t,n){var a;super(t,n),Pe(this,"cause",void 0),Pe(this,"code",void 0),Pe(this,"response",void 0),Pe(this,"status",void 0),this.name=this.constructor.name,this.code=uP,this.cause=n.cause,this.status=n.response.status,this.response=n.response,Object.defineProperty(this,"response",{enumerable:!1}),(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}};const ep="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",QA="("+ep+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"',eP="("+ep+")\\s*=\\s*("+ep+")",tP=new RegExp("^[,\\s]*("+ep+")"),sP=new RegExp("^[,\\s]*"+QA+"[,\\s]*(.*)"),nP=new RegExp("^[,\\s]*"+eP+"[,\\s]*(.*)"),aP=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function Fp(e,t,n){if(e.status!==t){let r;var a;throw function(i){let o;if(o=function(l){if(!Zi(l,Response))throw Nt('"response" must be an instance of Response',Bs);const c=l.headers.get("www-authenticate");if(c===null)return;const u=[];let d=c;for(;d;){var h;let y=d.match(tP);const b=(h=y)===null||h===void 0?void 0:h[1].toLowerCase();if(!b)return;const m=d.substring(y[0].length);if(m&&!m.match(/^[\s,]/))return;const x=m.match(/^\s+(.*)$/),j=!!x;d=x?x[1]:void 0;const S={};let w;if(j)for(;d;){let k,N;if(y=d.match(sP)){var g=kn(y,4);if(k=g[1],N=g[2],d=g[3],N.includes("\\"))try{N=JSON.parse('"'.concat(N,'"'))}catch{}S[k.toLowerCase()]=N}else{if(!(y=d.match(nP))){if(y=d.match(aP)){if(Object.keys(S).length)break;var v=kn(y,3);w=v[1],d=v[2];break}return}var f=kn(y,4);k=f[1],N=f[2],d=f[3],S[k.toLowerCase()]=N}}else d=m||void 0;const C={scheme:b,parameters:S};w&&(C.token68=w),u.push(C)}return u.length?u:void 0}(i))throw new lx("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:o,response:i})}(e),(r=await async function(i){if(i.status>399&&i.status<500){$d(i),$1(i);try{const o=await i.clone().json();if(Zh(o)&&typeof o.error=="string"&&o.error.length)return o}catch{}}}(e))?(await((a=e.body)===null||a===void 0?void 0:a.cancel()),new Up("server responded with an error in the response body",{cause:r,response:e})):nt('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),dx,e)}}function M1(e){if(!cx.has(e))throw Nt('"options.DPoP" is not a valid DPoPHandle',Os)}function D1(e){var t;return(t=e.headers.get("content-type"))===null||t===void 0?void 0:t.split(";")[0]}async function Gp(e,t,n,a,r,i,o){return await n(e,t,r,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((o==null?void 0:o[Bn])||fetch)(a.href,{body:r,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:P1(a,o==null?void 0:o.signal)})}async function Pd(e,t,n,a,r,i){var o;const l=bl(e,"token_endpoint",t.use_mtls_endpoint_aliases,(i==null?void 0:i[ln])!==!0);r.set("grant_type",a);const c=Ad(i==null?void 0:i.headers);c.set("accept","application/json"),(i==null?void 0:i.DPoP)!==void 0&&(M1(i.DPoP),await i.DPoP.addProof(l,c,"POST"));const u=await Gp(e,t,n,l,r,c,i);return i==null||(o=i.DPoP)===null||o===void 0||o.cacheNonce(u,l),u}const z1=new WeakMap,rP=new WeakMap;function ov(e){if(!e.id_token)return;const t=z1.get(e);if(!t)throw Nt('"ref" was already garbage collected or did not resolve from the proper sources',Os);return t}async function ol(e,t,n,a,r,i){if(Wn(e),Hn(t),!Zi(n,Response))throw Nt('"response" must be an instance of Response',Bs);await Fp(n,200,"Token Endpoint"),$d(n);const o=await Wp(n);if(as(o.access_token,'"response" body "access_token" property',yt,{body:o}),as(o.token_type,'"response" body "token_type" property',yt,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let l=typeof o.expires_in!="number"?parseFloat(o.expires_in):o.expires_in;Kr(l,!0,'"response" body "expires_in" property',yt,{body:o}),o.expires_in=l}if(o.refresh_token!==void 0&&as(o.refresh_token,'"response" body "refresh_token" property',yt,{body:o}),o.scope!==void 0&&typeof o.scope!="string")throw nt('"response" body "scope" property must be a string',yt,{body:o});if(o.id_token!==void 0){as(o.id_token,'"response" body "id_token" property',yt,{body:o});const l=["aud","exp","iat","iss","sub"];t.require_auth_time===!0&&l.push("auth_time"),t.default_max_age!==void 0&&(Kr(t.default_max_age,!0,'"client.default_max_age"'),l.push("auth_time")),a!=null&&a.length&&l.push(...a);const c=await async function(h,g,v,f,y){let b,m,x=h.split("."),j=x[0],S=x[1],w=x.length;if(w===5){if(y===void 0)throw new bn("JWE decryption is not configured",{cause:h});var C=(h=await y(h)).split(".");j=C[0],S=C[1],w=C.length}if(w!==3)throw nt("Invalid JWT",yt,h);try{b=JSON.parse(Ko(Mi(j)))}catch(N){throw nt("failed to parse JWT Header body as base64url encoded JSON",tp,N)}if(!Zh(b))throw nt("JWT Header must be a top level object",yt,h);if(g(b),b.crit!==void 0)throw new bn('no JWT "crit" header parameter extensions are supported',{cause:{header:b}});try{m=JSON.parse(Ko(Mi(S)))}catch(N){throw nt("failed to parse JWT Payload body as base64url encoded JSON",tp,N)}if(!Zh(m))throw nt("JWT Payload must be a top level object",yt,h);const k=Qh()+v;if(m.exp!==void 0){if(typeof m.exp!="number")throw nt('unexpected JWT "exp" (expiration time) claim type',yt,{claims:m});if(m.exp<=k-f)throw nt('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',yd,{claims:m,now:k,tolerance:f,claim:"exp"})}if(m.iat!==void 0&&typeof m.iat!="number")throw nt('unexpected JWT "iat" (issued at) claim type',yt,{claims:m});if(m.iss!==void 0&&typeof m.iss!="string")throw nt('unexpected JWT "iss" (issuer) claim type',yt,{claims:m});if(m.nbf!==void 0){if(typeof m.nbf!="number")throw nt('unexpected JWT "nbf" (not before) claim type',yt,{claims:m});if(m.nbf>k+f)throw nt('unexpected JWT "nbf" (not before) claim value',yd,{claims:m,now:k,tolerance:f,claim:"nbf"})}if(m.aud!==void 0&&typeof m.aud!="string"&&!Array.isArray(m.aud))throw nt('unexpected JWT "aud" (audience) claim type',yt,{claims:m});return{header:b,claims:m,jwt:h}}(o.id_token,xP.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),Xh(t),iv(t),r).then(cP.bind(void 0,l)).then(oP.bind(void 0,e)).then(iP.bind(void 0,t.client_id)),u=c.claims,d=c.jwt;if(Array.isArray(u.aud)&&u.aud.length!==1){if(u.azp===void 0)throw nt('ID Token "aud" (audience) claim includes additional untrusted audiences',ar,{claims:u,claim:"aud"});if(u.azp!==t.client_id)throw nt('unexpected ID Token "azp" (authorized party) claim value',ar,{expected:t.client_id,claims:u,claim:"azp"})}u.auth_time!==void 0&&Kr(u.auth_time,!0,'ID Token "auth_time" (authentication time)',yt,{claims:u}),rP.set(n,d),z1.set(o,u)}if((i==null?void 0:i[o.token_type])!==void 0)i[o.token_type](n,o);else if(o.token_type!=="dpop"&&o.token_type!=="bearer")throw new bn("unsupported `token_type` value",{cause:{body:o}});return o}function iP(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw nt('unexpected JWT "aud" (audience) claim value',ar,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw nt('unexpected JWT "aud" (audience) claim value',ar,{expected:e,claims:t.claims,claim:"aud"});return t}function oP(e,t){var n,a;const r=(n=(a=e[W1])===null||a===void 0?void 0:a.call(e,t))!==null&&n!==void 0?n:e.issuer;if(t.claims.iss!==r)throw nt('unexpected JWT "iss" (issuer) claim value',ar,{expected:r,claims:t.claims,claim:"iss"});return t}const cx=new WeakSet,qb=Symbol(),lP={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function cP(e,t){for(const n of e)if(t.claims[n]===void 0)throw nt('JWT "'.concat(n,'" (').concat(lP[n],") claim missing"),yt,{claims:t.claims});return t}const Mm=Symbol(),Dm=Symbol();async function dP(e,t,n,a){return typeof(a==null?void 0:a.expectedNonce)=="string"||typeof(a==null?void 0:a.maxAge)=="number"||a!=null&&a.requireIdToken?async function(r,i,o,l,c,u,d){const h=[];switch(l){case void 0:l=Mm;break;case Mm:break;default:as(l,'"expectedNonce" argument'),h.push("nonce")}switch(c!=null||(c=i.default_max_age),c){case void 0:c=Dm;break;case Dm:break;default:Kr(c,!0,'"maxAge" argument'),h.push("auth_time")}const g=await ol(r,i,o,h,u,d);as(g.id_token,'"response" body "id_token" property',yt,{body:g});const v=ov(g);if(c!==Dm){const f=Qh()+Xh(i),y=iv(i);if(v.auth_time+c<f-y)throw nt("too much time has elapsed since the last End-User authentication",yd,{claims:v,now:f,tolerance:y,claim:"auth_time"})}if(l===Mm){if(v.nonce!==void 0)throw nt('unexpected ID Token "nonce" claim value',ar,{expected:void 0,claims:v,claim:"nonce"})}else if(v.nonce!==l)throw nt('unexpected ID Token "nonce" claim value',ar,{expected:l,claims:v,claim:"nonce"});return g}(e,t,n,a.expectedNonce,a.maxAge,a[dr],a.recognizedTokenTypes):async function(r,i,o,l,c){const u=await ol(r,i,o,void 0,l,c),d=ov(u);if(d){if(i.default_max_age!==void 0){Kr(i.default_max_age,!0,'"client.default_max_age"');const h=Qh()+Xh(i),g=iv(i);if(d.auth_time+i.default_max_age<h-g)throw nt("too much time has elapsed since the last End-User authentication",yd,{claims:d,now:h,tolerance:g,claim:"auth_time"})}if(d.nonce!==void 0)throw nt('unexpected ID Token "nonce" claim value',ar,{expected:void 0,claims:d,claim:"nonce"})}return u}(e,t,n,a==null?void 0:a[dr],a==null?void 0:a.recognizedTokenTypes)}const uP="OAUTH_WWW_AUTHENTICATE_CHALLENGE",hP="OAUTH_RESPONSE_BODY_ERROR",lv="OAUTH_UNSUPPORTED_OPERATION",pP="OAUTH_AUTHORIZATION_RESPONSE_ERROR",tp="OAUTH_PARSE_ERROR",yt="OAUTH_INVALID_RESPONSE",U1="OAUTH_RESPONSE_IS_NOT_JSON",dx="OAUTH_RESPONSE_IS_NOT_CONFORM",F1="OAUTH_HTTP_REQUEST_FORBIDDEN",G1="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",yd="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",ar="OAUTH_JWT_CLAIM_COMPARISON_FAILED",cv="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",mP="OAUTH_MISSING_SERVER_METADATA",fP="OAUTH_INVALID_SERVER_METADATA";async function gP(e){if(!Zi(e,Response))throw Nt('"response" must be an instance of Response',Bs);await Fp(e,200,"Revocation Endpoint")}function $d(e){if(e.bodyUsed)throw Nt('"response" body has been used already',Os)}function Kb(e){const t=e.algorithm;if(typeof t.modulusLength!="number"||t.modulusLength<2048)throw new bn("unsupported ".concat(t.name," modulusLength"),{cause:e})}function vP(e){switch(e.algorithm.namedCurve){case"P-256":return"SHA-256";case"P-384":return"SHA-384";case"P-521":return"SHA-512";default:throw new bn("unsupported ECDSA namedCurve",{cause:e})}}async function yP(e){if(e.method!=="POST")throw Nt("form_post responses are expected to use the POST method",Os,{cause:e});if(D1(e)!=="application/x-www-form-urlencoded")throw Nt("form_post responses are expected to use the application/x-www-form-urlencoded content-type",Os,{cause:e});return async function(t){if(t.bodyUsed)throw Nt("form_post Request instances must contain a readable body",Os,{cause:t});return t.text()}(e)}function xP(e,t,n,a){if(e===void 0)if(Array.isArray(t)){if(!t.includes(a.alg))throw nt('unexpected JWT "alg" header parameter',yt,{header:a,expected:t,reason:"authorization server metadata"})}else{if(n===void 0)throw nt('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if(typeof n=="string"?a.alg!==n:typeof n=="function"?!n(a.alg):!n.includes(a.alg))throw nt('unexpected JWT "alg" header parameter',yt,{header:a,expected:n,reason:"default value"})}else if(typeof e=="string"?a.alg!==e:!e.includes(a.alg))throw nt('unexpected JWT "alg" header parameter',yt,{header:a,expected:e,reason:"client configuration"})}function xi(e,t){const n=e.getAll(t),a=n[0];if(n.length>1)throw nt('"'.concat(t,'" parameter must be provided only once'),yt);return a}const jP=Symbol(),bP=Symbol();function wP(e,t,n,a){if(Wn(e),Hn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw Nt('"parameters" must be an instance of URLSearchParams, or URL',Bs);if(xi(n,"response"))throw nt('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',yt,{parameters:n});const r=xi(n,"iss"),i=xi(n,"state");if(!r&&e.authorization_response_iss_parameter_supported)throw nt('response parameter "iss" (issuer) missing',yt,{parameters:n});if(r&&r!==e.issuer)throw nt('unexpected "iss" (issuer) response parameter value',yt,{expected:e.issuer,parameters:n});switch(a){case void 0:case bP:if(i!==void 0)throw nt('unexpected "state" response parameter encountered',yt,{expected:void 0,parameters:n});break;case jP:break;default:if(as(a,'"expectedState" argument'),i!==a)throw nt(i===void 0?'response parameter "state" missing':'unexpected "state" response parameter value',yt,{expected:a,parameters:n})}if(xi(n,"error"))throw new L1("authorization response from the server is an error",{cause:n});const o=xi(n,"id_token"),l=xi(n,"token");if(o!==void 0||l!==void 0)throw new bn("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),cx.add(c),c;var c}async function Wp(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$1;try{t=await e.json()}catch(a){throw n(e),nt('failed to parse "response" body as JSON',tp,a)}if(!Zh(t))throw nt('"response" body must be a top level object',yt,{body:t});return t}const zm=Symbol(),W1=Symbol(),sp=new TextEncoder,ll=new TextDecoder;function H1(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const a=t.reduce((o,l)=>o+l.length,0),r=new Uint8Array(a);let i=0;for(const o of t)r.set(o,i),i+=o.length;return r}function Jo(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);if(a>127)throw new TypeError("non-ASCII string encountered in encode()");t[n]=a}return t}function B1(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function Od(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e=="string"?e:ll.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=ll.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{return B1(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}function Um(e){let t=e;return typeof t=="string"&&(t=sp.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:"base64url",omitPadding:!0}):function(n){if(Uint8Array.prototype.toBase64)return n.toBase64();const a=[];for(let r=0;r<n.length;r+=32768)a.push(String.fromCharCode.apply(null,n.subarray(r,r+32768)));return btoa(a.join(""))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}const Nr=function(e){return new TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&arguments[1]!==void 0?arguments[1]:"algorithm.name"," must be ").concat(e))},to=(e,t)=>e.name===t;function Fm(e,t){var n;if(n=e.hash,parseInt(n.name.slice(4),10)!==t)throw Nr("SHA-".concat(t),"algorithm.hash")}function SP(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":if(!to(e.algorithm,"HMAC"))throw Nr("HMAC");Fm(e.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if(!to(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Nr("RSASSA-PKCS1-v1_5");Fm(e.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if(!to(e.algorithm,"RSA-PSS"))throw Nr("RSA-PSS");Fm(e.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if(!to(e.algorithm,"Ed25519"))throw Nr("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!to(e.algorithm,t))throw Nr(t);break;case"ES256":case"ES384":case"ES512":{if(!to(e.algorithm,"ECDSA"))throw Nr("ECDSA");const a=function(r){switch(r){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==a)throw Nr(a,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}(function(a,r){if(r&&!a.usages.includes(r))throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(r,"."))})(e,n)}function V1(e,t){for(var n=arguments.length,a=new Array(n>2?n-2:0),r=2;r<n;r++)a[r-2]=arguments[r];if((a=a.filter(Boolean)).length>2){const o=a.pop();e+="one of type ".concat(a.join(", "),", or ").concat(o,".")}else a.length===2?e+="one of type ".concat(a[0]," or ").concat(a[1],"."):e+="of type ".concat(a[0],".");if(t==null)e+=" Received ".concat(t);else if(typeof t=="function"&&t.name)e+=" Received function ".concat(t.name);else if(typeof t=="object"&&t!=null){var i;(i=t.constructor)!==null&&i!==void 0&&i.name&&(e+=" Received an instance of ".concat(t.constructor.name))}return e}const Jb=function(e,t){for(var n=arguments.length,a=new Array(n>2?n-2:0),r=2;r<n;r++)a[r-2]=arguments[r];return V1("Key for the ".concat(e," algorithm must be "),t,...a)};class Cs extends Error{constructor(t,n){var a;super(t,n),Pe(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}}Pe(Cs,"code","ERR_JOSE_GENERIC");class Qn extends Cs{constructor(t,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(t,{cause:{claim:a,reason:r,payload:n}}),Pe(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),Pe(this,"claim",void 0),Pe(this,"reason",void 0),Pe(this,"payload",void 0),this.claim=a,this.reason=r,this.payload=n}}Pe(Qn,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class dv extends Cs{constructor(t,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(t,{cause:{claim:a,reason:r,payload:n}}),Pe(this,"code","ERR_JWT_EXPIRED"),Pe(this,"claim",void 0),Pe(this,"reason",void 0),Pe(this,"payload",void 0),this.claim=a,this.reason=r,this.payload=n}}Pe(dv,"code","ERR_JWT_EXPIRED");class q1 extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}Pe(q1,"code","ERR_JOSE_ALG_NOT_ALLOWED");class vn extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JOSE_NOT_SUPPORTED")}}Pe(vn,"code","ERR_JOSE_NOT_SUPPORTED");Pe(class extends Cs{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),Pe(this,"code","ERR_JWE_DECRYPTION_FAILED")}},"code","ERR_JWE_DECRYPTION_FAILED");Pe(class extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JWE_INVALID")}},"code","ERR_JWE_INVALID");class qt extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JWS_INVALID")}}Pe(qt,"code","ERR_JWS_INVALID");class aa extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JWT_INVALID")}}Pe(aa,"code","ERR_JWT_INVALID");Pe(class extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JWK_INVALID")}},"code","ERR_JWK_INVALID");class ux extends Cs{constructor(){super(...arguments),Pe(this,"code","ERR_JWKS_INVALID")}}Pe(ux,"code","ERR_JWKS_INVALID");class hx extends Cs{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),Pe(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}Pe(hx,"code","ERR_JWKS_NO_MATCHING_KEY");class K1 extends Cs{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),Pe(this,Symbol.asyncIterator,void 0),Pe(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}Pe(K1,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class J1 extends Cs{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),Pe(this,"code","ERR_JWKS_TIMEOUT")}}Pe(J1,"code","ERR_JWKS_TIMEOUT");class Y1 extends Cs{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),Pe(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}Pe(Y1,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const Z1=e=>{if((e==null?void 0:e[Symbol.toStringTag])==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},X1=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",Yb=e=>Z1(e)||X1(e);function Zb(e,t){if(e)throw new TypeError("".concat(t," can only be called once"))}function Xb(e,t,n){try{return Od(e)}catch{throw new n("Failed to base64url decode the ".concat(t))}}function Pa(e){if(typeof(t=e)!="object"||t===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}function Q1(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const a=t.filter(Boolean);if(a.length===0||a.length===1)return!0;let r;for(const i of a){const o=Object.keys(i);if(r&&r.size!==0)for(const l of o){if(r.has(l))return!1;r.add(l)}else r=new Set(o)}return!0}const uv=e=>Pa(e)&&typeof e.kty=="string";function eE(e,t){if(e.startsWith("RS")||e.startsWith("PS")){const n=t.algorithm.modulusLength;if(typeof n!="number"||n<2048)throw new TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}}function tE(e,t){const n="SHA-".concat(e.slice(-3));switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new vn("alg ".concat(e," is not supported either by JOSE or your javascript runtime"))}}async function sE(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(function(a){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return V1("Key must be ",a,...i)}(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:"SHA-".concat(e.slice(-3)),name:"HMAC"},!1,[n])}return SP(t,e,n),t}const cu='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function ch(e){var t,n;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const a=function(l){let c,u;switch(l.kty){case"AKP":switch(l.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":c={name:l.alg},u=l.priv?["sign"]:["verify"];break;default:throw new vn(cu)}break;case"RSA":switch(l.alg){case"PS256":case"PS384":case"PS512":c={name:"RSA-PSS",hash:"SHA-".concat(l.alg.slice(-3))},u=l.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":c={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(l.alg.slice(-3))},u=l.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":c={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(l.alg.slice(-3),10)||1)},u=l.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new vn(cu)}break;case"EC":switch(l.alg){case"ES256":case"ES384":case"ES512":c={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[l.alg]},u=l.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":c={name:"ECDH",namedCurve:l.crv},u=l.d?["deriveBits"]:[];break;default:throw new vn(cu)}break;case"OKP":switch(l.alg){case"Ed25519":case"EdDSA":c={name:"Ed25519"},u=l.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":c={name:l.crv},u=l.d?["deriveBits"]:[];break;default:throw new vn(cu)}break;default:throw new vn('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:c,keyUsages:u}}(e),r=a.algorithm,i=a.keyUsages,o=Le({},e);return o.kty!=="AKP"&&delete o.alg,delete o.use,crypto.subtle.importKey("jwk",o,r,(t=e.ext)!==null&&t!==void 0?t:!e.d&&!e.priv,(n=e.key_ops)!==null&&n!==void 0?n:i)}const so="given KeyObject instance cannot be used for this algorithm";let Mr;const Qb=async function(e,t,n){let a=arguments.length>3&&arguments[3]!==void 0&&arguments[3];Mr||(Mr=new WeakMap);let r=Mr.get(e);if(r!=null&&r[n])return r[n];const i=await ch(Le(Le({},t),{},{alg:n}));return a&&Object.freeze(e),r?r[n]=i:Mr.set(e,{[n]:i}),i};async function nE(e,t){if(e instanceof Uint8Array||Z1(e))return e;if(X1(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey=="function")try{return((a,r)=>{Mr||(Mr=new WeakMap);let i=Mr.get(a);if(i!=null&&i[r])return i[r];const o=a.type==="public",l=!!o;let c;if(a.asymmetricKeyType==="x25519"){switch(r){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(so)}c=a.toCryptoKey(a.asymmetricKeyType,l,o?[]:["deriveBits"])}if(a.asymmetricKeyType==="ed25519"){if(r!=="EdDSA"&&r!=="Ed25519")throw new TypeError(so);c=a.toCryptoKey(a.asymmetricKeyType,l,[o?"verify":"sign"])}switch(a.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(r!==a.asymmetricKeyType.toUpperCase())throw new TypeError(so);c=a.toCryptoKey(a.asymmetricKeyType,l,[o?"verify":"sign"])}if(a.asymmetricKeyType==="rsa"){let d;switch(r){case"RSA-OAEP":d="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":d="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":d="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":d="SHA-512";break;default:throw new TypeError(so)}if(r.startsWith("RSA-OAEP"))return a.toCryptoKey({name:"RSA-OAEP",hash:d},l,o?["encrypt"]:["decrypt"]);c=a.toCryptoKey({name:r.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:d},l,[o?"verify":"sign"])}if(a.asymmetricKeyType==="ec"){var u;const d=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get((u=a.asymmetricKeyDetails)===null||u===void 0?void 0:u.namedCurve);if(!d)throw new TypeError(so);const h={ES256:"P-256",ES384:"P-384",ES512:"P-521"};h[r]&&d===h[r]&&(c=a.toCryptoKey({name:"ECDSA",namedCurve:d},l,[o?"verify":"sign"])),r.startsWith("ECDH-ES")&&(c=a.toCryptoKey({name:"ECDH",namedCurve:d},l,o?[]:["deriveBits"]))}if(!c)throw new TypeError(so);return i?i[r]=c:Mr.set(a,{[r]:c}),c})(e,t)}catch(a){if(a instanceof TypeError)throw a}let n=e.export({format:"jwk"});return Qb(e,n,t)}if(uv(e))return e.k?Od(e.k):Qb(e,e,t,!0);throw new Error("unreachable")}const Gm=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Mc=e=>{const t=e.data[e.pos++];if(128&t){const n=127&t;let a=0;for(let r=0;r<n;r++)a=a<<8|e.data[e.pos++];return a}return t},Dc=(e,t,n)=>{if(e.data[e.pos++]!==t)throw new Error(n)},ew=(e,t)=>{const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},NP=e=>{const t=(r=>{Dc(r,6,"Expected algorithm OID");const i=Mc(r);return ew(r,i)})(e);if(Gm(t,[43,101,110]))return"X25519";if(!Gm(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Dc(e,6,"Expected curve OID");const n=Mc(e),a=ew(e,n);for(const r of[{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}]){const i=r.name,o=r.oid;if(Gm(a,o))return i}throw new Error("Unsupported named curve")},kP=async(e,t,n,a)=>{var r;let i,o;const l=()=>["sign"];switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:"SHA-".concat(n.slice(-3))},o=l();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(n.slice(-3))},o=l();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(n.slice(-3),10)||1)},o=["decrypt","unwrapKey"];break;case"ES256":case"ES384":case"ES512":i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[n]},o=l();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{const c=a.getNamedCurve(t);i=c==="X25519"?{name:"X25519"}:{name:"ECDH",namedCurve:c}}catch{throw new vn("Invalid or unsupported key format")}o=["deriveBits"];break;case"Ed25519":case"EdDSA":i={name:"Ed25519"},o=l();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:n},o=l();break;default:throw new vn('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,(r=a==null?void 0:a.extractable)!==null&&r!==void 0?r:!1,o)},EP=(e,t,n)=>{var a;const r=((o,l)=>B1(o.replace(l,"")))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);let i=n;return t!=null&&(a=t.startsWith)!==null&&a!==void 0&&a.call(t,"ECDH-ES")&&(i||(i={}),i.getNamedCurve=o=>{const l={data:o,pos:0};return function(c){Dc(c,48,"Invalid PKCS#8 structure"),Mc(c),Dc(c,2,"Expected version field");const u=Mc(c);c.pos+=u,Dc(c,48,"Expected algorithm identifier"),Mc(c)}(l),NP(l)}),kP("pkcs8",r,t,i)};async function aE(e,t,n){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return EP(e,t,n)}function rE(e,t,n,a,r){if(r.crit!==void 0&&(a==null?void 0:a.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!a||a.crit===void 0)return new Set;if(!Array.isArray(a.crit)||a.crit.length===0||a.crit.some(o=>typeof o!="string"||o.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;i=n!==void 0?new Map([...Object.entries(n),...t.entries()]):t;for(const o of a.crit){if(!i.has(o))throw new vn('Extension Header Parameter "'.concat(o,'" is not recognized'));if(r[o]===void 0)throw new e('Extension Header Parameter "'.concat(o,'" is missing'));if(i.get(o)&&a[o]===void 0)throw new e('Extension Header Parameter "'.concat(o,'" MUST be integrity protected'))}return new Set(a.crit)}const no=e=>e==null?void 0:e[Symbol.toStringTag],Wm=(e,t,n)=>{if(t.use!==void 0){let i;switch(n){case"sign":case"verify":i="sig";break;case"encrypt":case"decrypt":i="enc"}if(t.use!==i)throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(i,'" when present'))}if(t.alg!==void 0&&t.alg!==e)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(e,'" when present'));if(Array.isArray(t.key_ops)){var a,r;let i;switch(!0){case(n==="sign"||n==="verify"):case e==="dir":case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):i=!e.includes("GCM")&&e.endsWith("KW")?n==="encrypt"?"wrapKey":"unwrapKey":n;break;case(n==="encrypt"&&e.startsWith("RSA")):i="wrapKey";break;case n==="decrypt":i=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(i&&((a=t.key_ops)===null||a===void 0||(r=a.includes)===null||r===void 0?void 0:r.call(a,i))===!1)throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i,'" when present'))}return!0};function iE(e,t,n){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((a,r,i)=>{if(!(r instanceof Uint8Array)){if(uv(r)){if((o=>o.kty==="oct"&&typeof o.k=="string")(r)&&Wm(a,r,i))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Yb(r))throw new TypeError(Jb(a,r,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(r.type!=="secret")throw new TypeError("".concat(no(r),' instances for symmetric algorithms must be of type "secret"'))}})(e,t,n);break;default:((a,r,i)=>{if(uv(r))switch(i){case"decrypt":case"sign":if((o=>o.kty!=="oct"&&(o.kty==="AKP"&&typeof o.priv=="string"||typeof o.d=="string"))(r)&&Wm(a,r,i))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if((o=>o.kty!=="oct"&&o.d===void 0&&o.priv===void 0)(r)&&Wm(a,r,i))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!Yb(r))throw new TypeError(Jb(a,r,"CryptoKey","KeyObject","JSON Web Key"));if(r.type==="secret")throw new TypeError("".concat(no(r),' instances for asymmetric algorithms must not be of type "secret"'));if(r.type==="public")switch(i){case"sign":throw new TypeError("".concat(no(r),' instances for asymmetric algorithm signing must be of type "private"'));case"decrypt":throw new TypeError("".concat(no(r),' instances for asymmetric algorithm decryption must be of type "private"'))}if(r.type==="private")switch(i){case"verify":throw new TypeError("".concat(no(r),' instances for asymmetric algorithm verifying must be of type "public"'));case"encrypt":throw new TypeError("".concat(no(r),' instances for asymmetric algorithm encryption must be of type "public"'))}})(e,t,n)}}var du,Hm;let va,tw;(typeof navigator>"u"||(du=navigator.userAgent)===null||du===void 0||(Hm=du.startsWith)===null||Hm===void 0||!Hm.call(du,"Mozilla/5.0 "))&&(tw="".concat("openid-client","/").concat("v6.8.4"),va={"user-agent":tw});const vs=e=>dh.get(e);let dh,uu;function oE(e){return e!==void 0?Bb(e):(uu||(uu=new WeakMap),(t,n,a,r)=>{let i;return(i=uu.get(n))||(function(o,l){if(typeof o!="string")throw $a("".concat(l," must be a string"),Md);if(o.length===0)throw $a("".concat(l," must not be empty"),Ld)}(n.client_secret,'"metadata.client_secret"'),i=Bb(n.client_secret),uu.set(n,i)),i(t,n,a,r)})}const ua=Bn,Ld="ERR_INVALID_ARG_VALUE",Md="ERR_INVALID_ARG_TYPE";function $a(e,t,n){const a=new TypeError(e,{cause:n});return Object.assign(a,{code:t}),a}function _P(e){return async function(t){return as(t,"codeVerifier"),Mi(await crypto.subtle.digest("SHA-256",Ko(t)))}(e)}function CP(){return O1()}let np=class extends Error{constructor(t,n){var a;super(t,n),Pe(this,"code",void 0),this.name=this.constructor.name,this.code=n==null?void 0:n.code,(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}};function Us(e,t,n){return new np(e,{cause:t,code:n})}function ks(e){if(e instanceof TypeError||e instanceof np||e instanceof Up||e instanceof L1||e instanceof lx)throw e;if(e instanceof ix)switch(e.code){case F1:throw Us("only requests to HTTPS are allowed",e,e.code);case G1:throw Us("only requests to HTTP or HTTPS are allowed",e,e.code);case dx:throw Us("unexpected HTTP response status code",e.cause,e.code);case U1:throw Us("unexpected response content-type",e.cause,e.code);case tp:throw Us("parsing error occured",e,e.code);case yt:throw Us("invalid response encountered",e,e.code);case ar:throw Us("unexpected JWT claim value encountered",e,e.code);case cv:throw Us("unexpected JSON attribute value encountered",e,e.code);case yd:throw Us("JWT timestamp claim value failed validation",e,e.code);default:throw Us(e.message,e,e.code)}if(e instanceof bn)throw Us("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw Us("runtime operation error",e,lv);case"NotSupportedError":throw Us("runtime unsupported operation",e,lv);case"TimeoutError":throw Us("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw Us("operation aborted",e,"OAUTH_ABORT")}throw new np("something went wrong",{cause:e})}async function TP(e,t,n,a,r){const i=await async function(c,u){var d,h;if(!(c instanceof URL))throw $a('"server" must be an instance of URL',Md);const g=!c.href.includes("/.well-known/"),v=(d=u==null?void 0:u.timeout)!==null&&d!==void 0?d:30,f=AbortSignal.timeout(1e3*v),y=await(g?JA(c,{algorithm:u==null?void 0:u.algorithm,[Bn]:u==null?void 0:u[ua],[ln]:u==null||(h=u.execute)===null||h===void 0?void 0:h.includes(aw),signal:f,headers:new Headers(va)}):((u==null?void 0:u[ua])||fetch)((ox(c,u==null||(b=u.execute)===null||b===void 0||!b.includes(aw)),c.href),{headers:Object.fromEntries(new Headers(Le({accept:"application/json"},va)).entries()),body:void 0,method:"GET",redirect:"manual",signal:f})).then(m=>async function(x,j){const S=x;if(!(S instanceof URL)&&S!==zm)throw Nt('"expectedIssuerIdentifier" must be an instance of URL',Bs);if(!Zi(j,Response))throw Nt('"response" must be an instance of Response',Bs);if(j.status!==200)throw nt('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',dx,j);$d(j);const w=await Wp(j);if(as(w.issuer,'"response" body "issuer" property',yt,{body:w}),S!==zm&&new URL(w.issuer).href!==S.href)throw nt('"response" body "issuer" property does not match the expected value',cv,{expected:S.href,body:w,attribute:"issuer"});return w}(zm,m)).catch(ks);var b;return g&&new URL(y.issuer).href!==c.href&&(function(m,x,j){return!(m.origin!=="https://login.microsoftonline.com"||j!=null&&j.algorithm&&j.algorithm!=="oidc"||(x[lE]=!0,0))}(c,y,u)||function(m,x){return!(!m.hostname.endsWith(".b2clogin.com")||x!=null&&x.algorithm&&x.algorithm!=="oidc")}(c,u)||(()=>{throw new np("discovered metadata issuer does not match the expected issuer",{code:cv,cause:{expected:c.href,body:y,attribute:"issuer"}})})()),y}(e,r),o=new cl(i,t,n,a);let l=vs(o);if(r!=null&&r[ua]&&(l.fetch=r[ua]),r!=null&&r.timeout&&(l.timeout=r.timeout),r!=null&&r.execute)for(const c of r.execute)c(o);return o}new TextDecoder;const lE=Symbol();let cl=class{constructor(t,n,a,r){var i,o,l,c,u;if(typeof n!="string"||!n.length)throw $a('"clientId" must be a non-empty string',Md);if(typeof a=="string"&&(a={client_secret:a}),((i=a)===null||i===void 0?void 0:i.client_id)!==void 0&&n!==a.client_id)throw $a('"clientId" and "metadata.client_id" must be the same',Ld);const d=Le(Le({},structuredClone(a)),{},{client_id:n});let h;d[nv]=(o=(l=a)===null||l===void 0?void 0:l[nv])!==null&&o!==void 0?o:0,d[av]=(c=(u=a)===null||u===void 0?void 0:u[av])!==null&&c!==void 0?c:30,h=r||(typeof d.client_secret=="string"&&d.client_secret.length?oE(d.client_secret):(y,b,m,x)=>{m.set("client_id",b.client_id)});let g=Object.freeze(d);const v=structuredClone(t);lE in t&&(v[W1]=y=>{let b=y.claims.tid;return t.issuer.replace("{tenantid}",b)});let f=Object.freeze(v);dh||(dh=new WeakMap),dh.set(this,{__proto__:null,as:f,c:g,auth:h,tlsOnly:!0,jwksCache:{}})}serverMetadata(){const t=structuredClone(vs(this).as);return function(n){Object.defineProperties(n,function(a){return{supportsPKCE:{__proto__:null,value(){var r;let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"S256";return((r=a.code_challenge_methods_supported)===null||r===void 0?void 0:r.includes(i))===!0}}}}(n))}(t),t}clientMetadata(){return structuredClone(vs(this).c)}get timeout(){return vs(this).timeout}set timeout(t){vs(this).timeout=t}get[ua](){return vs(this).fetch}set[ua](t){vs(this).fetch=t}};function Dd(e){Object.defineProperties(e,function(t){let n;if(t.expires_in!==void 0){const a=new Date;a.setSeconds(a.getSeconds()+t.expires_in),n=a.getTime()}return{expiresIn:{__proto__:null,value(){if(n){const a=Date.now();return n>a?Math.floor((n-a)/1e3):0}}},claims:{__proto__:null,value(){try{return ov(this)}catch{return}}}}}(e))}async function sw(e,t,n){var a;let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];const i=(a=e.headers.get("retry-after"))===null||a===void 0?void 0:a.trim();if(i===void 0)return;let o;if(/^\d+$/.test(i))o=parseInt(i,10);else{const l=new Date(i);if(Number.isFinite(l.getTime())){const c=new Date,u=l.getTime()-c.getTime();u>0&&(o=Math.ceil(u/1e3))}}if(r&&!Number.isFinite(o))throw new ix("invalid Retry-After header value",{cause:e});o>t&&await cE(o-t,n)}function cE(e,t){return new Promise((n,a)=>{const r=i=>{try{t.throwIfAborted()}catch(l){return void a(l)}if(i<=0)return void n();const o=Math.min(i,5);setTimeout(()=>r(i-o),1e3*o)};r(e)})}async function nw(e,t){Ma(e);const n=vs(e),a=n.as,r=n.c,i=n.auth,o=n.fetch,l=n.tlsOnly,c=n.timeout;return async function(u,d,h,g,v){Wn(u),Hn(d);const f=bl(u,"backchannel_authentication_endpoint",d.use_mtls_endpoint_aliases,(v==null?void 0:v[ln])!==!0),y=new URLSearchParams(g);y.set("client_id",d.client_id);const b=Ad(v==null?void 0:v.headers);return b.set("accept","application/json"),Gp(u,d,h,f,y,b,v)}(a,r,i,t,{[Bn]:o,[ln]:!l,headers:new Headers(va),signal:ai(c)}).then(u=>async function(d,h,g){if(Wn(d),Hn(h),!Zi(g,Response))throw Nt('"response" must be an instance of Response',Bs);await Fp(g,200,"Backchannel Authentication Endpoint"),$d(g);const v=await Wp(g);as(v.auth_req_id,'"response" body "auth_req_id" property',yt,{body:v});let f=typeof v.expires_in!="number"?parseFloat(v.expires_in):v.expires_in;return Kr(f,!0,'"response" body "expires_in" property',yt,{body:v}),v.expires_in=f,v.interval!==void 0&&Kr(v.interval,!1,'"response" body "interval" property',yt,{body:v}),v}(a,r,u)).catch(ks)}async function dE(e,t,n,a){var r,i;Ma(e),n=new URLSearchParams(n);let o=(r=t.interval)!==null&&r!==void 0?r:5;const l=(i=a==null?void 0:a.signal)!==null&&i!==void 0?i:AbortSignal.timeout(1e3*t.expires_in);try{await cE(o,l)}catch(k){ks(k)}const c=vs(e),u=c.as,d=c.c,h=c.auth,g=c.fetch,v=c.tlsOnly,f=c.nonRepudiation,y=c.timeout,b=c.decrypt,m=(k,N)=>dE(e,Le(Le({},t),{},{interval:k}),n,Le(Le({},a),{},{signal:l,flag:N})),x=function(k,N){const L=ai(N);if(!L)return{signal:k,cleanup(){}};const _=new AbortController,E=I=>{const $=I.target;_.abort($.reason)};return k.aborted?_.abort(k.reason):L.aborted?_.abort(L.reason):(k.addEventListener("abort",E,{once:!0}),L.addEventListener("abort",E,{once:!0})),{signal:_.signal,cleanup(){k.removeEventListener("abort",E),L.removeEventListener("abort",E)}}}(l,y),j=await async function(k,N,L,_,E){Wn(k),Hn(N),as(_,'"authReqId"');const I=new URLSearchParams(E==null?void 0:E.additionalParameters);return I.set("auth_req_id",_),Pd(k,N,L,"urn:openid:params:grant-type:ciba",I,E)}(u,d,h,t.auth_req_id,{[Bn]:g,[ln]:!v,additionalParameters:n,DPoP:a==null?void 0:a.DPoP,headers:new Headers(va),signal:x.signal}).catch(ks).finally(x.cleanup);var S;if(j.status===503&&j.headers.has("retry-after"))return await sw(j,o,l,!0),await((S=j.body)===null||S===void 0?void 0:S.cancel()),m(o);const w=async function(k,N,L,_){return ol(k,N,L,void 0,_==null?void 0:_[dr],_==null?void 0:_.recognizedTokenTypes)}(u,d,j,{[dr]:b});let C;try{C=await w}catch(k){if(wl(k,a))return m(o,rr);if(k instanceof Up)switch(k.error){case"slow_down":o+=5;case"authorization_pending":return await sw(k.response,o,l),m(o)}ks(k)}return C.id_token&&await(f==null?void 0:f(j)),Dd(C),C}function aw(e){vs(e).tlsOnly=!1}async function hv(e,t,n,a,r){if(Ma(e),!((r==null?void 0:r.flag)===rr||t instanceof URL||function(k,N){try{return Object.getPrototypeOf(k)[Symbol.toStringTag]===N}catch{return!1}}(t,"Request")))throw $a('"currentUrl" must be an instance of URL, or Request',Md);let i,o;const l=vs(e),c=l.as,u=l.c,d=l.auth,h=l.fetch,g=l.tlsOnly,v=l.jarm,f=l.hybrid,y=l.nonRepudiation,b=l.timeout,m=l.decrypt,x=l.implicit;if((r==null?void 0:r.flag)===rr)i=r.authResponse,o=r.redirectUri;else{if(!(t instanceof URL)){const k=t;switch(t=new URL(t.url),k.method){case"GET":break;case"POST":const N=new URLSearchParams(await yP(k));if(f)t.hash=N.toString();else for(const L of N.entries()){var j=kn(L,2);const _=j[0],E=j[1];t.searchParams.append(_,E)}break;default:throw $a("unexpected Request HTTP method",Ld)}}switch(o=function(k){return(k=new URL(k)).search="",k.hash="",k.href}(t),!0){case!!v:i=await v(t,n==null?void 0:n.expectedState);break;case!!f:i=await f(t,n==null?void 0:n.expectedNonce,n==null?void 0:n.expectedState,n==null?void 0:n.maxAge);break;case!!x:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=wP(c,u,t.searchParams,n==null?void 0:n.expectedState)}catch(k){ks(k)}}}const S=await async function(k,N,L,_,E,I,$){if(Wn(k),Hn(N),!cx.has(_))throw Nt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',Os);as(E,'"redirectUri"');const W=xi(_,"code");if(!W)throw nt('no authorization code in "callbackParameters"',yt);const R=new URLSearchParams($==null?void 0:$.additionalParameters);return R.set("redirect_uri",E),R.set("code",W),I!==qb&&(as(I,'"codeVerifier"'),R.set("code_verifier",I)),Pd(k,N,L,"authorization_code",R,$)}(c,u,d,i,o,(n==null?void 0:n.pkceCodeVerifier)||qb,{additionalParameters:a,[Bn]:h,[ln]:!g,DPoP:r==null?void 0:r.DPoP,headers:new Headers(va),signal:ai(b)}).catch(ks);typeof(n==null?void 0:n.expectedNonce)!="string"&&typeof(n==null?void 0:n.maxAge)!="number"||(n.idTokenExpected=!0);const w=dP(c,u,S,{expectedNonce:n==null?void 0:n.expectedNonce,maxAge:n==null?void 0:n.maxAge,requireIdToken:n==null?void 0:n.idTokenExpected,[dr]:m});let C;try{C=await w}catch(k){if(wl(k,r))return hv(e,void 0,n,a,Le(Le({},r),{},{flag:rr,authResponse:i,redirectUri:o}));ks(k)}return C.id_token&&await(y==null?void 0:y(S)),Dd(C),C}async function uE(e,t,n,a){Ma(e),n=new URLSearchParams(n);const r=vs(e),i=r.as,o=r.c,l=r.auth,c=r.fetch,u=r.tlsOnly,d=r.nonRepudiation,h=r.timeout,g=r.decrypt,v=await async function(b,m,x,j,S){Wn(b),Hn(m),as(j,'"refreshToken"');const w=new URLSearchParams(S==null?void 0:S.additionalParameters);return w.set("refresh_token",j),Pd(b,m,x,"refresh_token",w,S)}(i,o,l,t,{[Bn]:c,[ln]:!u,additionalParameters:n,DPoP:a==null?void 0:a.DPoP,headers:new Headers(va),signal:ai(h)}).catch(ks),f=async function(b,m,x,j){return ol(b,m,x,void 0,j==null?void 0:j[dr],j==null?void 0:j.recognizedTokenTypes)}(i,o,v,{[dr]:g});let y;try{y=await f}catch(b){if(wl(b,a))return uE(e,t,n,Le(Le({},a),{},{flag:rr}));ks(b)}return y.id_token&&await(d==null?void 0:d(v)),Dd(y),y}async function hE(e,t,n){Ma(e),t=new URLSearchParams(t);const a=vs(e),r=a.as,i=a.c,o=a.auth,l=a.fetch,c=a.tlsOnly,u=a.timeout,d=await async function(v,f,y,b,m){return Wn(v),Hn(f),Pd(v,f,y,"client_credentials",new URLSearchParams(b),m)}(r,i,o,t,{[Bn]:l,[ln]:!c,DPoP:n==null?void 0:n.DPoP,headers:new Headers(va),signal:ai(u)}).catch(ks),h=async function(v,f,y,b){return ol(v,f,y,void 0,void 0,void 0)}(r,i,d);let g;try{g=await h}catch(v){if(wl(v,n))return hE(e,t,Le(Le({},n),{},{flag:rr}));ks(v)}return Dd(g),g}function pv(e,t){Ma(e);const n=vs(e),a=n.as,r=n.c,i=n.tlsOnly,o=n.hybrid,l=n.jarm,c=n.implicit,u=bl(a,"authorization_endpoint",!1,i);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",o?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw $a("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Ld);l&&t.set("response_mode","jwt")}for(const h of t.entries()){var d=kn(h,2);const g=d[0],v=d[1];u.searchParams.append(g,v)}return u}async function pE(e,t,n){Ma(e);const a=pv(e,t),r=vs(e),i=r.as,o=r.c,l=r.auth,c=r.fetch,u=r.tlsOnly,d=r.timeout,h=await async function(f,y,b,m,x){var j;Wn(f),Hn(y);const S=bl(f,"pushed_authorization_request_endpoint",y.use_mtls_endpoint_aliases,(x==null?void 0:x[ln])!==!0),w=new URLSearchParams(m);w.set("client_id",y.client_id);const C=Ad(x==null?void 0:x.headers);C.set("accept","application/json"),(x==null?void 0:x.DPoP)!==void 0&&(M1(x.DPoP),await x.DPoP.addProof(S,C,"POST"));const k=await Gp(f,y,b,S,w,C,x);return x==null||(j=x.DPoP)===null||j===void 0||j.cacheNonce(k,S),k}(i,o,l,a.searchParams,{[Bn]:c,[ln]:!u,DPoP:n==null?void 0:n.DPoP,headers:new Headers(va),signal:ai(d)}).catch(ks),g=async function(f,y,b){if(Wn(f),Hn(y),!Zi(b,Response))throw Nt('"response" must be an instance of Response',Bs);await Fp(b,201,"Pushed Authorization Request Endpoint"),$d(b);const m=await Wp(b);as(m.request_uri,'"response" body "request_uri" property',yt,{body:m});let x=typeof m.expires_in!="number"?parseFloat(m.expires_in):m.expires_in;return Kr(x,!0,'"response" body "expires_in" property',yt,{body:m}),m.expires_in=x,m}(i,o,h);let v;try{v=await g}catch(f){if(wl(f,n))return pE(e,t,Le(Le({},n),{},{flag:rr}));ks(f)}return pv(e,{request_uri:v.request_uri})}function Ma(e){if(!(e instanceof cl))throw $a('"config" must be an instance of Configuration',Md);if(Object.getPrototypeOf(e)!==cl.prototype)throw $a("subclassing Configuration is not allowed",Ld)}function ai(e){return e?AbortSignal.timeout(1e3*e):void 0}function wl(e,t){return!(t==null||!t.DPoP||t.flag===rr)&&function(n){if(n instanceof lx){const a=n.cause,r=a[0];return a.length===1&&r.scheme==="dpop"&&r.parameters.error==="use_dpop_nonce"}return n instanceof Up&&n.error==="use_dpop_nonce"}(e)}Object.freeze(cl.prototype);const rr=Symbol();async function er(e,t,n,a){Ma(e);const r=vs(e),i=r.as,o=r.c,l=r.auth,c=r.fetch,u=r.tlsOnly,d=r.timeout,h=r.decrypt,g=r.nonRepudiation,v=await async function(m,x,j,S,w,C){return Wn(m),Hn(x),as(S,'"grantType"'),Pd(m,x,j,S,new URLSearchParams(w),C)}(i,o,l,t,new URLSearchParams(n),{[Bn]:c,[ln]:!u,DPoP:a==null?void 0:a.DPoP,headers:new Headers(va),signal:ai(d)}).catch(ks);let f;t==="urn:ietf:params:oauth:grant-type:token-exchange"&&(f={n_a:()=>{}});const y=async function(m,x,j,S){return ol(m,x,j,void 0,S==null?void 0:S[dr],S==null?void 0:S.recognizedTokenTypes)}(i,o,v,{[dr]:h,recognizedTokenTypes:f});let b;try{b=await y}catch(m){if(wl(m,a))return er(e,t,n,Le(Le({},a),{},{flag:rr}));ks(m)}return b.id_token&&await(g==null?void 0:g(v)),Dd(b),b}async function RP(e,t,n){Ma(e);const a=vs(e),r=a.as,i=a.c,o=a.auth,l=a.fetch,c=a.tlsOnly,u=a.timeout;return async function(d,h,g,v,f){Wn(d),Hn(h),as(v,'"token"');const y=bl(d,"revocation_endpoint",h.use_mtls_endpoint_aliases,(f==null?void 0:f[ln])!==!0),b=new URLSearchParams(f==null?void 0:f.additionalParameters);b.set("token",v);const m=Ad(f==null?void 0:f.headers);return m.delete("accept"),Gp(d,h,g,y,b,m,f)}(r,i,o,t,{[Bn]:l,[ln]:!c,additionalParameters:new URLSearchParams(n),headers:new Headers(va),signal:ai(u)}).then(gP).catch(ks)}async function IP(e,t,n){if(!Pa(e))throw new qt("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new qt('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!="string")throw new qt("JWS Protected Header incorrect type");if(e.payload===void 0)throw new qt("JWS Payload missing");if(typeof e.signature!="string")throw new qt("JWS Signature missing or incorrect type");if(e.header!==void 0&&!Pa(e.header))throw new qt("JWS Unprotected Header incorrect type");let a={};if(e.protected)try{const y=Od(e.protected);a=JSON.parse(ll.decode(y))}catch{throw new qt("JWS Protected Header is invalid")}if(!Q1(a,e.header))throw new qt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r=Le(Le({},a),e.header);let i=!0;if(rE(qt,new Map([["b64",!0]]),n==null?void 0:n.crit,a,r).has("b64")&&(i=a.b64,typeof i!="boolean"))throw new qt('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const o=r.alg;if(typeof o!="string"||!o)throw new qt('JWS "alg" (Algorithm) Header Parameter missing or invalid');const l=n&&function(y,b){if(b!==void 0&&(!Array.isArray(b)||b.some(m=>typeof m!="string")))throw new TypeError('"'.concat(y,'" option must be an array of strings'));if(b)return new Set(b)}("algorithms",n.algorithms);if(l&&!l.has(o))throw new q1('"alg" (Algorithm) Header Parameter value not allowed');if(i){if(typeof e.payload!="string")throw new qt("JWS Payload must be a string")}else if(typeof e.payload!="string"&&!(e.payload instanceof Uint8Array))throw new qt("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof t=="function"&&(t=await t(a,e),c=!0),iE(o,t,"verify");const u=H1(e.protected!==void 0?Jo(e.protected):new Uint8Array,Jo("."),typeof e.payload=="string"?i?Jo(e.payload):sp.encode(e.payload):e.payload),d=Xb(e.signature,"signature",qt),h=await nE(t,o);if(!await async function(y,b,m,x){const j=await sE(y,b,"verify");eE(y,j);const S=tE(y,j.algorithm);try{return await crypto.subtle.verify(S,j,m,x)}catch{return!1}}(o,h,d,u))throw new Y1;let v;v=i?Xb(e.payload,"payload",qt):typeof e.payload=="string"?sp.encode(e.payload):e.payload;const f={payload:v};return e.protected!==void 0&&(f.protectedHeader=a),e.header!==void 0&&(f.unprotectedHeader=e.header),c?Le(Le({},f),{},{key:h}):f}const kr=e=>Math.floor(e.getTime()/1e3),AP=86400,PP=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function zc(e){const t=PP.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]);let a;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":a=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":a=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":a=Math.round(3600*n);break;case"day":case"days":case"d":a=Math.round(n*AP);break;case"week":case"weeks":case"w":a=Math.round(604800*n);break;default:a=Math.round(31557600*n)}return t[1]==="-"||t[4]==="ago"?-a:a}function ao(e,t){if(!Number.isFinite(t))throw new TypeError("Invalid ".concat(e," input"));return t}const rw=e=>e.includes("/")?e.toLowerCase():"application/".concat(e.toLowerCase());function $P(e,t){let n,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(ll.decode(t))}catch{}if(!Pa(n))throw new aa("JWT Claims Set must be a top-level JSON object");const r=a.typ;if(r&&(typeof e.typ!="string"||rw(e.typ)!==rw(r)))throw new Qn('unexpected "typ" JWT header value',n,"typ","check_failed");const i=a.requiredClaims,o=i===void 0?[]:i,l=a.issuer,c=a.subject,u=a.audience,d=a.maxTokenAge,h=[...o];d!==void 0&&h.push("iat"),u!==void 0&&h.push("aud"),c!==void 0&&h.push("sub"),l!==void 0&&h.push("iss");for(const m of new Set(h.reverse()))if(!(m in n))throw new Qn('missing required "'.concat(m,'" claim'),n,m,"missing");if(l&&!(Array.isArray(l)?l:[l]).includes(n.iss))throw new Qn('unexpected "iss" claim value',n,"iss","check_failed");if(c&&n.sub!==c)throw new Qn('unexpected "sub" claim value',n,"sub","check_failed");if(u&&(g=n.aud,v=typeof u=="string"?[u]:u,!(typeof g=="string"?v.includes(g):Array.isArray(g)&&v.some(Set.prototype.has.bind(new Set(g))))))throw new Qn('unexpected "aud" claim value',n,"aud","check_failed");var g,v;let f;switch(typeof a.clockTolerance){case"string":f=zc(a.clockTolerance);break;case"number":f=a.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const y=a.currentDate,b=kr(y||new Date);if((n.iat!==void 0||d)&&typeof n.iat!="number")throw new Qn('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new Qn('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>b+f)throw new Qn('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new Qn('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=b-f)throw new dv('"exp" claim timestamp check failed',n,"exp","check_failed")}if(d){const m=b-n.iat;if(m-f>(typeof d=="number"?d:zc(d)))throw new dv('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(m<0-f)throw new Qn('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}var hs=new WeakMap;let OP=class{constructor(t){if(tt(this,hs,void 0),!Pa(t))throw new TypeError("JWT Claims Set MUST be an object");Je(hs,this,structuredClone(t))}data(){return sp.encode(JSON.stringify(J(hs,this)))}get iss(){return J(hs,this).iss}set iss(t){J(hs,this).iss=t}get sub(){return J(hs,this).sub}set sub(t){J(hs,this).sub=t}get aud(){return J(hs,this).aud}set aud(t){J(hs,this).aud=t}set jti(t){J(hs,this).jti=t}set nbf(t){typeof t=="number"?J(hs,this).nbf=ao("setNotBefore",t):t instanceof Date?J(hs,this).nbf=ao("setNotBefore",kr(t)):J(hs,this).nbf=kr(new Date)+zc(t)}set exp(t){typeof t=="number"?J(hs,this).exp=ao("setExpirationTime",t):t instanceof Date?J(hs,this).exp=ao("setExpirationTime",kr(t)):J(hs,this).exp=kr(new Date)+zc(t)}set iat(t){t===void 0?J(hs,this).iat=kr(new Date):t instanceof Date?J(hs,this).iat=ao("setIssuedAt",kr(t)):J(hs,this).iat=ao("setIssuedAt",typeof t=="string"?kr(new Date)+zc(t):t)}};async function LP(e,t,n){var a;const r=await async function(o,l,c){if(o instanceof Uint8Array&&(o=ll.decode(o)),typeof o!="string")throw new qt("Compact JWS must be a string or Uint8Array");const u=o.split("."),d=u[0],h=u[1],g=u[2];if(u.length!==3)throw new qt("Invalid Compact JWS");const v=await IP({payload:h,protected:d,signature:g},l,c),f={payload:v.payload,protectedHeader:v.protectedHeader};return typeof l=="function"?Le(Le({},f),{},{key:v.key}):f}(e,t,n);if((a=r.protectedHeader.crit)!==null&&a!==void 0&&a.includes("b64")&&r.protectedHeader.b64===!1)throw new aa("JWTs MUST NOT use unencoded payload");const i={payload:$P(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t=="function"?Le(Le({},i),{},{key:r.key}):i}var hu=new WeakMap,Jn=new WeakMap,vr=new WeakMap;class MP{constructor(t){if(tt(this,hu,void 0),tt(this,Jn,void 0),tt(this,vr,void 0),!(t instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");Je(hu,this,t)}setProtectedHeader(t){return Zb(J(Jn,this),"setProtectedHeader"),Je(Jn,this,t),this}setUnprotectedHeader(t){return Zb(J(vr,this),"setUnprotectedHeader"),Je(vr,this,t),this}async sign(t,n){if(!J(Jn,this)&&!J(vr,this))throw new qt("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Q1(J(Jn,this),J(vr,this)))throw new qt("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const a=Le(Le({},J(Jn,this)),J(vr,this));let r=!0;if(rE(qt,new Map([["b64",!0]]),n==null?void 0:n.crit,J(Jn,this),a).has("b64")&&(r=J(Jn,this).b64,typeof r!="boolean"))throw new qt('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const i=a.alg;if(typeof i!="string"||!i)throw new qt('JWS "alg" (Algorithm) Header Parameter missing or invalid');let o,l,c,u;iE(i,t,"sign"),r?(o=Um(J(hu,this)),l=Jo(o)):(l=J(hu,this),o=""),J(Jn,this)?(c=Um(JSON.stringify(J(Jn,this))),u=Jo(c)):(c="",u=new Uint8Array);const d=H1(u,Jo("."),l),h=await nE(t,i),g=await async function(f,y,b){const m=await sE(f,y,"sign");eE(f,m);const x=await crypto.subtle.sign(tE(f,m.algorithm),m,b);return new Uint8Array(x)}(i,h,d),v={signature:Um(g),payload:o};return J(vr,this)&&(v.header=J(vr,this)),J(Jn,this)&&(v.protected=c),v}}var pu=new WeakMap;let DP=class{constructor(t){tt(this,pu,void 0),Je(pu,this,new MP(t))}setProtectedHeader(t){return J(pu,this).setProtectedHeader(t),this}async sign(t,n){const a=await J(pu,this).sign(t,n);if(a.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return"".concat(a.protected,".").concat(a.payload,".").concat(a.signature)}};var ro=new WeakMap,ba=new WeakMap;let zP=class{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};tt(this,ro,void 0),tt(this,ba,void 0),Je(ba,this,new OP(t))}setIssuer(t){return J(ba,this).iss=t,this}setSubject(t){return J(ba,this).sub=t,this}setAudience(t){return J(ba,this).aud=t,this}setJti(t){return J(ba,this).jti=t,this}setNotBefore(t){return J(ba,this).nbf=t,this}setExpirationTime(t){return J(ba,this).exp=t,this}setIssuedAt(t){return J(ba,this).iat=t,this}setProtectedHeader(t){return Je(ro,this,t),this}async sign(t,n){var a;const r=new DP(J(ba,this).data());if(r.setProtectedHeader(J(ro,this)),Array.isArray((a=J(ro,this))===null||a===void 0?void 0:a.crit)&&J(ro,this).crit.includes("b64")&&J(ro,this).b64===!1)throw new aa("JWTs MUST NOT use unencoded payload");return r.sign(t,n)}};function UP(e){return Pa(e)}var mu,Bm,fu=new WeakMap,Vm=new WeakMap;let FP=class{constructor(t){if(tt(this,fu,void 0),tt(this,Vm,new WeakMap),!function(n){return n&&typeof n=="object"&&Array.isArray(n.keys)&&n.keys.every(UP)}(t))throw new ux("JSON Web Key Set malformed");Je(fu,this,structuredClone(t))}jwks(){return J(fu,this)}async getKey(t,n){const a=Le(Le({},t),n==null?void 0:n.header),r=a.alg,i=a.kid,o=function(d){switch(typeof d=="string"&&d.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";case"ML":return"AKP";default:throw new vn('Unsupported "alg" value for a JSON Web Key Set')}}(r),l=J(fu,this).keys.filter(d=>{let h=o===d.kty;if(h&&typeof i=="string"&&(h=i===d.kid),!h||typeof d.alg!="string"&&o!=="AKP"||(h=r===d.alg),h&&typeof d.use=="string"&&(h=d.use==="sig"),h&&Array.isArray(d.key_ops)&&(h=d.key_ops.includes("verify")),h)switch(r){case"ES256":h=d.crv==="P-256";break;case"ES384":h=d.crv==="P-384";break;case"ES512":h=d.crv==="P-521";break;case"Ed25519":case"EdDSA":h=d.crv==="Ed25519"}return h}),c=l[0],u=l.length;if(u===0)throw new hx;if(u!==1){const d=new K1,h=J(Vm,this);throw d[Symbol.asyncIterator]=ZI(function*(){for(const g of l)try{yield yield YI(iw(h,g,r))}catch{}}),d}return iw(J(Vm,this),c,r)}};async function iw(e,t,n){const a=e.get(t)||e.set(t,{}).get(t);if(a[n]===void 0){const r=await async function(i,o,l){var c;if(!Pa(i))throw new TypeError("JWK must be an object");let u;switch(o!=null||(o=i.alg),u!=null||(u=(c=void 0)!==null&&c!==void 0?c:i.ext),i.kty){case"oct":if(typeof i.k!="string"||!i.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Od(i.k);case"RSA":if("oth"in i&&i.oth!==void 0)throw new vn('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return ch(Le(Le({},i),{},{alg:o,ext:u}));case"AKP":if(typeof i.alg!="string"||!i.alg)throw new TypeError('missing "alg" (Algorithm) Parameter value');if(o!==void 0&&o!==i.alg)throw new TypeError("JWK alg and alg option value mismatch");return ch(Le(Le({},i),{},{ext:u}));case"EC":case"OKP":return ch(Le(Le({},i),{},{alg:o,ext:u}));default:throw new vn('Unsupported "kty" (Key Type) Parameter value')}}(Le(Le({},t),{},{ext:!0}),n);if(r instanceof Uint8Array||r.type!=="public")throw new ux("JSON Web Key Set members must be public keys");a[n]=r}return a[n]}function ow(e){const t=new FP(e),n=async(a,r)=>t.getKey(a,r);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}let mv;(typeof navigator>"u"||(mu=navigator.userAgent)===null||mu===void 0||(Bm=mu.startsWith)===null||Bm===void 0||!Bm.call(mu,"Mozilla/5.0 "))&&(mv="".concat("jose","/").concat("v6.2.3"));const mE=Symbol(),uh=Symbol();var qm=new WeakMap,Km=new WeakMap,Jm=new WeakMap,gu=new WeakMap,ci=new WeakMap,Fa=new WeakMap,yr=new WeakMap,Ym=new WeakMap,di=new WeakMap,ui=new WeakMap;let GP=class{constructor(t,n){if(tt(this,qm,void 0),tt(this,Km,void 0),tt(this,Jm,void 0),tt(this,gu,void 0),tt(this,ci,void 0),tt(this,Fa,void 0),tt(this,yr,void 0),tt(this,Ym,void 0),tt(this,di,void 0),tt(this,ui,void 0),!(t instanceof URL))throw new TypeError("url must be an instance of URL");var a,r;Je(qm,this,new URL(t.href)),Je(Km,this,typeof(n==null?void 0:n.timeoutDuration)=="number"?n==null?void 0:n.timeoutDuration:5e3),Je(Jm,this,typeof(n==null?void 0:n.cooldownDuration)=="number"?n==null?void 0:n.cooldownDuration:3e4),Je(gu,this,typeof(n==null?void 0:n.cacheMaxAge)=="number"?n==null?void 0:n.cacheMaxAge:6e5),Je(yr,this,new Headers(n==null?void 0:n.headers)),mv&&!J(yr,this).has("User-Agent")&&J(yr,this).set("User-Agent",mv),J(yr,this).has("accept")||(J(yr,this).set("accept","application/json"),J(yr,this).append("accept","application/jwk-set+json")),Je(Ym,this,n==null?void 0:n[mE]),(n==null?void 0:n[uh])!==void 0&&(Je(ui,this,n==null?void 0:n[uh]),a=n==null?void 0:n[uh],r=J(gu,this),typeof a=="object"&&a!==null&&"uat"in a&&typeof a.uat=="number"&&!(Date.now()-a.uat>=r)&&"jwks"in a&&Pa(a.jwks)&&Array.isArray(a.jwks.keys)&&Array.prototype.every.call(a.jwks.keys,Pa)&&(Je(ci,this,J(ui,this).uat),Je(di,this,ow(J(ui,this).jwks))))}pendingFetch(){return!!J(Fa,this)}coolingDown(){return typeof J(ci,this)=="number"&&Date.now()<J(ci,this)+J(Jm,this)}fresh(){return typeof J(ci,this)=="number"&&Date.now()<J(ci,this)+J(gu,this)}jwks(){var t;return(t=J(di,this))===null||t===void 0?void 0:t.jwks()}async getKey(t,n){J(di,this)&&this.fresh()||await this.reload();try{return await J(di,this).call(this,t,n)}catch(a){if(a instanceof hx&&this.coolingDown()===!1)return await this.reload(),J(di,this).call(this,t,n);throw a}}async reload(){J(Fa,this)&&(typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel")&&Je(Fa,this,void 0),J(Fa,this)||Je(Fa,this,async function(t,n,a){const i=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(t,{method:"GET",signal:a,redirect:"manual",headers:n}).catch(o=>{throw o.name==="TimeoutError"?new J1:o});if(i.status!==200)throw new Cs("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new Cs("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(J(qm,this).href,J(yr,this),AbortSignal.timeout(J(Km,this)),J(Ym,this)).then(t=>{Je(di,this,ow(t)),J(ui,this)&&(J(ui,this).uat=Date.now(),J(ui,this).jwks=t),Je(ci,this,Date.now()),Je(Fa,this,void 0)}).catch(t=>{throw Je(Fa,this,void 0),t})),await J(Fa,this)}};const WP=["mfaToken"],HP=["mfaToken"];var hi,vu,Hl,pi,Bl,Vl,ql,Kl,yu,xu,Uc,Fc,Di,Gc,Wc,Jl,io,hh,Yl,ph,ju,Rn,bu,wu,ea,Na,Lo,it,un,Zl,Hc,Yo,Su,pt;function la(e){var t,n;if(typeof e!="object"||e===null)return{error:"unknown_error",error_description:String(e)};const a=e,r={error:(t=a.error)!==null&&t!==void 0?t:"",error_description:(n=a.error_description)!==null&&n!==void 0?n:"",message:a.message};if(a.error==="mfa_required"&&a.cause){r.mfa_token=typeof a.cause.mfa_token=="string"?a.cause.mfa_token:void 0;const i=a.cause.mfa_requirements;typeof i=="object"&&i!==null&&(r.mfa_requirements=i)}return r}var lw=class extends Error{constructor(e,t){super(t),Pe(this,"code",void 0),this.name="NotSupportedError",this.code=e}},ya=class extends Error{constructor(e,t,n){super(t),Pe(this,"cause",void 0),Pe(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}}},cw=class extends ya{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError"}},BP=class extends ya{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError"}},VP=class extends ya{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError"}},qP=class extends ya{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError"}},Zm=class extends ya{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode"}},ca=class extends ya{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError"}},KP=class extends ya{constructor(e,t){super("token_revocation_error",e,t),this.name="TokenRevocationError"}},xr=class extends Error{constructor(e){super(e),Pe(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError"}},Xm=class extends ya{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),Pe(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError"}},JP=class extends ya{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError"}},YP=class extends ya{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError"}},ZP=class extends ya{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError"}},fE=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),Pe(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError"}},yc=class extends Error{constructor(e){super(e),Pe(this,"code","organization_validation_error"),this.name="OrganizationValidationError"}};function fv(e){return Object.entries(e).filter(t=>kn(t,2)[1]!==void 0).reduce((t,n)=>Le(Le({},t),{},{[n[0]]:n[1]}),{})}function px(e){if(!e.trim())throw new yc("organization must not be blank")}function mx(e,t){if(!e)return;const n=t.trim();if(n.startsWith("org_")){const a=e.org_id;if(typeof a!="string")throw new yc("Organization Id (org_id) claim must be a string present in the ID token");if(a!==n)throw new yc('Organization Id (org_id) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(a,'"'))}else{const a=e.org_name;if(typeof a!="string")throw new yc("Organization Name (org_name) claim must be a string present in the ID token");if(a.toLowerCase()!==n.toLowerCase())throw new yc('Organization Name (org_name) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(a,'"'))}}var zd=class extends Error{constructor(t,n,a){super(n),Pe(this,"cause",void 0),Pe(this,"code",void 0),this.code=t,this.cause=a&&{error:a.error,error_description:a.error_description,message:a.message}}},gv=class extends zd{constructor(t,n){super("mfa_list_authenticators_error",t,n),this.name="MfaListAuthenticatorsError"}},vv=class extends zd{constructor(t,n){super("mfa_enrollment_error",t,n),this.name="MfaEnrollmentError"}},dw=class extends zd{constructor(t,n){super("mfa_delete_authenticator_error",t,n),this.name="MfaDeleteAuthenticatorError"}},yv=class extends zd{constructor(t,n){super("mfa_challenge_error",t,n),this.name="MfaChallengeError"}},uw=class extends zd{constructor(t,n){super("mfa_verify_error",t,n),this.name="MfaVerifyError"}};function XP(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var hn=class gE{constructor(t,n,a,r,i,o,l){Pe(this,"accessToken",void 0),Pe(this,"idToken",void 0),Pe(this,"refreshToken",void 0),Pe(this,"expiresAt",void 0),Pe(this,"scope",void 0),Pe(this,"claims",void 0),Pe(this,"authorizationDetails",void 0),Pe(this,"tokenType",void 0),Pe(this,"issuedTokenType",void 0),Pe(this,"recoveryCode",void 0),Pe(this,"act",void 0),this.accessToken=t,this.idToken=a,this.refreshToken=r,this.expiresAt=n,this.scope=i,this.claims=o,this.authorizationDetails=l}static fromTokenEndpointResponse(t){const n=t.id_token?t.claims():void 0,a=new gE(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return a.tokenType=t.token_type,a.issuedTokenType=t.issued_token_type,a}},QP={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},e2=(hi=new WeakMap,vu=new WeakMap,Hl=new WeakMap,pi=new WeakMap,Bl=new WeakMap,class{constructor(e){var t;tt(this,hi,void 0),tt(this,vu,void 0),tt(this,Hl,void 0),tt(this,pi,void 0),tt(this,Bl,void 0),Je(hi,this,"https://".concat(e.domain)),Je(vu,this,e.clientId),Je(Hl,this,e.clientSecret),Je(pi,this,(t=e.customFetch)!==null&&t!==void 0?t:function(){return fetch(...arguments)}),Je(Bl,this,e.getConfiguration)}async listAuthenticators(e){const t="".concat(J(hi,this),"/mfa/authenticators"),n=e.mfaToken,a=await J(pi,this).call(this,t,{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!a.ok){let r;try{r=await a.json()}catch{throw new gv("Failed to list authenticators")}throw new gv(r.error_description||"Failed to list authenticators",r)}return(await a.json()).map(XP)}async enrollAuthenticator(e){const t="".concat(J(hi,this),"/mfa/associate"),n=e.mfaToken,a=Tb(e,WP),r={authenticator_types:a.authenticatorTypes};"oobChannels"in a&&(r.oob_channels=a.oobChannels),"phoneNumber"in a&&a.phoneNumber&&(r.phone_number=a.phoneNumber),"email"in a&&a.email&&(r.email=a.email);const i=await J(pi,this).call(this,t,{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let o;try{o=await i.json()}catch{throw new vv("Failed to enroll authenticator")}throw new vv(o.error_description||"Failed to enroll authenticator",o)}return function(o){if(o.authenticator_type==="otp")return{authenticatorType:"otp",secret:o.secret,barcodeUri:o.barcode_uri,recoveryCodes:o.recovery_codes,id:o.id};if(o.authenticator_type==="oob")return{authenticatorType:"oob",oobChannel:o.oob_channel,oobCode:o.oob_code,bindingMethod:o.binding_method,id:o.id,barcodeUri:o.barcode_uri,recoveryCodes:o.recovery_codes};throw new Error("Unexpected authenticator type: ".concat(o.authenticator_type))}(await i.json())}async deleteAuthenticator(e){const t=e.authenticatorId,n=e.mfaToken,a="".concat(J(hi,this),"/mfa/authenticators/").concat(encodeURIComponent(t)),r=await J(pi,this).call(this,a,{method:"DELETE",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!r.ok){let i;try{i=await r.json()}catch{throw new dw("Failed to delete authenticator")}throw new dw(i.error_description||"Failed to delete authenticator",i)}}async challengeAuthenticator(e){const t="".concat(J(hi,this),"/mfa/challenge"),n=e.mfaToken,a=Tb(e,HP),r={mfa_token:n,client_id:J(vu,this),challenge_type:a.challengeType};J(Hl,this)&&(r.client_secret=J(Hl,this)),a.authenticatorId&&(r.authenticator_id=a.authenticatorId);const i=await J(pi,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let o;try{o=await i.json()}catch{throw new yv("Failed to challenge authenticator")}throw new yv(o.error_description||"Failed to challenge authenticator",o)}return function(o){const l={challengeType:o.challenge_type};return o.oob_code!==void 0&&(l.oobCode=o.oob_code),o.binding_method!==void 0&&(l.bindingMethod=o.binding_method),l}(await i.json())}async verify(e){if(!J(Bl,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const t=await J(Bl,this).call(this),n={mfa_token:e.mfaToken};e.audience&&(n.audience=e.audience),e.factorType==="otp"?n.otp=e.otp:e.factorType==="oob"?(n.oob_code=e.oobCode,e.bindingCode&&(n.binding_code=e.bindingCode)):e.factorType==="recovery-code"&&(n.recovery_code=e.recoveryCode);try{const o=await er(t,QP[e.factorType],n),l=hn.fromTokenEndpointResponse(o);return o.recovery_code&&(l.recoveryCode=o.recovery_code),l}catch(o){var a,r,i;if(o instanceof uw)throw o;const l=o;throw new uw(l.error_description||l.message||"Failed to verify MFA challenge",{error:(a=l.error)!==null&&a!==void 0?a:"mfa_verify_error",error_description:(r=(i=l.error_description)!==null&&i!==void 0?i:l.message)!==null&&r!==void 0?r:"Failed to verify MFA challenge"})}}}),fx=class extends Error{constructor(t,n,a){super(n),Pe(this,"cause",void 0),Pe(this,"code",void 0),this.code=t,this.cause=a&&{error:a.error,error_description:a.error_description,message:a.message}}},t2=class extends fx{constructor(t,n){super("passkey_register_error",t,n),this.name="PasskeyRegisterError"}},s2=class extends fx{constructor(t,n){super("passkey_challenge_error",t,n),this.name="PasskeyChallengeError"}},n2=class extends fx{constructor(t,n){super("passkey_get_token_error",t,n),this.name="PasskeyGetTokenError",this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}}},vE="urn:okta:params:oauth:grant-type:webauthn",a2=(Vl=new WeakMap,ql=new WeakMap,Kl=new WeakMap,yu=new WeakMap,xu=new WeakSet,class{constructor(e){var t;Dp(this,xu),tt(this,Vl,void 0),tt(this,ql,void 0),tt(this,Kl,void 0),tt(this,yu,void 0),Je(Vl,this,"https://".concat(e.domain)),Je(ql,this,e.clientId),Je(Kl,this,(t=e.customFetch)!==null&&t!==void 0?t:function(){return fetch(...arguments)}),Je(yu,this,e.grantRequest)}async register(e){const t="".concat(J(Vl,this),"/passkey/register"),n=Le(Le(Le(Le(Le(Le(Le(Le({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),a={client_id:J(ql,this),user_profile:n};e.realm&&(a.realm=e.realm),e.organization&&(a.organization=e.organization),e.userMetadata&&(a.user_metadata=e.userMetadata);const r=await J(Kl,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!r.ok){const l=await at(xu,this,hw).call(this,r);throw new t2(l.error_description||"Failed to request signup challenge",l)}return{authSession:(o=await r.json()).auth_session,authnParamsPublicKey:Le({},o.authn_params_public_key)};var o}async challenge(e){const t="".concat(J(Vl,this),"/passkey/challenge"),n={client_id:J(ql,this)};e!=null&&e.realm&&(n.realm=e.realm),e!=null&&e.organization&&(n.organization=e.organization);const a=await J(Kl,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok){const o=await at(xu,this,hw).call(this,a);throw new s2(o.error_description||"Failed to request login challenge",o)}return{authSession:(i=await a.json()).auth_session,authnParamsPublicKey:Le({},i.authn_params_public_key)};var i}async getTokenByPasskey(e){e.organization!==void 0&&px(e.organization);const t=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});let n;e.realm&&t.append("realm",e.realm),e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),e.organization&&t.append("organization",e.organization);try{n=await J(yu,this).call(this,vE,t)}catch(a){const r=la(a);throw new n2(r.error_description||"Failed to exchange passkey credential for tokens.",r)}return e.organization&&mx(n.claims,e.organization),n}});async function hw(e){try{return await e.json()}catch{return{error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText)}}}var Hp=class extends Error{constructor(t,n,a){super(n),Pe(this,"cause",void 0),Pe(this,"code",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.cause=a&&{error:a.error,error_description:a.error_description,message:a.message,mfa_token:a.mfa_token,mfa_requirements:a.mfa_requirements}}},xv=class extends Hp{constructor(t,n){super("passwordless_start_error",t,n),this.name="PasswordlessStartError"}},yE=class extends Hp{constructor(t,n){super("passwordless_verify_error",t,n),this.name="PasswordlessVerifyError"}},pw=class extends Hp{constructor(t,n){super("passwordless_db_get_token_error",t,n),this.name="PasswordlessDbGetTokenError"}},mh=class extends Hp{constructor(t,n,a,r){super("passwordless_challenge_error",t,a),Pe(this,"statusCode",void 0),Pe(this,"validationErrors",void 0),this.name="PasswordlessChallengeError",this.statusCode=n,this.validationErrors=r}};function jv(e){return/^\+[1-9]\d{1,14}$/.test(e)}async function xE(e,t,n){if(e.useMtls)return{};if(e.clientAssertionSigningKey){var a;const r=(a=e.clientAssertionSigningAlg)!==null&&a!==void 0?a:"RS256",i=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await aE(e.clientAssertionSigningKey,r);return{client_assertion:await new zP({}).setProtectedHeader({alg:r}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(i),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return{client_secret:e.clientSecret};throw new fE}var r2=(Uc=new WeakMap,Fc=new WeakMap,Di=new WeakMap,Gc=new WeakMap,Wc=new WeakMap,Jl=new WeakMap,io=new WeakSet,class{constructor(e){var t;Dp(this,io),tt(this,Uc,void 0),tt(this,Fc,void 0),tt(this,Di,void 0),tt(this,Gc,void 0),tt(this,Wc,void 0),tt(this,Jl,void 0),Je(Fc,this,e.domain),Je(Uc,this,"https://".concat(e.domain)),Je(Di,this,e.clientId),Je(Gc,this,(t=e.customFetch)!==null&&t!==void 0?t:function(){return fetch(...arguments)}),Je(Wc,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls}),Je(Jl,this,e.grantRequest)}async sendEmail(e){await at(io,this,mw).call(this,function(t){var n;const a=(n=t.send)!==null&&n!==void 0?n:"code",r={email:t.email,connection:"email",send:a};return a==="link"&&t.authParams&&(r.authParams=t.authParams),r}(e),"Failed to send passwordless email",e.language)}async sendSms(e){if(!jv(e.phoneNumber))throw new xv("Phone number must be in E.164 format (e.g. +14155550100).");await at(io,this,mw).call(this,function(t){return{phone_number:t.phoneNumber,connection:"sms"}}(e),"Failed to send passwordless SMS",e.language)}async challengeWithEmail(e){const t=function(n){var a;return{email:n.email,connection:n.connection,allow_signup:(a=n.allowSignup)!==null&&a!==void 0&&a}}(e);return at(io,this,fw).call(this,t,"Failed to request email OTP challenge")}async challengeWithPhoneNumber(e){if(!jv(e.phoneNumber))throw new mh("Phone number must be in E.164 format (e.g. +14155550100).",0,void 0,void 0);const t=function(n){var a;const r={phone_number:n.phoneNumber,connection:n.connection,allow_signup:(a=n.allowSignup)!==null&&a!==void 0&&a};return n.deliveryMethod&&(r.delivery_method=n.deliveryMethod),r}(e);return at(io,this,fw).call(this,t,"Failed to request phone OTP challenge")}async getTokenByPasswordlessDbConnection(e){const t=new URLSearchParams({auth_session:e.authSession,otp:e.otp});if(e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),!J(Jl,this))throw new pw("Missing grant request delegate.",la(new Error("missing grantRequest")));try{return await J(Jl,this).call(this,"http://auth0.com/oauth/grant-type/passwordless/otp",t)}catch(n){throw new pw("There was an error while trying to request a token.",la(n))}}});async function mw(e,t,n){var a;const r=await xE(J(Wc,this),J(Di,this),J(Fc,this)),i=Le(Le({client_id:J(Di,this)},e),r);let o,l;try{o=await J(Gc,this).call(this,"".concat(J(Uc,this),"/passwordless/start"),{method:"POST",headers:Le({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(i)})}catch{throw new xv("".concat(t,": a network error occurred."))}if(!o.ok){if(o.status!==204)try{l=await o.json()}catch{l=void 0}throw new xv(((a=l)===null||a===void 0?void 0:a.error_description)||t,l)}}async function fw(e,t){var n,a;const r=await xE(J(Wc,this),J(Di,this),J(Fc,this)),i=Le(Le({client_id:J(Di,this)},e),r);let o,l;try{o=await J(Gc,this).call(this,"".concat(J(Uc,this),"/otp/challenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}catch{throw new mh("challenge error: a network error occurred.",0,void 0,void 0)}if(o.ok){let c;try{c=await o.json()}catch{throw new mh("".concat(t,": could not parse the response body."),o.status,void 0,void 0)}return{authSession:c.auth_session}}try{l=await o.json()}catch{l=void 0}throw new mh(((n=l)===null||n===void 0?void 0:n.error_description)||t,o.status,l,(a=l)===null||a===void 0?void 0:a.validation_errors)}var jE=class extends Error{constructor(t,n,a){super(n),Pe(this,"cause",void 0),Pe(this,"code",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.cause=a&&{error:a.error,error_description:a.error_description,message:a.message}}},gw=class extends jE{constructor(t,n){super("signup_error",t,n),this.name="SignUpError"}},Qm=class extends jE{constructor(t,n){super("change_password_error",t,n),this.name="ChangePasswordError"}};function vw(e,t,n){for(const a of t)if(e[a]===null||e[a]===void 0||e[a]==="")throw new n('Required parameter "'.concat(String(a),'" was null, undefined, or empty.'))}var i2=(hh=new WeakMap,Yl=new WeakMap,ph=new WeakMap,ju=new WeakSet,class{constructor(e){var t;Dp(this,ju),tt(this,hh,void 0),tt(this,Yl,void 0),tt(this,ph,void 0),Je(hh,this,"https://".concat(e.domain)),Je(Yl,this,e.clientId),Je(ph,this,(t=e.customFetch)!==null&&t!==void 0?t:function(){return fetch(...arguments)})}async signUp(e){var t;vw(e,["email","password","connection"],gw);const n=Le({client_id:(t=e.clientId)!==null&&t!==void 0?t:J(Yl,this)},function(r){const i={email:r.email,password:r.password,connection:r.connection};return r.username!==void 0&&(i.username=r.username),r.givenName!==void 0&&(i.given_name=r.givenName),r.familyName!==void 0&&(i.family_name=r.familyName),r.name!==void 0&&(i.name=r.name),r.nickname!==void 0&&(i.nickname=r.nickname),r.picture!==void 0&&(i.picture=r.picture),r.userMetadata!==void 0&&(i.user_metadata=r.userMetadata),i}(e)),a=await at(ju,this,yw).call(this,"/dbconnections/signup",n,gw,"Failed to sign up");return function(r){var i,o;return{id:(i=(o=r._id)!==null&&o!==void 0?o:r.user_id)!==null&&i!==void 0?i:r.id,email:typeof r.email=="string"?r.email:"",emailVerified:!!r.email_verified,username:r.username,givenName:r.given_name,familyName:r.family_name,name:r.name,nickname:r.nickname,picture:r.picture,userMetadata:r.user_metadata}}(await a.json())}async changePassword(e){var t;if(vw(e,["connection"],Qm),!e.email&&!e.username)throw new Qm('Either "email" or "username" is required.');const n=Le({client_id:(t=e.clientId)!==null&&t!==void 0?t:J(Yl,this)},function(a){const r={connection:a.connection};return a.email!==void 0&&(r.email=a.email),a.username!==void 0&&(r.username=a.username),a.organization!==void 0&&(r.organization=a.organization),r}(e));return(await at(ju,this,yw).call(this,"/dbconnections/change_password",n,Qm,"Failed to request a password change")).text()}});async function yw(e,t,n,a){let r;try{r=await J(ph,this).call(this,"".concat(J(hh,this)).concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{throw new n("".concat(a,": a network error occurred."))}if(r.ok)return r;const i=await async function(o){let l;try{l=await o.json()}catch{return}return typeof l.error=="string"?l:typeof l.code=="string"?{error:l.code,error_description:typeof l.description=="string"?l.description:""}:void 0}(r);throw new n((i==null?void 0:i.error_description)||a,i)}var o2=(Rn=new WeakMap,bu=new WeakMap,wu=new WeakMap,class{constructor(e,t){tt(this,Rn,new Map),tt(this,bu,void 0),tt(this,wu,void 0),Je(wu,this,Math.max(1,Math.floor(e))),Je(bu,this,Math.max(0,Math.floor(t)))}get(e){const t=J(Rn,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return J(Rn,this).delete(e),J(Rn,this).set(e,t),t.value;J(Rn,this).delete(e)}}set(e,t){for(J(Rn,this).has(e)&&J(Rn,this).delete(e),J(Rn,this).set(e,{value:t,expiresAt:Date.now()+J(bu,this)});J(Rn,this).size>J(wu,this);){const n=J(Rn,this).keys().next().value;if(n===void 0)break;J(Rn,this).delete(n)}}}),xw=new Map;function jw(e){return{ttlMs:1e3*(typeof(e==null?void 0:e.ttl)=="number"?e.ttl:600),maxEntries:typeof(e==null?void 0:e.maxEntries)=="number"&&e.maxEntries>0?e.maxEntries:100}}var bw=class{static createDiscoveryCache(t){const n=(a=t.maxEntries,r=t.ttlMs,"".concat(a,":").concat(r));var a,r;let i=(o=n,xw.get(o));var o;return i||(i=new o2(t.maxEntries,t.ttlMs),xw.set(n,i)),i}static createJwksCache(){return{}}},bv="openid profile email offline_access",l2=Object.freeze(new Set(["grant_type","client_id","client_secret","client_assertion","client_assertion_type","subject_token","subject_token_type","requested_token_type","actor_token","actor_token_type","audience","aud","resource","resources","resource_indicator","scope","connection","login_hint","organization","assertion"]));function bE(e){if(e==null)throw new ca("subject_token is required");if(typeof e!="string")throw new ca("subject_token must be a string");if(e.trim().length===0)throw new ca("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new ca("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new ca("subject_token must not include the 'Bearer ' prefix")}function wE(e,t){if(t)for(const a of Object.entries(t)){var n=kn(a,2);const r=n[0],i=n[1];if(!l2.has(r))if(Array.isArray(i)){if(i.length>20)throw new ca("Parameter '".concat(r,"' exceeds maximum array size of ").concat(20));i.forEach(o=>{e.append(r,o)})}else e.append(r,i)}}var SE="urn:ietf:params:oauth:token-type:access_token",c2=(ea=new WeakMap,Na=new WeakMap,Lo=new WeakMap,it=new WeakMap,un=new WeakMap,Zl=new WeakMap,Hc=new WeakMap,Yo=new WeakMap,Su=new WeakMap,pt=new WeakSet,class{constructor(e){var t,n,a,r;if(Dp(this,pt),tt(this,ea,void 0),tt(this,Na,void 0),tt(this,Lo,void 0),tt(this,it,void 0),tt(this,un,void 0),tt(this,Zl,void 0),tt(this,Hc,void 0),tt(this,Yo,void 0),tt(this,Su,void 0),Pe(this,"mfa",void 0),Pe(this,"passkey",void 0),Pe(this,"passwordless",void 0),Pe(this,"database",void 0),Je(it,this,e),e.useMtls&&!e.customFetch)throw new lw("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");Je(un,this,function(o,l){if(l.enabled===!1)return o;const c={name:l.name,version:l.version},u=btoa(JSON.stringify(c));return async(d,h)=>{const g=d instanceof Request?new Headers(d.headers):new Headers;return h!=null&&h.headers&&new Headers(h.headers).forEach((v,f)=>{g.set(f,v)}),g.set("Auth0-Client",u),o(d,Le(Le({},h),{},{headers:g}))}}((t=e.customFetch)!==null&&t!==void 0?t:function(){return fetch(...arguments)},((n=e.telemetry)==null?void 0:n.enabled)===!1?n:{enabled:!0,name:(a=n==null?void 0:n.name)!==null&&a!==void 0?a:"@auth0/auth0-auth-js",version:(r=n==null?void 0:n.version)!==null&&r!==void 0?r:"1.12.0"}));const i=jw(e.discoveryCache);Je(Hc,this,bw.createDiscoveryCache(i)),Je(Yo,this,new Map),Je(Su,this,bw.createJwksCache()),this.mfa=new e2({domain:J(it,this).domain,clientId:J(it,this).clientId,clientSecret:J(it,this).clientSecret,customFetch:J(un,this),getConfiguration:async()=>(await at(pt,this,os).call(this)).configuration}),this.passkey=new a2({domain:J(it,this).domain,clientId:J(it,this).clientId,customFetch:J(un,this),grantRequest:async(o,l)=>{const c=(await at(pt,this,os).call(this)).serverMetadata,u=await at(pt,this,wv).call(this,c);u[ua]=function(h,g){return(v,f)=>{const y=f==null?void 0:f.body;if(g!==vE||!(y instanceof URLSearchParams))return h(v,f);const b={};for(const j of y){var m=kn(j,2);const S=m[0],w=m[1];b[S]=S==="authn_response"?JSON.parse(w):w}const x=new Headers(f==null?void 0:f.headers);return x.set("Content-Type","application/json"),h(v,Le(Le({},f),{},{headers:x,body:JSON.stringify(b)}))}}(J(un,this),o);const d=await er(u,o,l);return hn.fromTokenEndpointResponse(d)}}),this.passwordless=new r2({domain:J(it,this).domain,clientId:J(it,this).clientId,customFetch:J(un,this),clientSecret:J(it,this).clientSecret,clientAssertionSigningKey:J(it,this).clientAssertionSigningKey,clientAssertionSigningAlg:J(it,this).clientAssertionSigningAlg,useMtls:J(it,this).useMtls,grantRequest:async(o,l)=>{const c=(await at(pt,this,os).call(this)).configuration,u=await er(c,o,l);return hn.fromTokenEndpointResponse(u)}}),this.database=new i2({domain:J(it,this).domain,clientId:J(it,this).clientId,customFetch:J(un,this)})}async getServerMetadata(){return(await at(pt,this,os).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await at(pt,this,os).call(this)).serverMetadata;if(e!=null&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new lw("par_not_supported_error","The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");try{return await at(pt,this,ef).call(this,e)}catch(n){throw new JP(n)}}async buildLinkUserUrl(e){try{const t=await at(pt,this,ef).call(this,{authorizationParams:Le(Le({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:"openid link_account offline_access",id_token_hint:e.idToken})});return{linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(t){throw new YP(t)}}async buildUnlinkUserUrl(e){try{const t=await at(pt,this,ef).call(this,{authorizationParams:Le(Le({},e.authorizationParams),{},{requested_connection:e.connection,scope:"openid unlink_account",id_token_hint:e.idToken})});return{unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(t){throw new ZP(t)}}async backchannelAuthentication(e){const t=await at(pt,this,os).call(this),n=t.configuration,a=t.serverMetadata,r=fv(Le(Le({},J(it,this).authorizationParams),e==null?void 0:e.authorizationParams)),i=new URLSearchParams(Le(Le({scope:bv},r),{},{client_id:J(it,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:a.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&i.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const o=await nw(n,i),l=await dE(n,o);return hn.fromTokenEndpointResponse(l)}catch(o){throw new Xm(o)}}async initiateBackchannelAuthentication(e){const t=await at(pt,this,os).call(this),n=t.configuration,a=t.serverMetadata,r=fv(Le(Le({},J(it,this).authorizationParams),e==null?void 0:e.authorizationParams)),i=new URLSearchParams(Le(Le({scope:bv},r),{},{client_id:J(it,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:a.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&i.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const o=await nw(n,i);return{authReqId:o.auth_req_id,expiresIn:o.expires_in,interval:o.interval}}catch(o){throw new Xm(o)}}async backchannelAuthenticationGrant(e){let t=e.authReqId;const n=(await at(pt,this,os).call(this)).configuration,a=new URLSearchParams({auth_req_id:t});try{const r=await er(n,"urn:openid:params:grant-type:ciba",a);return hn.fromTokenEndpointResponse(r)}catch(r){throw new Xm(r)}}async getTokenForConnection(e){var t;if(e.refreshToken&&e.accessToken)throw new Zm("Either a refresh or access token should be specified, but not both.");const n=(t=e.accessToken)!==null&&t!==void 0?t:e.refreshToken;if(!n)throw new Zm("Either a refresh or access token must be specified.");try{return await this.exchangeToken({connection:e.connection,subjectToken:n,subjectTokenType:e.accessToken?SE:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint})}catch(a){throw a instanceof ca?new Zm(a.message,a.cause):a}}async exchangeToken(e){return"connection"in e?at(pt,this,u2).call(this,e):at(pt,this,h2).call(this,e)}async getTokenByCode(e,t){const n=(await at(pt,this,os).call(this)).configuration;let a;t.organization!==void 0&&px(t.organization);try{const r=await hv(n,e,{pkceCodeVerifier:t.codeVerifier});a=hn.fromTokenEndpointResponse(r)}catch(r){throw new cw("There was an error while trying to request a token.",la(r))}return t.organization&&mx(a.claims,t.organization),a}async getTokenByMagicLinkCode(e,t){const n=(await at(pt,this,os).call(this)).configuration;try{const a=await hv(n,e,{expectedState:t==null?void 0:t.expectedState});return hn.fromTokenEndpointResponse(a)}catch(a){const r=a instanceof Error&&a.message?a.message:"There was an error while trying to request a token.";throw new cw(r,a)}}async getTokenByRefreshToken(e){const t=(await at(pt,this,os).call(this)).configuration,n=new URLSearchParams;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope);try{const a=await uE(t,e.refreshToken,n);return hn.fromTokenEndpointResponse(a)}catch(a){throw new VP("The access token has expired and there was an error while trying to refresh it.",la(a))}}async revokeToken(e){const t=(await at(pt,this,os).call(this)).configuration,n={};e.tokenTypeHint&&(n.token_type_hint=e.tokenTypeHint);try{await RP(t,e.token,n)}catch(a){throw new KP("An error occurred while trying to revoke the token.",la(a))}}async getTokenByPassword(e){const t=(await at(pt,this,os).call(this)).configuration,n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.realm&&n.append("realm",e.realm);let a=t;if(e.auth0ForwardedFor){const r=await at(pt,this,gx).call(this);a=new cl(t.serverMetadata(),J(it,this).clientId,J(it,this).clientSecret,r),a[ua]=(i,o)=>J(un,this).call(this,i,Le(Le({},o),{},{headers:Le(Le({},o.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{const r=await er(a,"password",n);return hn.fromTokenEndpointResponse(r)}catch(r){throw new qP("There was an error while trying to request a token.",la(r))}}async getTokenByPasswordlessEmail(e){const t=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),at(pt,this,ww).call(this,t)}async getTokenByPasswordlessSms(e){if(!jv(e.phoneNumber))throw new yE("Phone number must be in E.164 format (e.g. +14155550100).");const t=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),at(pt,this,ww).call(this,t)}async getTokenByClientCredentials(e){const t=(await at(pt,this,os).call(this)).configuration;try{const n=new URLSearchParams({audience:e.audience});e.organization&&n.append("organization",e.organization);const a=await hE(t,n);return hn.fromTokenEndpointResponse(a)}catch(n){throw new BP("There was an error while trying to request a token.",la(n))}}async buildLogoutUrl(e){const t=await at(pt,this,os).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const a=new URL("https://".concat(J(it,this).domain,"/v2/logout"));return a.searchParams.set("returnTo",e.returnTo),a.searchParams.set("client_id",J(it,this).clientId),a}return function(a,r){Ma(a);const i=vs(a),o=i.as,l=i.c,c=bl(o,"end_session_endpoint",!1,i.tlsOnly);(r=new URLSearchParams(r)).has("client_id")||r.set("client_id",l.client_id);for(const d of r.entries()){var u=kn(d,2);const h=u[0],g=u[1];c.searchParams.append(h,g)}return c}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){const t=(await at(pt,this,os).call(this)).serverMetadata,n=jw(J(it,this).discoveryCache),a=t.jwks_uri;J(Zl,this)||Je(Zl,this,function(i,o){const l=new GP(i,o),c=async(u,d)=>l.getKey(u,d);return Object.defineProperties(c,{coolingDown:{get:()=>l.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>l.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>l.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>l.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>l.jwks(),enumerable:!0,configurable:!1,writable:!1}}),c}(new URL(a),{cacheMaxAge:n.ttlMs,[mE]:J(un,this),[uh]:J(Su,this)}));const r=(await LP(e.logoutToken,J(Zl,this),{issuer:t.issuer,audience:J(it,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in r)&&!("sub"in r))throw new xr('either "sid" or "sub" (or both) claims must be present');if("sid"in r&&typeof r.sid!="string")throw new xr('"sid" claim must be a string');if("sub"in r&&typeof r.sub!="string")throw new xr('"sub" claim must be a string');if("nonce"in r)throw new xr('"nonce" claim is prohibited');if(!("events"in r))throw new xr('"events" claim is missing');if(typeof r.events!="object"||r.events===null)throw new xr('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in r.events))throw new xr('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if(typeof r.events["http://schemas.openid.net/event/backchannel-logout"]!="object")throw new xr('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return{sid:r.sid,sub:r.sub}}});function d2(){const e=J(it,this).domain.toLowerCase();return"".concat(e,"|mtls:").concat(J(it,this).useMtls?"1":"0")}async function wv(e){const t=await at(pt,this,gx).call(this),n=new cl(e,J(it,this).clientId,J(it,this).clientSecret,t);return n[ua]=J(un,this),n}async function os(){if(J(ea,this)&&J(Na,this))return{configuration:J(ea,this),serverMetadata:J(Na,this)};const e=at(pt,this,d2).call(this),t=J(Hc,this).get(e);if(t)return Je(Na,this,t.serverMetadata),Je(ea,this,await at(pt,this,wv).call(this,t.serverMetadata)),{configuration:J(ea,this),serverMetadata:J(Na,this)};const n=J(Yo,this).get(e);if(n){const i=await n;return Je(Na,this,i.serverMetadata),Je(ea,this,await at(pt,this,wv).call(this,i.serverMetadata)),{configuration:J(ea,this),serverMetadata:J(Na,this)}}const a=(async()=>{const i=await at(pt,this,gx).call(this),o=await TP(new URL("https://".concat(J(it,this).domain)),J(it,this).clientId,{use_mtls_endpoint_aliases:J(it,this).useMtls},i,{[ua]:J(un,this)}),l=o.serverMetadata();return J(Hc,this).set(e,{serverMetadata:l}),{configuration:o,serverMetadata:l}})(),r=a.then(i=>({serverMetadata:i.serverMetadata}));r.catch(()=>{}),J(Yo,this).set(e,r);try{const i=await a,o=i.configuration,l=i.serverMetadata;Je(ea,this,o),Je(Na,this,l),J(ea,this)[ua]=J(un,this)}finally{J(Yo,this).delete(e)}return{configuration:J(ea,this),serverMetadata:J(Na,this)}}async function u2(e){var t,n;const a=(await at(pt,this,os).call(this)).configuration;if("audience"in e||"resource"in e)throw new ca("audience and resource parameters are not supported for Token Vault exchanges");bE(e.subjectToken);const r=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:(t=e.subjectTokenType)!==null&&t!==void 0?t:SE,requested_token_type:(n=e.requestedTokenType)!==null&&n!==void 0?n:"http://auth0.com/oauth/token-type/federated-connection-access-token"});e.loginHint&&r.append("login_hint",e.loginHint),e.scope&&r.append("scope",e.scope),wE(r,e.extra);try{const i=await er(a,"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",r);return hn.fromTokenEndpointResponse(i)}catch(i){throw new ca("Failed to exchange token for connection '".concat(e.connection,"'."),la(i))}}async function h2(e){const t=(await at(pt,this,os).call(this)).configuration;if(bE(e.subjectToken),e.organization!==void 0&&px(e.organization),e.actorToken!==void 0&&e.actorTokenType===void 0)throw new ca("actorTokenType is required when actorToken is provided");const n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});let a,r;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.requestedTokenType&&n.append("requested_token_type",e.requestedTokenType),e.organization&&n.append("organization",e.organization),e.actorToken&&n.append("actor_token",e.actorToken),e.actorTokenType&&n.append("actor_token_type",e.actorTokenType),wE(n,e.extra);try{r=await er(t,"urn:ietf:params:oauth:grant-type:token-exchange",n),a=hn.fromTokenEndpointResponse(r)}catch(o){throw new ca("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),la(o))}var i;if(e.organization&&mx(a.claims,e.organization),e.actorToken)if((i=a.claims)!==null&&i!==void 0&&i.act)a.act=a.claims.act;else try{a.act=function(o){if(typeof o!="string")throw new aa("JWTs must use Compact JWS serialization, JWT must be a string");const l=o.split("."),c=l[1],u=l.length;if(u===5)throw new aa("Only JWTs using Compact JWS serialization can be decoded");if(u!==3)throw new aa("Invalid JWT");if(!c)throw new aa("JWTs must contain a payload");let d,h;try{d=Od(c)}catch{throw new aa("Failed to base64url decode the payload")}try{h=JSON.parse(ll.decode(d))}catch{throw new aa("Failed to parse the decoded payload as JSON")}if(!Pa(h))throw new aa("Invalid JWT Claims Set");return h}(r.access_token).act}catch{}return a}async function ww(e){const t=(await at(pt,this,os).call(this)).configuration;try{const n=await er(t,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return hn.fromTokenEndpointResponse(n)}catch(n){throw new yE("There was an error while trying to request a token.",la(n))}}async function gx(){return J(Lo,this)||Je(Lo,this,(async()=>{if(!J(it,this).clientSecret&&!J(it,this).clientAssertionSigningKey&&!J(it,this).useMtls)throw new fE;if(J(it,this).useMtls)return(t,n,a,r)=>{a.set("client_id",n.client_id)};let e=J(it,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await aE(e,J(it,this).clientAssertionSigningAlg||"RS256")),e?function(t,n){return ZA(t)}(e):oE(J(it,this).clientSecret)})().catch(e=>{throw Je(Lo,this,void 0),e})),J(Lo,this)}async function ef(e){const t=(await at(pt,this,os).call(this)).configuration,n=CP(),a=await _P(n),r=fv(Le(Le({},J(it,this).authorizationParams),e==null?void 0:e.authorizationParams)),i=new URLSearchParams(Le(Le({scope:bv},r),{},{client_id:J(it,this).clientId,code_challenge:a,code_challenge_method:"S256"}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await pE(t,i):await pv(t,i),codeVerifier:n}}let Ud=class Sv extends Ct{constructor(t,n){super(t,n),Object.setPrototypeOf(this,Sv.prototype)}static fromPayload(t){let n=t.error,a=t.error_description;return new Sv(n,a)}},Sw=class NE extends Ud{constructor(t,n){super(t,n),Object.setPrototypeOf(this,NE.prototype)}},p2=class kE extends Ud{constructor(t,n){super(t,n),Object.setPrototypeOf(this,kE.prototype)}};class vx extends Ud{constructor(t,n){super(t,n),Object.setPrototypeOf(this,vx.prototype)}}class Mo extends Ud{constructor(t,n){super(t,n),Object.setPrototypeOf(this,Mo.prototype)}}class yx extends Ud{constructor(t,n){super(t,n),Object.setPrototypeOf(this,yx.prototype)}}class m2{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=t}set(t,n){this.cleanup(),this.contexts.set(t,Object.assign(Object.assign({},n),{createdAt:Date.now()}))}get(t){const n=this.contexts.get(t);if(n){if(!(Date.now()-n.createdAt>this.ttlMs))return n;this.contexts.delete(t)}}remove(t){this.contexts.delete(t)}cleanup(){const t=Date.now();for(const a of this.contexts){var n=kn(a,2);const r=n[0];t-n[1].createdAt>this.ttlMs&&this.contexts.delete(r)}}get size(){return this.contexts.size}}class f2{constructor(t,n){this.authJsMfaClient=t,this.auth0Client=n,this.contextManager=new m2}setMFAAuthDetails(t,n,a,r){this.contextManager.set(t,{scope:n,audience:a,mfaRequirements:r})}async getAuthenticators(t){var n,a,r;const i=this.contextManager.get(t);if(!i)throw new Sw("invalid_request","MFA context not found for this MFA token");const o=(a=(n=i.mfaRequirements)===null||n===void 0?void 0:n.challenge)===null||a===void 0?void 0:a.map(l=>l.type);try{const l=await this.authJsMfaClient.listAuthenticators({mfaToken:t});return o&&o.length!==0?l.filter(c=>!!c.type&&o.includes(c.type)):l}catch(l){throw l instanceof gv?new Sw((r=l.cause)===null||r===void 0?void 0:r.error,l.message):l}}async enroll(t){var n;const a=function(r){const i=GA[r.factorType];return Object.assign(Object.assign(Object.assign({mfaToken:r.mfaToken,authenticatorTypes:i.authenticatorTypes},i.oobChannels&&{oobChannels:i.oobChannels}),"phoneNumber"in r&&{phoneNumber:r.phoneNumber}),"email"in r&&{email:r.email})}(t);try{return await this.authJsMfaClient.enrollAuthenticator(a)}catch(r){throw r instanceof vv?new p2((n=r.cause)===null||n===void 0?void 0:n.error,r.message):r}}async challenge(t){var n;try{const a={challengeType:t.challengeType,mfaToken:t.mfaToken};return t.authenticatorId&&(a.authenticatorId=t.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(a)}catch(a){throw a instanceof yv?new vx((n=a.cause)===null||n===void 0?void 0:n.error,a.message):a}}async getEnrollmentFactors(t){const n=this.contextManager.get(t);if(!n||!n.mfaRequirements)throw new yx("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");return n.mfaRequirements.enroll&&n.mfaRequirements.enroll.length!==0?n.mfaRequirements.enroll:[]}async verify(t){const n=this.contextManager.get(t.mfaToken);if(!n)throw new Mo("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");const a=function(o){return"otp"in o&&o.otp?WA:"oobCode"in o&&o.oobCode?HA:"recoveryCode"in o&&o.recoveryCode?BA:void 0}(t);if(!a)throw new Mo("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const r=n.scope,i=n.audience;try{const o=await this.auth0Client._requestTokenForMfa({grant_type:a,mfaToken:t.mfaToken,scope:r,audience:i,otp:t.otp,oob_code:t.oobCode,binding_code:t.bindingCode,recovery_code:t.recoveryCode});return this.contextManager.remove(t.mfaToken),o}catch(o){throw o instanceof Mo?new Mo(o.error,o.error_description):o}}}class ka extends Error{constructor(t,n,a){super(n),this.name="PasskeyError",this.code=t,this.cause=a,Object.setPrototypeOf(this,ka.prototype)}}var ji,xo;class g2{constructor(t,n){ji.set(this,void 0),xo.set(this,void 0),Eb(this,ji,t),Eb(this,xo,n)}async signup(t){if(!window.PublicKeyCredential)throw new ka("passkey_not_supported","WebAuthn is not supported in this browser.");const n=t.scope,a=t.audience,r=Qs(t,["scope","audience"]),i=await oi(this,ji,"f").register(r),o=Nw(i.authnParamsPublicKey),l=await navigator.credentials.create({publicKey:o});if(!l)throw new ka("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const c=Ew(l);return oi(this,xo,"f")._requestTokenForPasskey({authSession:i.authSession,credential:c,realm:r.realm,organization:r.organization,scope:n,audience:a})}async login(t){if(!window.PublicKeyCredential)throw new ka("passkey_not_supported","WebAuthn is not supported in this browser.");const n=t||{},a=n.scope,r=n.audience,i=Qs(n,["scope","audience"]),o=await oi(this,ji,"f").challenge(Object.keys(i).length>0?i:void 0),l=kw(o.authnParamsPublicKey),c=await navigator.credentials.get({publicKey:l});if(!c)throw new ka("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const u=_w(c);return oi(this,xo,"f")._requestTokenForPasskey({authSession:o.authSession,credential:u,realm:i.realm,organization:i.organization,scope:a,audience:r})}async getSignupChallenge(t){if(!window.PublicKeyCredential)throw new ka("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await oi(this,ji,"f").register(t);return{authSession:n.authSession,publicKey:Nw(n.authnParamsPublicKey)}}async getLoginChallenge(t){if(!window.PublicKeyCredential)throw new ka("passkey_not_supported","WebAuthn is not supported in this browser.");const n=await oi(this,ji,"f").challenge(t);return{authSession:n.authSession,publicKey:kw(n.authnParamsPublicKey)}}async getTokenWithPasskey(t){if(!window.PublicKeyCredential)throw new ka("passkey_not_supported","WebAuthn is not supported in this browser.");const n=t.authSession,a=t.credential,r=t.realm,i=t.organization,o=t.scope,l=t.audience,c=a.response;let u;if(c instanceof AuthenticatorAttestationResponse)u=Ew(a);else{if(!(c instanceof AuthenticatorAssertionResponse))throw new ka("passkey_invalid_credential","The provided credential is not a valid attestation or assertion response.");u=_w(a)}return oi(this,xo,"f")._requestTokenForPasskey({authSession:n,credential:u,realm:r,organization:i,scope:o,audience:l})}}function Ir(e){const t=new Uint8Array(e),n=Array.from(t,a=>String.fromCharCode(a)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Nv(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),a=atob(n),r=new Uint8Array(a.length);for(let i=0;i<a.length;i++)r[i]=a.charCodeAt(i);return r.buffer}function Nw(e){return Object.assign(Object.assign({},e),{challenge:Nv(e.challenge),user:Object.assign(Object.assign({},e.user),{id:Nv(e.user.id)}),pubKeyCredParams:e.pubKeyCredParams,authenticatorSelection:e.authenticatorSelection})}function kw(e){return Object.assign(Object.assign({},e),{challenge:Nv(e.challenge)})}function Ew(e){var t;const n=e.response;return{id:e.id,rawId:Ir(e.rawId),type:e.type,authenticatorAttachment:(t=e.authenticatorAttachment)!==null&&t!==void 0?t:void 0,response:{clientDataJSON:Ir(n.clientDataJSON),attestationObject:Ir(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}function _w(e){var t;const n=e.response;return{id:e.id,rawId:Ir(e.rawId),type:e.type,authenticatorAttachment:(t=e.authenticatorAttachment)!==null&&t!==void 0?t:void 0,response:{clientDataJSON:Ir(n.clientDataJSON),authenticatorData:Ir(n.authenticatorData),signature:Ir(n.signature),userHandle:n.userHandle?Ir(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}ji=new WeakMap,xo=new WeakMap;class v2{resolveOnlineAccess(t){if(t.refreshTokenMode!=="online")return!1;if(t.useRefreshTokens!==!0)throw new Ib('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(t.useDpop!==!0)throw new Ib('`refreshTokenMode: "online"` requires DPoP, which is missing or disabled.',"Set `useDpop: true` (DPoP is mandatory for online access).");return!0}constructor(t){let n,a;if(this.userCache=new _1().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0,refreshTokenMode:"offline"},this.onlineAccess=this.resolveOnlineAccess(t),this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),t),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),t.authorizationParams)}),typeof window<"u"&&(()=>{if(!Yh())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Yh().subtle===void 0)throw new Error(`
|
|
43
|
-
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
44
|
-
`)})(),this.lockManager=(Am||(Am=uA()),Am),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)a=t.cache;else{if(n=t.cacheLocation||Rb,!Fb(n))throw new Error('Invalid cache location "'.concat(n,'"'));a=Fb(n)()}var r;this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:Kg,this.cookieStorage=t.legacySameSiteCookie===!1?yo:IA,this.orgHintCookieName=(r=this.options.clientId,"auth0.".concat(r,".organization_hint")),this.isAuthenticatedCookieName=(d=>"auth0.".concat(d,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const i=t.useCookiesForTransactions?this.cookieStorage:AA;let o="";var l;this.onlineAccess?o=r1:this.options.useRefreshTokens&&(o="offline_access"),this.scope=function(d,h){for(var g=arguments.length,v=new Array(g>2?g-2:0),f=2;f<g;f++)v[f-2]=arguments[f];if(typeof d!="object")return{[bs]:lh(h,d,...v)};let y={[bs]:lh(h,...v)};return Object.keys(d).forEach(b=>{const m=d[b];y[b]=lh(h,m,...v)}),y}(this.options.authorizationParams.scope,"openid",o),this.transactionManager=new kA(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||i1,this.cacheManager=new NA(a,a.allKeys?void 0:new OA(a,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new zA(this.options.clientId):void 0,this.domainUrl=(l=this.options.domain,/^https?:\/\//.test(l)?l:"https://".concat(l)),this.tokenIssuer=((d,h)=>d?d.startsWith("https://")?d:"https://".concat(d,"/"):"".concat(h,"/"))(this.options.issuer,this.domainUrl);const c="".concat(this.domainUrl,"/me/"),u=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:d=>{var h;return this.getTokenSilently({authorizationParams:{scope:(h=d==null?void 0:d.scope)===null||h===void 0?void 0:h.join(" "),audience:c},detailedResponse:!0})}}));this.myAccount=new FA(u,c),this.authJsClient=new c2({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new f2(this.authJsClient.mfa,this),this.passkey=new g2(this.authJsClient.passkey,this),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n===Rb&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new $A,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(t){const n=this.options.auth0Client||Jg,a=Xg(n,!0),r=encodeURIComponent(btoa(JSON.stringify(a)));return"".concat(this.domainUrl).concat(t,"&auth0Client=").concat(r)}_authorizeUrl(t){return this._url("/authorize?".concat(vc(t)))}async _verifyIdToken(t,n,a){const r=await this.nowProvider();return _A({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:n,organization:a,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i!="string"?i:parseInt(i,10)||void 0),now:r});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(t){return new URLSearchParams(window.location.search).get(t)||void 0}_clearSessionTransferTokenFromUrl(t){try{const n=new URL(window.location.href);n.searchParams.has(t)&&(n.searchParams.delete(t),window.history.replaceState({},"",n.toString()))}catch{}}_applySessionTransferToken(t){const n=this.options.sessionTransferTokenQueryParamName;if(!n||t.session_transfer_token)return t;const a=this._extractSessionTransferToken(n);return a?(this._clearSessionTransferTokenFromUrl(n),Object.assign(Object.assign({},t),{session_transfer_token:a})):t}async _prepareAuthorizeUrl(t,n,a){var r;const i=Cm(zl()),o=Cm(zl()),l=zl(),c=await Ab(l),u=$b(c),d=await((r=this.dpop)===null||r===void 0?void 0:r.calculateThumbprint()),h=((v,f,y,b,m,x,j,S,w)=>Object.assign(Object.assign(Object.assign({client_id:v.clientId},v.authorizationParams),y),{scope:Fl(f,y.scope,y.audience),response_type:"code",response_mode:S||"query",state:b,nonce:m,redirect_uri:j||v.authorizationParams.redirect_uri,code_challenge:x,code_challenge_method:"S256",dpop_jkt:w}))(this.options,this.scope,t,i,o,u,t.redirect_uri||this.options.authorizationParams.redirect_uri||a,n==null?void 0:n.response_mode,d),g=this._authorizeUrl(h);return{nonce:o,code_verifier:l,scope:h.scope,audience:h.audience||bs,redirect_uri:h.redirect_uri,state:i,url:g}}async loginWithPopup(t,n){var a;if(t=t||{},!(n=n||{}).popup&&(n.popup=(c=>{const u=window.screenX+(window.innerWidth-400)/2,d=window.screenY+(window.innerHeight-600)/2;return window.open(c,"auth0:authorize:popup","left=".concat(u,",top=").concat(d,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!n.popup))throw new nA;const r=this._applySessionTransferToken(t.authorizationParams||{}),i=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await((c,u)=>new Promise((d,h)=>{let g;const v=setInterval(()=>{c.popup&&c.popup.closed&&(clearInterval(v),clearTimeout(f),window.removeEventListener("message",g,!1),h(new sA(c.popup)))},1e3),f=setTimeout(()=>{clearInterval(v),h(new tA(c.popup)),window.removeEventListener("message",g,!1)},1e3*(c.timeoutInSeconds||60));g=function(y){if(y.origin===u&&y.data&&y.data.type==="authorization_response"){if(clearTimeout(f),clearInterval(v),window.removeEventListener("message",g,!1),c.closePopup!==!1&&c.popup.close(),y.data.response.error)return h(Ct.fromPayload(y.data.response));d(y.data.response)}},window.addEventListener("message",g)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(i.url).origin);if(i.state!==o.state)throw new Ct("state_mismatch","Invalid state");const l=((a=t.authorizationParams)===null||a===void 0?void 0:a.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:l})}async getUser(){var t;if(await this._isSessionCeilingReached())return;const n=await this._getIdTokenFromCache();return(t=n==null?void 0:n.decodedToken)===null||t===void 0?void 0:t.user}async getIdTokenClaims(){var t;if(await this._isSessionCeilingReached())return;const n=await this._getIdTokenFromCache();return(t=n==null?void 0:n.decodedToken)===null||t===void 0?void 0:t.claims}async loginWithRedirect(){var t;const n=Gb(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),a=n.openUrl,r=n.fragment,i=n.appState,o=Qs(n,["openUrl","fragment","appState"]),l=((t=o.authorizationParams)===null||t===void 0?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(o.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),d=u.url,h=Qs(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:i,response_type:Ei.Code}),l&&{organization:l}));const g=r?"".concat(d,"#").concat(r):d;a?await a(g):window.location.assign(g)}async handleRedirectCallback(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split("?").slice(1);if(t.length===0)throw new Error("There are no query params available for parsing.");const n=this.transactionManager.get();if(!n)throw new Ct("missing_transaction","Invalid state");this.transactionManager.remove();const a=(r=>{r.indexOf("#")>-1&&(r=r.substring(0,r.indexOf("#")));const i=new URLSearchParams(r);return{state:i.get("state"),code:i.get("code")||void 0,connect_code:i.get("connect_code")||void 0,error:i.get("error")||void 0,error_description:i.get("error_description")||void 0}})(t.join(""));return n.response_type===Ei.ConnectCode?this._handleConnectAccountRedirectCallback(a,n):this._handleLoginRedirectCallback(a,n)}async _handleLoginRedirectCallback(t,n){const a=t.code,r=t.state,i=t.error,o=t.error_description;if(i)throw new QI(i,o||i,r,n.appState);if(!n.code_verifier||n.state&&n.state!==r)throw new Ct("state_mismatch","Invalid state");const l=n.organization,c=n.nonce,u=n.redirect_uri;return await this._requestToken(Object.assign({audience:n.audience,scope:n.scope,code_verifier:n.code_verifier,grant_type:"authorization_code",code:a},u?{redirect_uri:u}:{}),{nonceIn:c,organization:l}),{appState:n.appState,response_type:Ei.Code}}async _handleConnectAccountRedirectCallback(t,n){const a=t.connect_code,r=t.state,i=t.error,o=t.error_description;if(i)throw new eA(i,o||i,n.connection,r,n.appState);if(!a)throw new Ct("missing_connect_code","Missing connect code");if(!(n.code_verifier&&n.state&&n.auth_session&&n.redirect_uri&&n.state===r))throw new Ct("state_mismatch","Invalid state");const l=await this.myAccount.completeAccount({auth_session:n.auth_session,connect_code:a,redirect_uri:n.redirect_uri,code_verifier:n.code_verifier});return Object.assign(Object.assign({},l),{appState:n.appState,response_type:Ei.ConnectCode})}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Ub))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Ub)}try{await this.getTokenSilently(t)}catch{}}async getTokenSilently(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var n,a;const r=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Fl(this.scope,(n=t.authorizationParams)===null||n===void 0?void 0:n.scope,((a=t.authorizationParams)===null||a===void 0?void 0:a.audience)||this.options.authorizationParams.audience)})}),i=await((o,l)=>{let c=Om[l];return c||(c=o().finally(()=>{delete Om[l],c=null}),Om[l]=c),c})(()=>this._getTokenSilently(r),"".concat(this.options.clientId,"::").concat(r.authorizationParams.audience,"::").concat(r.authorizationParams.scope));return t.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(t){const n=t.cacheMode,a=Qs(t,["cacheMode"]);if(await this._isSessionCeilingReached())return;if(n!=="off"){const l=await this._getEntryFromCache({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||bs,clientId:this.options.clientId,cacheMode:n});if(l)return l}if(n==="cache-only")return;const r=(i=this.options.clientId,o=a.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(i,".").concat(o));var i,o;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(n!=="off"){const v=await this._getEntryFromCache({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||bs,clientId:this.options.clientId});if(v)return v}const l=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(a):await this._getTokenFromIFrame(a),c=l.id_token,u=l.token_type,d=l.access_token,h=l.oauthTokenScope,g=l.expires_in;return Object.assign(Object.assign({id_token:c,token_type:u,access_token:d},h?{scope:h}:null),{expires_in:g})})}catch(l){if(this._isInteractiveError(l)&&this.options.interactiveErrorHandler==="popup")return await this._handleInteractiveErrorWithPopup(a);throw l}}_isInteractiveError(t){return t instanceof Zg||t instanceof Ct&&this._isIframeMfaError(t)}_isIframeMfaError(t){return t.error==="login_required"&&t.error_description==="Multifactor authentication required"}async _handleInteractiveErrorWithPopup(t){try{await this.loginWithPopup({authorizationParams:t.authorizationParams});const n=await this._getEntryFromCache({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||bs,clientId:this.options.clientId});if(!n)throw new Ct("interactive_handler_cache_miss","Token not found in cache after interactive authentication");return n}catch(n){throw n}}async getTokenWithPopup(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var a,r;const i=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Fl(this.scope,(a=t.authorizationParams)===null||a===void 0?void 0:a.scope,((r=t.authorizationParams)===null||r===void 0?void 0:r.audience)||this.options.authorizationParams.audience)})});return n=Object.assign(Object.assign({},XI),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new mn({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){t.clientId!==null?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},a=n.federated,r=Qs(n,["federated"]),i=a?"&federated":"";return this._url("/v2/logout?".concat(vc(Object.assign({clientId:t.clientId},r))))+i}async revokeRefreshToken(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.options.useRefreshTokens)return;const n=t.audience||this.options.authorizationParams.audience||bs,a=await this.cacheManager.getRefreshTokensByAudience(n,this.options.clientId);await async function(r,i){let o=r.baseUrl,l=r.timeout,c=r.auth0Client,u=r.useFormData,d=r.refreshTokens,h=r.audience,g=r.client_id,v=r.onRefreshTokenRevoked;const f=l||Kg,y="refresh_token",b="".concat(o,"/oauth/revoke"),m={"Content-Type":u?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(Xg(c||Jg)))};if(i){const j={client_id:g,token_type_hint:y},S=u?vc(j):JSON.stringify(j);try{return await ev({type:"revoke",timeout:f,fetchUrl:b,fetchOptions:{method:"POST",body:S,headers:m},useFormData:u,auth:{audience:h??bs}},i)}catch(w){throw new Ct("revoke_error",w.message)}}for(const j of d){const S={client_id:g,token_type_hint:y,token:j},w=u?vc(S):JSON.stringify(S),C=await k1(b,{method:"POST",body:w,headers:m},f);if(!C.ok){let k,N;try{var x=JSON.parse(await C.text());k=x.error,N=x.error_description}catch{}throw new Ct(k||"revoke_error",N||"HTTP error ".concat(C.status))}await(v==null?void 0:v(j))}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:a,audience:n,onRefreshTokenRevoked:r=>this.cacheManager.stripRefreshToken(r)},this.worker),this.onlineAccess&&await this._clearLocalSession()}async logout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=Gb(t),a=n.openUrl,r=Qs(n,["openUrl"]);await this._clearLocalSession(t.clientId);const i=this._buildLogoutUrl(r);a?await a(i):a!==!1&&window.location.assign(i)}async _getTokenFromIFrame(t){const n=(a=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(a));var a;try{return await this.lockManager.runWithLock(n,5e3,async()=>{const r=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),i=this.cookieStorage.get(this.orgHintCookieName);i&&!r.organization&&(r.organization=i);const o=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin),l=o.url,c=o.state,u=o.nonce,d=o.code_verifier,h=o.redirect_uri,g=o.scope,v=o.audience;if(window.crossOriginIsolated)throw new Ct("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const f=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let y;try{y=new URL(this.domainUrl).origin}catch{y=this.domainUrl}const b=await function(x,j){let S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((w,C)=>{const k=window.document.createElement("iframe");k.setAttribute("width","0"),k.setAttribute("height","0"),k.style.display="none";const N=()=>{window.document.body.contains(k)&&(window.document.body.removeChild(k),window.removeEventListener("message",L,!1))};let L;const _=setTimeout(()=>{C(new zp),N()},1e3*S);L=function(E){if(E.origin!=j||!E.data||E.data.type!=="authorization_response")return;const I=E.source;I&&I.close(),E.data.response.error?C(Ct.fromPayload(E.data.response)):w(E.data.response),clearTimeout(_),window.removeEventListener("message",L,!1),setTimeout(N,2e3)},window.addEventListener("message",L,!1),window.document.body.appendChild(k),k.setAttribute("src",x)})}(l,y,f);if(c!==b.state)throw new Ct("state_mismatch","Invalid state");const m=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:d,code:b.code,grant_type:"authorization_code",redirect_uri:h,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:u,organization:r.organization});return Object.assign(Object.assign({},m),{scope:g,oauthTokenScope:m.scope,audience:v})})}catch(r){throw r.error==="login_required"&&(r instanceof Ct&&this._isIframeMfaError(r)&&this.options.interactiveErrorHandler==="popup"||this.logout({openUrl:!1})),r}}async _getTokenUsingRefreshToken(t){const n=await this.cacheManager.get(new mn({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new f1(t.authorizationParams.audience||bs,t.authorizationParams.scope)}const a=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof t.timeoutInSeconds=="number"?1e3*t.timeoutInSeconds:null,i=((d,h,g,v)=>{var f;if(d&&g&&v){if(h.audience!==g)return h.scope;const y=v.split(" "),b=((f=h.scope)===null||f===void 0?void 0:f.split(" "))||[],m=b.every(x=>y.includes(x));return y.length>=b.length&&m?v:h.scope}return h.scope})(this.options.useMrrt,t.authorizationParams,n==null?void 0:n.audience,n==null?void 0:n.scope);try{const d=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:a}),r&&{timeout:r}),{scopesToRequest:i});if(!this.onlineAccess&&d.refresh_token&&(n!=null&&n.refresh_token)&&await this.cacheManager.updateEntry(n.refresh_token,d.refresh_token),this.options.useMrrt&&(o=n==null?void 0:n.audience,l=n==null?void 0:n.scope,c=t.authorizationParams.audience,u=t.authorizationParams.scope,o!==c||!((h,g)=>{const v=(g==null?void 0:g.split(" "))||[];return((h==null?void 0:h.split(" "))||[]).every(f=>v.includes(f))})(u,l))){const h=MA(i,d.scope,this.onlineAccess);if(h){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw await this.cacheManager.remove(this.options.clientId,t.authorizationParams.audience,t.authorizationParams.scope),new aA(t.authorizationParams.audience||"default",h)}}return Object.assign(Object.assign({},d),{scope:t.authorizationParams.scope,oauthTokenScope:d.scope,audience:t.authorizationParams.audience||bs})}catch(d){if(d.message){if(d.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),d;if((d.message.includes("Missing Refresh Token")||d.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t)}throw d}var o,l,c,u}async _saveEntryInCache(t){const n=t.decodedToken.claims,a=n.session_expiry,r=n.iat;if(a!==void 0){if(typeof a!="number")throw new Ct("invalid_token","Invalid session_expiry: value must be a number.");if(a>=1e10)throw new Ct("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(r===void 0||a<=r)throw new Ct("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const i=t.id_token,o=t.decodedToken,l=Qs(t,["id_token","decodedToken"]);this.userCache.set(yi,{id_token:i,decodedToken:o}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(l)}async _clearLocalSession(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.clientId;var n;t===null?await this.cacheManager.clear():await this.cacheManager.clear(t),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(yi);try{await((n=this.dpop)===null||n===void 0?void 0:n.clear())}catch{}if(this.worker)try{await ev({type:"clear"},this.worker)}catch{}}async _isSessionCeilingReached(){var t,n;const a=this.userCache.get(yi),r=a??await this.cacheManager.getIdToken(new mn({clientId:this.options.clientId})),i=(n=(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.claims)===null||n===void 0?void 0:n.session_expiry;if(i===void 0)return!1;const o=await this.nowProvider();return Math.floor(o/1e3)>=i-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||bs,n=this.scope[t],a=await this.cacheManager.getIdToken(new mn({clientId:this.options.clientId,audience:t,scope:n})),r=this.userCache.get(yi);return a&&a.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set(yi,a),a)}async _getEntryFromCache(t){let n=t.scope,a=t.audience,r=t.clientId,i=t.cacheMode;const o=await this.cacheManager.get(new mn({scope:n,audience:a,clientId:r}),60,this.options.useMrrt,i);if(o&&o.access_token){const l=o.token_type,c=o.access_token,u=o.oauthTokenScope,d=o.expires_in,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,token_type:l||"Bearer",access_token:c},u?{scope:u}:null),{expires_in:d})}}_storeMfaContext(t,n,a){t instanceof Zg&&this.mfa.setMFAAuthDetails(t.mfa_token,n,a,t.mfa_requirements)}async _requestToken(t,n){var a,r,i,o,l,c;const u=n||{},d=u.nonceIn,h=u.organization,g=u.scopesToRequest;try{const v=await Lb(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop,preserveRefreshToken:this.onlineAccess},t),{scope:g||t.scope}),this.worker);let f=await this._verifyIdToken(v.id_token,d,h);if(t.grant_type==="authorization_code"){const y=await this._getIdTokenFromCache();!((r=(a=y==null?void 0:y.decodedToken)===null||a===void 0?void 0:a.claims)===null||r===void 0)&&r.sub&&y.decodedToken.claims.sub!==f.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(yi))}if(t.grant_type!=="authorization_code"){const y=await this._getIdTokenFromCache(),b=(o=(i=y==null?void 0:y.decodedToken)===null||i===void 0?void 0:i.claims)===null||o===void 0?void 0:o.session_expiry;b!==void 0&&(f=Object.assign(Object.assign({},f),{claims:Object.assign(Object.assign({},f.claims),{session_expiry:b})}))}return!v.refresh_token&&this.onlineAccess&&(v.refresh_token=(l=t.refresh_token)!==null&&l!==void 0?l:(c=await this.cacheManager.get(new mn({scope:g||t.scope,audience:t.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt))===null||c===void 0?void 0:c.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},v),{decodedToken:f,scope:t.scope,audience:t.audience||bs}),v.scope?{oauthTokenScope:v.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(h||f.claims.org_id),Object.assign(Object.assign({},v),{decodedToken:f})}catch(v){throw t.grant_type!=="authorization_code"&&this._storeMfaContext(v,g||t.scope,t.audience),v}}_buildTokenExchangeParams(t){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),{grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:t.subject_token,subject_token_type:t.subject_token_type}),t.actor_token&&{actor_token:t.actor_token}),t.actor_token_type&&{actor_token_type:t.actor_token_type}),{scope:Fl(this.scope,t.scope,t.audience||this.options.authorizationParams.audience),audience:t.audience||this.options.authorizationParams.audience,organization:t.organization||this.options.authorizationParams.organization})}async loginWithCustomTokenExchange(t){return this._requestToken(this._buildTokenExchangeParams(t))}async customTokenExchange(t){const n=this._buildTokenExchangeParams(t);try{const a=await Lb(Object.assign(Object.assign({},n),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return a.id_token&&await this._verifyIdToken(a.id_token,void 0,t.organization),a}catch(a){throw this._storeMfaContext(a,n.scope,n.audience),a}}async exchangeToken(t){return this.loginWithCustomTokenExchange(t)}_assertDpop(t){if(!t)throw new Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(t){return this._assertDpop(this.dpop),this.dpop.getNonce(t)}setDpopNonce(t,n){return this._assertDpop(this.dpop),this.dpop.setNonce(t,n)}generateDpopProof(t){return this._assertDpop(this.dpop),this.dpop.generateProof(t)}createFetcher(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new UA(t,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:n=>{var a;return this.getTokenSilently({authorizationParams:{scope:(a=n==null?void 0:n.scope)===null||a===void 0?void 0:a.join(" "),audience:n==null?void 0:n.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(t.dpopNonceId),setDpopNonce:n=>this.setDpopNonce(n,t.dpopNonceId),generateDpopProof:n=>this.generateDpopProof(n)})}async connectAccountWithRedirect(t){const n=t.openUrl,a=t.appState,r=t.connection,i=t.scopes,o=t.authorization_params,l=t.redirectUri,c=l===void 0?this.options.authorizationParams.redirect_uri||window.location.origin:l;if(!r)throw new Error("connection is required");const u=Cm(zl()),d=zl(),h=await Ab(d),g=$b(h),v=await this.myAccount.connectAccount({connection:r,scopes:i,redirect_uri:c,state:u,code_challenge:g,code_challenge_method:"S256",authorization_params:o}),f=v.connect_uri,y=v.connect_params,b=v.auth_session;this.transactionManager.create({state:u,code_verifier:d,auth_session:b,redirect_uri:c,appState:a,connection:r,response_type:Ei.ConnectCode});const m=new URL(f);m.searchParams.set("ticket",y.ticket),n?await n(m.toString()):window.location.assign(m)}async _requestTokenForPasskey(t){const n=t.audience||this.options.authorizationParams.audience,a=t.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:t.authSession,authn_response:t.credential},t.realm&&{realm:t.realm}),a&&{organization:a}),{scope:Fl(this.scope,t.scope,n),audience:n}))}async _requestTokenForMfa(t,n){const a=t.mfaToken,r=Qs(t,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:a}),n)}}async function y2(e){const t=new v2(e);return await t.checkSession(),t}function x2(e){var r;const t=new URLSearchParams(e),n=t.get("error");if(!n)return null;const a=(r=t.get("error_description"))==null?void 0:r.trim();return a?a.length>300?`${a.slice(0,300)}…`:a:`Auth0 rejected the sign-in request (${n}).`}let _a=null,ap=null,xc=!1,fh=null,tf=!1;function j2(e){fh=e}async function b2(e){if(e.provider!=="auth0"||!e.domain||!e.clientId)return _a=null,ap=null,xc=!1,{user:null,freshLogin:!1,error:null};_a=await y2({domain:e.domain,clientId:e.clientId,authorizationParams:{redirect_uri:window.location.origin,audience:e.audience},cacheLocation:"localstorage",useRefreshTokens:!0});const t=window.location.search,n=x2(t);n&&window.history.replaceState({},document.title,window.location.pathname);const a=t.includes("code=")&&t.includes("state=");if(a){try{await _a.handleRedirectCallback()}catch{}window.history.replaceState({},document.title,window.location.pathname)}if(ap=async()=>{try{return await _a.getTokenSilently()}catch{return xc&&!tf&&(tf=!0,fh==null||fh()),null}},!await _a.isAuthenticated())return xc=!1,{user:null,freshLogin:a,error:n};xc=!0,tf=!1;const r=await _a.getUser();return{user:r?{email:r.email,name:r.name,picture:r.picture,emailVerified:r.email_verified}:null,freshLogin:a,error:n}}async function w2(e=!1){_a&&await _a.loginWithRedirect({authorizationParams:e?{screen_hint:"signup"}:{}})}async function S2(){_a&&(xc=!1,await _a.logout({logoutParams:{returnTo:window.location.origin}}))}async function EE(){window.open("https://app.prooflane.ai/billing","_blank","noopener")}async function Ka(){return ap?ap():null}const dl=["security","contracts","rag","prompt","perf"],N2="high",sf={balanced:{weights:{security:.35,contracts:.25,rag:.2,prompt:.1,perf:.1}},enterprise:{weights:{security:.3,contracts:.25,rag:.25,perf:.1,prompt:.1}},developer:{weights:{security:.25,contracts:.2,rag:.15,perf:.2,prompt:.2}}},Cw="balanced",xd=[{id:"development",name:"Development",description:"Fast feedback. Critical security and breaking contracts still block.",weights:sf.developer.weights,passAt:75,reviewAt:60,hardGates:{contracts:!0,securityMaxSeverity:"critical",exposureMaxSeverity:"off",poisoning:"warn"}},{id:"staging",name:"Staging",description:"Balanced release confidence before production.",weights:sf.balanced.weights,passAt:85,reviewAt:70,hardGates:{contracts:!0,securityMaxSeverity:"high",exposureMaxSeverity:"critical",poisoning:"warn",ragMinScore:75,perfMinScore:80}},{id:"production",name:"Production",description:"Strict release policy for customer-facing MCP systems.",weights:sf.enterprise.weights,passAt:90,reviewAt:75,hardGates:{contracts:!0,securityMaxSeverity:"high",exposureMaxSeverity:"critical",poisoning:"block",ragMinScore:85,promptMinScore:90,perfMinScore:90}}],_E="kawach.release.policies",CE="kawach.release.policy",kv="staging";function rp(){try{const e=JSON.parse(localStorage.getItem(_E)||"null");return Array.isArray(e)&&e.length?e:xd}catch{return xd}}function Tw(e){try{localStorage.setItem(_E,JSON.stringify(e)),window.dispatchEvent(new Event("kawach:policies"))}catch{}}function xx(){try{return localStorage.getItem(CE)||kv}catch{return kv}}function TE(e){try{localStorage.setItem(CE,e),window.dispatchEvent(new Event("kawach:policies"))}catch{}}function RE(e,t){return e.find(n=>n.id===t)??e.find(n=>n.id===kv)??e[0]??xd[1]}const Sl={security:"Security",contracts:"Contracts",rag:"Retrieval",prompt:"Prompts",perf:"Performance"},k2="kawach.deploy.profile";function E2(){try{return localStorage.getItem(k2)||Cw}catch{return Cw}}function mi(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function _2(e){var r,i,o,l,c;const t=RE(xd,e.id),n=e.hardGates??t.hardGates,a=["off","low","medium","high","critical"].includes(n.securityMaxSeverity)?n.securityMaxSeverity:t.hardGates.securityMaxSeverity;return{id:String(e.id).slice(0,100),name:String(e.name).slice(0,120),description:String(e.description).slice(0,500),weights:{security:mi((r=e.weights)==null?void 0:r.security,t.weights.security),contracts:mi((i=e.weights)==null?void 0:i.contracts,t.weights.contracts),rag:mi((o=e.weights)==null?void 0:o.rag,t.weights.rag),prompt:mi((l=e.weights)==null?void 0:l.prompt,t.weights.prompt),perf:mi((c=e.weights)==null?void 0:c.perf,t.weights.perf)},passAt:mi(e.passAt,t.passAt),reviewAt:mi(e.reviewAt,t.reviewAt),hardGates:{contracts:!!n.contracts,securityMaxSeverity:a,...["off","low","medium","high","critical"].includes(n.exposureMaxSeverity??"")?{exposureMaxSeverity:n.exposureMaxSeverity}:{exposureMaxSeverity:t.hardGates.exposureMaxSeverity??"critical"},poisoning:["block","warn","off"].includes(n.poisoning)?n.poisoning:t.hardGates.poisoning??"warn",...typeof n.ragMinScore=="number"&&Number.isFinite(n.ragMinScore)?{ragMinScore:n.ragMinScore}:{},...typeof n.promptMinScore=="number"&&Number.isFinite(n.promptMinScore)?{promptMinScore:n.promptMinScore}:{},...typeof n.perfMinScore=="number"&&Number.isFinite(n.perfMinScore)?{perfMinScore:n.perfMinScore}:{},...["off","low","medium","high","critical"].includes(n.modelSecurityMaxSeverity??"")?{modelSecurityMaxSeverity:n.modelSecurityMaxSeverity}:{}}}}function C2(){return{version:"release-policy-v1",activePolicyId:xx().slice(0,100),profile:E2().slice(0,100),policies:rp().slice(0,25).map(_2)}}const fn=e=>e?e.score??(e.total?Math.round(e.pass/e.total*100):null):null,IE=e=>!!e&&(e.fail>0||e.error>0),AE=e=>e==="security"?"security":e==="contract"||e==="mcp"?"contracts":e==="rag"?"rag":e==="prompt"?"prompt":e==="perf"?"perf":null,T2=e=>e.hardGates.modelSecurityMaxSeverity??N2;function R2(e,t){const n=e.find(i=>i.pillar==="model");if(!n)return null;const a=fn(n),r=jx(n,T2(t))?"blocked":n.fail>0||n.drift>0||n.error>0?"warning":"pass";return{run:n,score:a,status:r}}const Rw={low:1,medium:2,high:3,critical:4},PE=(e,t)=>t!=="off"&&(Rw[e??"low"]??0)>=Rw[t];function jx(e,t){return!e||!e.fail||t==="off"?!1:PE(e.severity,t)}function Ev(e,t){return!e||!e.drift||!t||t==="off"?!1:PE(e.exposureSeverity,t)}function $E(e,t){return t==="block"&&!!(e!=null&&e.poisoned)}function I2(e,t){const n=t.weights,a=[...e].reverse(),r={},i=[];for(const o of a){const l=AE(o.pillar);if(!l)continue;r[l]=o;const c={};let u=0,d=0;for(const j of dl){const S=fn(r[j]);c[j]=S,S!=null&&(u+=n[j],d+=S*n[j])}const h=u?Math.round(d/u):null,g=r.security,v=r.contracts,f=r.rag,y=r.prompt,b=r.perf,m=t.hardGates.contracts&&!!(v!=null&&v.fail)||jx(g,t.hardGates.securityMaxSeverity)||Ev(g,t.hardGates.exposureMaxSeverity)||$E(g,t.hardGates.poisoning)||IE(b)||t.hardGates.ragMinScore!=null&&(fn(f)??100)<t.hardGates.ragMinScore||t.hardGates.promptMinScore!=null&&(fn(y)??100)<t.hardGates.promptMinScore||t.hardGates.perfMinScore!=null&&(fn(b)??100)<t.hardGates.perfMinScore,x=h==null?"unknown":m?"blocked":h>=t.passAt?"pass":h>=t.reviewAt?"review":"blocked";i.push({at:o.createdAt,overall:h,verdict:x,scores:c})}return i}function A2(e){for(let t=e.length-2;t>=0;t--)if(e[t].verdict==="pass")return e[t];return null}function P2(e,t,n,a){const r=[],{security:i,contracts:o,rag:l,prompt:c,perf:u}=e;if(n.hardGates.contracts&&o&&o.fail>0&&r.push({severity:"blocker",dimension:"contracts",title:"MCP contract validation failed",why:o.finding||"A tool's input/output schema changed since the last green run.",impact:"Consumers may break — clients calling these tools still expect the previous schema.",fix:"Open Contract Diff to see exactly what changed, then restore the schema or update clients.",jumpTo:"contracts",jumpLabel:"Contract Diff"}),i&&jx(i,n.hardGates.securityMaxSeverity)&&r.push({severity:"blocker",dimension:"security",title:`${i.severity==="critical"?"Critical":"High"} verified security breach`,why:i.finding||`${i.fail} red-team attack${i.fail===1?"":"s"} crossed a protected boundary.`,impact:"A protected boundary was observed to cross — the agent leaked data, invoked a forbidden tool, or a payload executed.",fix:"Open Security → review the breached attack, patch the tool or add a guard, then re-run.",jumpTo:"security",jumpLabel:"Review breach"}),(a==null?void 0:a.status)==="blocked"&&r.push({severity:"blocker",dimension:"model",title:`${a.run.severity==="critical"?"Critical":"High"} model supply-chain finding`,why:a.run.finding||`${a.run.fail} Model & Supply Chain finding${a.run.fail===1?"":"s"} at or above the policy severity.`,impact:"The artifact this deployment is built from carries a verified exposure or poisoning. Nothing was executed to establish it — the evidence is structural.",fix:"Open Security → Model & Supply Chain, review the finding, obtain a clean artifact revision, then re-scan.",jumpTo:"security",jumpLabel:"Review artifact"}),i&&Ev(i,n.hardGates.exposureMaxSeverity)&&r.push({severity:"blocker",dimension:"security",title:`${i.exposureSeverity==="critical"?"Critical":"High"} verified exposure`,why:`${i.drift} dangerous capabilit${i.drift===1?"y is":"ies are"} advertised with no confirmation, dry-run or approval control declared in the tool contract.`,impact:"Nothing was executed, so no boundary crossing is claimed. But if server-side authorization or approval controls are absent, a compromised agent could potentially invoke the operation.",fix:"Open Security → declare the safeguard in the tool contract (a required confirmation argument or an MCP annotation), or remove the capability from the advertised surface.",jumpTo:"security",jumpLabel:"Review exposure"}),i&&$E(i,n.hardGates.poisoning)&&r.push({severity:"blocker",dimension:"security",title:"Verified poisoning in reachable content",why:`${i.poisoned} finding${i.poisoned===1?"":"s"} located embedded agent-directed instructions in reachable resource content.`,impact:"The instruction-bearing content was verified as present. No agent was observed consuming it, but an agent that does could be influenced into unintended tool use.",fix:"Open Security → remove the embedded instructions from the served resource, or treat resource bodies as untrusted data in the agent harness.",jumpTo:"security",jumpLabel:"Review poisoning"}),n.hardGates.ragMinScore!=null&&(fn(l)??100)<n.hardGates.ragMinScore&&r.push({severity:"blocker",dimension:"rag",title:"RAG score below policy",why:`RAG scored ${fn(l)}; policy requires at least ${n.hardGates.ragMinScore}.`,impact:"Retrieved context may not be reliable enough to release.",fix:"Inspect the failing RAG queries and re-run after correcting retrieval.",jumpTo:"rag",jumpLabel:"Open RAG"}),n.hardGates.promptMinScore!=null&&(fn(c)??100)<n.hardGates.promptMinScore&&r.push({severity:"blocker",dimension:"prompt",title:"Prompt score below policy",why:`Prompts scored ${fn(c)}; policy requires at least ${n.hardGates.promptMinScore}.`,impact:"Pinned agent behavior has regressed below the release bar.",fix:"Open Prompt Automation, fix the regressions, and re-run.",jumpTo:"prompt-automation",jumpLabel:"Open Prompts"}),n.hardGates.perfMinScore!=null&&(fn(u)??100)<n.hardGates.perfMinScore&&r.push({severity:"blocker",dimension:"perf",title:"Performance below policy",why:`Performance scored ${fn(u)}; policy requires at least ${n.hardGates.perfMinScore}.`,impact:"The system does not meet the required load SLO.",fix:"Investigate the load test, then re-run Performance.",jumpTo:"performance",jumpLabel:"Open Performance"}),u&&IE(u)&&!r.some(d=>d.dimension==="perf"&&d.severity==="blocker")&&r.push({severity:"blocker",dimension:"perf",title:"Performance test returned request errors",why:u.finding||`${u.error||u.fail} load-test result${u.error+u.fail===1?"":"s"} failed.`,impact:"Latency from failed responses cannot establish that the service meets its release SLO.",fix:"Open Performance, correct the target errors, and re-run until the error rate is zero.",jumpTo:"performance",jumpLabel:"Open Performance"}),i&&i.drift>0&&!Ev(i,n.hardGates.exposureMaxSeverity)&&r.push({severity:"warning",dimension:"security",title:`Verified exposure — ${i.drift} reachable capabilit${i.drift===1?"y":"ies"}`,why:"A dangerous capability is advertised with no safeguard declared in its contract. Prooflane verified reachability by inspection and did not execute it.",impact:"Not a boundary crossing. It becomes one if server-side authorization or approval controls are also missing.",fix:"Open Security → declare the safeguard, or drop the capability from the advertised surface.",jumpTo:"security",jumpLabel:"Open Security"}),i&&(i.poisoned??0)>0&&n.hardGates.poisoning!=="block"&&n.hardGates.poisoning!=="off"&&r.push({severity:"warning",dimension:"security",title:`Verified poisoning — ${i.poisoned} finding${i.poisoned===1?"":"s"}`,why:"Agent-directed instructions were located in reachable resource content. No agent execution was observed.",impact:"An agent that consumes the resource could be influenced into unintended tool use or a policy violation.",fix:"Open Security → inspect the located fragments and sanitize the served content.",jumpTo:"security",jumpLabel:"Open Security"}),i&&i.fail>0&&i.severity!=="critical"&&i.severity!=="high"&&r.push({severity:"warning",dimension:"security",title:`Security breach — ${i.fail} attack${i.fail===1?"":"s"}`,why:i.finding||"A lower-severity red-team attack breached.",impact:"Limited exposure today, but worth closing before it compounds.",fix:"Open Security → triage the breached attacks.",jumpTo:"security",jumpLabel:"Open Security"}),(a==null?void 0:a.status)==="warning"&&r.push({severity:"warning",dimension:"model",title:`Model supply-chain review — ${a.run.fail+a.run.drift+a.run.error} item${a.run.fail+a.run.drift+a.run.error===1?"":"s"}`,why:a.run.finding||"Model & Supply Chain produced findings or inconclusive checks below the blocking severity.",impact:"Artifact provenance, packaging or template integrity is not fully established for this release.",fix:"Open Security → Model & Supply Chain and triage the remaining findings.",jumpTo:"security",jumpLabel:"Open Model Security"}),l&&l.drift>0&&r.push({severity:"warning",dimension:"rag",title:`Retrieval drift — ${l.drift} quer${l.drift===1?"y":"ies"}`,why:"Retrieved context changed versus the golden baseline.",impact:"Answers may cite different sources — a silent quality regression.",fix:"Open RAG Assurance → diff this run against golden to see what moved.",jumpTo:"rag",jumpLabel:"RAG diff"}),l&&l.fail>0&&r.push({severity:"warning",dimension:"rag",title:`Retrieval failing — ${l.fail} quer${l.fail===1?"y":"ies"}`,why:"Retrieval scored below the acceptance bar on these queries.",impact:"Grounding quality is slipping; downstream answers get less reliable.",fix:"Open RAG Assurance → inspect the failing queries.",jumpTo:"rag",jumpLabel:"Open RAG"}),u){const d=fn(u);d!=null&&d<90&&r.push({severity:"warning",dimension:"perf",title:`Performance below SLO — ${d}% under target`,why:"The share of requests under the latency target fell below 90%.",impact:"Users may see slower responses; the SLO is at risk under load.",fix:"Open Performance → inspect p95 latency and the load profile.",jumpTo:"performance",jumpLabel:"Open Performance"})}c&&c.fail>0&&r.push({severity:"warning",dimension:"prompt",title:`Prompt regression — ${c.fail} prompt${c.fail===1?"":"s"}`,why:"Prompt goldens diverged from their expected output.",impact:"Agent behavior shifted on cases you'd pinned as correct.",fix:"Open Prompt Automation → re-run the failing prompts and update or fix.",jumpTo:"prompt-automation",jumpLabel:"Open Prompts"});for(const d of t)d.delta!=null&&d.delta>0&&r.push({severity:"observation",dimension:d.bucket,title:`${Sl[d.bucket]} improved +${d.delta}`,why:"Score rose since the last green deployment.",impact:"No action needed.",fix:"—"});return r}function $2(e,t,n,a){if(a==="unknown")return 0;if(n>0)return Math.round(80+t*20);const r=e!=null?Math.max(0,Math.min(1,(e-75)/25)):0;return Math.round((t*.6+r*.4)*100)}function O2(e,t){var S;const n=t.weights,a=I2(e,t),r=A2(a),i=w=>e.find(C=>C.pillar===w),o=w=>e.find(C=>AE(C.pillar)===w),l={security:i("security"),contracts:o("contracts"),rag:i("rag"),prompt:i("prompt"),perf:i("perf")},c=dl.map(w=>{const C=fn(l[w]),k=r?r.scores[w]:null;return{bucket:w,score:C,prev:k,delta:C!=null&&k!=null?C-k:null,weight:n[w],run:l[w]}}),u=c.filter(w=>w.score!=null),d=u.reduce((w,C)=>w+C.weight,0),h=d?Math.round(u.reduce((w,C)=>w+C.score*C.weight,0)/d):null,g=R2(e,t),v=P2(l,c,t,g),f=v.filter(w=>w.severity==="blocker"),y=v.filter(w=>w.severity==="warning"),b=v.filter(w=>w.severity==="observation"),m=h==null?"unknown":f.length?"blocked":h>=t.passAt?"pass":h>=t.reviewAt?"review":"blocked",x=u.length/dl.length,j=u.reduce((w,C)=>{var k;return w+(((k=C.run)==null?void 0:k.total)??0)},0);return{overall:h,verdict:m,reason:((S=f[0])==null?void 0:S.title)??null,pillars:c,modelSecurity:g,blockers:f,warnings:y,observations:b,timeline:a.slice(-10),lastGreen:r,overallDelta:h!=null&&(r==null?void 0:r.overall)!=null?h-r.overall:null,coverage:x,policyPass:m==="pass",confidence:$2(h,x,f.length,m),evidence:{level:x>=.8?"High":x>=.5?"Medium":"Low",runs:u.length,graded:j},estFixMinutes:f.length?f.length*8:null}}const L2="We couldn't complete this request. Please try again. If the problem continues, contact Prooflane support.";function OE(e){return e.startsWith("/connect")?"We couldn't connect to the MCP server. Verify the connection settings and try again.":e.startsWith("/intelligence")?"We couldn't complete this request. Please try again shortly. No generation credit was consumed.":L2}async function G(e,t,n="POST",a={},r){const i=t!==void 0,o=await Ka(),l={...a};i&&(l["content-type"]="application/json"),o&&(l.authorization=`Bearer ${o}`);const c=await fetch(`/api${e}`,{method:!i&&n==="POST"?"GET":n,headers:l,body:i?JSON.stringify(t):void 0,...r?{cache:r}:{}}),u=await c.text();let d=null;try{d=u?JSON.parse(u):null}catch{d=null}if(!c.ok){const h=typeof(d==null?void 0:d.error)=="string"?d.error:typeof(d==null?void 0:d.message)=="string"?d.message:`Request failed (${c.status})`,g=new Error(c.status>=500?OE(e):h);throw g.status=c.status,g.code=typeof(d==null?void 0:d.code)=="string"?d.code:void 0,g.targetId=typeof(d==null?void 0:d.targetId)=="string"?d.targetId:void 0,g.upgrade=!!(d!=null&&d.upgrade),g.reference=typeof(d==null?void 0:d.reference)=="string"?d.reference:void 0,g}return d}async function Iw(e){const t=await Ka(),n=await fetch(`/api${e}`,{headers:t?{authorization:`Bearer ${t}`}:{}}),a=await n.text();if(!n.ok){let r=`Request failed (${n.status})`;try{const o=JSON.parse(a);r=o.error||o.message||r}catch{}const i=new Error(n.status>=500?OE(e):r);throw i.status=n.status,i}return a}async function M2(e,t,n="GET"){const a=await fetch(`/api${e}`,{method:n,headers:{},body:void 0,cache:"no-store"}),r=await a.text();let i=null;try{i=r?JSON.parse(r):null}catch{i=null}if(!a.ok)throw new Error(typeof(i==null?void 0:i.error)=="string"?i.error:`Local request failed (${a.status}).`);return i}function Aw(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))a==null||a===""||Array.isArray(a)&&!a.length||t.set(n,Array.isArray(a)?a.join(","):String(a));return t.toString()}const O={connect:(e,t)=>G("/connect",{connection:e,name:t}),capabilities:()=>G("/capabilities",void 0,"GET"),mcpConnections:()=>G("/mcp/connections",void 0,"GET"),mcpTools:e=>G(`/mcp/tools${e?`?connectionId=${encodeURIComponent(e)}`:""}`,void 0,"GET"),mcpRefreshTools:e=>G(`/mcp/connections/${encodeURIComponent(e)}/refresh`,{}),mcpReconnectConnection:(e,t,n)=>G(`/mcp/connections/${encodeURIComponent(e)}/reconnect`,{connection:t,displayName:n}),mcpActivateConnection:e=>G(`/mcp/connections/${encodeURIComponent(e)}/activate`,{}),mcpDisconnectConnection:e=>G(`/mcp/connections/${encodeURIComponent(e)}/disconnect`,{}),mcpRemoveConnection:e=>G(`/mcp/connections/${encodeURIComponent(e)}`,void 0,"DELETE"),targets:()=>G("/targets",void 0,"GET"),targetConnect:(e,t)=>G("/targets",{config:e,displayName:t}),targetReconnect:(e,t,n)=>G(`/targets/${encodeURIComponent(e)}/reconnect`,{config:t,displayName:n}),targetActivate:e=>G(`/targets/${encodeURIComponent(e)}/activate`,{}),targetTest:e=>G(`/targets/${encodeURIComponent(e)}/test`,{}),targetRefresh:e=>G(`/targets/${encodeURIComponent(e)}/refresh`,{}),targetDisconnect:e=>G(`/targets/${encodeURIComponent(e)}/disconnect`,{}),targetRemove:e=>G(`/targets/${encodeURIComponent(e)}`,void 0,"DELETE"),mcpBinding:(e,t)=>G(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,void 0,"GET"),mcpPutBinding:(e,t,n)=>G(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,n,"PUT"),mcpDeleteBinding:(e,t)=>G(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,void 0,"DELETE"),mcpStartRun:(e,t,n)=>G(`/features/${e}/${encodeURIComponent(t)}/mcp-runs`,n?{runId:n}:{}),mcpInvokeRun:(e,t,n=3e4)=>G(`/mcp/runs/${encodeURIComponent(e)}/invoke`,{input:t,timeoutMs:n}),config:()=>G("/config",void 0,"GET",{},"no-store"),disconnect:()=>G("/disconnect",{}),httpRequest:e=>G("/http/request",e),httpSnapshot:(e,t,n="captured")=>G("/http/snapshot",{request:e,response:t,origin:n}),oauthStart:(e,t)=>G("/connect/oauth/start",{url:e,name:t}),oauthStatus:e=>G(`/connect/oauth/status?flowId=${encodeURIComponent(e)}`,void 0,"GET"),callTool:(e,t)=>G(`/tools/${encodeURIComponent(e)}/call`,{input:t}),executeCapability:e=>G("/security/execute-capability",e),verifyHostedCapability:e=>G("/security/verify-capability",e),snapshotTool:(e,t)=>G(`/tools/${encodeURIComponent(e)}/snapshot`,{input:t}),diffValues:(e,t,n)=>G("/diff/values",{tool:e,expected:t,actual:n}),drift:e=>G("/drift",{baseline:e}),readResource:e=>G("/resources/read",{uri:e}),getPrompt:(e,t)=>G(`/prompts/${encodeURIComponent(e)}/get`,{args:t}),recordStart:e=>G("/record/start",{label:e}),recordStatus:()=>G("/record/status",void 0,"GET"),recordStop:()=>G("/record/stop",{}),sessions:()=>G("/sessions",void 0,"GET"),session:e=>G(`/sessions/${e}`,void 0,"GET"),markGolden:(e,t)=>G(`/sessions/${e}/golden`,{golden:t}),automate:(e,t)=>G(`/sessions/${e}/automate`,{format:t}),fault:(e,t,n)=>G(`/sessions/${e}/fault`,{step:t,type:n}),snapshots:()=>G("/snapshots",void 0,"GET"),automateContracts:(e,t)=>G("/automate/contracts",{snapshotIds:e,format:t}),updateSnapshot:(e,t)=>G(`/snapshots/${encodeURIComponent(e)}`,t,"PATCH"),deleteSnapshot:e=>G(`/snapshots/${encodeURIComponent(e)}`,void 0,"DELETE"),generatePrompts:e=>G("/prompts/generate",{tool:e}),customPrompts:()=>G("/prompts/custom",void 0,"GET"),generateAiPrompts:(e,t,n,a)=>G("/prompts/generate-ai",{tool:e,count:t,temperature:n,llm:a}),setPromptGolden:(e,t,n)=>G(`/prompts/custom/${e}/golden`,{expected:t,assert:n}),setPromptChecks:(e,t)=>G(`/prompts/custom/${e}/checks`,t),assertTool:(e,t,n,a)=>G("/prompts/assert",{tool:e,input:t,assertions:n,checkSchema:a}),addCustomPrompt:(e,t,n)=>G("/prompts/custom",{name:e,content:t,tool:n}),updateCustomPrompt:(e,t)=>G(`/prompts/custom/${encodeURIComponent(e)}`,t,"PATCH"),deleteCustomPrompt:e=>G(`/prompts/custom/${e}`,void 0,"DELETE"),saveRun:e=>G("/runs",e),runs:e=>G(`/runs${e?`?limit=${e}`:""}`,void 0,"GET"),assuranceHistory:(e={})=>{const t=Aw(e);return G(`/assurance-history${t?`?${t}`:""}`,void 0,"GET")},assuranceHistoryBackfill:()=>G("/assurance-history/backfill",{}),assuranceHistoryCompare:(e,t)=>G("/assurance-history/compare",{leftId:e,rightId:t}),assuranceHistoryPatterns:()=>G("/assurance-history/patterns",void 0,"GET"),assuranceHistoryAsk:(e,t)=>G("/assurance-history/ask",{question:e,idempotencyKey:t}),assuranceHistoryJob:e=>G(`/assurance-history/jobs/${encodeURIComponent(e)}`,void 0,"GET"),assuranceHistoryCancelJob:e=>G(`/assurance-history/jobs/${encodeURIComponent(e)}/cancel`,{}),assuranceHistorySavedSearches:()=>G("/assurance-history/saved-searches",void 0,"GET"),assuranceHistorySaveSearch:(e,t,n=!1)=>G("/assurance-history/saved-searches",{name:e,query:t,shared:n}),assuranceHistoryAnnotate:(e,t,n)=>G(`/assurance-history/${encodeURIComponent(e)}/annotations`,{disposition:t,note:n}),assuranceHistoryPromotions:()=>G("/assurance-history/promotions",void 0,"GET"),assuranceHistoryPromote:(e,t,n=!0)=>G(`/assurance-history/patterns/${encodeURIComponent(e)}/promote`,{sourceRecordId:t,draftedBySammy:n}),assuranceHistoryCancelPromotion:e=>G(`/assurance-history/promotions/${encodeURIComponent(e)}`,{state:"CANCELLED"}),assuranceHistoryEnterprise:(e={})=>{const t=Aw(e);return G(`/assurance-history/enterprise${t?`?${t}`:""}`,void 0,"GET")},assuranceHistoryEvidenceVault:()=>G("/assurance-history/evidence-vault",void 0,"GET"),assuranceHistoryRetention:e=>G("/assurance-history/enterprise/retention",{before:e}),assuranceHistoryAuditExport:(e,t)=>{const n=new URLSearchParams;return e&&n.set("from",e),t&&n.set("to",t),G(`/assurance-history/enterprise/audit-export${n.size?`?${n.toString()}`:""}`,void 0,"GET")},modelScanRun:e=>G("/model-scans/run",e),modelScans:(e=25)=>G(`/model-scans?limit=${e}`,void 0,"GET"),modelScan:e=>G(`/model-scans/${encodeURIComponent(e)}`,void 0,"GET"),deleteModelScan:e=>G(`/model-scans/${encodeURIComponent(e)}`,void 0,"DELETE"),exportModelScan:async(e,t)=>{var d;const n=await Ka(),a={};n&&(a.authorization=`Bearer ${n}`);const r=await fetch(`/api/model-scans/${encodeURIComponent(e)}/export?format=${t}`,{headers:a});if(!r.ok)throw new Error(`Export failed (${r.status}).`);const i=await r.blob(),l=((d=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:d[1])??`prooflane-model-scan.${t==="sarif"?"sarif.json":t}`,c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=l,u.click(),setTimeout(()=>URL.revokeObjectURL(c),1e3)},modelSecurityCatalog:()=>G("/model-security/packs",void 0,"GET"),modelSecurityHistory:(e=50)=>G(`/model-security?limit=${e}`,void 0,"GET"),modelSecurityScan:e=>G(`/model-security/${encodeURIComponent(e)}`,void 0,"GET"),deleteModelSecurityScan:e=>G(`/model-security/${encodeURIComponent(e)}`,void 0,"DELETE"),modelSecurityRunStream:async(e,t,n)=>{const a=await Ka(),r={"content-type":"application/json"};a&&(r.authorization=`Bearer ${a}`);const i=await fetch("/api/model-security/run",{method:"POST",headers:r,body:JSON.stringify({...e,stream:!0}),signal:n});if(!i.ok||!i.body){const d=await i.text().catch(()=>""),h=d?(()=>{try{return JSON.parse(d)}catch{return null}})():null;return{ok:!1,error:(h==null?void 0:h.error)||`Request failed (${i.status})`}}const o=i.body.getReader(),l=new TextDecoder;let c="",u={ok:!1,error:"The scan stream ended without a result."};for(;;){const d=await o.read();if(d.done)break;c+=l.decode(d.value,{stream:!0});let h;for(;(h=c.indexOf(`
|
|
45
|
-
`))>=0;){const g=c.slice(0,h).trim();if(c=c.slice(h+1),!g)continue;let v;try{v=JSON.parse(g)}catch{continue}v.t==="progress"&&v.event?t(v.event):v.t==="done"&&(u={ok:!!v.ok,report:v.report,error:v.error})}}return u},exportModelSecurityScan:async(e,t)=>{var d;const n=await Ka(),a={};n&&(a.authorization=`Bearer ${n}`);const r=await fetch(`/api/model-security/${encodeURIComponent(e)}/export?format=${t}`,{headers:a});if(!r.ok)throw new Error(`Export failed (${r.status}).`);const i=await r.blob(),l=((d=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:d[1])??`prooflane-model-supply-chain.${t==="sarif"?"sarif.json":t}`,c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=l,u.click(),setTimeout(()=>URL.revokeObjectURL(c),1e3)},tagsList:()=>G("/tags",void 0,"GET"),tagUpsert:e=>G("/tags",{test:e}),tagRemove:e=>G(`/tags/${encodeURIComponent(e)}`,void 0,"DELETE"),runAgent:(e,t,n,a)=>G("/prompts/run-agent",{tool:e,prompt:t,llm:n,case:a}),redteamCatalog:e=>G(`/redteam/catalog${e?`?layer=${e}`:""}`,void 0,"GET"),redteamPacks:()=>G("/redteam/packs",void 0,"GET"),redteamCampaigns:()=>G("/redteam/campaigns",void 0,"GET"),redteamCampaignRun:(e,t)=>G("/redteam/campaign",{id:e,llm:t}),ragRun:e=>G("/rag/run",e),ragDiff:(e,t=!1)=>G(`/rag/${t?"hosted-diff":"diff"}/${e}`,void 0,"GET"),redteamRun:(e,t,n)=>G("/redteam/run",{layer:e,llm:t,attackIds:n}),redteamRunStream:async(e,t,n,a,r,i)=>{const o=await Ka(),l={"content-type":"application/json"};o&&(l.authorization=`Bearer ${o}`);const c=await fetch("/api/redteam/run",{method:"POST",headers:l,body:JSON.stringify({layer:e,llm:t,attackIds:n,stream:!0,recordHistory:i==null?void 0:i.recordHistory}),signal:r});if(!c.ok||!c.body){const v=await c.text().catch(()=>""),f=v?(()=>{try{return JSON.parse(v)}catch{return null}})():null;return{ok:!1,error:(f==null?void 0:f.error)||`Request failed (${c.status})`}}const u=c.body.getReader(),d=new TextDecoder;let h="",g={ok:!1,error:"stream ended without a result"};for(;;){const{value:v,done:f}=await u.read();if(f)break;h+=d.decode(v,{stream:!0});let y;for(;(y=h.indexOf(`
|
|
46
|
-
`))>=0;){const b=h.slice(0,y).trim();if(h=h.slice(y+1),!b)continue;let m;try{m=JSON.parse(b)}catch{continue}m.t==="progress"?a({done:Number(m.done),total:Number(m.total),id:String(m.id),name:String(m.name),severity:String(m.severity)}):m.t==="done"&&(g={ok:!!m.ok,report:m.report,run:m.run,error:m.error})}}return g},perfRun:(e,t,n,a)=>G("/perf/run",{target:e,vus:t,durationS:n,targetMs:a}),llmRun:e=>G("/llm/run",e),workspaceConsent:(e,t,n)=>G("/workspace/consent",{version:e,termsAccepted:t,dataProcessingAccepted:n}),ciToken:()=>G("/ci/token",{}),githubOidcTrust:()=>G("/governance/github-oidc-trust",void 0,"GET"),githubOidcTrustSave:e=>G("/governance/github-oidc-trust",e,"PUT"),githubOidcTrustRevoke:()=>G("/governance/github-oidc-trust",void 0,"DELETE"),legacyRegressionGroupsList:()=>G("/gates",void 0,"GET"),legacyRegressionGroupSave:e=>G(`/gates/${encodeURIComponent(e.id)}`,{gate:e},"PUT"),legacyRegressionGroupRemove:e=>G(`/gates/${encodeURIComponent(e)}`,void 0,"DELETE"),suitesList:()=>G("/suites",void 0,"GET"),suiteCreate:e=>G("/suites",e),suiteArchive:e=>G(`/suites/${encodeURIComponent(e)}`,void 0,"DELETE"),suiteCreateVersion:(e,t)=>G(`/suites/${encodeURIComponent(e)}/versions`,t),suiteUpdateDraft:(e,t,n)=>G(`/suites/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),suiteReview:(e,t)=>G(`/suites/${encodeURIComponent(e)}/versions/${t}/review`,{}),suiteApprove:(e,t)=>G(`/suites/${encodeURIComponent(e)}/versions/${t}/approve`,{}),suiteDeprecate:(e,t)=>G(`/suites/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),suiteAssessDrift:e=>G(`/governance/suites/${encodeURIComponent(e)}/drift`,{}),localSuiteMigrationStatus:()=>G("/suite-migration/status",void 0,"GET"),localSuiteMigrationSync:e=>G("/suite-migration/sync",{selections:e}),policiesList:()=>G("/policies",void 0,"GET"),governedRuns:(e=50)=>G(`/governed-runs?limit=${e}`,void 0,"GET"),policyCreate:e=>G("/policies",e),policyCreateVersion:(e,t)=>G(`/policies/${encodeURIComponent(e)}/versions`,t),policyUpdateDraft:(e,t,n)=>G(`/policies/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),policyReview:(e,t)=>G(`/policies/${encodeURIComponent(e)}/versions/${t}/review`,{}),policyApprove:(e,t)=>G(`/policies/${encodeURIComponent(e)}/versions/${t}/approve`,{}),policyDeprecate:(e,t)=>G(`/policies/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGatesList:(e=!1)=>G(`/governance/gates${e?"?includeArchived=true":""}`,void 0,"GET"),governedGateCreate:e=>G("/governance/gates",e),governedGateGet:e=>G(`/governance/gates/${encodeURIComponent(e)}`,void 0,"GET"),governedGateRename:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}`,{displayName:t},"PATCH"),governedGateArchive:e=>G(`/governance/gates/${encodeURIComponent(e)}/archive`,{}),governedGateRestore:e=>G(`/governance/gates/${encodeURIComponent(e)}/restore`,{}),governedGateCreateVersion:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}/versions`,t),governedGateGetVersion:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,void 0,"GET"),governedGateUpdateDraft:(e,t,n)=>G(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),governedGateReview:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/review`,{}),governedGateApprove:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/approve`,{}),governedGateDeprecate:(e,t)=>G(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGateAliases:e=>G(`/governance/gates/${encodeURIComponent(e)}/aliases`,void 0,"GET"),governedGateAudit:(e,t=50)=>G(`/governance/gates/${encodeURIComponent(e)}/audit?limit=${t}`,void 0,"GET"),governedGateResolve:e=>G(`/governance/gates/${encodeURIComponent(e)}/resolve`,void 0,"GET"),governedGateRunLocal:e=>G(`/governance/gates/${encodeURIComponent(e)}/runs`,{}),governedGateStartLocalJob:e=>G(`/governance/gates/${encodeURIComponent(e)}/local-jobs`,{}),governedGateJobsLocal:(e=50)=>G(`/governance/local-gate-jobs?limit=${e}`,void 0,"GET"),governedGateJobLocal:e=>G(`/governance/local-gate-jobs/${encodeURIComponent(e)}`,void 0,"GET"),governedGateReportsLocal:(e=100)=>G(`/governance/gate-run-reports?limit=${e}`,void 0,"GET"),governedGateReportLocal:e=>G(`/governance/gate-run-reports/${encodeURIComponent(e)}`,void 0,"GET"),governedGateSpineReportLocal:e=>Iw(`/governance/gate-run-reports/${encodeURIComponent(e)}/report.html`),remoteRunners:()=>G("/governance/runners",void 0,"GET"),remoteRunnerRevoke:e=>G(`/governance/runners/${encodeURIComponent(e)}/revoke`,{}),governedGateRunRemote:(e,t,n)=>G(`/governance/gates/${encodeURIComponent(e)}/remote-runs`,{schemaVersion:"prooflane-remote-gate-run-request-v1",runnerId:t,requestId:n}),remoteRunnerJob:e=>G(`/governance/runner-jobs/${encodeURIComponent(e)}`,void 0,"GET"),remoteRunnerJobCancel:e=>G(`/governance/runner-jobs/${encodeURIComponent(e)}/cancel`,{}),governedGateSigningKey:e=>G(`/governance/gate-signing-keys/${encodeURIComponent(e)}`,void 0,"GET"),learningFindings:e=>G(`/governance/learning/runs/${encodeURIComponent(e)}/findings`,void 0,"GET"),learningDisposition:e=>G(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,void 0,"GET"),learningDispositionApprove:(e,t)=>G(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,t,"PUT"),learningGenerations:(e=50)=>G(`/governance/learning/generations?limit=${e}`,void 0,"GET"),learningGenerate:e=>G("/governance/learning/generations",{schemaVersion:"prooflane-learning-generation-request-v1"},"POST",{"idempotency-key":e}),learnedTests:(e=100)=>G(`/governance/learning/tests?limit=${e}`,void 0,"GET"),learnedTestReview:e=>G(`/governance/learning/tests/${encodeURIComponent(e)}/review`,{}),learnedTestApprove:e=>G(`/governance/learning/tests/${encodeURIComponent(e)}/approve`,{}),learningAudit:(e=100)=>G(`/governance/learning/audit?limit=${e}`,void 0,"GET"),legacyAssuranceBindings:()=>G("/assurance/gates",void 0,"GET",{},"no-store"),assurancePolicies:()=>G("/assurance/policies",void 0,"GET"),assurancePolicyCreate:e=>G("/assurance/policies",e),legacyAssuranceBindingPolicyUpdate:(e,t)=>G(`/assurance/gates/${encodeURIComponent(e)}/policy`,{policyVersion:t},"PATCH"),assuranceGateRun:e=>G(`/assurance/gates/${encodeURIComponent(e)}/runs`,{}),assuranceRun:e=>G(`/assurance/runs/${encodeURIComponent(e)}`,void 0,"GET"),assuranceRunReport:e=>Iw(`/assurance/runs/${encodeURIComponent(e)}/report`),assuranceRunCancel:e=>G(`/assurance/runs/${encodeURIComponent(e)}/cancel`,{}),sammyAnalyze:e=>G("/intelligence/analyze-options",e),intelligenceSurface:()=>G("/intelligence/surface",void 0,"GET",{},"no-store"),intelligenceSurfaceRefresh:()=>G("/intelligence/surface/refresh",{}),sammyGenerate:e=>G("/intelligence/generations",e),sammyGenerationJobCreate:e=>G("/intelligence/generation-jobs",e),sammyGenerationJob:e=>G(`/intelligence/generation-jobs/${encodeURIComponent(e)}`,void 0,"GET",{},"no-store"),sammyGenerationJobCancel:e=>G(`/intelligence/generation-jobs/${encodeURIComponent(e)}/cancel`,{}),evaluationAssetCreate:(e,t)=>G("/intelligence/evaluation-assets",{definition:e,...t?{localRef:t}:{}}),evaluationSession:()=>G("/intelligence/evaluation-session",void 0,"GET",{},"no-store"),evaluationSessionConfigure:e=>G("/intelligence/evaluation-session",e,"PUT"),evaluationSessionClear:()=>G("/intelligence/evaluation-session",void 0,"DELETE"),evaluationSessionTest:e=>G("/intelligence/evaluation-session/test",e),evaluationPreview:(e,t)=>G("/intelligence/evaluation-previews",{localRefs:e,executionMode:t}),sammyGeneration:e=>G(`/intelligence/generations/${encodeURIComponent(e)}`,void 0,"GET"),sammyGenerationReview:(e,t)=>G(`/intelligence/generations/${encodeURIComponent(e)}/review`,t),sammyGenerationApprove:(e,t)=>G(`/intelligence/generations/${encodeURIComponent(e)}/approve`,t),sammyGenerationAddManualItem:(e,t)=>G(`/intelligence/generations/${encodeURIComponent(e)}/items/manual`,t),sammyGenerationReviewItem:(e,t,n)=>G(`/intelligence/generations/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}/review`,n),sammyMaterializeSuite:e=>G(`/intelligence/generations/${encodeURIComponent(e)}/materialize-suite`,{}),intelligenceNativeArtifacts:(e,t)=>G(`/intelligence/native-artifacts?pillar=${e}${t?`&generationId=${encodeURIComponent(t)}`:""}`,void 0,"GET"),intelligenceNativeArtifactReview:(e,t,n)=>G(`/intelligence/native-artifacts/${encodeURIComponent(e)}/${encodeURIComponent(t)}/review`,n),regoldenVerifiedBaseline:(e,t)=>G("/contracts/verified-baselines/regolden",{baseline:e,verifiedBy:t}),sammyDatasets:()=>G("/intelligence/datasets",void 0,"GET"),sammyDatasetAdd:e=>G("/intelligence/datasets",e),annotationCreate:e=>G("/annotations",e),assuranceRunEvents:(e,t,n)=>{const a=new EventSource(`/api/assurance/runs/${encodeURIComponent(e)}/events`),r=["RUN_CREATED","RUN_STARTED","SUITE_LOADED","PILLAR_STARTED","TEST_STARTED","TEST_LOG","TEST_COMPLETED","FINDING_CREATED","PILLAR_COMPLETED","GATE_EVALUATING","GATE_DECIDED","RUN_COMPLETED","RUN_CANCELLED","RUN_FAILED"];for(const i of r)a.addEventListener(i,o=>{try{t(JSON.parse(o.data))}catch{}});return a.onerror=n,()=>a.close()},workspaceStatus:()=>G("/workspace/status",void 0,"GET"),gateRuns:(e=200)=>G(`/gate-runs?limit=${e}`,void 0,"GET"),syncGateRuns:e=>G("/gate-runs",{version:"prooflane-gate-runs-v1",runs:e.map(t=>({id:t.id,pillar:t.pillar,label:t.label,total:t.total,pass:t.pass,drift:t.drift,fail:t.fail,error:t.error,...t.score==null?{}:{score:t.score},...t.severity==null?{}:{severity:t.severity},...t.poisoned==null?{}:{poisoned:t.poisoned},...t.exposureSeverity==null?{}:{exposureSeverity:t.exposureSeverity},...t.durationMs==null?{}:{durationMs:t.durationMs},createdAt:t.createdAt,source:"inspector"}))}),workspaceBackupPreference:(e=24)=>G("/workspace/backup-preference",{automaticBackupAccepted:!0,cadenceHours:e}),workspaceBackup:()=>G("/workspace/backup",{releasePolicy:C2()}),workspaceLatestBackup:(e=!1)=>G(`/workspace/backup/latest${e?"?restorable=1":""}`,void 0,"GET"),workspaceBackupVersions:(e=50)=>G(`/workspace/backup/versions?limit=${e}`,void 0,"GET"),workspaceRestore:()=>G("/workspace/restore",{}),localWorkspaceLifecycle:async(e,t,n)=>{const a=await fetch("/api/workspace/local/lifecycle",{method:"POST",headers:{"content-type":"application/json","x-kawach-local-lifecycle":e},body:JSON.stringify({reason:t,subject:n})});if(!a.ok)throw new Error("Could not secure the local workspace.");return a.json()},intelligenceLease:(e,t=1)=>G("/intelligence/leases",{pillar:e,count:t}),securityAuthContext:()=>M2("/security/auth-context"),saveSecurityAuthProfile:e=>G("/security/auth-context/profiles",e),deleteSecurityAuthProfile:e=>G(`/security/auth-context/profiles/${encodeURIComponent(e)}`,void 0,"DELETE"),destroySecurityAuthSession:e=>G(`/security/auth-context/sessions/${encodeURIComponent(e)}/destroy`,{}),preflightSecurityAuth:e=>G("/security/auth-context/preflight",e),securityScanCreate:(e,t,n)=>G("/security/scans",{target:{name:e,type:"agent"},requestedControlIds:t,...n?{authContext:n}:{}}),hostedSecurityCatalog:()=>G("/security/catalog",void 0,"GET"),ragScanCreate:(e,t)=>G("/rag/scans",{target:{name:e,type:"rag"},requestedControlIds:t}),assuranceScanSnapshot:(e,t)=>G(`/${e}/scans/${encodeURIComponent(t)}`,void 0,"GET"),assuranceScanNextTask:(e,t)=>G(`/${e}/scans/${encodeURIComponent(t)}/next-task`,{}),assuranceScanEvidence:(e,t,n,a)=>G(`/${e}/scans/${encodeURIComponent(t)}/evidence`,{lease:n,evidence:a}),securityScanNextTask:e=>G(`/security/scans/${encodeURIComponent(e)}/next-task`,{}),securityScanEvidence:(e,t,n)=>G(`/security/scans/${encodeURIComponent(e)}/evidence`,{lease:t,evidence:n}),intelligenceExecute:e=>G("/intelligence/execute",e),intelligenceEvidence:(e,t)=>G("/intelligence/evidence",{lease:e,evidence:t}),intelligenceEvaluation:(e,t)=>G("/intelligence/evaluations",{lease:e,execution:t}),benchmarkRun:e=>G("/benchmark/run",e),benchmarkEntitlements:()=>G("/benchmark/entitlements",void 0,"GET"),benchmarkVerifyPurchase:e=>G("/benchmark/purchases/verify",e),benchmarkPlan:e=>G("/benchmark/plans",e),benchmarkReviseJudgingStrategy:(e,t)=>G("/benchmark/plans/judging-strategy",{plan:e,strategy:t}),benchmarkRunStream:async(e,t,n)=>{const a=await Ka(),r={"content-type":"application/json"};a&&(r.authorization=`Bearer ${a}`);const i=await fetch("/api/benchmark/run",{method:"POST",headers:r,body:JSON.stringify({...e,stream:!0}),signal:n});if(!i.ok||!i.body){const d=await i.text().catch(()=>""),h=d?(()=>{try{return JSON.parse(d)}catch{return null}})():null;return{ok:!1,error:(h==null?void 0:h.error)??`Request failed (${i.status})`,preflight:h==null?void 0:h.preflight}}const o=i.body.getReader(),l=new TextDecoder;let c="",u={ok:!1,error:"The benchmark stream ended without a result."};for(;;){const{value:d,done:h}=await o.read();if(h)break;c+=l.decode(d,{stream:!0});let g;for(;(g=c.indexOf(`
|
|
47
|
-
`))>=0;){const v=c.slice(0,g).trim();if(c=c.slice(g+1),!v)continue;let f;try{f=JSON.parse(v)}catch{continue}f.t==="progress"?t(f):f.t==="done"?u={ok:!0,report:f.report,workflow:f.workflow}:f.t==="error"&&(u={ok:!1,error:String(f.error??"The benchmark failed.")})}}return u},benchmarkHistory:()=>G("/benchmark/history",void 0,"GET"),benchmarkStoredRun:e=>G(`/benchmark/runs/${encodeURIComponent(e)}`,void 0,"GET"),benchmarkGenerateEvidence:e=>G("/benchmark/evidence/generate",e),ragRunStream:async(e,t,n,a=!1)=>{const r=await Ka(),i={"content-type":"application/json"};r&&(i.authorization=`Bearer ${r}`);const o=await fetch(`/api/rag/${a?"hosted-run":"run"}`,{method:"POST",headers:i,body:JSON.stringify({...e,stream:!0}),signal:n});if(!o.ok||!o.body){const h=await o.text().catch(()=>""),g=h?(()=>{try{return JSON.parse(h)}catch{return null}})():null;return{ok:!1,error:(g==null?void 0:g.error)||`Request failed (${o.status})`}}const l=o.body.getReader(),c=new TextDecoder;let u="",d={ok:!1,error:"The run ended without a result."};for(;;){const{value:h,done:g}=await l.read();if(g)break;u+=c.decode(h,{stream:!0});let v;for(;(v=u.indexOf(`
|
|
48
|
-
`))>=0;){const f=u.slice(0,v).trim();if(u=u.slice(v+1),!f)continue;let y;try{y=JSON.parse(f)}catch{continue}y.t==="progress"?t({done:Number(y.done),total:Number(y.total),id:String(y.id??""),name:String(y.name??""),mode:String(y.mode??"")}):y.t==="done"?d={ok:!!y.ok,report:y.report,diff:y.diff,run:y.run,error:y.error}:y.t==="error"&&(d={ok:!1,error:String(y.error??"Hosted RAG Assurance could not complete.")})}}return d},generatePromptCases:e=>G("/prompts/generate-cases",e),savePromptCases:(e,t="ai")=>G("/prompts/custom/bulk",{cases:e,source:t}),promptStudioCreate:e=>G("/prompt-studio/sessions",e),promptStudioSessions:()=>G("/prompt-studio/sessions",void 0,"GET"),promptStudioSession:e=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}`,void 0,"GET"),promptStudioDelete:e=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}`,void 0,"DELETE"),promptStudioSend:(e,t,n,a)=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}/messages`,{message:t,llm:n}),promptStudioSuggestions:e=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}/suggestions`,void 0,"GET"),promptStudioStop:e=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}/stop`,{}),promptStudioCallTool:(e,t,n,a=!1)=>G(`/prompt-studio/sessions/${encodeURIComponent(e)}/tools/${encodeURIComponent(t)}`,{input:n,confirmed:a}),boundaryFamilies:()=>G("/boundary/families",void 0,"GET"),boundaryDiscover:()=>G("/boundary/discover",{}),boundaryRun:(e,t)=>G("/boundary/run",{fixtures:e,families:t}),startTrial:()=>G("/trial/start",{})};function ur(){return s.jsx("div",{className:"brand-mark",children:s.jsxs("svg",{viewBox:"0 0 72 72",fill:"none",role:"img","aria-label":"Prooflane Agent Assurance Spine",children:[s.jsx("rect",{x:"10",y:"9",width:"52",height:"8",rx:"1",fill:"#E8A33D"}),s.jsx("rect",{x:"10",y:"20.5",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".82"}),s.jsx("rect",{x:"10",y:"32",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".56"}),s.jsx("rect",{x:"10",y:"43.5",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".38"}),s.jsx("rect",{x:"10",y:"55",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".26"}),s.jsx("path",{d:"M13 37.4 L31.5 57.3 L69.4 3.3 L65.7 2.6 L32.3 47.4 L19.7 33.9 Z",fill:"#34D399",stroke:"var(--bg)",strokeWidth:"2.6",strokeLinejoin:"round"}),s.jsx("path",{d:"M13 37.4 L31.5 57.3 L69.4 3.3 L65.7 2.6 L32.3 47.4 L19.7 33.9 Z",fill:"#34D399"})]})})}function Bc({label:e="Loading…",compact:t=!1}){return s.jsxs("div",{className:`kawach-loader${t?" compact":""}`,role:"status","aria-live":"polite",children:[s.jsx(ur,{}),s.jsx("span",{children:e})]})}function bx({severity:e}){return s.jsx("span",{className:`tag ${e}`,children:e})}function wx({verdict:e}){return s.jsx("span",{className:`tag ${e}`,children:e})}function Ls({value:e}){const t=typeof e=="string"?e:JSON.stringify(e,null,2);return s.jsx("div",{className:"codeblock",children:t??"null"})}function Vc({value:e}){const n=((typeof e=="string"?e:JSON.stringify(e,null,2))??"null").split(`
|
|
49
|
-
`);return s.jsxs("div",{className:"codeblock lined mono",children:[s.jsx("div",{className:"gutter",children:n.map((a,r)=>s.jsx("span",{children:r+1},r))}),s.jsx("div",{className:"code",children:n.map((a,r)=>s.jsx("span",{children:a||" "},r))})]})}function _v(e){const t=typeof e=="string"?e:JSON.stringify(e??null),n=new TextEncoder().encode(t).length;return n<1024?`${n} B`:`${(n/1024).toFixed(1)} KB`}function us({children:e}){return s.jsx("div",{className:"empty",children:e})}function Pw({message:e}){return s.jsx("div",{className:"toast",children:e})}function Bp({page:e,pageSize:t,total:n,onPage:a}){const r=Math.ceil(n/t);if(r<=1)return null;const i=e*t+1,o=Math.min(n,(e+1)*t);return s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center",justifyContent:"flex-end",marginTop:12},children:[s.jsxs("span",{className:"muted",style:{fontSize:12},children:[i,"–",o," of ",n]}),s.jsx("button",{className:"btn sm ghost",disabled:e<=0,onClick:()=>a(e-1),children:"← Prev"}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[e+1," / ",r]}),s.jsx("button",{className:"btn sm ghost",disabled:e>=r-1,onClick:()=>a(e+1),children:"Next →"})]})}const jc="1.0",Cv="prooflane.connections.example.json",LE=new Set(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD","TRACE"]),Sx=/^\$\{(env|session):([A-Za-z_][A-Za-z0-9_]*)\}$/,D2=/(?:authorization|api[-_]?key|token|secret|password|credential)/i;function z2(e){let t;try{t=typeof e=="string"?JSON.parse(e):structuredClone(e)}catch{return{manifest:{schemaVersion:jc,connections:[]},valid:!1,issues:[{path:"$",message:"Connection manifest must be valid JSON."}]}}const n=[];if(!Vs(t))return{manifest:{schemaVersion:jc,connections:[]},valid:!1,issues:[{path:"$",message:"Connection manifest must be a JSON object."}]};t.schemaVersion!==jc&&n.push({path:"schemaVersion",message:`schemaVersion must be ${jc}.`}),Array.isArray(t.connections)||n.push({path:"connections",message:"connections must be an array."});const a=Array.isArray(t.connections)?t.connections:[],r=new Set;return a.forEach((i,o)=>G2(i,o,r,n)),{manifest:t,issues:n,valid:n.length===0}}function U2(e,t){var n,a,r,i;if(e.type==="mcp"){const o=e.transport==="stdio"?{transport:"stdio",command:e.command,args:e.args,env:oo(e.env,t.secrets,`${e.id}.env`)}:J2(e,t.secrets);return{id:e.id,name:e.name,type:"MCP",config:{type:"MCP",name:e.name,connection:o},requiresStdioTrust:e.transport==="stdio"}}if(e.type==="http"){const o={type:"HTTP_API",name:e.name,baseUrl:e.baseUrl,authentication:nf(e.auth,t.secrets,e.id),headers:oo(e.headers,t.secrets,`${e.id}.headers`),environmentVariables:oo(e.env,t.secrets,`${e.id}.env`)},l=e.mode==="openapi"?{...o,mode:"OPENAPI",openApiUrl:e.openapi.url,openApiDocument:e.openapi.file?Y2(e.openapi.file,t):void 0}:{...o,mode:"MANUAL",method:e.method.toUpperCase(),path:e.path,capabilityName:e.capabilityName,requestTemplate:e.requestTemplate,responseMapping:e.responseMapping};return{id:e.id,name:e.name,type:"HTTP_API",config:l,requiresStdioTrust:!1}}if(e.type==="rag"){const o=e.retriever;return{id:e.id,name:e.name,type:"RAG",requiresStdioTrust:!1,config:{type:"RAG",mode:e.mode==="full-chain"?"FULL_CHAIN":"RETRIEVER_ONLY",name:e.name,endpoint:o.endpoint,method:((n=o.method)==null?void 0:n.toUpperCase())??"POST",authentication:nf(e.auth,t.secrets,e.id),headers:oo(e.headers,t.secrets,`${e.id}.headers`),queryMapping:o.queryMapping,answerMapping:e.mode==="full-chain"?o.answerMapping:void 0,retrievedItemsMapping:o.retrievedItemsMapping,citationMapping:e.mode==="full-chain"?o.citationMapping:void 0,documentIdMapping:o.documentIdMapping,documentTextMapping:o.documentTextMapping,metadataMapping:o.metadataMapping,testQuery:(a=e.connectionTest)==null?void 0:a.query}}}return e.type==="model"?{id:e.id,name:e.name,type:"MODEL",requiresStdioTrust:!1,config:{type:"MODEL",provider:Z2(e.compatibility),name:e.name,model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey?zi(e.apiKey,t.secrets,`${e.id}.apiKey`):void 0,headers:oo(e.headers,t.secrets,`${e.id}.headers`),parameters:e.modelParameters,path:e.compatibility==="custom"?e.path:void 0,requestTemplate:e.compatibility==="custom"?e.requestTemplate:void 0,responseMapping:e.compatibility==="custom"?e.responseMapping:void 0}}:{id:e.id,name:e.name,type:"AGENT",requiresStdioTrust:!1,config:{type:"AGENT",name:e.name,endpoint:e.invocation.endpoint,method:((r=e.invocation.method)==null?void 0:r.toUpperCase())??"POST",authentication:nf(e.auth,t.secrets,e.id),headers:oo(e.headers,t.secrets,`${e.id}.headers`),requestTemplate:e.requestTemplate,inputMapping:e.mapping.input,responseMapping:e.mapping.response,toolCallMapping:e.mapping.toolCalls,retrievalMapping:e.mapping.retrieval,stateMapping:e.mapping.state,traceMapping:e.mapping.trace,finalStateMapping:e.mapping.finalState,testInput:(i=e.connectionTest)==null?void 0:i.input}}}function F2(e){return e.type==="mcp"?e.transport==="stdio"?`MCP Server · stdio · ${[e.command,...e.args??[]].join(" ")}`:`MCP Server · remote HTTP · ${e.url}`:e.type==="http"?`HTTP / API · ${e.mode} · ${e.baseUrl}`:e.type==="rag"?`RAG System · ${e.mode} · ${(e.retriever.method??"POST").toUpperCase()} ${e.retriever.endpoint}`:e.type==="model"?`Model Endpoint · ${e.compatibility} · ${e.model}`:`AI Agent · ${(e.invocation.method??"POST").toUpperCase()} ${e.invocation.endpoint}`}const Tv={schemaVersion:jc,connections:[{id:"example-mcp-stdio",name:"Example MCP stdio",type:"mcp",transport:"stdio",command:"node",args:["examples/mock-server.mjs"],env:{API_KEY:"${env:MCP_API_KEY}"}},{id:"example-mcp-remote",name:"Example Remote MCP",type:"mcp",transport:"remote-http",url:"https://example.com/mcp",auth:{type:"bearer",token:"${env:MCP_BEARER_TOKEN}"}},{id:"example-http-openapi",name:"Example OpenAPI target",type:"http",mode:"openapi",baseUrl:"https://api.example.com",openapi:{url:"/openapi.json"},env:{},auth:{type:"none"},headers:{}},{id:"example-http-manual",name:"Example Manual HTTP target",type:"http",mode:"manual",baseUrl:"https://api.example.com",method:"POST",path:"/chat",capabilityName:"chat_completion",requestTemplate:{input:"{{input}}"},responseMapping:{output:"output",answer:"answer",toolCalls:"toolCalls",citations:"citations",metadata:"metadata"},auth:{type:"none"},headers:{},env:{}},{id:"example-rag-retriever",name:"Example Retriever-only RAG",type:"rag",mode:"retriever-only",retriever:{endpoint:"https://rag.example.com/query",method:"POST",queryMapping:"query",retrievedItemsMapping:"retrievedItems",documentIdMapping:"id",documentTextMapping:"text",metadataMapping:"metadata"},connectionTest:{query:"prooflane connection test"},auth:{type:"api-key",header:"x-api-key",key:"${prompt}"},headers:{}},{id:"example-rag-full",name:"Example Full-chain RAG",type:"rag",mode:"full-chain",retriever:{endpoint:"https://rag.example.com/query",method:"POST",queryMapping:"query",retrievedItemsMapping:"retrievedItems",documentIdMapping:"id",documentTextMapping:"text",metadataMapping:"metadata",answerMapping:"answer",citationMapping:"citations"},connectionTest:{query:"prooflane connection test"},auth:{type:"none"},headers:{}},{id:"example-model-openai",name:"Example OpenAI-compatible Model",type:"model",compatibility:"openai-compatible",baseUrl:"http://localhost:11434/v1",model:"example-model",apiKey:"${session:TARGET_MODEL_API_KEY}",modelParameters:{temperature:0},headers:{}},{id:"example-model-anthropic",name:"Example Anthropic-compatible Model",type:"model",compatibility:"anthropic-compatible",baseUrl:"https://api.anthropic.com/v1",model:"example-model",apiKey:"${session:TARGET_MODEL_API_KEY}",modelParameters:{temperature:0},headers:{}},{id:"example-model-custom",name:"Example Custom Model",type:"model",compatibility:"custom",baseUrl:"http://localhost:3000",model:"example-model",path:"/invoke",apiKey:"${session:TARGET_MODEL_API_KEY}",requestTemplate:{prompt:"{{prompt}}"},responseMapping:{answer:"answer",toolCalls:"toolCalls",metadata:"metadata"},modelParameters:{},headers:{}},{id:"example-agent",name:"Example AI Agent",type:"agent",invocation:{endpoint:"http://localhost:3000/agent",method:"POST"},mapping:{input:"input",response:"response",toolCalls:"toolCalls",retrieval:"retrievalEvents",state:"stateTransitions",trace:"trace",finalState:"finalState"},requestTemplate:{},connectionTest:{input:{input:"prooflane connection test"}},auth:{type:"bearer",token:"${prompt}"},headers:{}}]};[...LE];function G2(e,t,n,a){const r=`connections[${t}]`;if(!Vs(e)){a.push({path:r,message:"connection must be an object."});return}if(cn(e,"id",r,a),cn(e,"name",r,a),typeof e.id=="string"&&(n.has(e.id)&&a.push({path:`${r}.id`,message:"connection id must be unique."}),n.add(e.id)),e.enabled!==void 0&&typeof e.enabled!="boolean"&&a.push({path:`${r}.enabled`,message:"enabled must be a boolean."}),!["mcp","http","rag","model","agent"].includes(String(e.type))){a.push({path:`${r}.type`,message:"type must be mcp, http, rag, model, or agent."});return}e.type==="mcp"?W2(e,r,a):e.type==="http"?H2(e,r,a):e.type==="rag"?B2(e,r,a):e.type==="model"?V2(e,r,a):q2(e,r,a),ME(e,r,a)}function W2(e,t,n){e.transport==="stdio"?(cn(e,"command",t,n),e.args!==void 0&&(!Array.isArray(e.args)||e.args.some(a=>typeof a!="string"))&&n.push({path:`${t}.args`,message:"args must be an array of strings."}),ul(e.env,`${t}.env`,n)):e.transport==="remote-http"?(Fd(e,"url",t,n),Vp(e.auth,`${t}.auth`,n,!0),Vs(e.auth)&&e.auth.type==="api-key"&&n.push({path:`${t}.auth.type`,message:"MCP remote HTTP does not expose API-key authentication in the current form."})):n.push({path:`${t}.transport`,message:"MCP transport must be stdio or remote-http."})}function H2(e,t,n){if(Fd(e,"baseUrl",t,n),Vp(e.auth,`${t}.auth`,n),ul(e.headers,`${t}.headers`,n),ul(e.env,`${t}.env`,n),e.mode==="openapi"){const a=Vs(e.openapi)?e.openapi:null;a?[a.url,a.file].filter(i=>typeof i=="string"&&i.trim()).length!==1&&n.push({path:`${t}.openapi`,message:"Specify exactly one OpenAPI url or file."}):n.push({path:`${t}.openapi`,message:"OpenAPI mode requires an openapi object."})}else e.mode==="manual"?(Nx(e,t,n),cn(e,"path",t,n),e.responseMapping!==void 0&&!Vs(e.responseMapping)&&n.push({path:`${t}.responseMapping`,message:"responseMapping must be an object."})):n.push({path:`${t}.mode`,message:"HTTP mode must be openapi or manual."})}function B2(e,t,n){e.mode!=="full-chain"&&e.mode!=="retriever-only"&&n.push({path:`${t}.mode`,message:"RAG mode must be full-chain or retriever-only."});const a=Vs(e.retriever)?e.retriever:null;if(!a){n.push({path:`${t}.retriever`,message:"retriever must be an object."});return}Fd(a,"endpoint",`${t}.retriever`,n),a.method!==void 0&&Nx(a,`${t}.retriever`,n);for(const r of["queryMapping","retrievedItemsMapping","documentIdMapping","documentTextMapping"])cn(a,r,`${t}.retriever`,n);e.mode==="full-chain"&&cn(a,"answerMapping",`${t}.retriever`,n),Vp(e.auth,`${t}.auth`,n),ul(e.headers,`${t}.headers`,n)}function V2(e,t,n){["openai-compatible","anthropic-compatible","custom"].includes(String(e.compatibility))||n.push({path:`${t}.compatibility`,message:"Unsupported model compatibility mode."}),Fd(e,"baseUrl",t,n),cn(e,"model",t,n),e.apiKey!==void 0&&gh(e.apiKey,`${t}.apiKey`,n),e.modelParameters!==void 0&&!Vs(e.modelParameters)&&n.push({path:`${t}.modelParameters`,message:"modelParameters must be an object."}),ul(e.headers,`${t}.headers`,n),e.compatibility==="custom"&&(cn(e,"path",t,n),(!Vs(e.responseMapping)||!($w(e.responseMapping,"answer")||$w(e.responseMapping,"output")))&&n.push({path:`${t}.responseMapping`,message:"Custom model requires an answer or output response mapping."}))}function q2(e,t,n){const a=Vs(e.invocation)?e.invocation:null,r=Vs(e.mapping)?e.mapping:null;a?(Fd(a,"endpoint",`${t}.invocation`,n),a.method!==void 0&&Nx(a,`${t}.invocation`,n)):n.push({path:`${t}.invocation`,message:"invocation must be an object."}),r?(cn(r,"input",`${t}.mapping`,n),cn(r,"response",`${t}.mapping`,n)):n.push({path:`${t}.mapping`,message:"mapping must be an object."}),Vp(e.auth,`${t}.auth`,n),ul(e.headers,`${t}.headers`,n)}function Vp(e,t,n,a=!1){if(e!==void 0){if(!Vs(e)){n.push({path:t,message:"auth must be an object."});return}e.type==="none"||a&&e.type==="oauth"||(e.type==="bearer"?gh(e.token,`${t}.token`,n):e.type==="basic"?(cn(e,"username",t,n),gh(e.password,`${t}.password`,n)):e.type==="api-key"?(cn(e,"header",t,n),gh(e.key,`${t}.key`,n)):n.push({path:`${t}.type`,message:`auth type must be none, bearer, basic, api-key${a?", or oauth":""}.`}))}}function gh(e,t,n){(typeof e!="string"||!e.trim())&&n.push({path:t,message:"Provide a direct local credential or use ${prompt}, ${env:NAME}, or ${session:NAME}."})}function ME(e,t,n){if(Vs(e))for(const[a,r]of Object.entries(e))typeof r=="string"&&D2.test(a)&&!["username","name"].includes(a)&&r!=="${prompt}"&&!Sx.test(r)&&!K2(t,a)?n.push({path:`${t}.${a}`,message:"This credential-like field is not a supported local credential field. Use the target's auth, headers, env, or model apiKey field."}):Vs(r)&&ME(r,`${t}.${a}`,n)}function K2(e,t){return e.endsWith(".auth")&&["token","password","key"].includes(t)||t==="apiKey"&&/^connections\[\d+\]$/.test(e)?!0:e.endsWith(".headers")||e.endsWith(".env")}function ul(e,t,n){e!==void 0&&(!Vs(e)||Object.values(e).some(a=>typeof a!="string"))&&n.push({path:t,message:"must be an object with string values."})}function cn(e,t,n,a){(typeof e[t]!="string"||!e[t].trim())&&a.push({path:`${n}.${t}`,message:`${t} is required.`})}function Fd(e,t,n,a){if(cn(e,t,n,a),typeof e[t]=="string")try{if(!new URL(e[t]).protocol.startsWith("http"))throw new Error}catch{a.push({path:`${n}.${t}`,message:`${t} must be an HTTP(S) URL.`})}}function Nx(e,t,n){cn(e,"method",t,n),typeof e.method=="string"&&!LE.has(e.method.toUpperCase())&&n.push({path:`${t}.method`,message:"method is not supported."})}function $w(e,t){return Vs(e)&&typeof e[t]=="string"&&!!e[t].trim()}function Vs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nf(e,t,n){return!e||e.type==="none"?{mode:"NONE"}:e.type==="bearer"?{mode:"BEARER",token:zi(e.token,t,`${n}.auth.token`)}:e.type==="basic"?{mode:"BASIC",username:e.username,password:zi(e.password,t,`${n}.auth.password`)}:{mode:"API_KEY",header:e.header,key:zi(e.key,t,`${n}.auth.key`)}}function J2(e,t){const n=e.auth;if(!n||n.type==="none"||n.type==="oauth")return{transport:"http",url:e.url};if(n.type==="bearer")return{transport:"http",url:e.url,bearerToken:zi(n.token,t,`${e.id}.auth.token`)};if(n.type==="basic")return{transport:"http",url:e.url,basicAuth:{username:n.username,password:zi(n.password,t,`${e.id}.auth.password`)}};throw new Error("MCP remote HTTP supports NONE, BEARER, BASIC, or OAuth authentication; API_KEY is not available in the current form.")}function zi(e,t,n){const a=Sx.exec(e);if(e!=="${prompt}"&&!a)return e;const r=e==="${prompt}"?t.prompt(n):(a==null?void 0:a[1])==="env"?t.env(a[2]):(a==null?void 0:a[1])==="session"?t.session(a[2]):void 0;if(!r)throw new Error(`A local secret is required for ${n}.`);return r}function oo(e,t,n){if(e)return Object.fromEntries(Object.entries(e).map(([a,r])=>[a,r==="${prompt}"||Sx.test(r)?zi(r,t,`${n}.${a}`):r]))}function Y2(e,t){if(!t.readOpenApiFile)throw new Error(`OpenAPI file ${e} must be selected or resolved locally before connecting.`);return t.readOpenApiFile(e)}function Z2(e){return e==="openai-compatible"?"OPENAI_COMPATIBLE":e==="anthropic-compatible"?"ANTHROPIC_COMPATIBLE":"CUSTOM"}function X2(e){return!!(e&&typeof e=="object"&&"code"in e&&e.code==="TARGET_NOT_FOUND")}function Q2({type:e,reconnectTarget:t,onConnected:n,onReconnectTargetMissing:a}){const[r,i]=p.useState((t==null?void 0:t.displayName)??s$(e)),[o,l]=p.useState(()=>e==="RAG"?"FULL_CHAIN":"OPENAPI"),[c,u]=p.useState(""),[d,h]=p.useState(""),[g,v]=p.useState(""),[f,y]=p.useState(),[b,m]=p.useState("POST"),[x,j]=p.useState("/"),[S,w]=p.useState(""),[C,k]=p.useState("{}"),[N,L]=p.useState(""),[_,E]=p.useState("NONE"),[I,$]=p.useState(""),[W,R]=p.useState(""),[H,Y]=p.useState(""),[K,ce]=p.useState("x-api-key"),[F,ie]=p.useState(""),[ue,oe]=p.useState("{}"),[B,Q]=p.useState("query"),[X,me]=p.useState("answer"),[fe,P]=p.useState("retrievedItems"),[T,he]=p.useState("citations"),[q,se]=p.useState("id"),[ge,de]=p.useState("text"),[Ne,Oe]=p.useState("metadata"),[_e,re]=p.useState("prooflane connection test"),[V,le]=p.useState("OPENAI_COMPATIBLE"),[ee,xe]=p.useState(""),[Fe,Be]=p.useState("{}"),[st,ae]=p.useState("input"),[Ce,He]=p.useState("response"),[qe,dt]=p.useState("toolCalls"),[ye,Ke]=p.useState("retrievalEvents"),[U,te]=p.useState("stateTransitions"),[ke,we]=p.useState("trace"),[Te,ve]=p.useState("finalState"),[z,D]=p.useState('{"input":"prooflane connection test"}'),[A,ne]=p.useState(!1),[Re,Ee]=p.useState(null),[ze,wt]=p.useState(null),be=()=>_==="BEARER"?{mode:"BEARER",token:I}:_==="BASIC"?{mode:"BASIC",username:W,password:H}:_==="API_KEY"?{mode:"API_KEY",header:K,key:F}:{mode:"NONE"},_t=()=>{const pe=Ow(C,"Headers");return e==="HTTP_API"?{type:e,mode:o,name:r,baseUrl:c,authentication:be(),headers:Nu(pe,"Headers"),environmentVariables:t$(N),...o==="OPENAPI"?{openApiUrl:g||void 0,openApiDocument:f}:{method:b,path:x,capabilityName:S||void 0,requestTemplate:bc(ue,"Request template"),responseMapping:{output:"output",answer:"answer",toolCalls:"toolCalls",citations:"citations",metadata:"metadata"}}}:e==="RAG"?{type:e,mode:o,name:r,endpoint:d,method:b,authentication:be(),headers:Nu(pe,"Headers"),queryMapping:B,answerMapping:o==="FULL_CHAIN"?X:void 0,retrievedItemsMapping:fe,citationMapping:o==="FULL_CHAIN"&&T||void 0,documentIdMapping:q,documentTextMapping:ge,metadataMapping:Ne||void 0,testQuery:_e}:e==="MODEL"?{type:e,provider:V,name:r,model:ee,baseUrl:c,apiKey:F||void 0,headers:Nu(pe,"Headers"),parameters:Ow(Fe,"Model parameters"),path:V==="CUSTOM"?x:void 0,requestTemplate:V==="CUSTOM"?bc(ue,"Request template"):void 0,responseMapping:V==="CUSTOM"?{answer:X,toolCalls:qe,metadata:Ne}:void 0}:{type:e,name:r,endpoint:d,method:b,authentication:be(),headers:Nu(pe,"Headers"),requestTemplate:ue.trim()&&ue.trim()!=="{}"?bc(ue,"Request template"):void 0,inputMapping:st,responseMapping:Ce,toolCallMapping:qe||void 0,retrievalMapping:ye||void 0,stateMapping:U||void 0,traceMapping:ke||void 0,finalStateMapping:Te||void 0,testInput:bc(z,"Test input")}},Dt=async()=>{ne(!0),wt(null),Ee("Running a local, non-governed connection test…");try{const pe=_t(),Xe=t?await O.targetReconnect(t.id,pe,r):await O.targetConnect(pe,r);Ee(`${Xe.connectionTest.message} Target fingerprint created.`),n(Xe.capabilities,Xe.target)}catch(pe){t&&X2(pe)?(Ee("The saved target no longer exists in this local workspace. Review these values, then create a new connection."),wt(null),a==null||a(t)):(Ee(null),wt(pe instanceof Error?pe.message:"The target connection failed."))}finally{ne(!1)}};return s.jsxs("div",{className:"target-adapter-form stack",children:[s.jsx(ct,{label:"Name",children:s.jsx("input",{className:"field",value:r,onChange:pe=>i(pe.target.value)})}),e==="HTTP_API"&&s.jsxs(s.Fragment,{children:[s.jsx(af,{value:o,onChange:l,values:["OPENAPI","MANUAL"]}),s.jsx(ct,{label:"Base URL",children:s.jsx("input",{className:"field",value:c,onChange:pe=>u(pe.target.value),placeholder:"https://api.example.com"})}),o==="OPENAPI"?s.jsxs(s.Fragment,{children:[s.jsx(ct,{label:"OpenAPI URL",children:s.jsx("input",{className:"field",value:g,onChange:pe=>v(pe.target.value),placeholder:"/openapi.json or https://…"})}),s.jsx(ct,{label:"OpenAPI file (JSON or YAML)",children:s.jsx("input",{className:"field",type:"file",accept:".json,.yaml,.yml,application/json,application/yaml,text/yaml",onChange:pe=>{var St;const Xe=(St=pe.target.files)==null?void 0:St[0];Xe&&Xe.text().then(y)}})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Method",children:s.jsx("input",{className:"field",value:b,onChange:pe=>m(pe.target.value.toUpperCase())})}),s.jsx(ct,{label:"Path",children:s.jsx("input",{className:"field",value:x,onChange:pe=>j(pe.target.value)})})]}),s.jsx(ct,{label:"Capability name",children:s.jsx("input",{className:"field",value:S,onChange:pe=>w(pe.target.value),placeholder:"chat_completion"})}),s.jsx(lo,{label:"Request template",value:ue,onChange:oe})]}),s.jsx(ct,{label:"Environment variables (KEY=VALUE, local only)",children:s.jsx("textarea",{className:"field",value:N,onChange:pe=>L(pe.target.value)})})]}),e==="RAG"&&s.jsxs(s.Fragment,{children:[s.jsx(af,{value:o,onChange:l,values:["FULL_CHAIN","RETRIEVER_ONLY"]}),s.jsx(ct,{label:o==="FULL_CHAIN"?"Endpoint":"Retriever endpoint",children:s.jsx("input",{className:"field",value:d,onChange:pe=>h(pe.target.value),placeholder:"https://rag.example.com/query"})}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Method",children:s.jsxs("select",{className:"field",value:b,onChange:pe=>m(pe.target.value),children:[s.jsx("option",{children:"POST"}),s.jsx("option",{children:"GET"}),s.jsx("option",{children:"PUT"}),s.jsx("option",{children:"PATCH"}),s.jsx("option",{children:"DELETE"})]})}),s.jsx(ct,{label:b==="GET"?"Query parameter":"Query mapping",children:s.jsx("input",{className:"field",value:B,onChange:pe=>Q(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[o==="FULL_CHAIN"&&s.jsx(ct,{label:"Answer mapping",children:s.jsx("input",{className:"field",value:X,onChange:pe=>me(pe.target.value)})}),s.jsx(ct,{label:"Retrieved items mapping",children:s.jsx("input",{className:"field",value:fe,onChange:pe=>P(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Document ID mapping",children:s.jsx("input",{className:"field",value:q,onChange:pe=>se(pe.target.value)})}),s.jsx(ct,{label:"Document text mapping",children:s.jsx("input",{className:"field",value:ge,onChange:pe=>de(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[o==="FULL_CHAIN"&&s.jsx(ct,{label:"Citation mapping",children:s.jsx("input",{className:"field",value:T,onChange:pe=>he(pe.target.value)})}),s.jsx(ct,{label:"Metadata mapping (optional)",children:s.jsx("input",{className:"field",value:Ne,onChange:pe=>Oe(pe.target.value)})})]}),b==="GET"&&s.jsxs("div",{className:"target-domain-boundary",children:["GET sends the test query as a URL parameter. For Wikipedia page search, use ",s.jsx("span",{className:"mono",children:"q"}),", ",s.jsx("span",{className:"mono",children:"pages"}),", ",s.jsx("span",{className:"mono",children:"id"}),", and ",s.jsx("span",{className:"mono",children:"excerpt"}),"."]}),s.jsx(ct,{label:"Connection-test query",children:s.jsx("input",{className:"field",value:_e,onChange:pe=>re(pe.target.value)})})]}),e==="MODEL"&&s.jsxs(s.Fragment,{children:[s.jsx(af,{value:V,onChange:le,values:["OPENAI_COMPATIBLE","ANTHROPIC_COMPATIBLE","CUSTOM"]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Base URL",children:s.jsx("input",{className:"field",value:c,onChange:pe=>u(pe.target.value)})}),s.jsx(ct,{label:"Model",children:s.jsx("input",{className:"field",value:ee,onChange:pe=>xe(pe.target.value)})})]}),s.jsx(ct,{label:"Target-model API key (session only)",children:s.jsx("input",{className:"field",type:"password",value:F,onChange:pe=>ie(pe.target.value),autoComplete:"off"})}),s.jsx(lo,{label:"Model parameters",value:Fe,onChange:Be}),V==="CUSTOM"&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{label:"Invocation path",children:s.jsx("input",{className:"field",value:x,onChange:pe=>j(pe.target.value)})}),s.jsx(lo,{label:"Request template",value:ue,onChange:oe})]}),s.jsx("div",{className:"target-domain-boundary",children:"TARGET MODEL credentials remain separate from evaluation judges and Sammy providers."})]}),e==="AGENT"&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{label:"Invocation endpoint",children:s.jsx("input",{className:"field",value:d,onChange:pe=>h(pe.target.value)})}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Method",children:s.jsx("input",{className:"field",value:b,onChange:pe=>m(pe.target.value.toUpperCase())})}),s.jsx(ct,{label:"Input mapping",children:s.jsx("input",{className:"field",value:st,onChange:pe=>ae(pe.target.value)})})]}),s.jsx(lo,{label:"Request template",value:ue,onChange:oe}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Response mapping",children:s.jsx("input",{className:"field",value:Ce,onChange:pe=>He(pe.target.value)})}),s.jsx(ct,{label:"Tool-call mapping",children:s.jsx("input",{className:"field",value:qe,onChange:pe=>dt(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Retrieval mapping",children:s.jsx("input",{className:"field",value:ye,onChange:pe=>Ke(pe.target.value)})}),s.jsx(ct,{label:"State mapping",children:s.jsx("input",{className:"field",value:U,onChange:pe=>te(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Trace mapping",children:s.jsx("input",{className:"field",value:ke,onChange:pe=>we(pe.target.value)})}),s.jsx(ct,{label:"Final state mapping",children:s.jsx("input",{className:"field",value:Te,onChange:pe=>ve(pe.target.value)})})]}),s.jsx(lo,{label:"Connection-test input",value:z,onChange:D})]}),e!=="MODEL"&&s.jsx(e$,{mode:_,setMode:E,token:I,setToken:$,username:W,setUsername:R,password:H,setPassword:Y,apiKeyHeader:K,setApiKeyHeader:ce,apiKey:F,setApiKey:ie}),s.jsx(lo,{label:"Headers (values remain local)",value:C,onChange:k}),Re&&s.jsx("div",{className:"target-form-status",children:Re}),ze&&s.jsx("div",{className:"mcp-selector-error",children:ze}),s.jsx("button",{className:"btn primary",onClick:()=>void Dt(),disabled:A,children:A?"Testing connection…":t?"Test & reconnect":"Test & connect"})]})}function e$(e){return s.jsxs(s.Fragment,{children:[s.jsx(ct,{label:"Authentication",children:s.jsxs("select",{className:"field",value:e.mode,onChange:t=>e.setMode(t.target.value),children:[s.jsx("option",{children:"NONE"}),s.jsx("option",{children:"BEARER"}),s.jsx("option",{children:"BASIC"}),s.jsx("option",{children:"API_KEY"})]})}),e.mode==="BEARER"&&s.jsx(ct,{label:"Bearer token",children:s.jsx("input",{className:"field",type:"password",value:e.token,onChange:t=>e.setToken(t.target.value)})}),e.mode==="BASIC"&&s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Username",children:s.jsx("input",{className:"field",value:e.username,onChange:t=>e.setUsername(t.target.value)})}),s.jsx(ct,{label:"Password",children:s.jsx("input",{className:"field",type:"password",value:e.password,onChange:t=>e.setPassword(t.target.value)})})]}),e.mode==="API_KEY"&&s.jsxs("div",{className:"grid-2",children:[s.jsx(ct,{label:"Header",children:s.jsx("input",{className:"field",value:e.apiKeyHeader,onChange:t=>e.setApiKeyHeader(t.target.value)})}),s.jsx(ct,{label:"API key",children:s.jsx("input",{className:"field",type:"password",value:e.apiKey,onChange:t=>e.setApiKey(t.target.value)})})]})]})}function ct({label:e,children:t}){return s.jsxs("label",{children:[s.jsx("span",{className:"label",children:e}),t]})}function lo({label:e,value:t,onChange:n}){return s.jsx(ct,{label:e,children:s.jsx("textarea",{className:"field target-json-field",value:t,onChange:a=>n(a.target.value)})})}function af({value:e,onChange:t,values:n}){return s.jsx("div",{className:"row target-mode-choice",children:n.map(a=>s.jsx("button",{className:`btn sm ${e===a?"primary":"ghost"}`,onClick:()=>t(a),children:a.replaceAll("_"," ")},a))})}function bc(e,t){try{return e.trim()?JSON.parse(e):{}}catch{throw new Error(`${t} must be valid JSON.`)}}function Ow(e,t){const n=bc(e,t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${t} must be a JSON object.`);return n}function Nu(e,t){if(Object.values(e).some(n=>typeof n!="string"))throw new Error(`${t} values must be strings.`);return e}function t$(e){return Object.fromEntries(e.split(`
|
|
50
|
-
`).map(t=>t.trim()).filter(Boolean).map(t=>{const n=t.indexOf("=");if(n<1)throw new Error("Environment variables must use KEY=VALUE, one per line.");return[t.slice(0,n),t.slice(n+1)]}))}function s$(e){return{HTTP_API:"HTTP API",RAG:"RAG system",MODEL:"Model endpoint",AGENT:"AI agent"}[e]}function Lw({onClose:e,onConnected:t,reconnectConnection:n,reconnectTarget:a,availableTypes:r=["MCP","HTTP_API","RAG","MODEL","AGENT"],initialType:i,initialImport:o=!1,onTargetConnected:l,onReconnectTargetMissing:c}){const[u,d]=p.useState(()=>n?"MCP":(a==null?void 0:a.type)??i??null),[h,g]=p.useState(()=>(n==null?void 0:n.transport)==="stdio"?"stdio":n?"http":"stdio"),[v,f]=p.useState((n==null?void 0:n.displayName)??""),[y,b]=p.useState("node"),[m,x]=p.useState("examples/mock-server.mjs"),[j,S]=p.useState(""),[w,C]=p.useState(""),[k,N]=p.useState(""),[L,_]=p.useState(""),[E,I]=p.useState(""),[$,W]=p.useState(!1),[R,H]=p.useState(!1),[Y,K]=p.useState(null),[ce,F]=p.useState(null),[ie,ue]=p.useState(()=>o&&!n&&!a&&!i),[oe,B]=p.useState(null),[Q,X]=p.useState(null),[me,fe]=p.useState([]),[P,T]=p.useState(null),[he,q]=p.useState(null),[se,ge]=p.useState({}),de=p.useRef(null),Ne=r$(w),Oe=()=>{ue(!1),B(null),X(null),fe([]),q(null),ge({}),T(null),K(null),F(null)},_e=async ee=>{if(!ee)return;const xe=z2(await ee.text());B(ee.name),X(xe.valid?xe.manifest:null),fe(xe.issues.map(Fe=>`${Fe.path}: ${Fe.message}`)),q(null),ge({}),K(null),F(null),de.current&&(de.current.value="")},re=async ee=>{var Fe;if(Mw(ee).some(Be=>{var st;return!((st=se[Be.id])!=null&&st.trim())})){q(ee.id),F("Enter each required local credential before testing this connection.");return}T(ee.id),F(null),K("Running the existing local, non-governed connection test…");try{let Be;if(ee.type==="http"&&ee.mode==="openapi"&&ee.openapi.file&&(Be=await d$(ee.openapi.file,".json,.yaml,.yml,application/json,application/yaml,text/yaml")),ee.type==="mcp"&&ee.transport==="stdio"){const ae=[ee.command,...ee.args??[]].join(" ");if(!window.confirm(`Trust and execute this imported local MCP command?
|
|
51
|
-
|
|
52
|
-
${ae}
|
|
53
|
-
|
|
54
|
-
Preview and validation have not executed it.`)){K("Imported stdio command was not executed.");return}}if(ee.type==="mcp"&&ee.transport==="remote-http"&&((Fe=ee.auth)==null?void 0:Fe.type)==="oauth"){const ae=await O.oauthStart(ee.url,ee.name);if(ae.status==="connected"){t(ae.capabilities,ee.name);return}for(ae.authUrl&&window.open(ae.authUrl,"_blank","noopener");;){await new Promise(He=>setTimeout(He,1500));const Ce=await O.oauthStatus(ae.flowId);if(Ce.status==="connected"){t(Ce.capabilities,ee.name);return}if(Ce.status==="error")throw new Error(Ce.error??"Authorization failed.")}}const st=U2(ee,{secrets:c$(se),...Be!==void 0?{readOpenApiFile:()=>Be}:{}});if(st.config.type==="MCP"){const ae=await O.connect(st.config.connection,st.name);t(ae.capabilities,ae.connection.displayName,ae.connection)}else{const ae=await O.targetConnect(st.config,st.name);l==null||l(ae.capabilities,ae.target)}}catch(Be){K(null),F(Be instanceof Error?Be.message:"The imported connection failed.")}finally{T(null)}};if(!u&&ie)return s.jsx("div",{className:"modal-backdrop",onClick:Oe,children:s.jsxs("div",{className:"modal target-connect-modal",onClick:ee=>ee.stopPropagation(),children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:16},children:[s.jsxs("div",{children:[s.jsx("div",{className:"screen-title",children:"Import connection config"}),s.jsxs("div",{className:"screen-sub",style:{marginTop:4},children:["Choose a ",s.jsx("span",{className:"mono",children:"prooflane.connections.json"})," file, review its target, then enter credentials locally."]})]}),s.jsx("button",{className:"btn sm ghost",onClick:Oe,children:"← Target types"})]}),s.jsxs("div",{className:"target-domain-boundary",style:{marginTop:16},children:["Credential fields accept a direct value, ",s.jsx("span",{className:"mono",children:"${prompt}"}),", ",s.jsx("span",{className:"mono",children:"${env:NAME}"}),", or ",s.jsx("span",{className:"mono",children:"${session:NAME}"}),". Direct values stay in this local file; references produce masked fields below. No environment variable is required."]}),s.jsxs("div",{className:"row",style:{marginTop:16,gap:8,flexWrap:"wrap"},children:[s.jsx("input",{ref:de,type:"file",accept:".json,application/json",hidden:!0,onChange:ee=>{var xe;return void _e((xe=ee.target.files)==null?void 0:xe[0])}}),s.jsx("button",{className:"btn primary",onClick:()=>{var ee;return(ee=de.current)==null?void 0:ee.click()},children:oe?"Choose another file":"Choose config file"}),s.jsx("button",{className:"btn ghost",onClick:()=>Dw(Cv,Tv),children:"Download sample config"}),oe&&s.jsx("span",{className:"muted mono",style:{alignSelf:"center",fontSize:10},children:oe})]}),me.length>0&&s.jsx("div",{className:"drift dirty",style:{marginTop:14,marginBottom:0},children:s.jsxs("div",{className:"drift-row",style:{alignItems:"flex-start"},children:[s.jsx("span",{className:"tag fail",children:"invalid config"}),s.jsxs("div",{children:[s.jsx("ul",{style:{margin:0,paddingLeft:18},children:me.map(ee=>s.jsx("li",{children:ee},ee))}),s.jsxs("div",{style:{marginTop:10,fontSize:10},children:[s.jsx("div",{children:s.jsx("strong",{children:"Bearer token"})}),s.jsx("div",{className:"mono",children:'"auth": { "type": "bearer", "token": "${prompt}" }'}),s.jsx("div",{style:{marginTop:6},children:s.jsx("strong",{children:"API key header"})}),s.jsx("div",{className:"mono",children:'"auth": { "type": "api-key", "header": "x-api-key", "key": "${prompt}" }'})]})]})]})}),Q&&s.jsxs("div",{className:"stack",style:{marginTop:16,gap:10},children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Imported connection preview"}),s.jsx("div",{className:"muted",style:{fontSize:11},children:"Select one target. Credentials remain in memory only for this connection attempt."})]}),Q.connections.map(ee=>{const xe=r.includes(i$(ee)),Fe=Mw(ee),Be=o$(ee),st=he===ee.id,ae=!xe||ee.enabled===!1||P!==null;return s.jsxs("div",{className:"card stack",style:{padding:12,gap:10},children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"center"},children:[s.jsxs("span",{children:[s.jsxs("span",{className:"row",style:{gap:7},children:[s.jsx("strong",{children:ee.name}),Be&&s.jsx("b",{className:"tag warn",children:"credential in file"})]}),s.jsx("small",{className:"muted",style:{display:"block"},children:F2(ee)}),Be&&s.jsx("small",{className:"muted",style:{display:"block"},children:"The direct credential is read from this local file for Test & connect and is not saved elsewhere."})]}),s.jsx("button",{className:"btn sm primary",disabled:ae,onClick:()=>Fe.length?(q(ee.id),F(null),K(null)):void re(ee),children:ee.enabled===!1?"Disabled":xe?Fe.length?st?"Credentials below":"Enter credentials":P===ee.id?"Testing…":"Test & connect":"Unavailable"})]}),st&&Fe.length>0&&s.jsxs("div",{className:"stack",style:{gap:9,paddingTop:10,borderTop:"1px solid var(--border-soft)"},children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Local credentials"}),s.jsx("div",{className:"muted",style:{fontSize:10},children:"These values are masked, used for this connection attempt, and never written to the manifest or browser storage."})]}),Fe.map(Ce=>s.jsxs("label",{children:[s.jsx("span",{className:"label",children:Ce.label}),s.jsx("input",{className:"field",type:"password",autoComplete:"off",value:se[Ce.id]??"",onChange:He=>ge(qe=>({...qe,[Ce.id]:He.target.value}))})]},Ce.id)),s.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:s.jsx("button",{className:"btn primary",disabled:P!==null||Fe.some(Ce=>{var He;return!((He=se[Ce.id])!=null&&He.trim())}),onClick:()=>void re(ee),children:P===ee.id?"Testing connection…":"Test & connect"})})]})]},ee.id)})]}),Y&&s.jsx("div",{className:"target-form-status",style:{marginTop:14},children:Y}),ce&&s.jsx("div",{className:"mcp-selector-error",style:{marginTop:14},children:ce}),s.jsxs("div",{className:"row spread",style:{marginTop:18},children:[s.jsx("button",{className:"btn ghost",onClick:Oe,children:"Back"}),s.jsx("button",{className:"btn ghost",onClick:e,children:"Cancel"})]})]})});if(!u)return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"modal target-connect-modal",onClick:ee=>ee.stopPropagation(),children:[s.jsx("div",{className:"screen-title",children:"Connect a target"}),s.jsx("div",{className:"screen-sub",style:{marginTop:4,marginBottom:18},children:"Choose the AI system Prooflane should discover and evaluate."}),s.jsx("div",{className:"target-type-grid",children:DE.map(ee=>{const xe=r.includes(ee.type);return s.jsxs("button",{className:"target-type-card",disabled:!xe,onClick:()=>d(ee.type),children:[s.jsx("span",{children:ee.label}),s.jsx("small",{children:ee.description}),!xe&&s.jsx("b",{children:"COMING SOON"}),xe&&ee.type!=="MCP"&&s.jsx("b",{children:"BETA"})]},ee.type)})}),s.jsxs("div",{className:"row",style:{marginTop:16,gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{ue(!0),K(null),F(null)},children:"Import connection config"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>Dw(Cv,Tv),children:"Download sample config"})]}),s.jsxs("div",{className:"row spread",style:{marginTop:18},children:[s.jsx("button",{className:"btn ghost",onClick:e,children:"Cancel"}),s.jsx("span",{className:"muted",style:{fontSize:11},children:"Credentials and raw execution evidence remain local."})]})]})});if(u!=="MCP")return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"modal target-connect-modal target-adapter-modal",onClick:ee=>ee.stopPropagation(),children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",marginBottom:16},children:[s.jsxs("div",{children:[s.jsx("div",{className:"screen-title",children:a?`Reconnect ${a.displayName}`:`Connect ${n$(u)}`}),s.jsx("div",{className:"screen-sub",children:"Connection tests are local and non-governed. They cannot create release evidence."})]}),!a&&s.jsx("button",{className:"btn sm ghost",onClick:()=>d(null),children:"← Types"})]}),s.jsx(Q2,{type:u,reconnectTarget:a,onConnected:(ee,xe)=>{l==null||l(ee,xe)},onReconnectTargetMissing:c}),s.jsx("div",{className:"row",style:{marginTop:12},children:s.jsx("button",{className:"btn ghost",onClick:e,children:"Cancel"})})]})});const V=async()=>{H(!0),F(null),K("Starting authorization…");try{const ee=await O.oauthStart(w.trim(),v.trim()||void 0);if(ee.status==="connected"){t(ee.capabilities,v.trim()||void 0);return}for(ee.authUrl&&window.open(ee.authUrl,"_blank","noopener"),K(ee.redirectUri?`Waiting for browser authorization… Callback: ${ee.redirectUri}`:"Waiting for you to authorize in the browser…");;){await new Promise(Fe=>setTimeout(Fe,1500));const xe=await O.oauthStatus(ee.flowId);if(xe.status==="connected"){t(xe.capabilities,v.trim()||void 0);return}if(xe.status==="error")throw new Error(xe.error??"Authorization failed.")}}catch(ee){const xe=ee instanceof Error?ee.message:String(ee);/dynamic client registration|invalid redirect_uri/i.test(xe)?(W(!1),F("This server rejected Prooflane's OAuth redirect URI. Restart Prooflane Inspector and retry. If your MCP provider requires pre-registration, add the callback URL shown during authorization to that provider's OAuth client settings.")):F(xe),K(null)}finally{H(!1)}},le=async()=>{if(h==="http"&&$){if(n){F("OAuth reconnect is not available for a saved registry entry yet. Re-enter a bearer token, or remove this entry and authorize it again.");return}await V();return}H(!0),F(null);try{let ee;h==="stdio"?ee={transport:"stdio",command:y.trim(),args:m.trim()?m.trim().split(/\s+/):[],env:a$(j)}:ee={transport:"http",url:w.trim(),bearerToken:k.trim()||void 0,basicAuth:!Ne&&(L.trim()||E)?{username:L.trim(),password:E}:void 0};const xe=v.trim()||(n==null?void 0:n.displayName)||void 0,Fe=n?await O.mcpReconnectConnection(n.id,ee,xe):await O.connect(ee,xe);t(Fe.capabilities,Fe.connection.displayName,Fe.connection)}catch(ee){F(ee instanceof Error?ee.message:String(ee))}finally{H(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"modal",onClick:ee=>ee.stopPropagation(),children:[s.jsx("div",{className:"screen-title",style:{marginBottom:4},children:n?`Reconnect ${n.displayName}`:"Connect a target"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:16},children:n?"For security, connection details and credentials were not saved. Enter them again to reconnect this registry entry.":"MCP Server · local stdio process or remote HTTP transport."}),s.jsxs("div",{className:"row",style:{marginBottom:14},children:[s.jsx("button",{className:`btn sm ${h==="stdio"?"primary":"ghost"}`,onClick:()=>g("stdio"),children:"stdio"}),s.jsx("button",{className:`btn sm ${h==="http"?"primary":"ghost"}`,onClick:()=>g("http"),children:"remote HTTP"})]}),s.jsxs("div",{className:"stack",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"label",children:["Name ",n?"":"(optional)"]}),s.jsx("input",{className:"field",value:v,onChange:ee=>f(ee.target.value),placeholder:"my-server"})]}),h==="stdio"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Command"}),s.jsx("input",{className:"field",value:y,onChange:ee=>b(ee.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Arguments (space-separated)"}),s.jsx("input",{className:"field",value:m,onChange:ee=>x(ee.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Env (KEY=VALUE, one per line)"}),s.jsx("textarea",{className:"field",value:j,onChange:ee=>S(ee.target.value),placeholder:"API_KEY=xxx",style:{minHeight:60}})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Server URL"}),s.jsx("input",{className:"field",value:w,onChange:ee=>C(ee.target.value),placeholder:"https://example.com/mcp"})]}),s.jsxs("label",{className:"row",style:{gap:8,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:$,onChange:ee=>W(ee.target.checked)}),s.jsx("span",{children:"Authorize via OAuth 2.1 (opens your browser)"})]}),Ne&&s.jsx("div",{className:"drift",style:{marginBottom:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag informational",children:"GitHub"}),s.jsx("span",{children:"Use OAuth, or paste a GitHub personal access token below. Basic auth is not supported by this endpoint."})]})}),!$&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Bearer token (optional)"}),s.jsx("input",{className:"field",value:k,onChange:ee=>N(ee.target.value),placeholder:"issued out-of-band"})]}),!Ne&&s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Basic auth — user (optional)"}),s.jsx("input",{className:"field",value:L,onChange:ee=>_(ee.target.value),placeholder:"username",autoComplete:"off"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Basic auth — password"}),s.jsx("input",{className:"field",type:"password",value:E,onChange:ee=>I(ee.target.value),placeholder:"password",autoComplete:"off"})]})]})]})]})]}),Y&&s.jsx("div",{className:"drift",style:{marginTop:14,marginBottom:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag informational",children:"oauth"}),s.jsx("span",{children:Y})]})}),ce&&s.jsx("div",{className:"drift dirty",style:{marginTop:14,marginBottom:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:ce})]})}),s.jsxs("div",{className:"row spread",style:{marginTop:18},children:[s.jsxs("div",{className:"row",children:[!n&&s.jsx("button",{className:"btn ghost",onClick:()=>d(null),children:"← Types"}),s.jsx("button",{className:"btn ghost",onClick:e,children:"Cancel"})]}),s.jsx("button",{className:"btn primary",onClick:le,disabled:R,children:R?h==="http"&&$?"Authorizing…":"Connecting…":h==="http"&&$?"Authorize":"Connect"})]})]})})}const DE=[{type:"MCP",label:"MCP Server",description:"Tools, prompts, and resources"},{type:"HTTP_API",label:"HTTP / API",description:"OpenAPI, REST, chat, and inference APIs"},{type:"RAG",label:"RAG System",description:"Full-chain or retriever-only"},{type:"MODEL",label:"Model Endpoint",description:"Provider or OpenAI-compatible endpoint"},{type:"AGENT",label:"AI Agent",description:"Generic invocation and trace adapter"}];function n$(e){var t;return((t=DE.find(n=>n.type===e))==null?void 0:t.label)??e}function a$(e){const t={};for(const n of e.split(`
|
|
55
|
-
`)){const a=n.trim();if(!a)continue;const r=a.indexOf("=");r>0&&(t[a.slice(0,r)]=a.slice(r+1))}return t}function r$(e){try{const t=new URL(e.trim());return t.hostname==="api.githubcopilot.com"&&t.pathname.startsWith("/mcp")}catch{return!1}}function i$(e){return e.type==="mcp"?"MCP":e.type==="http"?"HTTP_API":e.type==="rag"?"RAG":e.type==="model"?"MODEL":"AGENT"}function Mw(e){const t=new Map,n=(a,r)=>{if(typeof a=="string"){const i=/^\$\{(env|session):([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(a),o=a==="${prompt}"?`prompt:${r}`:i?`${i[1]}:${i[2]}`:null;o&&!t.has(o)&&t.set(o,{id:o,label:l$(r,i==null?void 0:i[2])});return}if(Array.isArray(a)){a.forEach((i,o)=>n(i,`${r}.${o}`));return}if(a&&typeof a=="object")for(const[i,o]of Object.entries(a))n(o,`${r}.${i}`)};return n(e,e.id),[...t.values()]}function o$(e){const t=a=>typeof a=="string"&&a.trim().length>0&&a!=="${prompt}"&&!/^\$\{(env|session):[A-Za-z_][A-Za-z0-9_]*\}$/.test(a);return e.type==="model"&&t(e.apiKey)||"auth"in e&&e.auth&&(e.auth.type==="bearer"&&t(e.auth.token)||e.auth.type==="basic"&&t(e.auth.password)||e.auth.type==="api-key"&&t(e.auth.key))?!0:["headers"in e?e.headers:void 0,"env"in e?e.env:void 0].some(a=>Object.entries(a??{}).some(([r,i])=>/authorization|api[-_]?key|token|secret|password|credential/i.test(r)&&t(i)))}function l$(e,t){var r,i;if(t)return t.replaceAll("_"," ");if(e.endsWith(".auth.key"))return"API key";if(e.endsWith(".auth.token"))return"Bearer token";if(e.endsWith(".auth.password"))return"Password";if(e.endsWith(".apiKey"))return"Target-model API key";const n=(r=/\.headers\.([^.]+)$/.exec(e))==null?void 0:r[1];if(n)return`${n} header value`;const a=(i=/\.env\.([^.]+)$/.exec(e))==null?void 0:i[1];return a?a.replaceAll("_"," "):"Connection secret"}function c$(e){const t=n=>{var a;return((a=e[n])==null?void 0:a.trim())||void 0};return{env:n=>t(`env:${n}`),session:n=>t(`session:${n}`),prompt:n=>t(`prompt:${n}`)}}function Dw(e,t){const n=URL.createObjectURL(new Blob([`${JSON.stringify(t,null,2)}
|
|
56
|
-
`],{type:"application/json"})),a=document.createElement("a");a.href=n,a.download=e,a.click(),URL.revokeObjectURL(n)}function d$(e,t){return new Promise((n,a)=>{const r=document.createElement("input");r.type="file",r.accept=t,r.onchange=()=>{var o;const i=(o=r.files)==null?void 0:o[0];if(!i){a(new Error(`Select the local OpenAPI file referenced by ${e}.`));return}i.text().then(n,a)},r.click()})}function u$({caps:e,connected:t,notify:n,onConnect:a,onNavigatePrompts:r}){const i=(e==null?void 0:e.tools)??[],[o,l]=p.useState(null),[c,u]=p.useState(null),d=`kawach.baseline.${(e==null?void 0:e.serverName)??"server"}`;p.useEffect(()=>{if(!t||!e){u(null);return}const v=localStorage.getItem(d);if(!v){u(null);return}O.drift(JSON.parse(v)).then(u).catch(()=>u(null))},[t,e,d]),p.useEffect(()=>{!o&&i.length&&l(i[0].name)},[i,o]);const h=()=>{e&&(localStorage.setItem(d,JSON.stringify(e)),n("Saved current capabilities as baseline"),u({items:[],worstSeverity:null,clean:!0}))};if(!t)return s.jsxs(us,{children:["Not connected to an MCP server."," ",s.jsx("button",{className:"btn sm primary",style:{marginLeft:8},onClick:a,children:"Connect"})]});const g=i.find(v=>v.name===o)??null;return s.jsxs(s.Fragment,{children:[s.jsx(h$,{report:c,onSaveBaseline:h}),s.jsxs("div",{className:"split",children:[s.jsxs("div",{className:"list",children:[i.map(v=>s.jsxs("button",{className:`list-item ${o===v.name?"active":""}`,onClick:()=>l(v.name),children:[s.jsx("div",{className:"name",children:v.name}),s.jsx("div",{className:"desc",children:v.description??"—"})]},v.name)),i.length===0&&s.jsx(us,{children:"No tools on this server."})]}),g?s.jsx(p$,{tool:g,notify:n,onNavigatePrompts:r},g.name):s.jsx(us,{children:"Select a tool."})]})]})}function h$({report:e,onSaveBaseline:t}){return e?s.jsxs("div",{className:`drift ${e.clean?"clean":"dirty"}`,children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{className:"drift-head",children:[s.jsx("span",{className:`conn-dot ${e.clean?"on":""}`,style:e.clean?{}:{background:"var(--warn)"}}),e.clean?"Connect-time validation passed — no capability drift vs baseline.":`Connect-time validation — ${e.items.length} drift item(s)`]}),s.jsx("button",{className:"btn sm ghost",onClick:t,children:"Update baseline"})]}),!e.clean&&s.jsx("div",{className:"drift-list",children:e.items.map((n,a)=>s.jsxs("div",{className:"drift-row",children:[s.jsx(bx,{severity:n.severity}),s.jsx("span",{children:n.message})]},a))})]}):s.jsxs("div",{className:"drift",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsx("div",{className:"drift-head muted",children:"No baseline saved for this server — connect-time validation inactive."}),s.jsx("button",{className:"btn sm",onClick:t,children:"Save as baseline"})]})}function p$({tool:e,notify:t,onNavigatePrompts:n}){const a=p.useMemo(()=>m$(e.inputSchema),[e]),[r,i]=p.useState(JSON.stringify(a,null,2)),[o,l]=p.useState(void 0),[c,u]=p.useState(null),[d,h]=p.useState(null),[g,v]=p.useState(!1),f=()=>{try{return r.trim()?JSON.parse(r):{}}catch{throw new Error("Input is not valid JSON.")}},y=async S=>{v(!0);try{await S()}catch(w){t(w instanceof Error?w.message:String(w))}finally{v(!1)}},b=()=>y(async()=>{const S=await O.callTool(e.name,f());u(S),h(null)}),m=()=>y(async()=>{const S=await O.snapshotTool(e.name,f());l(S.expectedOutput),u(null),h(null),t(`Saved baseline for ${e.name} — see Contracts`)}),x=()=>y(async()=>{if(o===void 0)throw new Error("Snapshot an expected output first.");const S=await O.callTool(e.name,f());u(S),h(await O.diffValues(e.name,o,S.output))}),j=()=>y(async()=>{const S=await O.generatePrompts(e.name);t(`Generated ${S.prompts.length} prompts for ${e.name} — see Prompts`),n()});return s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"detail-head",children:[s.jsx("div",{className:"detail-title",children:e.name}),e.outputSchema&&s.jsx("span",{className:"pill",children:"has output schema"})]}),s.jsx("div",{className:"detail-desc",children:e.description??"No description."}),e.inputSchema&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section-label",children:"Input schema"}),s.jsx(Ls,{value:e.inputSchema})]}),s.jsx("div",{className:"section-label",children:"Input"}),s.jsx("textarea",{className:"field",value:r,onChange:S=>i(S.target.value)}),s.jsxs("div",{className:"actions",children:[s.jsx("button",{className:"btn primary",onClick:b,disabled:g,children:"Call"}),s.jsx("button",{className:"btn",onClick:m,disabled:g,title:"Capture this call as a runnable contract (see Contracts)",children:"Automate"}),s.jsx("button",{className:"btn",onClick:x,disabled:g||o===void 0,children:"Diff"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn",onClick:j,disabled:g,title:"Generate positive / negative / boundary test prompts from this tool",children:"Generate Prompt"})]}),o!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section-label",children:"Expected (baseline)"}),s.jsx(Ls,{value:o})]}),c&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"section-label row",style:{gap:8},children:[s.jsxs("span",{children:["Actual · ",s.jsxs("span",{className:"muted",children:[c.latencyMs,"ms"]})]}),c.isError&&s.jsx("span",{className:"tag fail",children:"tool error"})]}),s.jsx(Ls,{value:c.output})]}),d&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"section-label row",style:{gap:8},children:["Diff ",s.jsx(wx,{verdict:d.verdict})]}),d.items.length===0?s.jsx("div",{className:"muted",children:"No differences vs expected."}):s.jsx("div",{className:"drift-list",children:d.items.map((S,w)=>s.jsxs("div",{className:"drift-row",children:[s.jsx(bx,{severity:S.severity}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:S.path})," — ",S.message]})]},w))})]})]})}function m$(e){const t={},n=(e==null?void 0:e.properties)??{},a=Array.isArray(e==null?void 0:e.required)?e.required:null,r=a&&a.length>0?a:Object.keys(n);for(const i of r){const o=n[i];o&&(t[i]=zE(o))}return t}function zE(e){const t=e;if(t.default!==void 0)return t.default;if(Array.isArray(t.enum)&&t.enum.length>0)return t.enum[0];switch(Array.isArray(e.type)?e.type[0]:e.type){case"number":case"integer":return typeof t.minimum=="number"?t.minimum:0;case"boolean":return!1;case"array":{const a=typeof t.minItems=="number"?t.minItems:0,r=t.items;return a>0&&r&&typeof r=="object"&&!Array.isArray(r)?Array.from({length:a},()=>zE(r)):[]}case"object":return{};default:return""}}function jd({title:e,state:t,hint:n,onStop:a,stopLabel:r="■ Stop"}){const i=!!(t&&t.total>0),o=i?Math.min(100,Math.round(t.done/t.total*100)):0;return s.jsxs("div",{className:"card",style:{padding:18},children:[s.jsxs("div",{className:"row",style:{justifyContent:"space-between",alignItems:"center",gap:12,marginBottom:10},children:[s.jsxs("div",{className:"stack",style:{gap:3,minWidth:0},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:i?`${e} · ${t.done} of ${t.total} done`:e}),s.jsx("span",{className:"muted mono",style:{fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t!=null&&t.label?`▸ ${t.label}`:n??"starting…"})]}),a&&s.jsx("button",{className:"btn sm ghost",onClick:a,style:{color:"var(--fail, #ff5c5c)",flexShrink:0},title:"Stop this run",children:r})]}),s.jsx("div",{style:{height:8,borderRadius:999,background:"var(--border)",overflow:"hidden"},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i?o:void 0,"aria-label":e,"aria-busy":!0,children:s.jsx("div",{className:"run-progress-fill",style:{height:"100%",width:i?`${o}%`:"10%",background:"var(--accent, #f5a623)",borderRadius:999,opacity:i?1:.55}})}),i&&s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:6},"aria-live":"polite",children:[o,"% complete"]})]})}let kx=null,Ex=null;function zw(e,t){const n=e instanceof Error?e.message:String(e);return(t.trim()?n.split(t.trim()).join("[REDACTED]"):n).replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 [REDACTED]").replace(/((?:api[_ -]?key|access[_ -]?token|password|client[_ -]?secret)\s*["']?\s*[:=]\s*["']?)[^"',\s&}]+/gi,"$1[REDACTED]").replace(/[\r\n]+/g," ").slice(0,300)}function _x(e){typeof window>"u"||(e!=="judge"&&window.dispatchEvent(new Event("kawach:llm")),e!=="target"&&window.dispatchEvent(new Event("kawach:judge-llm")))}try{for(const e of["kawach.llm","kawach.assurance.judge","kawach.rag.judge"])localStorage.removeItem(e)}catch{}function Es(){return kx}function Cx(e){kx=e,_x("target")}function hl(){return Ex}function f$(e){Ex=e,_x("judge")}function g$(){kx=null,Ex=null,_x("all")}function Ws(e=Es()){return!!(e!=null&&e.model&&(e!=null&&e.apiKey))}function mr(e){return typeof window>"u"?()=>{}:(window.addEventListener("kawach:llm",e),window.addEventListener("kawach:judge-llm",e),()=>{window.removeEventListener("kawach:llm",e),window.removeEventListener("kawach:judge-llm",e)})}function v$(e){return/anthropic/i.test(e)?"anthropic":"openai"}function qp({initial:e,onClose:t,onSave:n,title:a="Model connection (BYOK)",badge:r="shared · session only",description:i,eyebrow:o,saveLabel:l="Use for this session",testConnection:c,summary:u}){const[d,h]=p.useState((e==null?void 0:e.baseUrl)??""),[g,v]=p.useState((e==null?void 0:e.model)??""),[f,y]=p.useState((e==null?void 0:e.apiKey)??""),[b,m]=p.useState((e==null?void 0:e.inPrice)!=null?String(e.inPrice):""),[x,j]=p.useState((e==null?void 0:e.outPrice)!=null?String(e.outPrice):""),[S,w]=p.useState(!1),[C,k]=p.useState(!1),[N,L]=p.useState(null),_=()=>({provider:v$(d),baseUrl:d.trim()||void 0,model:g.trim(),apiKey:f.trim(),inPrice:b.trim()?Number(b):void 0,outPrice:x.trim()?Number(x):void 0}),E=async()=>{if(!g.trim()||!f.trim()){L({ok:!1,text:"Enter a model and API key first."});return}w(!0),L(null);try{const R=_();if(c)L({ok:!0,text:await c(R)});else{const H=await O.llmRun({provider:R.provider,baseUrl:R.baseUrl,model:R.model,apiKey:R.apiKey,prompt:"Reply with the single word: ok"});L(H.ok?{ok:!0,text:`Connected — ${H.model??g.trim()} · ${H.latencyMs}ms`}:{ok:!1,text:H.error??"Request failed."})}}catch(R){L({ok:!1,text:zw(R,f)})}finally{w(!1)}},I=async()=>{k(!0),L(null);try{await n(_())}catch(R){L({ok:!1,text:zw(R,f)})}finally{k(!1)}},$=_(),W=s.jsx("div",{className:"modal-backdrop llm-config-backdrop",onClick:t,children:s.jsxs("div",{className:"modal llm-config-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":a,children:[o&&s.jsx("div",{className:"eyebrow",children:o}),s.jsxs("div",{className:"row",style:{gap:8,marginBottom:4,alignItems:"center"},children:[s.jsx("div",{className:"screen-title",children:a}),s.jsx("span",{className:"pill",title:"Local, your own key",children:r})]}),s.jsx("div",{className:"screen-sub",style:{marginBottom:16},children:i??s.jsxs(s.Fragment,{children:["Connect once for Prompt, RAG, Security, and evaluation screens. Your key stays ",s.jsx("b",{children:"in memory on this machine"})," — it is never written to disk or the project DB, and is sent only to the endpoint you configure. These calls are billed by your provider and are",s.jsx("b",{children:" never metered by Prooflane"}),"."]})}),s.jsxs("div",{className:"stack",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Endpoint (base URL)"}),s.jsx("input",{className:"field",value:d,onChange:R=>h(R.target.value),placeholder:"https://your-provider.example/v1 · local loopback endpoint"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Model"}),s.jsx("input",{className:"field",value:g,onChange:R=>v(R.target.value),placeholder:"Enter the model identifier from your provider"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"API key"}),s.jsx("input",{className:"field",type:"password",autoComplete:"off",value:f,onChange:R=>y(R.target.value),placeholder:"held in memory only — never saved"})]}),s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Input $ / 1M tokens (optional)"}),s.jsx("input",{className:"field mono",value:b,onChange:R=>m(R.target.value),placeholder:"e.g. 5"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Output $ / 1M tokens (optional)"}),s.jsx("input",{className:"field mono",value:x,onChange:R=>j(R.target.value),placeholder:"e.g. 25"})]})]})]}),u&&s.jsx("div",{className:"llm-config-summary",children:typeof u=="function"?u($):u}),N&&s.jsxs("div",{style:{marginTop:12,fontSize:12.5,color:N.ok?"var(--pass)":"var(--fail)",wordBreak:"break-word"},children:[N.ok?"✓ ":"✗ ",N.text]}),s.jsxs("div",{className:"row spread",style:{marginTop:16},children:[s.jsx("button",{className:"btn ghost",onClick:E,disabled:S||C,children:S?"Testing…":"Test connection"}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:t,disabled:C,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void I(),disabled:S||C,children:C?"Connecting…":l})]})]})]})});return typeof document>"u"?W:ax.createPortal(W,document.body)}function UE({onChange:e}){const[t,n]=p.useState(hl()),[a,r]=p.useState(!1);p.useEffect(()=>mr(()=>n(hl())),[]);const i=Ws(t);return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>r(!0),title:i?"Judge connected — click to change (your key, in memory only)":"Configure a separate local evaluator for assurance results",children:s.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{width:7,height:7,borderRadius:"50%",flex:"none",background:i?"var(--pass)":"var(--faint)"}}),i?`Judge · ${t.model}`:"Configure judge"]})}),a&&s.jsx(qp,{initial:t,title:"Independent judge (BYOK)",badge:"local · judge key",description:s.jsxs(s.Fragment,{children:["Connect a separate evaluator by endpoint, model, and key. This key stays ",s.jsx("b",{children:"in memory on this machine"})," — never saved to disk and never uploaded to Prooflane Cloud. Prooflane uses this model only to evaluate RAG and prompt results."]}),onClose:()=>r(!1),onSave:o=>{f$(o),n(o),r(!1),e==null||e(o)}})]})}function Qr({onChange:e,className:t,label:n}){const[a,r]=p.useState(Es()),[i,o]=p.useState(!1);p.useEffect(()=>mr(()=>r(Es())),[]);const l=Ws(a);return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:t??"btn sm ghost",title:l?"LLM connected — click to change the run target (your key, in memory only)":"LLM not connected — click to connect one for agent-assisted checks",onClick:()=>o(!0),style:l?void 0:{opacity:.85},children:s.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{width:7,height:7,borderRadius:"50%",flex:"none",background:l?"var(--pass)":"var(--faint)"}}),n??(l?`LLM · ${a.model}`:"LLM · not connected")]})}),i&&s.jsx(qp,{initial:a,onClose:()=>o(!1),onSave:c=>{Cx(c),r(c),o(!1),e==null||e(c)}})]})}const Uw=/(delete|remove|drop|destroy|purge|wipe|truncate|reset|revoke|kill|terminate|overwrite|erase|unlink|rmdir|force[-_ ]?push)/i,y$=/(create|write|update|patch|put|post|upload|send|publish|merge|deploy|rename|move|set_|add_)/i,x$=/(confirm|force|dry.?run|acknowledge|i_understand|really|approve)/i;function vh(e){var l;const t=e.name??"",n=e.description??"",a=Object.keys(((l=e.inputSchema)==null?void 0:l.properties)??{}).filter(c=>x$.test(c)),r=Uw.exec(t),i=Uw.exec(n);if(r||i){const c=[r?`The tool name contains the destructive verb "${r[1].toLowerCase()}".`:`The tool description mentions "${i[1].toLowerCase()}".`];return a.length&&c.push(`It advertises a confirmation argument (${a.join(", ")}), which Prompt Studio does not set for you.`),{tool:t,risk:"destructive",requiresConfirmation:!0,reasons:c,confirmationArgs:a}}const o=y$.exec(t);return o?{tool:t,risk:"write",requiresConfirmation:!1,confirmationArgs:a,reasons:[`The tool name contains the write verb "${o[1].toLowerCase()}" — executing it may change real data.`]}:{tool:t,risk:"read",requiresConfirmation:!1,reasons:[],confirmationArgs:a}}const ku={destructive:{tone:"fail",label:"destructive"},write:{tone:"warn",label:"writes data"},read:{tone:"info",label:"read-only"}},j$=e=>Array.isArray(e.type)?String(e.type[0]):String(e.type??"string");function b$(e){const t={};for(const[n,a]of Object.entries((e==null?void 0:e.properties)??{}))a&&typeof a=="object"&&"default"in a&&a.default!==void 0&&(t[n]=a.default);return t}function Rv(e){return!!(e!=null&&e.properties&&Object.keys(e.properties).length>0)}function FE({schema:e,value:t,onChange:n,disabled:a=!1,idPrefix:r}){const i=p.useId(),o=r??i,l=p.useMemo(()=>new Set((e==null?void 0:e.required)??[]),[e]),c=Object.entries((e==null?void 0:e.properties)??{});if(!c.length)return s.jsx("div",{className:"muted",style:{fontSize:12},children:"This tool advertises no input schema — use raw JSON below."});const u=(d,h)=>{const g={...t};h===void 0||h===""?delete g[d]:g[d]=h,n(g)};return s.jsx("div",{className:"stack",style:{gap:10},children:c.map(([d,h])=>{const g=j$(h),v=`${o}-${d}`,f=l.has(d),y=Array.isArray(h.enum)?h.enum:null,b=t[d];return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsxs("label",{className:"label",htmlFor:v,style:{fontSize:11.5},children:[d,f&&s.jsx("span",{style:{color:"var(--fail)"},title:"required",children:" *"}),s.jsx("span",{className:"muted mono",style:{fontSize:10.5,marginLeft:6},children:g})]}),y?s.jsxs("select",{id:v,className:"field",disabled:a,value:b===void 0?"":String(b),onChange:m=>u(d,m.target.value||void 0),children:[s.jsx("option",{value:"",children:"— unset —"}),y.map(m=>s.jsx("option",{value:String(m),children:String(m)},String(m)))]}):g==="boolean"?s.jsxs("label",{className:"row",style:{gap:6,alignItems:"center",fontSize:12.5},children:[s.jsx("input",{id:v,type:"checkbox",disabled:a,checked:b===!0,onChange:m=>u(d,m.target.checked?!0:void 0)}),s.jsx("span",{className:"muted",children:b===!0?"true":"unset"})]}):g==="number"||g==="integer"?s.jsx("input",{id:v,className:"field",type:"number",disabled:a,value:b===void 0?"":String(b),onChange:m=>u(d,m.target.value===""?void 0:Number(m.target.value))}):g==="array"||g==="object"?s.jsx(w$,{id:v,disabled:a,value:b,onChange:m=>u(d,m)}):s.jsx("input",{id:v,className:"field",disabled:a,value:b===void 0?"":String(b),onChange:m=>u(d,m.target.value||void 0)}),h.description&&s.jsx("span",{className:"muted",style:{fontSize:11},children:String(h.description).slice(0,200)})]},d)})})}function w$({id:e,value:t,onChange:n,disabled:a}){const[r,i]=p.useState(t===void 0?"":JSON.stringify(t)),[o,l]=p.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("input",{id:e,className:"field mono",disabled:a,style:{borderColor:o?"var(--fail)":void 0},placeholder:'JSON value, e.g. ["a","b"]',value:r,onChange:c=>{i(c.target.value);const u=c.target.value.trim();if(!u){l(!1),n(void 0);return}try{n(JSON.parse(u)),l(!1)}catch{l(!0)}}}),o&&s.jsx("span",{style:{fontSize:11,color:"var(--fail)"},children:"Invalid JSON — this field is ignored until it parses."})]})}function GE({value:e,onChange:t,label:n="Raw JSON",placeholder:a,rows:r=5}){const i=p.useId(),[o,l]=p.useState(e===void 0?"":JSON.stringify(e,null,2)),[c,u]=p.useState(!1);return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:i,style:{fontSize:11.5},children:n}),s.jsx("textarea",{id:i,className:"field mono",rows:r,style:{borderColor:c?"var(--fail)":void 0,minHeight:84},placeholder:a??'{ "query": "…" }',value:o,onChange:d=>{l(d.target.value);const h=d.target.value.trim();if(!h){u(!1),t(void 0,!0);return}try{const g=JSON.parse(h);u(!1),t(g,!0)}catch{u(!0),t(void 0,!1)}}}),c&&s.jsx("span",{style:{fontSize:11.5,color:"var(--fail)"},children:"Invalid JSON — the last valid value is still in use."})]})}const S$={"retrieval-quality":"Retrieval quality","tool-selection":"Tool selection","retriever-behavior":"Retriever behavior","retrieval-contract":"Retrieval contract","retrieval-drift":"Retrieval drift","chain-validation":"End-to-end chain",resilience:"Resilience (fault injection)"};function Zs(e){return(e.userQuery??"").trim()||e.query}function ta(e){return(e.name??"").trim()||Zs(e)||e.id}function WE(e,t=!1){return e.mode??(t?"full-chain":"retriever-only")}function HE(e){return e.input??{query:Zs(e)}}function BE(e,t){const n=(e.mode??(e.answer!==void 0?"full-chain":"retriever-only"))==="full-chain",a=Zs(e.case),r=[];return r.push(n?{kind:"user-query",label:"User query",value:a}:{kind:"retrieval-query",label:"Retrieval query",value:a}),n&&r.push({kind:"target-model",label:"Target model",value:(t==null?void 0:t.targetModel)??"configured target model"}),r.push({kind:"tool-selected",label:n?"Tool selected":"MCP retriever",value:e.tool,detail:e.selection?[{label:"Router pick",value:e.selection.picked??"(unresolved)"},...e.case.expectedTool?[{label:"Expected",value:e.case.expectedTool,pass:e.selection.picked===e.case.expectedTool}]:[],...e.selection.reason?[{label:"Reason",value:e.selection.reason}]:[]]:void 0}),r.push({kind:"tool-input",label:"Tool input",json:e.input??HE(e.case)}),r.push({kind:"retrieved-context",label:n?"Retrieved context":"Results",value:`${e.resultCount} record${e.resultCount===1?"":"s"} in ${e.latencyMs}ms${e.isError?" · retriever error":""}`}),n&&e.answer!==void 0&&r.push({kind:"generated-answer",label:"Generated answer",value:e.answer||"(no answer)"}),n&&(e.faithfulness!==void 0||e.relevance!==void 0)&&r.push({kind:"judge",label:"Judge",value:e.judged?`LLM-judged${t!=null&&t.judgeModel?` · ${t.judgeModel}`:""}`:"heuristic (no judge model)",detail:[...e.faithfulness!==void 0?[{label:"Faithfulness",value:String(e.faithfulness),pass:e.faithfulness>=70}]:[],...e.relevance!==void 0?[{label:"Relevance",value:String(e.relevance),pass:e.relevance>=70}]:[]]}),n||r.push({kind:"assurance",label:"Assurance",detail:e.checks.map(i=>({label:S$[i.dimension],value:i.detail,pass:i.pass}))}),r}const Iv="prooflane.rag.handoff";function N$(e){try{sessionStorage.setItem(Iv,JSON.stringify(e))}catch{}}function k$(){try{const e=sessionStorage.getItem(Iv);return e?(sessionStorage.removeItem(Iv),JSON.parse(e)):null}catch{return null}}const Av="prooflane.prompt-studio.handoff",rf="prooflane.prompt-studio.current";function E$(e){try{sessionStorage.setItem(Av,JSON.stringify(e))}catch{}}function _$(){try{const e=sessionStorage.getItem(Av);return e?(sessionStorage.removeItem(Av),JSON.parse(e)):null}catch{return null}}const C$={"user-message":"user","assistant-message":"assistant","model-continuation":"assistant","model-request":"system","tool-call":"tool","tool-result":"tool","manual-tool-call":"tool","manual-tool-result":"tool","run-completed":"system","run-failed":"system"},Fw=(e,t=160)=>{const n=typeof e=="string"?e:JSON.stringify(e??null);return n&&n.length>t?`${n.slice(0,t)}…`:n??""};function T$({caps:e,connected:t,notify:n,onNavigate:a}){var he;const[r,i]=p.useState("chat"),[o,l]=p.useState(()=>typeof window>"u"||window.innerWidth>=1100),[c,u]=p.useState(!1),[d,h]=p.useState(null),[g,v]=p.useState([]),[f,y]=p.useState([]),[b,m]=p.useState(""),[x,j]=p.useState(""),[S,w]=p.useState(!1),[C,k]=p.useState(null),[N,L]=p.useState(null),[_,E]=p.useState(!1),[I,$]=p.useState(null),[W,R]=p.useState(null),[,H]=p.useState(0);p.useEffect(()=>mr(()=>H(q=>q+1)),[]);const Y=Es(),K=p.useMemo(()=>(e==null?void 0:e.tools)??[],[e]),ce=p.useRef(null),F=p.useRef(null),ie=p.useRef(null),ue=p.useCallback(async()=>{try{const q=await O.promptStudioSessions();y(q.sessions)}catch{}},[]),oe=p.useCallback(async q=>{const se=Es();try{const ge=await O.promptStudioCreate({name:q==null?void 0:q.name,config:{model:(se==null?void 0:se.model)??"(not configured)",provider:(se==null?void 0:se.provider)??"openai",system:((q==null?void 0:q.system)??x)||void 0,mcpServer:e==null?void 0:e.serverName},source:q!=null&&q.source?{kind:q.source.kind,id:q.source.id,name:q.source.name}:void 0});return h(ge.session),v([]),E(!1),R(null),L(null),ue(),ge.session}catch(ge){return L({title:"Could not start a session",detail:ge instanceof Error?ge.message:String(ge)}),null}},[e==null?void 0:e.serverName,ue,x]);p.useEffect(()=>{if(d)try{sessionStorage.setItem(rf,d.id)}catch{}},[d]),p.useEffect(()=>{const q=_$();if(ue(),!q){let se=null;try{se=sessionStorage.getItem(rf)}catch{se=null}se&&O.promptStudioSession(se).then(ge=>{h(ge.session),v(ge.events)}).catch(()=>{try{sessionStorage.removeItem(rf)}catch{}});return}(async()=>{var ge;await oe({name:`${q.kind==="failure"?"Investigate":"Try"} · ${q.name}`,source:q})&&(m(q.prompt),q.failure&&n(`Loaded the failing run's output for ${q.name} — the saved test is untouched until you save changes.`),(ge=ie.current)==null||ge.focus())})()},[]),p.useEffect(()=>{const q=ce.current;if(!q)return;let se=-1;const ge=()=>{const _e=Math.round(q.getBoundingClientRect().top+window.scrollY)+24;Math.abs(_e-se)<2||(se=_e,q.style.setProperty("--ps-chrome",`${_e}px`))};ge();const de=()=>requestAnimationFrame(ge),Ne=new ResizeObserver(de);return Ne.observe(document.body),q.parentElement&&Ne.observe(q.parentElement),window.addEventListener("resize",de),()=>{Ne.disconnect(),window.removeEventListener("resize",de)}},[r]),p.useEffect(()=>{const q=F.current;q&&(q.scrollTop=q.scrollHeight)},[g.length]);async function B(){const q=b.trim();if(!q)return;if(!(Y!=null&&Y.model)||!Y.apiKey){L({title:"Model provider not configured",detail:"Choose a model and enter your own key — Prompt Studio runs against your provider, not a hosted Prooflane model."});return}let se=d;if(!se&&(se=await oe(),!se))return;w(!0),L(null),k({done:0,total:1,label:"sending the turn to the model"});const ge={id:`local-${Date.now()}`,sessionId:se.id,turnId:`turn-${se.turns+1}`,sequence:-1,timestamp:new Date().toISOString(),type:"user-message",payload:{text:q}};v(de=>[...de,ge]),m("");try{const de=await O.promptStudioSend(se.id,q,{provider:Y.provider,baseUrl:Y.baseUrl,model:Y.model,apiKey:Y.apiKey});h(de.session),v(Ne=>[...Ne.filter(Oe=>Oe.sequence>=0),...de.events]),k({done:1,total:1,label:"turn complete"}),!de.ok&&de.error&&L({title:de.errorTitle??"The turn did not complete",detail:de.error}),ue()}catch(de){L({title:"The turn did not complete",detail:de.message}),v(Oe=>Oe.filter(_e=>_e.sequence>=0))}finally{w(!1),setTimeout(()=>k(null),400)}}async function Q(){if(d)try{await O.promptStudioStop(d.id),n("Stop requested — the run halts before the next model call.")}catch{}}async function X(q,se){try{const ge=await O.promptStudioSession(q);if(se==="read-only"){h(ge.session),v(ge.events),E(!0),i("chat");return}if(await oe({name:`${ge.session.name} (copy)`,system:ge.session.config.system})){const Ne=[...ge.events].reverse().find(Oe=>Oe.type==="user-message");m((Ne==null?void 0:Ne.payload.text)??""),i("chat")}}catch(ge){L({title:"Could not open that session",detail:ge instanceof Error?ge.message:String(ge)})}}const me=g.filter(q=>q.type==="tool-call"||q.type==="tool-result"||q.type==="manual-tool-call"||q.type==="manual-tool-result"),fe=me.filter(q=>q.type==="tool-result"&&/search|retriev|query|lookup|find|fetch/i.test(q.payload.tool??"")),P=((he=[...g].reverse().find(q=>q.type==="user-message"))==null?void 0:he.payload.text)??"",T=me.filter(q=>q.type.endsWith("-call")).length;return s.jsxs("div",{className:"prompt-studio ps-window",ref:ce,children:[s.jsxs("header",{className:"ps-titlebar",children:[s.jsxs("div",{className:"ps-title",children:[s.jsx("span",{className:`ps-dot ${S?"busy":t?"live":""}`,"aria-hidden":"true"}),s.jsx("span",{className:"ps-title-name",children:"prompt studio"}),d&&s.jsxs("span",{className:"ps-title-meta",title:`Session ${d.name}`,children:[d.turns," turn",d.turns===1?"":"s"," · ",d.toolCalls," call",d.toolCalls===1?"":"s"]}),_&&s.jsx("span",{className:"tag info ps-chip",children:"read-only"})]}),s.jsxs("div",{className:"ps-seg",role:"tablist","aria-label":"Prompt Studio",children:[s.jsx("button",{role:"tab","aria-selected":r==="chat",className:r==="chat"?"active":"",onClick:()=>i("chat"),children:"Chat"}),s.jsxs("button",{role:"tab","aria-selected":r==="tools",className:r==="tools"?"active":"",onClick:()=>i("tools"),children:["Tools ",s.jsx("span",{className:"count",children:K.length})]}),s.jsx("button",{role:"tab","aria-selected":r==="sessions",className:r==="sessions"?"active":"",onClick:()=>{i("sessions"),ue()},children:"Sessions"})]}),s.jsxs("div",{className:"ps-actions",children:[s.jsx(Qr,{className:"ps-ghost",label:Y!=null&&Y.model?Y.model:"choose model"}),s.jsxs("span",{className:`ps-status ${t?"live":""}`,title:t?`Connected to ${(e==null?void 0:e.serverName)??"the MCP server"}`:"No MCP server connected — the model runs without tools",children:["mcp ",t?`· ${K.length} tools`:"· off"]}),s.jsxs("button",{className:`ps-ghost ${c?"on":""}`,"aria-pressed":c,onClick:()=>u(q=>!q),title:"Session system prompt",children:["system",x.trim()?" ●":""]}),s.jsx("button",{className:"ps-ghost primary",onClick:()=>void oe(),children:"New session"})]})]}),c&&s.jsxs("div",{className:"ps-system",children:[s.jsx("label",{className:"ps-system-label",htmlFor:"studio-system",children:"Session system prompt"}),s.jsx("textarea",{id:"studio-system",className:"ps-system-input",placeholder:"Optional system prompt applied when a new session starts.",value:x,onChange:q=>j(q.target.value)}),s.jsxs("span",{className:"ps-hint",children:["Applied to the next ",s.jsx("b",{children:"New session"}),". Your provider key is held in this browser session only; transcripts stay on this device and are never sent to hosted generation."]})]}),N&&s.jsxs("div",{className:"ps-banner fail",role:"alert",children:[s.jsx("span",{className:"tag fail",children:N.title}),s.jsx("span",{children:N.detail})]}),(S||C)&&s.jsx("div",{className:"ps-banner",children:s.jsx(jd,{title:"Prompt Studio turn",state:C,hint:"waiting on the model and its tool calls",onStop:S?()=>void Q():void 0})}),r==="chat"&&s.jsxs("div",{className:"ps-body",children:[s.jsx("main",{className:"ps-stream",ref:F,"aria-live":"polite","aria-label":"Conversation",children:g.length===0?s.jsxs("div",{className:"ps-empty",children:[s.jsx("p",{children:"Start a manual model + MCP session."}),s.jsx("p",{className:"ps-hint",children:"Choose a model above, connect an MCP server for tools, then send a message."})]}):g.map(q=>s.jsx(R$,{event:q},q.id))}),s.jsxs("aside",{className:`ps-rail ${o?"open":""}`,"aria-label":"MCP activity","aria-hidden":!o,children:[s.jsxs("div",{className:"ps-rail-head",children:[s.jsx("span",{children:"mcp activity"}),s.jsxs("span",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsxs("span",{className:"ps-rail-count",children:[T," call",T===1?"":"s"]}),s.jsx("button",{className:"ps-rail-close",onClick:()=>l(!1),title:"Hide MCP activity",children:"▸"})]})]}),s.jsxs("div",{className:"ps-rail-body",children:[me.length===0?s.jsx("p",{className:"ps-hint",children:"No tool calls yet. When the model calls an MCP tool, the call, its arguments, latency and result appear here."}):me.map(q=>s.jsx(I$,{event:q},q.id)),fe.length>0&&s.jsxs("div",{className:"ps-handoff",children:[s.jsx("span",{className:"ps-handoff-label",children:"Retrieval"}),s.jsxs("span",{children:[fe.length," retrieval-shaped tool call",fe.length===1?"":"s"," observed. Prompt Studio reports this as a fact only — retrieval quality, grounding, drift and golden baselines are graded in RAG Assurance."]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{const q=fe[fe.length-1];N$({query:P,tool:q.payload.tool,origin:"prompt-studio"}),a==null||a("rag"),n("Opened in RAG Assurance — grade this retrieval there.")},children:"Open in RAG Assurance"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{a==null||a("security"),n("Security owns adversarial verdicts — run this surface there.")},children:"Test this in Security"})]})]})]})]}),!o&&s.jsx("button",{className:"ps-rail-toggle","aria-expanded":!1,onClick:()=>l(!0),title:"Show MCP activity",children:`◂ activity${T?` ${T}`:""}`})]}),r==="chat"&&s.jsxs("footer",{className:"ps-composer",children:[s.jsxs("div",{className:"ps-composer-row",children:[s.jsx("span",{className:"ps-caret","aria-hidden":"true",children:"›"}),s.jsx("textarea",{id:"studio-composer",ref:ie,className:"ps-input",rows:1,placeholder:_?"This session is read-only — duplicate it from Sessions to continue.":"Ask something…",value:b,disabled:_,onChange:q=>m(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&(q.preventDefault(),B())}}),s.jsx("button",{className:"ps-send",onClick:()=>void B(),disabled:S||_||!b.trim(),children:S?"Sending…":"Send"})]}),s.jsxs("div",{className:"ps-composer-foot",children:[s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap"},children:[s.jsx("button",{className:"ps-ghost",onClick:()=>$("prompt"),disabled:!P,children:"Save as Prompt"}),s.jsx("button",{className:"ps-ghost",onClick:()=>$("test"),disabled:!P,children:"Save as Test"})]}),s.jsx("span",{className:"ps-hint mono",children:"⌘/Ctrl + ↵"})]})]}),r==="tools"&&s.jsx("div",{className:"ps-panel",children:s.jsx(A$,{tools:K,connected:t,sessionId:(d==null?void 0:d.id)??null,ensureSession:async()=>d||await oe(),onEvents:q=>v(se=>[...se,...q]),notify:n})}),r==="sessions"&&s.jsx("div",{className:"ps-panel",children:s.jsx(P$,{sessions:f,current:(d==null?void 0:d.id)??null,onOpen:X,onRefresh:()=>void ue()})}),I&&d&&s.jsx($$,{mode:I,sessionId:d.id,sessionName:d.name,defaultPrompt:P,tools:K,onClose:()=>$(null),onSaved:q=>{$(null),R(q),n(q.kind==="test"?`Saved as a Prompt Test: ${q.name}`:`Saved to the Prompt Library: ${q.name}`)}}),W&&s.jsx("div",{className:"card",style:{padding:"12px 14px",borderColor:"var(--pass)"},children:s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap",alignItems:"center"},children:[s.jsxs("span",{style:{fontSize:13},children:[s.jsx("b",{children:W.name})," is now a repeatable test. Benchmarking and Gates consume saved tests — not exploratory sessions."]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{a==null||a("benchmark")},children:"Add to Benchmark"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{a==null||a("gates")},children:"Add to Gate"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>R(null),children:"Dismiss"})]})]})})]})}function R$({event:e}){const t=C$[e.type];if(e.type==="model-request")return null;if(e.type==="run-failed")return s.jsxs("div",{className:"studio-event",role:"alert",children:[s.jsx("span",{className:"tag fail",children:e.payload.errorKind??"failed"}),s.jsx("span",{style:{fontSize:12.5},children:e.payload.error})]});if(e.type==="run-completed")return s.jsxs("div",{className:"studio-event muted",style:{fontSize:11.5},children:[s.jsx("span",{className:"tag pass",children:"turn complete"}),e.payload.latencyMs!=null&&s.jsxs("span",{className:"metric",children:[e.payload.latencyMs," ms"]}),e.payload.usage&&s.jsxs("span",{className:"metric",children:[e.payload.usage.inputTokens+e.payload.usage.outputTokens," tok"]})]});if(t==="tool"){const n=e.type==="tool-call"||e.type==="manual-tool-call";return s.jsxs("div",{className:"studio-event",children:[s.jsx("span",{className:`tag ${n?"informational":e.payload.isError?"fail":"pass"}`,children:n?"tool call":e.payload.isError?"tool error":"tool result"}),s.jsx("span",{className:"mono",style:{fontSize:12},children:e.payload.tool}),n?s.jsx("span",{className:"mono muted",style:{fontSize:11.5},children:Fw(e.payload.input,120)}):s.jsx("span",{className:"mono muted",style:{fontSize:11.5},children:Fw(e.payload.output,120)}),e.payload.latencyMs!=null&&s.jsxs("span",{className:"metric",children:[e.payload.latencyMs," ms"]})]})}return s.jsxs("div",{className:`msg ${t==="assistant"?"assistant":"user"}`,children:[s.jsx("span",{className:"msg-role",children:t==="assistant"?e.type==="model-continuation"?"assistant · continued":"assistant":"you"}),s.jsx("div",{className:"msg-bubble",style:{whiteSpace:"pre-wrap"},children:e.payload.text||"(empty)"})]})}function I$({event:e}){const[t,n]=p.useState(!1),a=e.type==="tool-call"||e.type==="manual-tool-call",r=e.type.startsWith("manual");return s.jsxs("div",{className:"card",style:{padding:"9px 11px"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{className:`tag ${a?"informational":e.payload.isError?"fail":"pass"}`,children:a?"tool call":"result"}),r&&s.jsx("span",{className:"pill",children:"manual"}),s.jsx("span",{className:"mono",style:{fontSize:12.5,fontWeight:500},children:e.payload.tool}),s.jsx("span",{style:{flex:1}}),e.payload.latencyMs!=null&&s.jsxs("span",{className:"metric",children:[e.payload.latencyMs," ms"]}),s.jsx("button",{className:"btn sm ghost","aria-expanded":t,onClick:()=>n(i=>!i),children:t?"Hide":a?"Arguments":"View result"})]}),t&&s.jsx("div",{style:{marginTop:8},children:s.jsx(Ls,{value:a?e.payload.input:e.payload.output})})]})}function A$({tools:e,connected:t,sessionId:n,ensureSession:a,onEvents:r,notify:i}){const[o,l]=p.useState(""),[c,u]=p.useState(""),[d,h]=p.useState({}),[g,v]=p.useState(!1),[f,y]=p.useState(!1),[b,m]=p.useState(null),[x,j]=p.useState(null),[S,w]=p.useState(null),C=p.useRef(null),k=p.useRef(null),N=e.find(I=>I.name===o),L=p.useMemo(()=>c?e.filter(I=>I.name.toLowerCase().includes(c.toLowerCase())):e,[e,c]),_=N?vh(N):null;p.useEffect(()=>{N&&(h(b$(N.inputSchema)),j(null),w(null))},[N]),p.useEffect(()=>{var I,$;b?(I=C.current)==null||I.focus():($=k.current)==null||$.focus()},[b]);async function E(I){var W;if(!N)return;const $=n?{id:n}:await a();if($){y(!0),w(null);try{const R=await O.promptStudioCallTool($.id,N.name,d,I);if(R.confirmationRequired&&R.risk){m(R.risk);return}m(null),j({output:R.output,isError:!!R.isError,latencyMs:R.latencyMs??0,schema:R.schema??null,request:d}),(W=R.events)!=null&&W.length&&r(R.events),i(`${N.name} executed in ${R.latencyMs??0} ms`)}catch(R){const H=R;if(H.status===428){m(vh(N));return}w({title:"The tool call failed",detail:H.message})}finally{y(!1)}}}return t?s.jsxs("div",{className:"studio-grid",children:[s.jsxs("section",{className:"card studio-column","aria-label":"Advertised tools",children:[s.jsxs("div",{className:"studio-column-head",children:[s.jsx("span",{className:"section-label",style:{margin:0},children:"Tools"}),s.jsxs("span",{className:"muted mono",style:{fontSize:11},children:[L.length,"/",e.length]})]}),s.jsx("div",{style:{padding:"0 12px 8px"},children:s.jsx("input",{className:"field",placeholder:"Filter tools…",value:c,onChange:I=>u(I.target.value),"aria-label":"Filter tools"})}),s.jsx("div",{className:"list studio-tool-list",children:L.map(I=>{const $=vh(I);return s.jsxs("button",{className:`list-item ${o===I.name?"active":""}`,onClick:W=>{k.current=W.currentTarget,l(I.name)},children:[s.jsxs("div",{className:"name row",style:{gap:6,alignItems:"center"},children:[s.jsx("span",{children:I.name}),$.risk!=="read"&&s.jsx("span",{className:`tag ${ku[$.risk].tone}`,children:ku[$.risk].label})]}),s.jsx("div",{className:"desc",children:I.description??"—"})]},I.name)})})]}),s.jsx("section",{className:"card studio-column","aria-label":"Tool invocation",children:N?s.jsxs("div",{className:"stack",style:{gap:12,padding:12},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{className:"mono",style:{fontWeight:600},children:N.name}),_&&s.jsx("span",{className:`tag ${ku[_.risk].tone}`,children:ku[_.risk].label})]}),N.description&&s.jsx("span",{className:"muted",style:{fontSize:12},children:N.description}),s.jsxs("div",{className:"tabbar",role:"tablist","aria-label":"Argument editor",children:[s.jsx("button",{role:"tab","aria-selected":!g,className:`tab ${g?"":"active"}`,onClick:()=>v(!1),disabled:!Rv(N.inputSchema),children:"Schema form"}),s.jsx("button",{role:"tab","aria-selected":g,className:`tab ${g?"active":""}`,onClick:()=>v(!0),children:"Raw JSON"})]}),!g&&Rv(N.inputSchema)?s.jsx(FE,{schema:N.inputSchema,value:d,onChange:h,idPrefix:`tool-${N.name}`}):s.jsx(GE,{value:d,label:"Arguments (JSON)",onChange:(I,$)=>{$&&h(I??{})}}),s.jsx("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:s.jsx("button",{className:"btn primary",onClick:()=>void E(!1),disabled:f,children:f?"Executing…":"Execute"})}),S&&s.jsx("div",{className:"drift dirty",role:"alert",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:S.title}),s.jsx("span",{style:{fontSize:13},children:S.detail})]})}),x&&s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsxs("div",{className:"statusline",children:[s.jsx("span",{className:`tag ${x.isError?"fail":"pass"}`,children:x.isError?"tool error":"ok"}),s.jsxs("span",{className:"metric",children:[x.latencyMs," ms"]}),x.schema?s.jsxs("span",{className:`tag ${x.schema.pass?"pass":"fail"}`,children:["schema ",x.schema.pass?"valid":"invalid"]}):s.jsx("span",{className:"pill",children:"no output schema advertised"})]}),s.jsxs("div",{className:"stack",style:{gap:4},children:[s.jsx("span",{className:"section-label",children:"Request"}),s.jsx(Ls,{value:x.request})]}),s.jsxs("div",{className:"stack",style:{gap:4},children:[s.jsx("span",{className:"section-label",children:"Result"}),s.jsx(Ls,{value:x.output})]}),x.schema&&!x.schema.pass&&s.jsx("ul",{className:"muted",style:{fontSize:12,margin:0,paddingLeft:18},children:x.schema.errors.slice(0,6).map((I,$)=>s.jsx("li",{children:I},$))})]})]}):s.jsx(us,{children:"Select a tool to build a call from its advertised schema."})}),b&&s.jsx("div",{className:"modal-backdrop",role:"presentation",children:s.jsx("div",{className:"modal card",role:"alertdialog","aria-modal":"true","aria-labelledby":"destructive-title","aria-describedby":"destructive-body",children:s.jsxs("div",{className:"stack",style:{gap:10,padding:16},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"tag fail",children:"destructive operation"}),s.jsx("strong",{id:"destructive-title",children:"This action may modify or delete data"})]}),s.jsxs("div",{id:"destructive-body",className:"stack",style:{gap:6},children:[s.jsxs("span",{style:{fontSize:13},children:["Prooflane classified ",s.jsx("span",{className:"mono",children:b.tool})," as destructive:"]}),s.jsx("ul",{className:"muted",style:{fontSize:12.5,margin:0,paddingLeft:18},children:b.reasons.map((I,$)=>s.jsx("li",{children:I},$))}),s.jsx("span",{className:"muted",style:{fontSize:12},children:"This is a classification of the advertised surface, not a security finding. Security remains the source of truth for security verdicts."})]}),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>m(null),children:"Cancel"}),s.jsx("button",{ref:C,className:"btn sm primary",onClick:()=>void E(!0),disabled:f,children:"Confirm and execute"})]})]})})})]}):s.jsx(us,{children:"Connect an MCP server (top-right) to invoke its tools manually. Prompt Studio uses the same MCP client as the rest of the Inspector."})}function P$({sessions:e,current:t,onOpen:n,onRefresh:a}){return s.jsxs("section",{className:"stack",style:{gap:10},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center"},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[e.length," session",e.length===1?"":"s"," in this Inspector process. Transcripts are never written to disk or to a cloud backup."]}),s.jsx("button",{className:"btn sm ghost",onClick:a,children:"Refresh"})]}),e.length===0?s.jsx(us,{children:"No Prompt Studio sessions yet."}):e.map(r=>s.jsxs("div",{className:"card row spread",style:{padding:"10px 12px",gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:2,minWidth:0},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontWeight:600,fontSize:13},children:r.name}),r.id===t&&s.jsx("span",{className:"tag info",children:"open"}),r.source&&s.jsxs("span",{className:"pill",children:["from ",r.source.kind,": ",r.source.name]})]}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[r.config.model," · ",r.config.mcpServer??"no MCP server"," · ",r.turns," turn",r.turns===1?"":"s"," · ",r.toolCalls," tool call",r.toolCalls===1?"":"s"," · ",r.latencyMs," ms",r.usage.inputTokens+r.usage.outputTokens>0&&s.jsxs(s.Fragment,{children:[" · ",r.usage.inputTokens+r.usage.outputTokens," tok"]})," · ",new Date(r.updatedAt).toLocaleString()]})]}),s.jsxs("div",{className:"row",style:{gap:6},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>n(r.id,"read-only"),children:"Open read-only"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>n(r.id,"duplicate"),children:"Duplicate"})]})]},r.id))]})}function $$({mode:e,sessionId:t,sessionName:n,defaultPrompt:a,tools:r,onClose:i,onSaved:o}){const[l,c]=p.useState(n.slice(0,80)),[u,d]=p.useState(a),[h,g]=p.useState(""),[v,f]=p.useState(null),[y,b]=p.useState({}),[m,x]=p.useState(!1),[j,S]=p.useState(null),w=p.useRef(null),C=p.useRef(null);p.useEffect(()=>{var N,L;return C.current=document.activeElement,(L=(N=w.current)==null?void 0:N.querySelector("input,textarea,button"))==null||L.focus(),()=>{var _,E;(E=(_=C.current)==null?void 0:_.focus)==null||E.call(_)}},[]),p.useEffect(()=>{e==="test"&&(async()=>{try{const N=await O.promptStudioSuggestions(t);f(N.suggestions),b(Object.fromEntries(N.suggestions.map(_=>[_.id,_.selected])));const L=N.suggestions.find(_=>_.kind==="expect-tool");L!=null&&L.tool&&g(L.tool)}catch{f([])}})()},[e,t]);async function k(){const N=l.trim()||"Prompt Studio capture";if(!u.trim()){S("The prompt text cannot be empty.");return}x(!0),S(null);try{const L=await O.addCustomPrompt(N,u.trim(),h||void 0);if(e==="test"&&v){const _=v.filter(W=>y[W.id]),E=_.map(W=>W.assertion).filter(W=>!!W),I=_.some(W=>W.checkSchema);(E.length||I)&&await O.setPromptChecks(L.id,{assertions:E,checkSchema:I});const $=_.find(W=>W.kind==="response-contains"&&W.expectedText);$!=null&&$.expectedText&&await O.setPromptGolden(L.id,$.expectedText,"contains")}o({kind:e,id:L.id,name:N})}catch(L){const _=L;S(_.upgrade?`${_.message} Saved prompts are limited by your plan.`:_.message)}finally{x(!1)}}return s.jsx("div",{className:"modal-backdrop",role:"presentation",onKeyDown:N=>{N.key==="Escape"&&i()},children:s.jsx("div",{className:"modal card",role:"dialog","aria-modal":"true","aria-labelledby":"studio-save-title",ref:w,children:s.jsxs("div",{className:"stack",style:{gap:12,padding:16},children:[s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("strong",{id:"studio-save-title",children:e==="test"?"Save as Test":"Save as Prompt"}),s.jsx("span",{className:"muted",style:{fontSize:12},children:e==="test"?"Review the suggested checks before saving. Nothing is asserted that you did not select.":"Saves the prompt and its context into the Prompt Library. No assertions are added."})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"studio-save-name",children:"Name"}),s.jsx("input",{id:"studio-save-name",className:"field",value:l,onChange:N=>c(N.target.value)})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"studio-save-prompt",children:"Prompt"}),s.jsx("textarea",{id:"studio-save-prompt",className:"field mono",style:{minHeight:110},value:u,onChange:N=>d(N.target.value)})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"studio-save-tool",children:"Tool under test"}),s.jsxs("select",{id:"studio-save-tool",className:"field",value:h,onChange:N=>g(N.target.value),children:[s.jsx("option",{value:"",children:"— none —"}),r.map(N=>s.jsx("option",{value:N.name,children:N.name},N.name))]})]}),e==="test"&&s.jsxs("div",{className:"stack",style:{gap:6},children:[s.jsx("span",{className:"section-label",style:{margin:0},children:"Suggested checks"}),v===null?s.jsx("span",{className:"muted",style:{fontSize:12},children:"Reading what this session did…"}):v.length===0?s.jsx("span",{className:"muted",style:{fontSize:12},children:"No checks could be derived from this session — save the prompt and add assertions in the Library."}):v.map(N=>s.jsxs("label",{className:"row",style:{gap:8,alignItems:"flex-start",fontSize:12.5,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:!!y[N.id],onChange:L=>b(_=>({..._,[N.id]:L.target.checked}))}),s.jsxs("span",{className:"stack",style:{gap:2},children:[s.jsx("span",{children:s.jsx("b",{children:N.label})}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:N.detail})]})]},N.id))]}),j&&s.jsx("div",{className:"muted",style:{color:"var(--fail)",fontSize:12.5},role:"alert",children:j}),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:i,children:"Cancel"}),s.jsx("button",{className:"btn sm primary",onClick:()=>void k(),disabled:m,children:m?"Saving…":e==="test"?"Save test":"Save prompt"})]})]})})})}const O$=()=>`t_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Gw=e=>{const t=new Set,n=[];for(const a of e.split(",")){const r=a.trim();r&&!t.has(r.toLowerCase())&&(t.add(r.toLowerCase()),n.push(r))}return n};function Nl({title:e,subtitle:t,defaultName:n,capture:a,onClose:r}){const[i,o]=p.useState(n),[l,c]=p.useState(""),[u,d]=p.useState([]),[h,g]=p.useState(!1),[v,f]=p.useState(null),[y,b]=p.useState(0),m=p.useMemo(()=>{try{return[].concat(a())}catch{return[]}},[]),x=m.length>1,[j,S]=p.useState(()=>new Set(m.map((_,E)=>E))),w=_=>S(E=>{const I=new Set(E);return I.has(_)?I.delete(_):I.add(_),I}),C=(_,E)=>_.name||`Item ${E+1}`;p.useEffect(()=>{let _=!0;return O.tagsList().then(E=>{if(!_)return;const I=new Set;for(const $ of E.config.tests)for(const W of $.tags)I.add(W);d([...I].sort())}).catch(()=>{}),()=>{_=!1}},[]);const k=Gw(l),N=_=>c(E=>Gw(`${E},${_}`).join(", ")),L=async()=>{if(!k.length){f("Add at least one tag.");return}const _=m.filter((E,I)=>j.has(I));if(!_.length){f(x?"Select at least one item to tag.":"Nothing to capture — run or select a test first.");return}g(!0),f(null);try{let E=0;for(const I of _){const $={id:O$(),name:(_.length===1?i:I.name)||I.name||i,tags:k,pillar:I.pillar,createdAt:new Date().toISOString(),...I.tool?{tool:I.tool}:{},...I.security?{security:I.security}:{},...I.rag?{rag:I.rag}:{},...I.prompt?{prompt:I.prompt}:{},...I.contract?{contract:I.contract}:{},...I.performance?{performance:I.performance}:{},...I.gate?{gate:I.gate}:{}};await O.tagUpsert($),E++}b(E),setTimeout(r,850)}catch(E){f(E instanceof Error?E.message:"Could not capture the test.")}finally{g(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:r,children:s.jsxs("div",{className:"modal",onClick:_=>_.stopPropagation(),children:[s.jsx("div",{className:"screen-title",style:{marginBottom:4},children:e}),s.jsx("div",{className:"screen-sub",style:{marginBottom:14},children:t}),y>0?s.jsxs("div",{className:"card",style:{padding:14,fontSize:13},children:[s.jsx("span",{className:"tag pass",children:"saved"})," ","Captured ",y," test",y===1?"":"s"," for CI. Find ",y===1?"it":"them"," on the ",s.jsx("b",{children:"Gates"})," screen."]}):s.jsxs(s.Fragment,{children:[x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"section-label",children:["Include (",j.size,"/",m.length,")"]}),s.jsxs("div",{className:"card inset",style:{padding:8,maxHeight:180,overflowY:"auto"},children:[s.jsxs("label",{className:"row",style:{gap:8,fontSize:12.5,padding:"3px 4px",cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:j.size===m.length,ref:_=>{_&&(_.indeterminate=j.size>0&&j.size<m.length)},onChange:_=>S(_.target.checked?new Set(m.map((E,I)=>I)):new Set)}),s.jsx("span",{className:"muted",children:"Select all"})]}),m.map((_,E)=>s.jsxs("label",{className:"row",style:{gap:8,fontSize:13,padding:"3px 4px",cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:j.has(E),onChange:()=>w(E)}),s.jsx("span",{children:C(_,E)})]},E))]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section-label",children:"Name"}),s.jsx("input",{className:"field",value:i,onChange:_=>o(_.target.value),placeholder:"Test name"})]}),s.jsx("div",{className:"section-label",style:{marginTop:12},children:"Tags (comma-separated)"}),s.jsx("input",{className:"field mono",value:l,onChange:_=>c(_.target.value),placeholder:"pr, release, smoke"}),u.length>0&&s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap",marginTop:8},children:[s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Existing:"}),u.map(_=>s.jsx("button",{className:"btn sm ghost",style:{padding:"2px 8px"},onClick:()=>N(_),children:_},_))]}),v&&s.jsx("div",{style:{color:"var(--fail)",marginTop:10,fontSize:12.5},children:v}),s.jsxs("div",{className:"row",style:{marginTop:16,justifyContent:"flex-end",gap:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:r,disabled:h,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:L,disabled:h||!k.length||x&&j.size===0,children:h?"Saving…":`Capture ${x?`${j.size} `:""}for CI`})]})]})]})})}let tr={runs:[],source:"local"},yh;const Pv=new Set,VE=new Set(["mcp","contract","prompt","perf","security","rag","model"]),qE=()=>tr;function of(){yh=void 0,Ai({runs:[],source:"local"})}function Oa(e){const t=new Map(tr.runs.map(n=>[n.id,n]));for(const n of e)t.set(n.id,n);Ai({runs:[...t.values()].sort((n,a)=>Date.parse(a.createdAt)-Date.parse(n.createdAt)),source:"local"})}function Eu(e){const t=e.flatMap(JE);if(!t.length)return;const n=new Map(tr.runs.map(a=>[a.id,a]));for(const a of t)n.set(a.id,a);Ai({runs:[...n.values()].sort((a,r)=>Date.parse(r.createdAt)-Date.parse(a.createdAt)),source:"cloud",syncedAt:new Date().toISOString()})}function KE(e){return Pv.add(e),()=>{Pv.delete(e)}}function Ai(e){tr=e;for(const t of Pv)t(tr)}function L$(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.label=="string"&&typeof t.pillar=="string"&&VE.has(t.pillar)&&typeof t.createdAt=="string"&&["total","pass","drift","fail","error"].every(n=>typeof t[n]=="number")}function M$(e){if(!e||typeof e!="object")return null;const t=e.runs;return Array.isArray(t)&&t.every(L$)?t:null}function JE(e){return!e.counts||e.status==="RUNNING"?[]:(e.pillarSummary.length?e.pillarSummary:[{pillar:"mcp",decision:e.automatedDecision==="BLOCK"?"BLOCK":e.automatedDecision==="REVIEW"?"REVIEW":"PASS",...e.counts}]).flatMap(n=>{const a=n.pillar==="tool"?"mcp":n.pillar==="performance"?"perf":VE.has(n.pillar)?n.pillar:null;return a?[{id:`${e.id}:${n.pillar}`,pillar:a,label:e.gate?`Gate ${e.gate.slug}@${e.gate.version}`:`Suite ${e.suite.slug}@${e.suite.version}`,total:n.total,pass:n.passed,drift:n.decision==="REVIEW"?Math.max(1,n.failed):0,fail:n.failed,error:n.errors,durationMs:e.durationMs??void 0,createdAt:e.startedAt,governance:{runId:e.id,gate:e.gate?{gateId:e.gate.gateId,gateVersionId:e.gate.gateVersionId,slug:e.gate.slug,version:e.gate.version,manifestHash:e.gate.manifestHash}:null,suite:{suiteId:e.suite.suiteId,suiteVersionId:e.suite.suiteVersionId,slug:e.suite.slug,version:e.suite.version,manifestHash:e.suite.manifestHash},policy:{policyId:e.policy.policyId,policyVersionId:e.policy.policyVersionId,version:e.policy.version,manifestHash:e.policy.manifestHash},targetFingerprint:e.targetFingerprint,evidenceFingerprint:e.evidenceFingerprint,runnerType:e.runner.type,status:e.status,automatedDecision:e.automatedDecision,finalDecision:e.finalDecision,completedAt:e.completedAt}}]:[]})}async function Ds(){return yh??(yh=O.runs(200).then(async e=>{Ai({runs:e,source:"local"});try{const t=await O.gateRuns(200),n=new Map(tr.runs.map(a=>[a.id,a]));for(const a of t.runs)n.has(a.id)||n.set(a.id,a);Ai({runs:[...n.values()].sort((a,r)=>Date.parse(r.createdAt)-Date.parse(a.createdAt)),source:"cloud",syncedAt:t.syncedAt})}catch{}try{const n=(await O.governedRuns(200)).runs.flatMap(JE);if(n.length){const a=new Map(tr.runs.map(r=>[r.id,r]));for(const r of n)a.set(r.id,r);Ai({runs:[...a.values()].sort((r,i)=>Date.parse(i.createdAt)-Date.parse(r.createdAt)),source:"cloud",syncedAt:new Date().toISOString()})}}catch{}try{const{backup:t}=await O.workspaceLatestBackup(),n=t?M$(t.value):null;if(t&&n!==null){const a=new Map(n.map(o=>[o.id,o]));for(const o of e)a.set(o.id,o);for(const o of tr.runs)a.set(o.id,o);const r=[...a.values()].sort((o,l)=>Date.parse(l.createdAt)-Date.parse(o.createdAt)),i=t.value.capturedAt;Ai({runs:r,source:"cloud",syncedAt:typeof i=="string"?i:t.createdAt})}}catch{}return tr}).finally(()=>{yh=void 0})),yh}const D$=["==","!=","<","<=",">",">=","contains","not-contains","exists","not-exists","length<=","length>=","length=="];function z$(e){if(typeof e!="string")return e;const t=e.trim();if(t==="")return"";if(t==="true")return!0;if(t==="false")return!1;if(/^-?\d+(\.\d+)?$/.test(t))return Number(t);if(/^[[{"]/.test(t))try{return JSON.parse(t)}catch{}return t}function U$({prompt:e,tool:t,connected:n,notify:a,onSaved:r}){const[i,o]=p.useState(()=>JSON.stringify(e.input??{},null,2)),[l,c]=p.useState(e.assertions??[]),[u,d]=p.useState(!!e.checkSchema),[h,g]=p.useState(null),[v,f]=p.useState(void 0),[y,b]=p.useState(!1),[m,x]=p.useState(null),[j,S]=p.useState(!1),[w,C]=p.useState(!1),k=()=>{try{return i.trim()?JSON.parse(i):{}}catch{a("Input isn't valid JSON.");return}},N=()=>l.map(I=>({...I,value:z$(I.value)})),L=async()=>{const I=k();I!==void 0&&(await O.setPromptChecks(e.id,{input:I,assertions:N(),checkSchema:u}),a("Tool test saved"),r())},_=async()=>{if(!e.tool)return a("This prompt isn't bound to a tool.");if(!n)return a("Connect to the server first.");const I=k();if(I!==void 0){b(!0),x(null),g(null);try{const $=await O.assertTool(e.tool,I,N(),u);if(!$.ok){x($.error??"Run failed.");return}f($.output),g($.report??null),$.report&&O.saveRun({pillar:"prompt",label:`${e.name} · tool assertion`,total:1,pass:$.report.pass?1:0,drift:0,fail:$.report.pass?0:1,error:$.isError?1:0,latencyMs:$.latencyMs}).then(W=>{Oa([W]),Ds()}).catch(()=>{})}catch($){x($ instanceof Error?$.message:String($))}finally{b(!1)}}},E=(I,$)=>c(W=>W.map((R,H)=>H===I?{...R,...$}:R));return s.jsxs("div",{className:"card",style:{marginTop:10,background:"var(--panel-2, rgba(128,128,128,0.05))"},children:[s.jsxs("div",{className:"row spread",style:{marginBottom:8,flexWrap:"wrap",gap:8},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"section-label",style:{margin:0},children:"Tool test"}),e.tool?s.jsx("span",{className:"pill mono",children:e.tool}):s.jsx("span",{className:"tag warn",children:"no tool"}),(t==null?void 0:t.outputSchema)&&s.jsxs("button",{className:"btn sm ghost",onClick:()=>S(I=>!I),style:{padding:"2px 8px"},children:[j?"Hide":"Show"," schemas"]})]}),s.jsx("div",{className:"muted",style:{fontSize:11.5},children:"Calls the real tool and asserts on its output."})]}),j&&s.jsxs("div",{className:"grid-2",style:{marginBottom:10},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Input schema"}),s.jsx(Ls,{value:(t==null?void 0:t.inputSchema)??"(none advertised)"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Output schema"}),s.jsx(Ls,{value:(t==null?void 0:t.outputSchema)??"(none advertised)"})]})]}),s.jsx("div",{className:"section-label",children:"Input (JSON sent to the tool)"}),s.jsx("textarea",{className:"field mono",style:{minHeight:70},value:i,onChange:I=>o(I.target.value),placeholder:'{ "query": "llm", "maxResults": 20 }'}),s.jsx("div",{className:"section-label",style:{marginTop:10},children:"Assertions (all must pass)"}),s.jsxs("div",{className:"stack",style:{gap:6},children:[l.length===0&&s.jsxs("div",{className:"muted",style:{fontSize:12},children:["No rules yet — add one, e.g. ",s.jsx("span",{className:"mono",children:"results · length<= · 10"}),"."]}),l.map((I,$)=>{const W=I.op==="exists"||I.op==="not-exists";return s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("input",{className:"field mono",style:{flex:"1 1 40%"},placeholder:"path (e.g. results)",value:I.path,onChange:R=>E($,{path:R.target.value})}),s.jsx("select",{className:"field mono",style:{width:120},value:I.op,onChange:R=>E($,{op:R.target.value}),children:D$.map(R=>s.jsx("option",{value:R,children:R},R))}),s.jsx("input",{className:"field mono",style:{flex:"1 1 30%"},placeholder:W?"—":"value",disabled:W,value:W?"":String(I.value??""),onChange:R=>E($,{value:R.target.value})}),s.jsx("button",{className:"btn sm ghost",onClick:()=>c(R=>R.filter((H,Y)=>Y!==$)),title:"Remove",children:"✕"})]},$)})]}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>c(I=>[...I,{path:"",op:"length<=",value:""}]),children:"+ Add rule"}),s.jsxs("label",{className:"row",style:{gap:6,cursor:"pointer",fontSize:12.5},children:[s.jsx("input",{type:"checkbox",checked:u,onChange:I=>d(I.target.checked)}),s.jsxs("span",{children:["Validate against output schema",t&&!t.outputSchema?" (tool advertises none)":""]})]}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn sm ghost",onClick:()=>C(!0),disabled:!e.tool,title:"Capture this tool test to .prooflane/tags.json for CI",children:"Tag"}),s.jsx("button",{className:"btn sm ghost",onClick:L,children:"Save"}),s.jsx("button",{className:"btn sm primary",onClick:_,disabled:y||!n,children:y?"Running…":"▶ Run tool test"})]}),w&&s.jsx(Nl,{title:"Tag tool test",subtitle:s.jsxs(s.Fragment,{children:["Captures this tool call + assertions to ",s.jsx("span",{className:"mono",children:".prooflane/tags.json"}),". A CI job that names one of its tags runs exactly this functional test."]}),defaultName:`${e.name} · ${e.tool??"tool"}`,capture:()=>({pillar:"tool",tool:{name:e.tool,input:k()??{},assert:N(),checkSchema:u}}),onClose:()=>C(!1)}),!n&&s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:6},children:"Connect to the server to run — you can still edit & save now."}),m&&s.jsx("div",{style:{color:"var(--fail)",marginTop:8,fontSize:12.5},children:m}),h&&s.jsxs("div",{style:{marginTop:12},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",marginBottom:8},children:[s.jsx("span",{className:`tag ${h.pass?"pass":"fail"}`,children:h.pass?"PASS":"FAIL"}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[h.results.filter(I=>I.pass).length,"/",h.results.length," rules passed",h.schema?` · schema ${h.schema.pass?"valid":"invalid"}`:""]})]}),s.jsxs("div",{className:"stack",style:{gap:5},children:[h.results.map((I,$)=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline"},children:[s.jsx("span",{className:`tag ${I.pass?"pass":"fail"}`,style:{minWidth:42,textAlign:"center"},children:I.pass?"pass":"fail"}),s.jsx("span",{className:"mono",style:{fontSize:12},children:I.message})]},$)),h.schema&&!h.schema.pass&&h.schema.errors.map((I,$)=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline"},children:[s.jsx("span",{className:"tag fail",style:{minWidth:42,textAlign:"center"},children:"schema"}),s.jsx("span",{className:"mono",style:{fontSize:12},children:I})]},`s${$}`))]}),v!==void 0&&s.jsxs("div",{style:{marginTop:10},children:[s.jsx("div",{className:"section-label",children:"Tool output"}),s.jsx(Ls,{value:v})]})]})]})}const F$={title:"Security testing",plan:"Scale",theme:"security",blurb:"MCP-aware red teaming across six attack layers — see what an attacker could make your agent do.",features:["6-layer MCP-aware red team — prompt, protocol, tool abuse, resource, retrieval, multi-step","22 attacks mapped to OWASP LLM Top 10 + curated server/data packs","Severity-weighted resistance score & per-surface breakdown","Regression replay — catch newly-introduced breaches every deploy"],tiles:[{name:"Resistance",value:"91",label:"risk-weighted",tone:"warn"},{name:"Attacks",value:"22",label:"across 6 layers",tone:"info"},{name:"Breached",value:"2",label:"this run",tone:"fail"},{name:"Critical",value:"1",label:"needs a fix",tone:"fail"}],packs:["OWASP LLM Top 10","Prompt Injection","Tool Poisoning","Data Exfiltration","Agentic Escape","Resource Abuse"],findings:[{severity:"critical",title:"Tool poisoning → API key exfiltrated",detail:"A crafted resource tricked the agent into leaking its bearer token to an attacker-controlled tool."},{severity:"high",title:"Indirect prompt injection",detail:"Hidden instructions in a tool result hijacked the agent's next 3 calls."},{severity:"medium",title:"Unbounded resource read",detail:"The agent followed a file:// URI outside the allowed root."}],screenshot:{src:"/teasers/security-red-team.png",alt:"Security red-team screen with attack packs and assurance score"}},G$={title:"Model & Supply Chain Security",plan:"Scale",theme:"security",blurb:"Scan model artifacts, repositories, formats, packages, provenance, and integrity before deployment.",features:["Local model artifact and repository scanning with bounded parsing","Unsafe deserialization, embedded code and remote-code execution checks","Package integrity, provenance, license and model-format evidence","Hash drift detection and repeatable supply-chain release gates"],tiles:[{name:"Checks",value:"38",label:"artifact controls",tone:"info"},{name:"Critical",value:"2",label:"must fix",tone:"fail"},{name:"Integrity",value:"PASS",label:"hash verified",tone:"pass"},{name:"Provenance",value:"WARN",label:"review source",tone:"warn"}],packs:["Artifact format","Unsafe loading","Embedded code","Package integrity","Provenance","Hash drift"],findings:[{severity:"critical",title:"Unsafe model deserialization",detail:"The selected format can execute attacker-controlled code during model loading."},{severity:"high",title:"Remote code trust enabled",detail:"Repository configuration permits loading publisher-defined runtime code."},{severity:"medium",title:"Artifact digest changed",detail:"The scanned bytes no longer match the previously approved model identity."}],screenshot:{src:"/teasers/model-security.png",alt:"Prooflane model and supply-chain security scan preview"}},W$={title:"RAG Assurance",plan:"Scale",theme:"rag",blurb:"Retrieval assurance across seven dimensions — catch hallucination and drift before your users do.",features:["7 dimensions — quality, tool-selection, behavior, contract, drift, golden replay, end-to-end chain","Golden-baseline drift detection with a retrieval diff viewer","LLM-judged faithfulness & answer-relevance for the full chain","Every run logged for trend & regression — “why did the score change?”"],tiles:[{name:"Assurance score",value:"88",label:"across queries",tone:"warn"},{name:"Dimensions",value:"7",label:"graded",tone:"info"},{name:"Faithfulness",value:"92%",label:"grounded",tone:"pass"},{name:"Drift",value:"3",label:"vs golden",tone:"fail"}],packs:["Faithfulness","Answer Relevance","Tool-selection","Retrieval Drift","Golden Replay","Poisoning Guard"],findings:[{severity:"high",title:"Faithfulness dropped 12 pts",detail:"3 answers cited context that was never retrieved — hallucination risk in production."},{severity:"medium",title:"Retrieval drift vs golden",detail:"Top-k results reordered after the last index rebuild — silent quality regression."},{severity:"low",title:"Wrong tool picked",detail:"Router chose search_web over search_docs on 2 grounded queries."}],screenshot:{src:"/teasers/rag-assurance.jpg",alt:"RAG Assurance screen with retrieval test configuration"}},H$={title:"Deployment Gates",plan:"Scale",theme:"gates",blurb:"Bundle every pillar into named gates and block the deploy when assurance regresses.",features:["Bundle contracts, prompts, security & RAG into named test cycles","Export .kawach/suites.json and fail CI on new breaches, drift or contract violations","Deployment verdict — BLOCKED / WARN / PASS with hard gates you define","Tag any test into a gate from Security, RAG, Contracts or Prompts"],tiles:[{name:"Gates",value:"4",label:"configured",tone:"info"},{name:"Verdict",value:"BLOCK",label:"on last deploy",tone:"fail"},{name:"Blocking",value:"2",label:"hard gates",tone:"warn"},{name:"Regressions",value:"1",label:"new this run",tone:"fail"}],packs:["Pre-deploy","Nightly regression","Release candidate","Security gate","RAG gate"],findings:[{severity:"critical",title:"Deploy BLOCKED",detail:"“release-candidate” gate failed — a new critical breach appeared since the last green run."},{severity:"high",title:"Contract regression",detail:"search returned 0 results for a golden query that passed yesterday."},{severity:"medium",title:"RAG drift over threshold",detail:"Assurance score fell below the 85 gate on the nightly cycle."}]},Ww={title:"Deployment Assurance",plan:"Scale",theme:"deployment",blurb:"A release-readiness decision: what blocks shipping, what is optional, and the shortest path to green.",features:["Release readiness across Security, Contracts, Performance, RAG and Prompts","Hard blockers separated from optional warnings and safe-to-ignore observations","Change since last green, evidence coverage and an estimated path to green","CI-ready deployment verdicts and trend history"],tiles:[{name:"Release readiness",value:"BLOCKED",label:"1 blocker to fix",tone:"fail"},{name:"Warnings",value:"2",label:"optional follow-up",tone:"warn"},{name:"Coverage",value:"5/5",label:"assurance pillars",tone:"pass"},{name:"Estimated effort",value:"8 min",label:"to green",tone:"info"}],packs:["Release readiness","Hard gates","Change since green","Evidence coverage","CI verdicts"],findings:[{severity:"critical",title:"Contract validation failed",detail:"A schema changed since the last green deployment."},{severity:"high",title:"Security regression",detail:"A newly introduced high-severity breach needs triage before release."},{severity:"medium",title:"Performance below SLO",detail:"A non-blocking latency warning is ready for follow-up."}],screenshot:{src:"/teasers/deployment-assurance.jpg",alt:"Prooflane Deployment Assurance release-readiness dashboard"}},B$=[{label:"MCP servers",free:"1 local",scale:"1 production",team:"5",enterprise:"Unlimited"},{label:"MCP tools monitored",free:"5",scale:"10",team:"50",enterprise:"Unlimited"},{label:"Security attacks",free:"❌",scale:"Choose any 10",team:"Full library",enterprise:"Full + custom"},{label:"Prompt regressions",free:"10",scale:"100/month",team:"1000/month",enterprise:"Unlimited"},{label:"Performance",free:"10 VUs",scale:"100 VUs",team:"500 VUs",enterprise:"Custom"},{label:"RAG monitored retrievers",free:"❌",scale:"10",team:"100",enterprise:"Unlimited"},{label:"Deployment Assurance",free:"❌",scale:"✅",team:"✅",enterprise:"✅"},{label:"History & trends",free:"7 days",scale:"90 days",team:"1 year",enterprise:"Unlimited"},{label:"CI/CD",free:"❌",scale:"✅",team:"✅",enterprise:"✅"},{label:"Rule feed",free:"Static",scale:"Live",team:"Live",enterprise:"Priority"}],V$={critical:"fail",high:"fail",medium:"warn",low:"info"};function Do({title:e,plan:t,theme:n,blurb:a,features:r,tiles:i,packs:o,findings:l,screenshot:c}){const[u,d]=p.useState(!1),h=()=>d(!0);return s.jsxs("div",{className:"stack",style:{gap:18},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",flexWrap:"wrap",gap:12},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"tag info",children:"🔒 preview"}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:a})]}),s.jsxs("button",{className:"btn sm primary",onClick:h,children:["Unlock ",e]})]}),s.jsxs("div",{style:{position:"relative",cursor:"pointer"},onClick:h,children:[c?s.jsx("div",{className:"card",style:{overflow:"hidden",pointerEvents:"none",userSelect:"none"},children:s.jsx("img",{src:c.src,alt:c.alt,style:{display:"block",width:"100%",maxHeight:500,objectFit:"cover",objectPosition:"top",opacity:.58,filter:"blur(0.45px)"}})}):s.jsx("div",{className:"tiles",style:{opacity:.5,filter:"blur(0.4px)",pointerEvents:"none",userSelect:"none"},children:i.map(g=>s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${g.tone}`}),s.jsx("span",{className:"tile-name",children:g.name})]}),s.jsx("div",{className:"tile-value",style:{color:`var(--${g.tone})`},children:g.value}),s.jsx("div",{className:"tile-label",children:g.label})]},g.name))}),s.jsx("div",{className:"locked-mirror-stage",children:s.jsxs("div",{className:`locked-mirror locked-mirror--${n}`,role:"button",tabIndex:0,"aria-label":`Unlock ${e}`,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&h()},children:[s.jsx("div",{className:"locked-mirror-shine","aria-hidden":"true"}),s.jsx("div",{className:"locked-mirror-visual",children:s.jsx("img",{src:"/teasers/prooflane-lock.png",alt:"","aria-hidden":"true"})}),s.jsxs("div",{className:"locked-mirror-copy",children:[s.jsxs("span",{className:"locked-mirror-kicker",children:["Protected capability · ",t]}),s.jsxs("div",{className:"locked-mirror-title",children:[e," is locked"]}),s.jsx("div",{className:"locked-mirror-subtitle",children:"Unlock the complete workflow, evidence, and history."}),s.jsxs("span",{className:"locked-mirror-action",children:["View plans ",s.jsx("span",{"aria-hidden":"true",children:"→"})]})]})]})})]}),s.jsxs("div",{className:"card",style:{padding:16,cursor:"pointer"},onClick:h,children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",marginBottom:10},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Packs you'd unlock"}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[o.length," suites"]})]}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:o.map(g=>s.jsx("span",{className:"tag",style:{opacity:.9},children:g},g))})]}),s.jsxs("div",{className:"card",style:{padding:16,cursor:"pointer"},onClick:h,children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",marginBottom:10},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Sample findings from a live run"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"illustrative"})]}),s.jsx("div",{className:"stack",style:{gap:10},children:l.map(g=>s.jsxs("div",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[s.jsx("span",{className:`tag ${V$[g.severity]}`,style:{textTransform:"uppercase",flexShrink:0},children:g.severity}),s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:g.title}),s.jsx("span",{className:"muted",style:{fontSize:12,filter:"blur(2.6px)",userSelect:"none"},children:g.detail})]})]},g.title))}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:14,alignItems:"center"},children:[s.jsx("button",{className:"btn sm primary",onClick:g=>{g.stopPropagation(),h()},children:"Unlock full results"}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Run these against your own server on the ",t," plan."]})]})]}),u&&s.jsx(YE,{title:e,plan:t,features:r,onClose:()=>d(!1)})]})}function YE({title:e,plan:t,features:n,onClose:a,description:r}){return s.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:20},onClick:a,children:s.jsx("div",{className:"card",style:{maxWidth:680,width:"100%",maxHeight:"90vh",overflowY:"auto",padding:20},onClick:i=>i.stopPropagation(),children:s.jsxs("div",{className:"stack",style:{gap:12},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsxs("span",{className:"tag warn",children:[t," plan"]}),s.jsx("span",{className:"muted",style:{fontSize:12},children:"Upgrade your plan"})]}),s.jsxs("div",{style:{fontSize:18,fontWeight:600},children:[e," is a paid feature"]}),s.jsx("span",{className:"muted",style:{fontSize:13},children:r??s.jsxs(s.Fragment,{children:["Upgrade to the ",s.jsx("b",{children:t})," plan to run ",e.toLowerCase()," against your MCP server. Included:"]})}),s.jsx("div",{className:"stack",style:{gap:6},children:n.map(i=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{style:{color:"var(--pass)",fontWeight:700},children:"✓"}),s.jsx("span",{style:{fontSize:13},children:i})]},i))}),s.jsx(q$,{}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:4},children:[s.jsx("button",{className:"btn primary",onClick:()=>EE(),children:"Review upgrade options"}),s.jsx("button",{className:"btn ghost",onClick:a,children:"Maybe later"})]}),s.jsx("span",{className:"muted",style:{fontSize:11},children:"Your key & data stay local — Prooflane never charges per test; plans unlock the pillar, not your usage."})]})})})}function q$(){return s.jsx("div",{style:{overflowX:"auto",border:"1px solid var(--border)",borderRadius:8},children:s.jsxs("table",{style:{width:"100%",minWidth:570,borderCollapse:"collapse",fontSize:11.5},children:[s.jsx("thead",{children:s.jsx("tr",{children:["Plan","Free","Scale","Team","Enterprise"].map(e=>s.jsx("th",{style:{textAlign:e==="Plan"?"left":"center",padding:"6px 8px",borderBottom:"1px solid var(--border)",color:"var(--text)",fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.35px"},children:e},e))})}),s.jsx("tbody",{children:B$.map(e=>s.jsxs("tr",{children:[s.jsx("td",{style:{padding:"5px 8px",borderBottom:"1px solid var(--border)",fontWeight:600},children:e.label}),[e.free,e.scale,e.team,e.enterprise].map((t,n)=>s.jsx("td",{style:{padding:"5px 8px",textAlign:"center",borderBottom:"1px solid var(--border)",color:t==="—"?"var(--faint)":void 0},children:t},n))]},e.label))})]})})}function ZE(e,t,n="application/json"){const a=new Blob([t],{type:n}),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}const lf=25,XE={mcp:"MCP",contract:"Contract",prompt:"Prompt",perf:"Perf",security:"Security",rag:"RAG",model:"Model"},QE={prompt:"Prompt","mcp-protocol":"MCP protocol","tool-abuse":"Tool abuse",resource:"Resource",retrieval:"Retrieval",agentic:"Multi-step"};function cf(e){return e.score!=null?e.score:e.total?Math.round(e.pass/e.total*100):null}function e_(e,t){return t==="critical"?{label:"Critical",tone:"fail"}:t==="high"?{label:"High",tone:"fail"}:t==="medium"?{label:"Medium",tone:"warn"}:t==="low"?{label:"Low",tone:"info"}:e==null?null:e>=95?{label:"Low",tone:"pass"}:e>=75?{label:"Medium",tone:"warn"}:e>=40?{label:"High",tone:"fail"}:{label:"Critical",tone:"fail"}}function t_(e){return e==null?null:e<1e3?`${e} ms`:e<1e4?`${(e/1e3).toFixed(1)} s`:`${Math.round(e/1e3)} s`}const K$=e=>`${e.pillar}|${e.layer??e.label}`;function Tx({runs:e,hidePillar:t}){const[n,a]=p.useState(0),[r,i]=p.useState(null),o=p.useMemo(()=>{const u=new Map,d=new Map;for(let h=e.length-1;h>=0;h--){const g=e[h],v=K$(g),f=d.get(v),y=cf(g);u.set(g.id,f&&y!=null?y-(cf(f)??0):null),d.set(v,g)}return u},[e]),l=e.slice(n*lf,(n+1)*lf),c=t?8:9;return s.jsxs("div",{children:[s.jsx("div",{className:"tbl-scroll",children:s.jsxs("table",{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Run"}),!t&&s.jsx("th",{children:"Pillar"}),s.jsx("th",{children:"Layer"}),s.jsx("th",{children:"Result"}),s.jsx("th",{children:"Risk"}),s.jsx("th",{children:"Trend"}),s.jsx("th",{children:"Tokens (in / out)"}),s.jsx("th",{children:"Duration"}),s.jsx("th",{children:"When"})]})}),s.jsx("tbody",{children:l.map(u=>{const d=cf(u),h=u.pillar==="security",g=h?e_(d,u.severity):null,v=u.fail>0?"fail":u.drift>0||u.error>0?"warn":"pass",f=h?(g==null?void 0:g.tone)??"info":v,y=r===u.id;return s.jsx(J$,{r:u,score:d,isSec:h,risk:g,resultTone:f,trend:o.get(u.id)??null,dur:t_(u.durationMs??u.latencyMs),cols:c,hidePillar:t,open:y,onToggle:()=>i(y?null:u.id)},u.id)})})]})}),s.jsx(Bp,{page:n,pageSize:lf,total:e.length,onPage:a})]})}function J$({r:e,score:t,isSec:n,risk:a,resultTone:r,trend:i,dur:o,cols:l,hidePillar:c,open:u,onToggle:d}){return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{style:{cursor:"pointer"},onClick:d,children:[s.jsx("td",{children:s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsxs("span",{className:"row",style:{gap:6,alignItems:"center"},children:[s.jsx("span",{className:"muted",style:{fontSize:10},children:u?"▼":"▶"}),n?"Red team":e.label]}),n&&e.total>0&&(e.fail===0&&e.drift===0&&e.error===0?s.jsx("span",{style:{fontSize:11.5,color:"var(--pass)"},children:"✓ All attacks resisted"}):e.finding?s.jsxs("span",{style:{fontSize:11.5,color:"var(--fail)"},children:["✗ Failed: ",e.finding]}):e.fail>0?s.jsxs("span",{style:{fontSize:11.5,color:"var(--fail)"},children:["✗ ",e.fail," breached"]}):e.drift>0?s.jsxs("span",{style:{fontSize:11.5,color:"var(--warn)"},children:["△ ",e.drift," exposed"]}):s.jsxs("span",{style:{fontSize:11.5,color:"var(--warn)"},children:["! ",e.error," inconclusive"]}))]})}),!c&&s.jsx("td",{children:s.jsx("span",{className:"pill",children:XE[e.pillar]})}),s.jsx("td",{children:e.layer?s.jsx("span",{className:"pill",children:QE[e.layer]??e.layer}):s.jsx("span",{className:"muted",children:"—"})}),s.jsx("td",{children:t==null?s.jsx("span",{className:"muted",children:"—"}):n?s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsxs("span",{className:`tag ${r}`,children:["Score ",t]}),s.jsxs("span",{className:"muted mono",style:{fontSize:11},children:[e.pass," resisted · ",s.jsxs("span",{style:{color:e.fail?"var(--fail)":void 0},children:[e.fail," breached"]}),e.drift>0&&s.jsxs(s.Fragment,{children:[" · ",s.jsxs("span",{style:{color:"var(--warn)"},children:[e.drift," exposed"]})]}),e.error>0&&s.jsxs(s.Fragment,{children:[" · ",e.error," inconclusive"]})]})]}):s.jsxs("span",{className:`tag ${r}`,children:[t,"% · ",e.pass,"/",e.total]})}),s.jsx("td",{children:a?s.jsx("span",{className:`tag ${a.tone}`,children:a.label}):s.jsx("span",{className:"muted",children:"—"})}),s.jsx("td",{children:s.jsx(Y$,{delta:i})}),s.jsx("td",{className:"mono",children:e.tokens!=null?s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{children:e.tokens.toLocaleString()}),(e.inputTokens!=null||e.outputTokens!=null)&&s.jsxs("span",{className:"muted",style:{fontSize:10.5},children:["↓",(e.inputTokens??0).toLocaleString()," / ↑",(e.outputTokens??0).toLocaleString()]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsx("td",{className:"mono",children:o??"—"}),s.jsx("td",{className:"muted",style:{whiteSpace:"nowrap"},children:new Date(e.createdAt).toLocaleString()})]}),u&&s.jsx("tr",{children:s.jsx("td",{colSpan:l,style:{background:"var(--bg-subtle, rgba(127,127,127,0.04))",padding:"14px 18px"},children:s.jsx(Z$,{r:e,score:t,isSec:n})})})]})}function Y$({delta:e}){if(e==null)return s.jsx("span",{className:"muted",style:{fontSize:11},children:"new"});if(e===0)return s.jsx("span",{className:"muted mono",style:{fontSize:12},children:"—"});const t=e>0;return s.jsxs("span",{className:"mono",style:{fontSize:12,color:t?"var(--pass)":"var(--fail)"},children:[t?"▲":"▼",Math.abs(e)]})}function Z$({r:e,score:t,isSec:n}){var r,i,o,l,c,u;const a=[];if(a.push({label:n?"Assurance score":"Score",value:t!=null?String(t):"—",tone:n?((r=e_(t,e.severity))==null?void 0:r.tone)??"info":void 0}),e.layer&&a.push({label:"Layer",value:QE[e.layer]??e.layer}),a.push({label:"Duration",value:t_(e.durationMs??e.latencyMs)??"—"}),a.push({label:n?"Attacks":"Checks",value:String(e.total)}),a.push({label:n?"Resisted":"Passed",value:String(e.pass),tone:"pass"}),a.push({label:n?"Breached":"Failed",value:String(e.fail),tone:e.fail?"fail":"pass"}),e.error>0&&a.push({label:"Errors",value:String(e.error),tone:"warn"}),e.model&&a.push({label:"Model",value:e.model,mono:!0}),e.tokens!=null&&a.push({label:"Tokens · total",value:e.tokens.toLocaleString(),mono:!0}),e.inputTokens!=null&&a.push({label:"Tokens · input",value:e.inputTokens.toLocaleString(),mono:!0}),e.outputTokens!=null&&a.push({label:"Tokens · output",value:e.outputTokens.toLocaleString(),mono:!0}),e.costUsd!=null&&a.push({label:"Cost",value:`$${e.costUsd.toFixed(4)}`,mono:!0}),e.governance){const d=e.governance.finalDecision??e.governance.automatedDecision??e.governance.status;a.push({label:"Governed Run",value:e.governance.runId,mono:!0}),a.push({label:"Gate",value:e.governance.gate?`${e.governance.gate.slug}@${e.governance.gate.version}`:"Suite compatibility",mono:!0}),a.push({label:"Gate decision",value:d,tone:d==="READY"?"pass":d==="BLOCK"||d==="EXECUTION_ERROR"?"fail":"warn"}),a.push({label:"Run status",value:e.governance.status,mono:!0}),a.push({label:"Suite",value:`${e.governance.suite.slug}@${e.governance.suite.version}`,mono:!0}),a.push({label:"Policy",value:`v${e.governance.policy.version}`,mono:!0}),a.push({label:"Runner",value:e.governance.runnerType,mono:!0})}return s.jsxs("div",{className:"stack",style:{gap:12},children:[s.jsx("div",{className:"row",style:{gap:22,flexWrap:"wrap"},children:a.map(d=>s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:d.label}),s.jsx("span",{className:d.mono?"mono":void 0,style:{fontSize:13,color:d.tone?`var(--${d.tone})`:void 0},children:d.value})]},d.label))}),e.finding&&s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Primary finding"}),s.jsx("span",{style:{fontSize:13,color:"var(--fail)"},children:e.finding}),e.pillar==="perf"?s.jsx("span",{className:"muted",style:{fontSize:12},children:"Detailed load-test metrics are available on the Performance screen."}):e.evidence&&!e.evidenceRecord&&!((i=e.evidenceRecords)!=null&&i.length)&&s.jsx("span",{className:"muted",style:{fontSize:12},children:e.evidence})]}),e.evidenceRecord||(o=e.evidenceRecords)!=null&&o.length?s.jsx(X$,{records:(l=e.evidenceRecords)!=null&&l.length?e.evidenceRecords:[e.evidenceRecord]}):e.evidence&&!e.finding?s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Legacy evidence"}),s.jsx("span",{className:"muted",style:{fontSize:12},children:e.evidence})]}):null,n&&s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Open the ",s.jsx("b",{children:"Security"})," pillar to re-run this layer and see the full per-attack drill-down."]}),e.governance&&s.jsxs("div",{className:"card mono",style:{padding:10,fontSize:10.5,lineHeight:1.6},children:["Gate version ID ",((c=e.governance.gate)==null?void 0:c.gateVersionId)??"none",s.jsx("br",{}),"Gate hash ",((u=e.governance.gate)==null?void 0:u.manifestHash)??"none",s.jsx("br",{}),"Suite version ID ",e.governance.suite.suiteVersionId,s.jsx("br",{}),"Suite hash ",e.governance.suite.manifestHash,s.jsx("br",{}),"Policy version ID ",e.governance.policy.policyVersionId,s.jsx("br",{}),"Policy hash ",e.governance.policy.manifestHash,s.jsx("br",{}),"Target ",e.governance.targetFingerprint,s.jsx("br",{}),"Evidence ",e.governance.evidenceFingerprint??"pending"]})]})}function X$({records:e}){return s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsxs("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:["Structured evidence · ",e.length," record",e.length===1?"":"s"]}),e.map(t=>{const n=_u(t.evidenceStrength),a=_u(t.verification),r=t.observedFacts.map(o=>_u(o)),i=t.assertionResults.map(o=>_u(o));return s.jsxs("details",{className:"card",style:{padding:10},open:e.length===1,children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsxs("strong",{children:[t.conclusion,t.failureOrigin?` · origin ${t.failureOrigin}`:""]}),s.jsxs("span",{className:"mono muted",style:{marginLeft:8,fontSize:10},children:[t.module," · ",t.evidenceId]})]}),s.jsxs("div",{className:"stack",style:{gap:9,marginTop:10},children:[s.jsx(Ga,{label:"What was expected",values:t.expectedBehavior??["NOT RECORDED"]}),s.jsx(Ga,{label:"What was observed",values:t.observedBehavior??["NOT OBSERVED"]}),s.jsx(Ga,{label:"Proof",values:r.length?r.map(o=>`${Yn(o.key)}: ${Yn(o.value)} · ${Yn(o.source)}${o.authoritative===!0?" · authoritative":""}`):["No structured proof facts were recorded."],mono:!0}),s.jsx(Ga,{label:"Assertions",values:i.length?i.map(o=>`${Yn(o.status)} · ${Yn(o.description)} · expected ${Yn(o.expected)} · observed ${Yn(o.observed)}${o.failureOrigin?` · origin ${Yn(o.failureOrigin)}`:""}`):["No assertions were recorded."]}),s.jsx(Ga,{label:"Verification",values:[`${Yn(a.method)} · ${a.executionPerformed===!0?`execution performed${typeof a.durationMs=="number"?` in ${a.durationMs} ms`:""}`:"no execution performed"} · ${a.destructiveOperationPerformed===!0?"destructive action performed":a.mutationPerformed===!0?"bounded mutation performed":"no mutation or destructive action performed"}`]}),s.jsx(Ga,{label:"Evidence strength",values:[`${Yn(n.label)} · ${Yn(n.reason)}`]}),typeof t.riskInterpretation=="string"&&s.jsx(Ga,{label:"Why it matters",values:[t.riskInterpretation]}),typeof t.verificationLimit=="string"&&s.jsx(Ga,{label:"Verification limit",values:[t.verificationLimit]}),typeof t.remediation=="string"&&s.jsx(Ga,{label:"Remediation",values:[t.remediation]})]})]},t.evidenceId)})]})}function Ga({label:e,values:t,mono:n}){return s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("span",{className:"muted",style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),t.map((a,r)=>s.jsx("span",{className:n?"mono":void 0,style:{fontSize:12,overflowWrap:"anywhere"},children:a},`${e}:${r}`))]})}function _u(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Yn(e){return e===void 0?"NOT RECORDED":e===null?"NOT OBSERVED":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}const df=15;function Q$({caps:e,connected:t}){return s.jsx(lO,{caps:e,connected:t})}const s_={positive:"pass",negative:"fail",boundary:"warn",injection:"fail",custom:"informational"},Cu={ai:{label:"✨ AI",title:"Generated by an LLM"},generated:{label:"⚙ tool",title:"Generated by Prooflane's built-in generator"},manual:{label:"✍ manual",title:"Manually added"}},eO=e=>new Set(e.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/).filter(Boolean)),tO=new Set(["a","an","and","are","as","at","be","been","being","but","by","can","could","did","do","does","for","from","had","has","have","he","her","hers","him","his","i","if","in","into","is","it","its","me","my","of","on","or","our","ours","she","should","so","such","than","that","the","their","theirs","them","then","there","these","they","this","those","to","was","we","were","what","when","which","who","will","with","would","you","your","yours"]);function Hw(e){const t=[...eO(e)],n=t.filter(a=>!tO.has(a));return new Set(n.length?n:t)}function sO(e,t){const n=Hw(e),a=Hw(t);if(n.size===0&&a.size===0)return 1;if(n.size===0||a.size===0)return 0;let r=0;for(const c of n)a.has(c)&&r++;if(r===0)return 0;const i=r/n.size,o=r/a.size,l=4;return(1+l)*i*o/(l*i+o)}function nO(e,t,n){if(n==="exact")return e.trim()===t.trim()?"pass":"fail";if(n==="contains")return e.toLowerCase().includes(t.trim().toLowerCase())?"pass":"fail";const a=sO(e,t);return a>=.8?"pass":a>=.5?"drift":"fail"}function Bw(e,t){if(!e||!t||t.inPrice==null||t.outPrice==null)return null;const n=e.inputTokens/1e6*t.inPrice+e.outputTokens/1e6*t.outPrice;return`$${n<.01?n.toFixed(5):n.toFixed(4)}`}function aO({notify:e,tools:t=[],core:n=!1,connected:a=!1,tab:r="library",onOpenStudio:i}){const o=!n,[l,c]=p.useState([]),[u,d]=p.useState(null),[h,g]=p.useState(null),[v,f]=p.useState(null),[y,b]=p.useState(""),[m,x]=p.useState(""),[j,S]=p.useState(""),[w,C]=p.useState(""),[k,N]=p.useState(""),[L,_]=p.useState(""),[E,I]=p.useState(""),[$,W]=p.useState(""),[R,H]=p.useState(""),[Y,K]=p.useState(Es()),[ce,F]=p.useState(!1),[ie,ue]=p.useState(!1),[oe,B]=p.useState(!1),[Q,X]=p.useState(null),[me,fe]=p.useState(!1),[P,T]=p.useState({}),[he,q]=p.useState([]),[se,ge]=p.useState(!1),[de,Ne]=p.useState(null),[Oe,_e]=p.useState(null),re=r==="runs"?"history":"test";p.useEffect(()=>mr(()=>K(Es())),[]);const V=async()=>{ge(!0);try{const A=await O.runs(500);q(A.filter(ne=>ne.pillar==="prompt"))}finally{ge(!1)}};p.useEffect(()=>{re==="history"&&V()},[re]);const le=()=>O.customPrompts().then(c).catch(()=>{});p.useEffect(()=>{le()},[]);const ee=[...new Set(l.map(A=>A.tool).filter(Boolean))].sort(),xe=[...new Set(l.map(A=>A.category))].sort(),Fe=[...new Set(l.map(A=>A.source).filter(Boolean))].sort(),Be=l.filter(A=>(!E||A.tool===E)&&(!$||A.category===$)&&(!R||A.source===R)),[st,ae]=p.useState(0);p.useEffect(()=>ae(0),[E,$,R,l.length]);const Ce=Be.slice(st*df,(st+1)*df),He=async A=>{var ze,wt;if(!!(A.tool&&a)){const be=await O.runAgent(A.tool,A.content,{provider:Y.provider,baseUrl:Y.baseUrl,model:Y.model,apiKey:Y.apiKey},{id:A.id,category:A.category,assertions:A.assertions,checkSchema:A.checkSchema});return!be.ok&&((ze=be.evaluation)==null?void 0:ze.status)==="ERROR"?{error:be.error,latencyMs:be.latencyMs,toolCalls:be.toolCalls,agentic:!0,evaluation:be.evaluation}:!be.ok&&be.evaluation?{text:be.evaluation.observed,model:be.model,latencyMs:be.latencyMs,usage:be.usage,verdict:be.evaluation.verdict,toolCalls:be.toolCalls,agentic:!0,evaluation:be.evaluation}:be.ok?{text:be.text,model:be.model,latencyMs:be.latencyMs,usage:be.usage,verdict:((wt=be.evaluation)==null?void 0:wt.verdict)??"drift",toolCalls:be.toolCalls,agentic:!0,evaluation:be.evaluation}:{error:be.error,latencyMs:be.latencyMs,toolCalls:be.toolCalls,agentic:!0}}const Re=await O.llmRun({...Y,prompt:A.content});if(!Re.ok)return{error:Re.error,latencyMs:Re.latencyMs};const Ee=A.expected?nO(Re.text??"",A.expected,A.assert??"similar"):void 0;return{text:Re.text,model:Re.model,latencyMs:Re.latencyMs,usage:Re.usage,verdict:Ee}},qe=(A,ne)=>{var _t,Dt,pe,Xe,St;const Re=!ne.error,Ee=ne.verdict,ze=(_t=ne.evaluation)==null?void 0:_t.status,wt=ne.usage?ne.usage.inputTokens+ne.usage.outputTokens:void 0,be=ne.usage&&Y&&Y.inPrice!=null&&Y.outPrice!=null?ne.usage.inputTokens/1e6*Y.inPrice+ne.usage.outputTokens/1e6*Y.outPrice:void 0;return O.saveRun({pillar:"prompt",label:A.name??"Prompt run",total:1,pass:ze?ze==="PASS"?1:0:Ee?Ee==="pass"?1:0:Re?1:0,drift:ze?ze==="INCONCLUSIVE"?1:0:Ee==="drift"?1:0,fail:ze?ze==="FAIL"?1:0:Ee==="fail"?1:0,error:ze?ze==="ERROR"?1:0:Re?0:1,tokens:wt,inputTokens:(Dt=ne.usage)==null?void 0:Dt.inputTokens,outputTokens:(pe=ne.usage)==null?void 0:pe.outputTokens,costUsd:be,latencyMs:ne.latencyMs??0,model:ne.model??(Y==null?void 0:Y.model),finding:ze&&ze!=="PASS"?(Xe=ne.evaluation)==null?void 0:Xe.summary:void 0,evidence:ne.evaluation?`Expected: ${ne.evaluation.expected} Observed: ${ne.evaluation.observed}`:void 0,evidenceRecord:(St=ne.evaluation)==null?void 0:St.evidenceRecord}).then(kt=>(Oa([kt]),Ds(),kt)).catch(()=>{})},dt=async(A,ne)=>{if(!Y||!Y.apiKey||!Y.model){F(!0);return}const Re=l.find(Ee=>Ee.id===A);if(Re){if(Re.tool&&!a){e("Connect to the server to run this prompt against its tool.");return}X(A),d(A);try{const Ee=await He(Re);T(ze=>({...ze,[A]:Ee})),qe(Re,Ee)}catch(Ee){T(ze=>({...ze,[A]:{error:Ee instanceof Error?Ee.message:String(Ee)}}))}finally{X(null)}}},ye=async()=>{var St,kt;if(!Y||!Y.apiKey||!Y.model){F(!0);return}const A=Be;if(A.length===0){e("No prompts to run.");return}fe(!0),_e({done:0,total:A.length,label:(St=A[0])==null?void 0:St.name});let ne=0,Re=0,Ee=0,ze=0,wt=0,be=0,_t=0,Dt=0,pe=0;const Xe=[];try{for(const[xt,rs]of A.entries()){X(rs.id),_e({done:xt,total:A.length,label:rs.name});try{const Ye=await He(rs);T(es=>({...es,[rs.id]:Ye}));const Xt=!Ye.error,zs=Ye.verdict,At=(kt=Ye.evaluation)==null?void 0:kt.status;ne+=At?At==="PASS"?1:0:zs?zs==="pass"?1:0:Xt?1:0,Re+=At?At==="INCONCLUSIVE"?1:0:zs==="drift"?1:0,Ee+=At?At==="FAIL"?1:0:zs==="fail"?1:0,ze+=At?At==="ERROR"?1:0:Xt?0:1,Ye.evaluation&&Xe.push(Ye.evaluation.evidenceRecord),Ye.usage&&(be+=Ye.usage.inputTokens,_t+=Ye.usage.outputTokens,wt+=Ye.usage.inputTokens+Ye.usage.outputTokens),Ye.usage&&Y.inPrice!=null&&Y.outPrice!=null&&(Dt+=Ye.usage.inputTokens/1e6*Y.inPrice+Ye.usage.outputTokens/1e6*Y.outPrice),Ye.latencyMs&&(pe+=Ye.latencyMs)}catch(Ye){ze+=1,T(Xt=>({...Xt,[rs.id]:{error:Ye instanceof Error?Ye.message:String(Ye)}}))}}const ht=await O.saveRun({pillar:"prompt",label:`Prompt regression (${A.length})`,total:A.length,pass:ne,drift:Re,fail:Ee,error:ze,tokens:wt||void 0,inputTokens:be||void 0,outputTokens:_t||void 0,costUsd:Dt||void 0,latencyMs:A.length?Math.round(pe/A.length):void 0,model:Y.model,evidenceRecords:Xe.length?Xe:void 0}).catch(()=>{});ht&&(Oa([ht]),await Ds()),e(`Regression: ${ne} pass · ${Re} inconclusive · ${Ee} fail · ${ze} error of ${A.length}`)}finally{fe(!1),X(null),_e(null)}},Ke=(A,ne)=>{var Ee,ze;const Re=ne==="failure"?((Ee=P[A.id])==null?void 0:Ee.error)??((ze=P[A.id])==null?void 0:ze.text):void 0;E$({kind:ne,id:A.id,name:A.name,prompt:A.content,tool:A.tool,failure:Re?Re.slice(0,2e3):void 0}),i==null||i()},U=async A=>{var ne,Re;try{const Ee=await O.savePromptCases(A,"ai");if(!Ee.ok)return e(Ee.error??"Could not save the selected cases."),!1;const ze=Ee.skipped??0;return e(`Added ${((ne=Ee.prompts)==null?void 0:ne.length)??0} case${(((Re=Ee.prompts)==null?void 0:Re.length)??0)===1?"":"s"} to the library${ze?` (${ze} near-duplicate${ze>1?"s":""} skipped)`:""}`),le(),!0}catch(Ee){return Ee!=null&&Ee.upgrade?(B(!0),!1):(e(Ee instanceof Error?Ee.message:String(Ee)),!1)}},te=async A=>{try{await navigator.clipboard.writeText(A),e("Prompt copied to clipboard")}catch{e("Couldn't access the clipboard")}},ke=async()=>{if(!L){e(t.length?"Pick the tool this prompt tests.":"Connect a server first, then pick a tool.");return}if(!k.trim()){e("Enter prompt text first.");return}await O.addCustomPrompt(w.trim()||"Untitled prompt",k.trim(),L),C(""),N(""),_(""),Ne(null),le()},we=async A=>{await O.deleteCustomPrompt(A),le()},Te=A=>{b(A.name),x(A.content),S(A.tool??""),f(A.id),d(null),g(null)},ve=async()=>{if(v){if(!m.trim()){e("Prompt text can't be empty.");return}await O.updateCustomPrompt(v,{name:y.trim()||"Untitled prompt",content:m.trim(),tool:j||null}),f(null),e("Prompt updated"),le()}},z=async(A,ne)=>{await O.setPromptGolden(A,ne,"similar"),e("Saved as golden — future runs pass/fail against it"),le()},D=async A=>{await O.setPromptGolden(A,null,"similar"),e("Golden cleared"),le()};return s.jsx("div",{className:"prompt-regression-workspace",children:re==="history"?s.jsxs("section",{className:"prompt-history",children:[s.jsxs("div",{className:"assurance-run-toolbar",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Prompt regression history"}),s.jsx("p",{children:"Every individual test and suite run, including grades, model usage, latency, and drift."})]}),s.jsx("button",{className:"btn sm ghost",onClick:V,disabled:se,children:se?"Refreshing…":"Refresh"})]}),he.length?s.jsx(Tx,{runs:he,hidePillar:!0}):s.jsx(us,{children:se?"Loading prompt runs…":"No prompt regression runs yet."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"assurance-run-toolbar prompt-regression-toolbar",children:[s.jsxs("div",{children:[s.jsx("strong",{children:r==="library"?"Prompt library":"Regression suite"}),s.jsx("p",{children:r==="library"?"Reusable prompt and test assets. Write them manually, generate test cases with AI, import a suite, or save one from Prompt Studio.":"Exercise reusable prompts against a configured model, grade them against goldens, and preserve the evidence for deployment decisions."})]}),s.jsx("div",{className:"prompt-regression-actions",children:r==="library"?s.jsx("button",{className:"btn primary",onClick:()=>Ne(de?null:"menu"),"aria-expanded":de!==null,children:"+ Add prompts"}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",title:"Export prompts and their golden or latest outputs",onClick:()=>{const A=Be.map(ne=>{var Re;return{p:ne,expected:ne.expected??((Re=P[ne.id])==null?void 0:Re.text)}}).filter(ne=>!!ne.expected);if(!A.length)return e("Run the prompts first — Export suite pins each prompt's current output as its golden baseline.");ZE("prompts.json",JSON.stringify(A.map(({p:ne,expected:Re})=>({name:ne.name,content:ne.content,tool:ne.tool,input:ne.input,expected:Re,assert:ne.assert??"similar"})),null,2))},children:"Export suite"}),s.jsx("button",{className:"btn sm ghost",title:"Add these prompts to a CI gate",onClick:()=>{if(!Be.some(A=>{var ne;return A.expected||((ne=P[A.id])==null?void 0:ne.text)}))return e("Run the prompts first — adding to a gate pins each prompt's current output as its regression baseline.");ue(!0)},children:"Add to gate"}),s.jsx("button",{className:"btn primary",onClick:ye,disabled:me||Be.length===0,children:me?"Running…":`Run regression${Be.length?` (${Be.length})`:""}`})]})})]}),r==="test"&&s.jsxs("section",{className:"tiles rag-config-grid prompt-regression-config-grid",children:[s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-title",children:[s.jsx("span",{className:"dot neutral"})," Suite scope"]}),s.jsxs("div",{className:"prompt-config-value",children:[Be.length," ",s.jsxs("span",{children:["of ",l.length," cases"]})]}),s.jsx("p",{children:"Positive, negative, boundary, injection, and custom evidence cases."})]}),s.jsxs("div",{className:`tile ${Y?"ready":""}`,children:[s.jsxs("div",{className:"tile-title",children:[s.jsx("span",{className:`dot ${Y?"ok":"neutral"}`})," Run target"]}),s.jsx("div",{className:"prompt-config-value",children:Y?Y.model:"Not configured"}),s.jsx("p",{children:Y?`${Y.provider} · your own key, held in this browser session`:"Choose any OpenAI-compatible or Anthropic model."}),s.jsx("button",{className:"btn sm ghost",onClick:()=>F(!0),children:Y?"Change model":"Configure model"})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-title",children:[s.jsx("span",{className:"dot neutral"})," Golden coverage"]}),s.jsxs("div",{className:"prompt-config-value",children:[l.filter(A=>A.expected).length," ",s.jsx("span",{children:"graded cases"})]}),s.jsx("p",{children:"Cases without a golden remain explicitly ungraded until evidence is saved."}),s.jsxs("span",{className:"prompt-config-note",children:[l.length-l.filter(A=>A.expected).length," need a golden"]})]})]}),r==="test"&&me&&s.jsx(jd,{title:"Running prompt regression",state:Oe,hint:"one model call per prompt"}),oe&&s.jsx(YE,{title:"AI prompt generation",plan:"Scale",onClose:()=>B(!1),description:s.jsxs(s.Fragment,{children:["Upgrade to the ",s.jsx("b",{children:"Scale"})," plan to generate test prompts with AI. Your own-key prompt runs remain free."]}),features:["AI-generated positive, negative, boundary, and injection test cases","100 prompt regressions per month","90 days of history and trends","CI/CD and Deployment Assurance"]}),ie&&s.jsx(Nl,{title:"Tag prompt regression",subtitle:s.jsxs(s.Fragment,{children:["Captures each shown prompt as a regression test, pinning its ",s.jsx("b",{children:"golden"})," — or, if you haven't set one, its ",s.jsx("b",{children:"latest run output"})," — as the expected baseline. A CI job that names one of its tags grades these prompts against your model."]}),defaultName:"Prompt regression",capture:()=>Be.map(A=>{var ne;return{p:A,golden:A.expected??((ne=P[A.id])==null?void 0:ne.text)}}).filter(A=>!!A.golden).map(({p:A,golden:ne})=>({pillar:"prompt",name:A.name,prompt:{content:A.content,expected:ne,assert:A.assert??"similar"}})),onClose:()=>ue(!1)}),ce&&s.jsx(qp,{initial:Y,onClose:()=>F(!1),onSave:A=>{Cx(A),K(A),F(!1),e(`Run target set: ${A.provider} · ${A.model||"?"}`)}}),r==="library"&&de&&s.jsx(rO,{mode:de,setMode:Ne,tools:t,gated:o,llm:Y,onNeedModel:()=>F(!0),onNeedUpgrade:()=>B(!0),notify:e,onSaveCases:U,manual:{name:w,setName:C,content:k,setContent:N,addTool:L,setAddTool:_,submit:ke}}),s.jsxs("section",{className:"prompt-case-library",children:[s.jsxs("div",{className:"prompt-library-header",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"Evidence case library"}),s.jsx("h2",{children:"Reusable prompt cases"}),s.jsxs("p",{children:[Be.length===l.length?`${l.length} cases`:`${Be.length} of ${l.length} cases`," in the current view."]})]}),s.jsxs("div",{className:"prompt-library-filters",children:[xe.length>1&&s.jsxs("select",{className:"field",value:$,onChange:A=>W(A.target.value),title:"Filter by category",children:[s.jsx("option",{value:"",children:"All types"}),xe.map(A=>s.jsx("option",{value:A,children:A},A))]}),Fe.length>1&&s.jsxs("select",{className:"field",value:R,onChange:A=>H(A.target.value),title:"Filter by source",children:[s.jsx("option",{value:"",children:"All sources"}),Fe.map(A=>{var ne;return s.jsx("option",{value:A,children:((ne=Cu[A])==null?void 0:ne.label)??A},A)})]}),ee.length>0&&s.jsxs("select",{className:"field",value:E,onChange:A=>I(A.target.value),title:"Filter by tool",children:[s.jsx("option",{value:"",children:"All tools"}),ee.map(A=>s.jsx("option",{value:A,children:A},A))]})]})]}),l.length===0&&!de?s.jsx(us,{children:s.jsxs("div",{className:"stack",style:{gap:8,alignItems:"flex-start"},children:[s.jsx("span",{style:{fontWeight:600},children:"No prompts yet."}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:t.length?"Write one manually, generate test cases with AI, or save one from Prompt Studio.":"Connect an MCP server (top-right) so its tools appear here, then write, generate, or import prompts."}),s.jsx("button",{className:"btn sm primary",onClick:()=>Ne("menu"),children:"+ Add prompts"})]})}):s.jsxs("div",{className:"prompt-regression-list",children:[Ce.map(A=>s.jsxs("article",{className:"prompt-regression-card",children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("span",{className:`tag ${s_[A.category]??"informational"}`,children:A.category}),s.jsx("span",{style:{fontWeight:500},children:A.name}),A.source&&Cu[A.source]&&s.jsx("span",{className:"pill",title:Cu[A.source].title,children:Cu[A.source].label}),A.tool&&s.jsx("span",{className:"pill mono",children:A.tool}),A.expected&&s.jsx("span",{className:"pill",title:"Has a golden expected output — runs are graded",style:{cursor:"pointer"},onClick:()=>D(A.id),children:"★ golden"}),A.assertions&&A.assertions.length>0&&s.jsxs("span",{className:"pill",title:"Has tool-assertion rules",children:["✓ ",A.assertions.length," rule",A.assertions.length>1?"s":""]})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm",onClick:()=>dt(A.id,A.content),disabled:Q===A.id,title:"Run against your own provider key — no hosted-generation charge; your provider bills the call.",children:Q===A.id?"Running…":"▶ Run"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>g(h===A.id?null:A.id),disabled:!A.tool,title:A.tool?"Call the tool with structured input and assert on its output":"Bind this prompt to a tool first",children:h===A.id?"Hide test":"🎯 Tool test"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>v===A.id?f(null):Te(A),title:"Edit this prompt's text / tool",children:v===A.id?"Hide edit":"✎ Edit"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>d(u===A.id?null:A.id),children:u===A.id?"Hide":"View"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>Ke(A,"prompt"),title:"Open an independent exploratory session. The saved prompt is not modified until you save changes.",children:"Try in Prompt Studio"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>te(A.content),title:"Copy prompt text",children:"Copy"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>we(A.id),title:"Delete",children:"✕"})]})]}),v===A.id&&s.jsxs("div",{className:"card",style:{marginTop:10,background:"var(--panel-2, rgba(128,128,128,0.05))"},children:[s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Name"}),s.jsx("input",{className:"field",value:y,onChange:ne=>b(ne.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Tool"}),s.jsxs("select",{className:"field",value:j,onChange:ne=>S(ne.target.value),children:[s.jsx("option",{value:"",children:t.length?"— none —":"(connect a server)"}),t.map(ne=>s.jsx("option",{value:ne.name,children:ne.name},ne.name))]})]})]}),s.jsx("div",{className:"section-label",children:"Prompt text"}),s.jsx("textarea",{className:"field mono",style:{minHeight:120},value:m,onChange:ne=>x(ne.target.value)}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:10,justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>f(null),children:"Cancel"}),s.jsx("button",{className:"btn sm primary",onClick:ve,children:"Save"})]})]}),h===A.id&&s.jsx(U$,{prompt:A,tool:t.find(ne=>ne.name===A.tool),connected:a,notify:e,onSaved:le}),u===A.id&&s.jsx("div",{className:"msg-bubble",style:{marginTop:10,whiteSpace:"pre-wrap"},children:A.content}),P[A.id]&&s.jsxs("div",{style:{marginTop:10},children:[s.jsxs("div",{className:"statusline",style:{marginTop:0,marginBottom:8},children:[P[A.id].verdict?s.jsxs("span",{className:`tag ${P[A.id].verdict}`,children:[P[A.id].verdict,A.expected&&!P[A.id].agentic?" vs golden":P[A.id].agentic?" · observed tool behavior":""]}):s.jsx("span",{className:"muted",children:P[A.id].agentic?"Agent run":"Model response"}),P[A.id].model&&s.jsx("span",{className:"pill",children:P[A.id].model}),P[A.id].usage&&s.jsxs("span",{className:"metric",children:[P[A.id].usage.inputTokens+P[A.id].usage.outputTokens," tok"]}),Bw(P[A.id].usage,Y)&&s.jsx("span",{className:"metric",children:Bw(P[A.id].usage,Y)}),P[A.id].latencyMs!=null&&s.jsxs("span",{className:"metric",children:[P[A.id].latencyMs," ms"]}),s.jsx("span",{style:{flex:1}}),P[A.id].text&&s.jsx("button",{className:"btn sm ghost",onClick:()=>z(A.id,P[A.id].text),title:"Save this response as the expected golden output",children:A.expected?"Update golden":"★ Save as golden"}),(P[A.id].verdict==="fail"||P[A.id].error)&&s.jsx("button",{className:"btn sm ghost",onClick:()=>Ke(A,"failure"),title:"Reproduce this failure manually — the prompt, model configuration, tool binding and last result are preloaded into a fresh session.",children:"Investigate in Prompt Studio"})]}),P[A.id].toolCalls&&P[A.id].toolCalls.length>0&&s.jsx("div",{className:"stack",style:{gap:8,marginBottom:10},children:P[A.id].toolCalls.map((ne,Re)=>s.jsxs("div",{className:"card",style:{padding:"8px 12px"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",marginBottom:6},children:[s.jsx("span",{className:"tag informational",children:"tool call"}),s.jsx("span",{className:"mono",style:{fontSize:12.5,fontWeight:500},children:ne.name}),s.jsxs("span",{className:"mono muted",style:{fontSize:12},children:["(",JSON.stringify(ne.input),")"]}),s.jsx("span",{style:{flex:1}}),s.jsx("span",{className:`tag ${ne.isError?"fail":"pass"}`,children:ne.isError?"error":"ok"})]}),s.jsx(Ls,{value:ne.output})]},Re))}),P[A.id].error?s.jsx("div",{className:"msg-bubble",style:{color:"var(--fail)",whiteSpace:"pre-wrap"},children:P[A.id].error}):s.jsx("div",{className:"msg assistant",children:s.jsx("div",{className:"msg-bubble",children:P[A.id].text||"(empty response)"})})]})]},A.id)),s.jsx(Bp,{page:st,pageSize:df,total:Be.length,onPage:ae})]})]})]})})}const uf=["positive","negative","boundary","injection"];function rO({mode:e,setMode:t,tools:n,gated:a,llm:r,onNeedModel:i,onNeedUpgrade:o,notify:l,onSaveCases:c,manual:u}){return s.jsxs("section",{className:"prompt-editor-panel","aria-label":"Add prompts",children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:10,flexWrap:"wrap"},children:[s.jsx("strong",{style:{fontSize:13},children:"Add prompts"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>t(null),children:"Close"})]}),s.jsxs("div",{className:"tabbar",role:"tablist","aria-label":"How to add prompts",style:{marginTop:10},children:[s.jsx("button",{role:"tab","aria-selected":e==="manual",className:`tab ${e==="manual"?"active":""}`,onClick:()=>t("manual"),children:"Write manually"}),s.jsx("button",{role:"tab","aria-selected":e==="generate",className:`tab ${e==="generate"?"active":""}`,onClick:()=>t("generate"),children:"Generate with AI"}),s.jsx("button",{role:"tab","aria-selected":e==="import",className:`tab ${e==="import"?"active":""}`,onClick:()=>t("import"),children:"Import"})]}),e==="menu"&&s.jsx("div",{className:"muted",style:{fontSize:12.5,marginTop:10},children:"Choose how to add prompts: write one by hand, generate reviewable test cases with Prooflane hosted AI, or import an exported suite."}),e==="manual"&&s.jsxs("div",{style:{marginTop:10},children:[s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",htmlFor:"manual-prompt-name",children:"Name"}),s.jsx("input",{id:"manual-prompt-name",className:"field",value:u.name,onChange:d=>u.setName(d.target.value),placeholder:"e.g. login jailbreak attempt"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"label",htmlFor:"manual-prompt-tool",children:["Tool under test ",s.jsx("span",{style:{color:"var(--fail)"},children:"*"})]}),s.jsxs("select",{id:"manual-prompt-tool",className:"field",value:u.addTool,onChange:d=>u.setAddTool(d.target.value),disabled:n.length===0,children:[s.jsx("option",{value:"",children:n.length?"Select a tool…":"Connect a server first"}),n.map(d=>s.jsx("option",{value:d.name,children:d.name},d.name))]})]})]}),s.jsx("div",{className:"section-label",children:"Prompt"}),s.jsx("textarea",{className:"field",value:u.content,onChange:d=>u.setContent(d.target.value),placeholder:"Write the prompt to test this tool…",style:{minHeight:100}}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",onClick:()=>void u.submit(),disabled:!u.addTool||!u.content.trim(),children:"Save prompt"})}),n.length===0&&s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:8},children:"Manual prompts must target a tool. Connect to a server (top-right) so its tools appear here."})]}),e==="generate"&&s.jsx(iO,{tools:n,gated:a,llm:r,onNeedModel:i,onNeedUpgrade:o,notify:l,onSaveCases:c}),e==="import"&&s.jsx(oO,{tools:n,notify:l,onSaveCases:c})]})}function iO({tools:e,gated:t,llm:n,onNeedModel:a,onNeedUpgrade:r,notify:i,onSaveCases:o}){var W;const[l,c]=p.useState(((W=e[0])==null?void 0:W.name)??""),[u,d]=p.useState(6),[h,g]=p.useState("balanced"),[v,f]=p.useState({positive:!0,negative:!0,boundary:!0,injection:!0}),[y,b]=p.useState(!1),[m,x]=p.useState(null),[j,S]=p.useState(null),[w,C]=p.useState({}),[k,N]=p.useState({}),[L,_]=p.useState(null);p.useEffect(()=>{!l&&e.length&&c(e[0].name)},[e,l]);const E=uf.filter(R=>v[R]);async function I(){if(t){r();return}if(!(n!=null&&n.model)||!n.apiKey){a();return}if(!l){i("Connect a server and choose one of its tools first.");return}b(!0),_(null),S(null),x(null);try{const R=await O.generatePromptCases({tool:l,count:u,strategy:h,types:E.length?E:uf,llm:{provider:n.provider,baseUrl:n.baseUrl,model:n.model,apiKey:n.apiKey}});if(!R.ok||!R.cases){_(R.error??"Generation failed.");return}S(R.cases),C(Object.fromEntries(R.cases.map(H=>[H.id,!0]))),N(Object.fromEntries(R.cases.map(H=>[H.id,H.prompt]))),i(`${R.cases.length} test case${R.cases.length===1?"":"s"} generated — review before saving.`)}catch(R){R!=null&&R.upgrade?r():_(R instanceof Error?R.message:String(R))}finally{b(!1)}}async function $(){if(!j)return;const R=j.filter(K=>w[K.id]);if(!R.length){i("Select at least one case.");return}x({done:0,total:R.length,label:R[0].name});const H=R.map((K,ce)=>{var ue;x({done:ce,total:R.length,label:K.name});const F=[];K.expectedBehavior&&F.push(`Expected behavior: ${K.expectedBehavior}`),K.expectedTool&&F.push(`Expected tool: ${K.expectedTool}`),(ue=K.forbiddenTools)!=null&&ue.length&&F.push(`Must not call: ${K.forbiddenTools.join(", ")}`);const ie=k[K.id]??K.prompt;return{category:K.type,name:K.name,content:F.length?`${ie}
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
${F.join(`
|
|
60
|
-
`)}`:ie,tool:K.source.toolName,assertions:K.assertions.length?K.assertions:void 0}}),Y=await o(H);x({done:R.length,total:R.length,label:"saved"}),Y&&(S(null),C({})),setTimeout(()=>x(null),500)}return s.jsxs("div",{className:"stack",style:{gap:12,marginTop:10},children:[s.jsxs("div",{className:"stack",style:{gap:4},children:[s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",alignItems:"center"},children:[s.jsx("span",{style:{fontWeight:600,fontSize:13},children:"Generate test cases with AI"}),s.jsx("span",{className:"tag warn",children:"Scale"}),s.jsx("span",{className:"pill",title:"Prooflane hosted AI — metered against your plan.",children:"hosted · metered"})]}),s.jsx("span",{className:"muted",style:{fontSize:12},children:"Generate positive, negative, boundary, and adversarial test cases from connected MCP tool schemas."}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[s.jsx("b",{children:"Generate"})," runs on Prooflane hosted AI and is metered against your plan. ",s.jsx("b",{children:"Run"})," executes against your own provider key with no hosted-generation charge."]})]}),s.jsxs("div",{className:"row",style:{gap:10,flexWrap:"wrap",alignItems:"flex-end"},children:[s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"gen-server",children:"Server"}),s.jsx("input",{id:"gen-server",className:"field",style:{width:180},value:e.length?"connected MCP server":"not connected",readOnly:!0})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"gen-tool",children:"Tool"}),s.jsxs("select",{id:"gen-tool",className:"field",style:{width:180},value:l,onChange:R=>c(R.target.value),disabled:e.length===0,children:[e.length===0&&s.jsx("option",{value:"",children:"connect a server"}),e.map(R=>s.jsx("option",{value:R.name,children:R.name},R.name))]})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"gen-count",children:"Cases"}),s.jsx("select",{id:"gen-count",className:"field",style:{width:96},value:u,onChange:R=>d(Number(R.target.value)),children:[3,6,9,12].map(R=>s.jsx("option",{value:R,children:R},R))})]}),s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("label",{className:"label",htmlFor:"gen-strategy",children:"Strategy"}),s.jsxs("select",{id:"gen-strategy",className:"field",style:{width:130},value:h,onChange:R=>g(R.target.value),children:[s.jsx("option",{value:"focused",children:"Focused"}),s.jsx("option",{value:"balanced",children:"Balanced"}),s.jsx("option",{value:"creative",children:"Creative"})]})]}),s.jsxs("fieldset",{className:"stack",style:{gap:3,border:"none",padding:0,margin:0},children:[s.jsx("legend",{className:"label",style:{padding:0},children:"Types"}),s.jsx("div",{className:"row",style:{gap:10,flexWrap:"wrap"},children:uf.map(R=>s.jsxs("label",{className:"row",style:{gap:5,alignItems:"center",fontSize:12.5,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:v[R],onChange:H=>f(Y=>({...Y,[R]:H.target.checked}))}),s.jsx("span",{style:{textTransform:"capitalize"},children:R})]},R))})]}),s.jsx("button",{className:"btn primary",onClick:()=>void I(),disabled:y||e.length===0,children:y?"Generating…":`${t?"🔒 ":"✨ "}Generate`})]}),y&&s.jsx(jd,{title:"Generating test cases",state:null,hint:"Prooflane hosted AI is drafting cases from the tool schema"}),m&&!y&&s.jsx(jd,{title:"Adding selected cases to the library",state:m}),L&&s.jsx("div",{className:"drift dirty",role:"alert",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"generation"}),s.jsx("span",{style:{fontSize:13},children:L})]})}),j&&s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",flexWrap:"wrap",gap:8},children:[s.jsxs("strong",{style:{fontSize:13},children:[j.length," test case",j.length===1?"":"s"," generated"]}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Nothing is saved until you add the selected cases."})]}),j.map(R=>s.jsxs("div",{className:"card",style:{padding:"10px 12px"},children:[s.jsxs("label",{className:"row",style:{gap:8,alignItems:"center",cursor:"pointer",flexWrap:"wrap"},children:[s.jsx("input",{type:"checkbox",checked:!!w[R.id],onChange:H=>C(Y=>({...Y,[R.id]:H.target.checked})),"aria-label":`Include ${R.name}`}),s.jsx("span",{className:`tag ${s_[R.type]??"informational"}`,children:R.type}),s.jsx("span",{style:{fontWeight:600,fontSize:13},children:R.name}),R.expectedTool&&s.jsxs("span",{className:"pill mono",children:["expects ",R.expectedTool]}),s.jsxs("span",{className:"pill",children:[R.assertions.length," assertion",R.assertions.length===1?"":"s"]})]}),s.jsx("textarea",{className:"field mono",style:{minHeight:74,marginTop:8},value:k[R.id]??R.prompt,onChange:H=>N(Y=>({...Y,[R.id]:H.target.value})),"aria-label":`Prompt for ${R.name}`}),R.expectedBehavior&&s.jsx("div",{className:"muted",style:{fontSize:11.5,marginTop:4},children:R.expectedBehavior}),R.assertions.length>0&&s.jsx("ul",{className:"muted mono",style:{fontSize:11,margin:"6px 0 0",paddingLeft:18},children:R.assertions.map((H,Y)=>s.jsxs("li",{children:[H.path||"$"," ",H.op,H.value!==void 0?` ${JSON.stringify(H.value)}`:""]},Y))})]},R.id)),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>void I(),disabled:y,children:"Regenerate"}),s.jsxs("button",{className:"btn sm primary",onClick:()=>void $(),children:["Add selected to Library (",j.filter(R=>w[R.id]).length,")"]})]})]})]})}function oO({tools:e,notify:t,onSaveCases:n}){const[a,r]=p.useState(null),[i,o]=p.useState(null),l=p.useRef(null),c=new Set(e.map(d=>d.name));function u(d){const h=new FileReader;h.onload=()=>{try{const g=JSON.parse(String(h.result));if(!Array.isArray(g))throw new Error("The file must contain a JSON array of prompts.");const v=g.filter(f=>!!f&&typeof f=="object").filter(f=>typeof f.content=="string"&&f.content.trim()).map(f=>({category:"custom",name:typeof f.name=="string"&&f.name.trim()?f.name.trim():"Imported prompt",content:f.content.trim(),tool:typeof f.tool=="string"&&c.has(f.tool)?f.tool:void 0}));if(!v.length)throw new Error("No usable prompts were found in that file.");r(v),o(null)}catch(g){r(null),o(g instanceof Error?g.message:String(g))}},h.readAsText(d)}return s.jsxs("div",{className:"stack",style:{gap:10,marginTop:10},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["Import a prompt suite exported from Prooflane (",s.jsx("span",{className:"mono",children:"prompts.json"}),"): an array of",s.jsxs("span",{className:"mono",children:[" ","{ name, content, tool }"]})," objects. Goldens and assertions are added after import, in the library."]}),s.jsx("input",{ref:l,type:"file",accept:"application/json,.json",className:"field","aria-label":"Prompt suite file",onChange:d=>{var g;const h=(g=d.target.files)==null?void 0:g[0];h&&u(h)}}),i&&s.jsx("div",{className:"muted",style:{color:"var(--fail)",fontSize:12.5},role:"alert",children:i}),a&&s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsxs("strong",{style:{fontSize:13},children:[a.length," prompt",a.length===1?"":"s"," ready to import"]}),s.jsxs("ul",{className:"muted",style:{fontSize:12,margin:0,paddingLeft:18},children:[a.slice(0,8).map((d,h)=>s.jsxs("li",{children:[d.name,d.tool?` · ${d.tool}`:""]},h)),a.length>8&&s.jsxs("li",{children:["…and ",a.length-8," more"]})]}),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{r(null),l.current&&(l.current.value="")},children:"Clear"}),s.jsxs("button",{className:"btn sm primary",onClick:()=>void(async()=>{await n(a)&&(r(null),l.current&&(l.current.value=""),t("Import complete."))})(),children:["Import ",a.length]})]})]})]})}function lO({caps:e,connected:t}){const n=(e==null?void 0:e.prompts)??[],[a,r]=p.useState(null);return s.jsxs("div",{children:[s.jsxs("div",{className:"detail-title",style:{fontSize:15,marginBottom:12},children:["Server prompts ",s.jsxs("span",{className:"muted",children:["(",n.length,")"]})]}),t?n.length===0?s.jsx(us,{children:"This server exposes no prompts."}):s.jsxs("div",{className:"split",children:[s.jsx("div",{className:"list",children:n.map(i=>s.jsxs("button",{className:`list-item ${a===i.name?"active":""}`,onClick:()=>r(i.name),children:[s.jsx("div",{className:"name",children:i.name}),s.jsx("div",{className:"desc",children:i.description??"—"})]},i.name))}),a?s.jsx(cO,{prompt:n.find(i=>i.name===a)},a):s.jsx(us,{children:"Select a prompt."})]}):s.jsx(us,{children:"Connect to a server to render its prompts."})]})}function cO({prompt:e}){const[t,n]=p.useState({}),[a,r]=p.useState(null),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(null),h=async()=>{c(!0),d(null);try{r(await O.getPrompt(e.name,t))}catch(g){d(g instanceof Error?g.message:String(g))}finally{c(!1)}};return s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"detail-title",style:{fontSize:15},children:e.name}),s.jsx("div",{className:"detail-desc",children:e.description??"No description."}),(e.arguments??[]).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section-label",children:"Arguments"}),s.jsx("div",{className:"stack",children:e.arguments.map(g=>s.jsxs("div",{children:[s.jsxs("label",{className:"label",children:[g.name,g.required?" *":""," ",g.description?s.jsxs("span",{className:"muted",children:["— ",g.description]}):null]}),s.jsx("input",{className:"field",value:t[g.name]??"",onChange:v=>n({...t,[g.name]:v.target.value})})]},g.name))})]}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",onClick:h,disabled:l,children:l?"Rendering…":"Render"})}),u&&s.jsx("div",{className:"muted",style:{color:"var(--fail)"},children:u}),a!=null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"section-label row",style:{gap:8},children:[s.jsx("span",{children:"Rendered"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn sm ghost",onClick:()=>o(g=>!g),children:i?"Pretty":"Raw"})]}),i?s.jsx(Ls,{value:a}):s.jsx(dO,{rendered:a})]})]})}function dO({rendered:e}){const t=Array.isArray(e.messages)?e.messages:[];return s.jsxs("div",{children:[e.description&&s.jsx("div",{className:"prompt-desc",children:e.description}),t.length===0&&s.jsx("div",{className:"muted",children:"No messages."}),t.map((n,a)=>{const r=n??{},i=r.role??"user";return s.jsxs("div",{className:`msg ${i==="assistant"?"assistant":"user"}`,children:[s.jsx("span",{className:"msg-role",children:i}),s.jsx("div",{className:"msg-bubble",children:uO(r.content)})]},a)})]})}function uO(e){return e==null?s.jsx("span",{className:"muted",children:"(empty)"}):typeof e=="string"?e:(Array.isArray(e)?e:[e]).map((n,a)=>{const r=n??{};return typeof r.text=="string"?s.jsx("span",{children:r.text},a):s.jsxs("span",{className:"msg-nontext",children:["[",r.type??"content","]"]},a)})}function hO({caps:e,notify:t,core:n,connected:a,onNavigate:r}){const[i,o]=p.useState("library");return s.jsxs("div",{className:"stack",style:{gap:16},children:[s.jsx("div",{className:"tabbar assurance-tabs",role:"tablist","aria-label":"Prompts",children:[["library","Library"],["test","Test"],["studio","Prompt Studio"],["runs","Runs"]].map(([l,c])=>s.jsx("button",{role:"tab","aria-selected":i===l,className:`tab ${i===l?"active":""}`,onClick:()=>o(l),children:c},l))}),i==="studio"?s.jsx(T$,{caps:e,connected:a,notify:t,onNavigate:r}):s.jsx(aO,{notify:t,tools:(e==null?void 0:e.tools)??[],core:n,connected:a,tab:i,onOpenStudio:()=>o("studio")})]})}const hf=20,Vw="contracts/server.kawach";async function pO(e,t){var i;const{tool:n,input:a,expectedOutput:r}=e.snapshot;try{if(e.kind==="http"){const d=a??{},h=await O.httpRequest({method:d.method??"GET",url:d.url??"",headers:d.headers,body:d.body});if(!h.ok)return{error:h.error??"Request failed."};const g=a_(h.body),v={status:h.status,statusText:h.statusText,body:g!==void 0?g:h.body};return{verdict:(await O.diffValues(n,r,v)).verdict}}const o=e.connection,l=((i=t.caps)==null?void 0:i.tools.some(d=>d.name===n))??!1;if(o&&(!t.connected||!l)){const d=r_(o);if(!d)return{error:"Origin can't be auto-connected."};await t.onConnect(d,o.name)}else if(!l&&!o)return{error:"Tool not on the current connection."};const c=await O.callTool(n,a??{});return{verdict:(await O.diffValues(n,r,c.output)).verdict}}catch(o){return{error:o instanceof Error?o.message:String(o)}}}function mO({connected:e,caps:t,onConnect:n,notify:a,onNavigateIntelligence:r}){const[i,o]=p.useState([]),[l,c]=p.useState(null),[u,d]=p.useState(new Set),[h,g]=p.useState({}),[v,f]=p.useState(!1),[y,b]=p.useState(new Set),[m,x]=p.useState(0),[j,S]=p.useState(!1),[w,C]=p.useState([]),[k,N]=p.useState([]),[L,_]=p.useState(!0),[E,I]=p.useState(null),[$,W]=p.useState(!0),[R]=p.useState(()=>{const T=localStorage.getItem("prooflane.intelligence.focusNativeGeneration")??void 0;return localStorage.removeItem("prooflane.intelligence.focusNativeGeneration"),T}),H=()=>(_(!0),I(null),O.intelligenceNativeArtifacts("contract",R).then(T=>{C(T.artifacts),N(T.deferred)}).catch(T=>{C([]),N([]),I(T instanceof Error?T.message:"Contract drafts could not be loaded.")}).finally(()=>_(!1))),Y=()=>O.snapshots().then(T=>(o(T),c(he=>{var q;return he&&T.some(se=>se.id===he)?he:((q=T[0])==null?void 0:q.id)??null}),T)).catch(()=>[]);p.useEffect(()=>{Y()},[]),p.useEffect(()=>{H()},[t]);const K=async(T,he)=>{if(window.confirm(`Delete the contract "${he}"? This can't be undone.`))try{await O.deleteSnapshot(T),d(q=>{const se=new Set(q);return se.delete(T),se}),g(q=>{const se={...q};return delete se[T],se}),await Y(),a("Contract deleted")}catch(q){a(q instanceof Error?q.message:"Couldn't delete the contract.")}},ce=T=>b(he=>{const q=new Set(he);return q.has(T)?q.delete(T):q.add(T),q});if(i.length===0&&!L&&w.length===0&&k.length===0&&!R&&!E)return s.jsxs(us,{children:["No saved baselines yet. In ",s.jsx("b",{children:"MCP Inspector"})," (or ",s.jsx("b",{children:"HTTP"}),"), set an input and click"," ",s.jsx("b",{children:"Automate"})," to capture one — it appears here."]});const F=i.find(T=>T.id===l)??null,ie=u.size===i.length&&i.length>0,ue=T=>{d(he=>{const q=new Set(he);return q.has(T)?q.delete(T):q.add(T),q})},oe=()=>d(ie?new Set:new Set(i.map(T=>T.id))),B=async()=>{const T=u.size?i.filter(q=>u.has(q.id)):i;f(!0),g({});const he={};try{for(const de of T){const Ne=await pO(de,{connected:e,caps:t,onConnect:n});he[de.id]=Ne,g(Oe=>({...Oe,[de.id]:Ne}))}const q=(de,Ne,Oe)=>{const _e=de.map(re=>he[re.id]).filter(Boolean);return _e.length?{pillar:Ne,label:Oe,total:_e.length,pass:_e.filter(re=>re.verdict==="pass").length,drift:_e.filter(re=>re.verdict==="drift").length,fail:_e.filter(re=>re.verdict==="fail").length,error:_e.filter(re=>re.error).length}:null},se=[q(T.filter(de=>de.kind==="mcp"),"mcp","MCP tools regression"),q(T.filter(de=>de.kind==="http"),"contract","Contract regression")].filter(Boolean),ge=[];for(const de of se)ge.push(await O.saveRun(de));Oa(ge),await Ds()}finally{f(!1)}},Q=Object.values(h),X={pass:Q.filter(T=>T.verdict==="pass").length,drift:Q.filter(T=>T.verdict==="drift").length,fail:Q.filter(T=>T.verdict==="fail").length,error:Q.filter(T=>T.error).length},me=i.slice(m*hf,(m+1)*hf),fe=[{key:"mcp",label:"MCP tool contracts"},{key:"http",label:"HTTP contracts"}].map(T=>({...T,items:me.filter(he=>he.kind===T.key)})).filter(T=>T.items.length>0),P=T=>{const he=h[T.id];return s.jsxs("article",{className:`contract-record-card ${l===T.id?"active":""}`,children:[s.jsx("input",{className:"contract-record-check",type:"checkbox",checked:u.has(T.id),onChange:()=>ue(T.id),onClick:q=>q.stopPropagation(),"aria-label":`Select ${T.snapshot.tool}`}),s.jsxs("button",{className:"contract-record-open",onClick:()=>c(T.id),children:[s.jsxs("span",{className:"contract-record-topline",children:[s.jsx("span",{className:`contract-kind ${T.kind}`,children:T.kind==="mcp"?"MCP tool":"HTTP"}),s.jsx("span",{className:"contract-record-date",children:new Date(T.createdAt).toLocaleString()})]}),s.jsx("strong",{className:"contract-record-name mono",children:T.snapshot.tool}),s.jsx("span",{className:"contract-record-meta",children:T.connection?n_(T.connection):T.origin==="schema"?"Schema-derived baseline":"Local recorded call"})]}),s.jsxs("div",{className:"contract-record-footer",children:[s.jsx("span",{children:he!=null&&he.verdict?s.jsx(wx,{verdict:he.verdict}):he!=null&&he.error?s.jsx("span",{className:"tag informational",title:he.error,children:"error"}):s.jsx("span",{className:"contract-ready",children:"Ready to verify"})}),s.jsxs("span",{className:"contract-record-actions",children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>c(T.id),children:"View evidence ↓"}),s.jsx("button",{className:"btn sm ghost contract-delete",title:"Delete this contract","aria-label":`Delete ${T.snapshot.tool}`,onClick:q=>{q.stopPropagation(),K(T.id,T.snapshot.tool)},children:"✕"})]})]})]},T.id)};return s.jsxs("div",{className:"contract-workspace",children:[s.jsxs("header",{className:"ct-bar",children:[s.jsxs("label",{className:"ct-selectall",title:"Select every recorded call",children:[s.jsx("input",{type:"checkbox",checked:ie,onChange:oe}),s.jsx("span",{children:"all"})]}),s.jsxs("div",{className:"ct-stats",role:"status",children:[s.jsxs("span",{children:[s.jsx("b",{children:i.length})," recorded"]}),s.jsxs("span",{className:u.size?"on":"",children:[s.jsx("b",{children:u.size})," selected"]}),s.jsxs("span",{children:[s.jsx("b",{children:Q.length})," verified"]}),Q.length>0&&s.jsxs("span",{className:"ct-pills",children:[X.pass>0&&s.jsxs("span",{className:"tag pass",children:[X.pass," pass"]}),X.drift>0&&s.jsxs("span",{className:"tag drift",children:[X.drift," drift"]}),X.fail>0&&s.jsxs("span",{className:"tag fail",children:[X.fail," fail"]}),X.error>0&&s.jsxs("span",{className:"tag informational",children:[X.error," error"]})]})]}),s.jsxs("div",{className:"ct-actions",children:[(R||w.length>0||k.length>0||E)&&s.jsxs("button",{className:`ct-ghost ${$?"primary":""}`,onClick:()=>W(T=>!T),children:["Intelligence · ",w.length]}),s.jsx("button",{className:"ct-ghost",title:"Add capability-drift to a CI gate",onClick:()=>S(!0),children:"Add to gate"}),s.jsx("button",{className:"ct-ghost primary",onClick:B,disabled:v,children:v?"Running…":u.size?`Verify ${u.size}`:"Verify all"})]})]}),$&&(R||w.length>0||k.length>0||E)&&s.jsxs("section",{className:"contract-library","aria-label":"Assurance Intelligence Contract artifacts",children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",marginBottom:10},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"Generated by Assurance Intelligence"}),s.jsx("div",{className:"muted",style:{fontSize:12},children:"Native Contract drafts are reviewed here; suite approval remains a separate immutable transition."})]}),r&&s.jsx("button",{className:"btn sm ghost",onClick:r,children:"Back to generation →"})]}),s.jsx("div",{className:"contract-record-grid",children:w.map(T=>s.jsx(fO,{artifact:T,notify:a,onChanged:H,onNavigateIntelligence:r},`${T.generationId}:${T.test.id}`))}),!L&&E&&s.jsx("div",{className:"drift dirty",role:"alert",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"CONTRACT DRAFTS UNAVAILABLE"}),s.jsx("span",{children:E}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void H(),children:"Retry"})]})}),!L&&!E&&R&&w.length===0&&k.length===0&&s.jsx("div",{className:"drift",role:"status",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag informational",children:"NO NATIVE CONTRACT DRAFTS"}),s.jsx("span",{children:"This Sammy revision did not author an executable Contract artifact. Review its deferred recommendations or regenerate it with a trusted positive fixture."})]})}),k.length>0&&s.jsxs("details",{style:{marginTop:12},children:[s.jsxs("summary",{className:"muted",style:{cursor:"pointer",fontSize:12.5},children:[k.length," deferred Contract recommendation",k.length===1?"":"s"]}),s.jsx("div",{className:"stack",style:{gap:6,marginTop:8},children:k.map(T=>s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:T.deferredReason??"DEFERRED"}),s.jsxs("span",{children:[s.jsx("b",{children:T.testType})," · ",T.reason]})]},`${T.generationId}:${T.recommendationId}:${T.testType}`))})]})]}),j&&s.jsx(Nl,{title:"Tag capability-drift test",subtitle:s.jsxs(s.Fragment,{children:["Captures a breaking-capability-drift check against ",s.jsx("span",{className:"mono",children:Vw})," to ",s.jsx("span",{className:"mono",children:".prooflane/tags.json"}),". Produce the committed baseline with ",s.jsx("span",{className:"mono",children:"prooflane connect --baseline"})," from the CLI."]}),defaultName:"Contract drift",capture:()=>({pillar:"contract",contract:{baseline:Vw}}),onClose:()=>S(!1)}),s.jsxs("section",{className:"contract-library",children:[fe.map(T=>{const he=y.has(T.key);return s.jsxs("div",{className:"contract-record-section",children:[s.jsxs("button",{className:"contract-section-head",onClick:()=>ce(T.key),children:[s.jsxs("span",{children:[s.jsx("span",{"aria-hidden":"true",children:he?"›":"⌄"})," ",T.label]}),s.jsxs("span",{children:[T.items.length," saved"]})]}),!he&&s.jsx("div",{className:"contract-record-grid",children:T.items.map(P)})]},T.key)}),s.jsx(Bp,{page:m,pageSize:hf,total:i.length,onPage:x})]}),s.jsx("section",{className:"contract-detail-region","aria-live":"polite",children:F?s.jsx(gO,{row:F,connected:e,caps:t,onConnect:n,notify:a,onChanged:Y,onClose:()=>c(null)},F.id):s.jsxs("div",{className:"contract-detail-empty",children:[s.jsx("span",{children:"Evidence pane"}),"Select a recorded call to inspect its input, golden output, and live diff."]})})]})}function fO({artifact:e,notify:t,onChanged:n,onNavigateIntelligence:a}){var y,b,m;const[r,i]=p.useState(!1),[o,l]=p.useState(()=>{var x;return JSON.stringify(((x=e.test.tool)==null?void 0:x.input)??{},null,2)}),[c,u]=p.useState(!1),d=e.test.intelligence,h=e.validation.expectedOutcome,g=JSON.stringify(((y=e.test.tool)==null?void 0:y.input)??{},null,2),v=async x=>{u(!0);try{const j=x==="MODIFIED"&&e.test.tool?{...e.test,tool:{...e.test.tool,input:JSON.parse(o)}}:void 0;await O.intelligenceNativeArtifactReview(e.generationId,e.test.id,{action:x,reviewedBy:"local-user",expectedRevisionNumber:e.generationRevisionNumber,replacement:j}),t(`Contract artifact ${x.toLowerCase()}`),i(!1),n()}catch(j){t(j instanceof Error?j.message:"Contract artifact review failed.")}finally{u(!1)}},f=async()=>{var j;const x=(j=e.test.contract)==null?void 0:j.baseline;if(!(!x||!window.confirm("Create a new immutable verified baseline version from the currently connected live MCP surface?"))){u(!0);try{const S=await O.regoldenVerifiedBaseline(x,"local-user");t(`Created verified baseline ${S.baseline}`),n()}catch(S){t(S instanceof Error?S.message:"Could not re-golden baseline.")}finally{u(!1)}}};return s.jsxs("article",{className:"contract-record-card intelligence-artifact",children:[s.jsxs("div",{className:"contract-record-open",style:{textAlign:"left"},children:[s.jsxs("span",{className:"contract-record-topline",children:[s.jsx("span",{className:"tag informational",children:"Generated by Assurance Intelligence"}),s.jsx("span",{className:`tag ${(d==null?void 0:d.reviewStatus)==="APPROVED"?"pass":(d==null?void 0:d.reviewStatus)==="MODIFIED"?"warn":"informational"}`,children:(d==null?void 0:d.reviewStatus)??"DRAFT"}),s.jsx("span",{className:`tag ${e.validation.status==="VALID"?"pass":"fail"}`,children:e.validation.status})]}),s.jsx("strong",{className:"contract-record-name",children:e.test.name}),s.jsxs("span",{className:"contract-record-meta mono",children:[((b=e.test.tool)==null?void 0:b.name)??((m=e.test.contract)==null?void 0:m.baseline)," · expected ",h]}),s.jsxs("span",{className:"contract-record-meta",children:[(d==null?void 0:d.source)??"RULE"," · ",Math.round(((d==null?void 0:d.confidence)??0)*100),"% · ",(d==null?void 0:d.authoringStatus)??"AUTHORED"," · ",e.validation.executionBoundary.replaceAll("_"," ").toLowerCase()]}),s.jsx("span",{className:"contract-record-meta",children:d==null?void 0:d.reason}),s.jsx("span",{className:"contract-record-meta",children:e.validation.detail}),e.baselineProvenance&&s.jsxs("span",{className:"contract-record-meta mono",children:["baseline v",e.baselineProvenance.version," · ",e.baselineProvenance.sourceKind," · ",e.baselineProvenance.verifiedBy," · ",e.baselineProvenance.baselineFingerprint]})]}),e.test.tool&&s.jsxs("details",{style:{margin:"0 12px 10px"},children:[s.jsx("summary",{className:"muted",style:{cursor:"pointer",fontSize:11.5},children:"Inspect generated input and expected outcome"}),s.jsxs("div",{className:"section-label",style:{marginTop:8},children:["Expected ",h]}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",margin:0},children:g})]}),r&&e.test.tool&&s.jsxs("div",{style:{padding:"0 12px 10px"},children:[s.jsx("div",{className:"section-label",children:"Native tool input (JSON)"}),s.jsx("textarea",{className:"field mono",style:{minHeight:110},value:o,onChange:x=>l(x.target.value)})]}),s.jsxs("div",{className:"contract-record-footer",children:[s.jsxs("span",{className:"mono muted",style:{fontSize:10},children:[e.generationId," · ",e.suiteId," v",e.suiteVersion]}),s.jsxs("span",{className:"contract-record-actions",children:[a&&s.jsx("button",{className:"btn sm ghost",onClick:()=>{localStorage.setItem("prooflane.intelligence.focusGeneration",e.generationId),a()},children:"Generation →"}),e.baselineProvenance&&s.jsx("button",{className:"btn sm ghost",disabled:c,onClick:f,children:"Re-golden"}),e.suiteStatus==="DRAFT"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",disabled:c||!e.test.tool,onClick:()=>r?void v("MODIFIED"):i(!0),children:r?"Apply modification":"Modify"}),s.jsx("button",{className:"btn sm ghost",disabled:c,onClick:()=>void v("REJECTED"),children:"Reject"}),s.jsx("button",{className:"btn sm primary",disabled:c||e.validation.blocksApproval,onClick:()=>void v("APPROVED"),children:"Approve"})]})]})]})]})}function gO({row:e,connected:t,caps:n,onConnect:a,notify:r,onChanged:i,onClose:o}){const{tool:l,input:c,expectedOutput:u}=e.snapshot,d=e.kind==="http",h=c??{},g=e.connection,[v,f]=p.useState("expected"),[y,b]=p.useState(void 0),[m,x]=p.useState(null),[j,S]=p.useState(null),[w,C]=p.useState(!1),[k,N]=p.useState(null),[L,_]=p.useState(!1),[E,I]=p.useState(h.method??"GET"),[$,W]=p.useState(h.url??""),[R,H]=p.useState(Object.entries(h.headers??{})),[Y,K]=p.useState(h.body??""),[ce,F]=p.useState(()=>JSON.stringify(c??{},null,2)),[ie,ue]=p.useState(()=>JSON.stringify(u??null,null,2)),[oe,B]=p.useState(null),[Q,X]=p.useState(!1),me=()=>{I(h.method??"GET"),W(h.url??""),H(Object.entries(h.headers??{})),K(h.body??""),F(JSON.stringify(c??{},null,2)),ue(JSON.stringify(u??null,null,2)),B(null),_(!0)},fe=async()=>{X(!0),B(null);try{let se,ge=l;if(d){const Ne=(E||"GET").toUpperCase(),Oe=$.trim();if(!Oe)throw new Error("URL is required.");const _e=Object.fromEntries(R.filter(([re])=>re.trim()).map(([re,V])=>[re.trim(),V]));se={method:Ne,url:Oe,headers:Object.keys(_e).length?_e:void 0,body:Y.trim()?Y:void 0},ge=`${Ne} ${Oe}`}else se=ce.trim()?JSON.parse(ce):{};const de=ie.trim()?JSON.parse(ie):null;await O.updateSnapshot(e.id,{tool:ge,input:se,expectedOutput:de}),r("Contract updated"),_(!1),i()}catch(se){B(se instanceof Error?se.message:String(se))}finally{X(!1)}},P=(n==null?void 0:n.tools.some(se=>se.name===l))??!1,T=!w&&(d||P||g!==void 0),he=async()=>{C(!0),N(null);try{if(d){const de=await O.httpRequest({method:h.method??"GET",url:h.url??"",headers:h.headers,body:h.body});if(!de.ok)throw new Error(de.error??"Request failed.");const Ne=a_(de.body),Oe={status:de.status,statusText:de.statusText,body:Ne!==void 0?Ne:de.body};b(Oe),x(de.latencyMs),S(await O.diffValues(l,u,Oe)),f("diff");return}if(g&&(!t||!P)){const de=r_(g);if(!de)throw new Error("This baseline's origin can't be auto-connected.");await a(de,g.name)}const se=await O.callTool(l,c??{});b(se.output),x(se.latencyMs);const ge=await O.diffValues(l,u,se.output);S(ge),f("diff")}catch(se){N(se instanceof Error?se.message:String(se)),f("actual")}finally{C(!1)}},q=p.useMemo(()=>vO(c),[c]);return L?s.jsxs("div",{className:"contract-detail-pane editing",children:[s.jsxs("div",{className:"contract-detail-header",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"Editing recorded call"}),s.jsx("div",{className:"contract-detail-title mono",children:l})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>_(!1),disabled:Q,children:"Cancel"}),s.jsx("button",{className:"btn sm primary",onClick:fe,disabled:Q,children:Q?"Saving…":"Save"})]})]}),d?s.jsxs("div",{className:"stack",style:{gap:12},children:[s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("select",{className:"field",style:{width:110},value:E,onChange:se=>I(se.target.value),children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>s.jsx("option",{value:se,children:se},se))}),s.jsx("input",{className:"field mono",style:{flex:1},value:$,onChange:se=>W(se.target.value),placeholder:"https://api.example.com/path"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Headers"}),R.map(([se,ge],de)=>s.jsxs("div",{className:"row",style:{gap:8,marginBottom:6},children:[s.jsx("input",{className:"field mono",style:{flex:"0 0 34%"},value:se,placeholder:"Header",onChange:Ne=>H(Oe=>Oe.map((_e,re)=>re===de?[Ne.target.value,_e[1]]:_e))}),s.jsx("input",{className:"field mono",style:{flex:1},value:ge,placeholder:"Value",onChange:Ne=>H(Oe=>Oe.map((_e,re)=>re===de?[_e[0],Ne.target.value]:_e))}),s.jsx("button",{className:"btn sm ghost",onClick:()=>H(Ne=>Ne.filter((Oe,_e)=>_e!==de)),title:"Remove header",children:"✕"})]},de)),s.jsx("button",{className:"btn sm ghost",onClick:()=>H(se=>[...se,["",""]]),children:"+ Add header"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Body"}),s.jsx("textarea",{className:"field mono",style:{minHeight:90},value:Y,onChange:se=>K(se.target.value),placeholder:"Request body (raw)"})]})]}):s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Input (JSON)"}),s.jsx("textarea",{className:"field mono",style:{minHeight:120},value:ce,onChange:se=>F(se.target.value),placeholder:'{ "arg": "value" }'})]}),s.jsxs("div",{style:{marginTop:12},children:[s.jsx("div",{className:"section-label",children:"Expected output (JSON)"}),s.jsx("textarea",{className:"field mono",style:{minHeight:140},value:ie,onChange:se=>ue(se.target.value)})]}),oe&&s.jsx("div",{style:{color:"var(--fail)",marginTop:10,fontSize:12.5},children:oe})]}):s.jsxs("div",{className:"contract-detail-pane",children:[s.jsxs("header",{className:"contract-detail-header",children:[s.jsxs("div",{className:"contract-detail-heading",children:[s.jsx("span",{className:"eyebrow",children:"Selected evidence"}),s.jsxs("div",{className:"contract-detail-title",children:[s.jsx("span",{className:`contract-kind ${e.kind}`,children:d?h.method??"HTTP":"MCP tool"}),s.jsx("strong",{className:"mono",children:d?h.url:l})]}),s.jsxs("div",{className:"contract-origin",children:[s.jsxs("span",{children:["Captured ",new Date(e.createdAt).toLocaleString()]}),s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{children:d?`HTTP · ${h.url}`:g?n_(g):"Origin not recorded"})]})]}),s.jsxs("div",{className:"contract-detail-actions",children:[s.jsx("button",{className:"btn sm ghost",onClick:me,title:"Edit this contract's endpoint, body, headers, or golden output",children:"Edit"}),s.jsx("button",{className:"btn sm ghost contract-close",onClick:o,"aria-label":"Close evidence pane",children:"Close"}),s.jsx("button",{className:"btn primary",onClick:he,disabled:!T,title:yO(!!g,P),children:w?"Verifying…":"Verify live behavior"})]})]}),e.origin==="schema"&&s.jsx("div",{className:"drift dirty",style:{marginTop:0,marginBottom:14},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag informational",children:"schema-derived"}),s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["Synthesized from an OpenAPI schema with placeholder values. Re-run against the live endpoint, then ",s.jsx("b",{children:"save the real response as the golden"})," — the first diff is expected to differ."]})]})}),!d&&!g&&!P&&s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"missing"}),s.jsxs("span",{children:["Tool ",s.jsx("span",{className:"mono",children:l})," isn't on the current connection, and this baseline has no recorded origin. Connect to the right server from the Tools tab."]})]})}),s.jsxs("section",{className:"contract-evidence-section",children:[s.jsxs("div",{className:"contract-evidence-heading",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"Recorded input"}),s.jsx("h3",{children:"Arguments used by this call"})]}),!d&&g&&!P&&s.jsx("span",{className:"tag informational",children:"Reconnects to origin when verified"})]}),q?q.length===0?s.jsx("div",{className:"contract-input-empty",children:"No arguments were recorded."}):s.jsx("div",{className:"contract-input-grid",children:q.map(([se,ge])=>s.jsxs("div",{className:"contract-input-item",children:[s.jsx("span",{children:se}),s.jsx("code",{children:ge})]},se))}):s.jsx(Vc,{value:c??{}})]}),s.jsxs("div",{className:"tabbar contract-result-tabs",children:[s.jsx("button",{className:`tab ${v==="expected"?"active":""}`,onClick:()=>f("expected"),children:"Expected"}),s.jsx("button",{className:`tab ${v==="actual"?"active":""}`,onClick:()=>f("actual"),children:"Actual"}),s.jsxs("button",{className:`tab ${v==="diff"?"active":""}`,onClick:()=>f("diff"),children:["Diff",j&&s.jsx("span",{className:"dot-badge",style:{background:xO(j.verdict)}})]})]}),s.jsxs("div",{className:"statusline contract-result-status",children:[j&&s.jsx(wx,{verdict:j.verdict}),m!==null&&s.jsxs("span",{className:"metric",children:[m," ms"]}),v==="expected"&&s.jsx("span",{className:"metric",children:_v(u)}),v==="actual"&&y!==void 0&&s.jsx("span",{className:"metric",children:_v(y)}),k&&s.jsx("span",{style:{color:"var(--fail)"},children:k})]}),s.jsxs("div",{className:"contract-result-surface",children:[v==="expected"&&s.jsx(Vc,{value:u}),v==="actual"&&(y===void 0?s.jsxs("div",{className:"muted",style:{padding:8},children:["Click ",s.jsx("b",{children:"Verify live behavior"})," to fetch live output."]}):s.jsx(Vc,{value:y})),v==="diff"&&(j===null?s.jsx("div",{className:"muted",style:{padding:8},children:"Verify the call to compare it against the golden response."}):j.items.length===0?s.jsx("div",{className:"muted",style:{padding:8},children:"✓ No differences vs the baseline."}):s.jsx("div",{className:"drift-list",children:j.items.map((se,ge)=>s.jsxs("div",{className:"drift-row",children:[s.jsx(bx,{severity:se.severity}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:se.path})," — ",se.message]})]},ge))}))]})]})}function vO(e){return e==null?[]:typeof e!="object"||Array.isArray(e)?null:Object.entries(e).map(([t,n])=>[t,typeof n=="object"&&n!==null?JSON.stringify(n):String(n)])}function yO(e,t){return t?"Run live and diff against the baseline":e?"Reconnect to the origin server, then run and diff":"This tool isn't on the current connection, and no origin is recorded"}function n_(e){const t=e.name?`${e.name} · `:"";if(e.transport==="http")return`${t}${e.url??"http"}`;const n=[e.command,...e.args??[]].filter(Boolean).join(" ");return`${t}stdio · ${n}`}function a_(e){if(e)try{return JSON.parse(e)}catch{return}}function r_(e){return e.transport==="http"?e.url?{transport:"http",url:e.url}:null:e.command?{transport:"stdio",command:e.command,args:e.args,cwd:e.cwd}:null}function xO(e){return e==="pass"?"var(--pass)":e==="fail"?"var(--fail)":"var(--warn)"}const i_={get:"var(--blue)",post:"var(--pass)",put:"var(--warn)",patch:"var(--accent)",delete:"var(--fail)"};function jO({notify:e,onNavigate:t}){const[n,a]=p.useState(""),[r,i]=p.useState(null),[o,l]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState("request"),g=p.useMemo(()=>r?EO(r):[],[r]),v=m=>{if(a(m),l(null),!m.trim()){i(null);return}try{i(JSON.parse(m)),u(null)}catch(x){l(x instanceof Error?x.message:"Invalid JSON"),i(null)}},f=m=>{const x=new FileReader;x.onload=()=>v(String(x.result)),x.readAsText(m)};if(!r)return s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"detail-desc",children:"Import an OpenAPI spec (JSON) to browse the underlying REST endpoints an MCP server wraps — no live connection required."}),s.jsx("div",{className:"actions",children:s.jsxs("label",{className:"btn",children:["Upload file",s.jsx("input",{type:"file",accept:".json,application/json",style:{display:"none"},onChange:m=>{var x;return((x=m.target.files)==null?void 0:x[0])&&f(m.target.files[0])}})]})}),s.jsx("div",{className:"section-label",children:"Or paste JSON"}),s.jsx("textarea",{className:"field",style:{minHeight:160},value:n,onChange:m=>v(m.target.value),placeholder:'{ "openapi": "3.0.0", "paths": { ... } }'}),o&&s.jsx("div",{style:{color:"var(--fail)",marginTop:8},children:o})]});const y=r.info??{},b=c!==null?g[c]:null;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{marginBottom:16},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"detail-title",style:{fontSize:15},children:[y.title??"OpenAPI spec"," ",y.version&&s.jsxs("span",{className:"pill",children:["v",y.version]})]}),s.jsxs("div",{className:"muted",children:[g.length," endpoints"]})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{i(null),a("")},children:"Import another"})]}),s.jsxs("div",{className:"split",children:[s.jsxs("div",{className:"list",children:[g.map((m,x)=>s.jsxs("button",{className:`list-item ${c===x?"active":""}`,onClick:()=>{u(x),h("request")},children:[s.jsxs("div",{className:"name",children:[s.jsx("span",{className:"mono",style:{color:i_[m.method]??"var(--text-2)",marginRight:8},children:m.method.toUpperCase()}),m.path]}),m.summary&&s.jsx("div",{className:"desc",children:m.summary})]},x)),g.length===0&&s.jsx(us,{children:"No paths found in this spec."})]}),s.jsx("div",{className:"card",children:b?s.jsx(bO,{spec:r,ep:b,tab:d,setTab:h,notify:e,onNavigate:t}):s.jsx(us,{children:"Select an endpoint."})})]})]})}function bO({spec:e,ep:t,tab:n,setTab:a,notify:r,onNavigate:i}){const o=p.useMemo(()=>_O(e,t),[e,t]),l=p.useMemo(()=>CO(e,t.operation),[e,t]),c=p.useMemo(()=>TO(e,t.operation),[e,t]),[u,d]=p.useState(!1),h=async()=>{var g,v;d(!0);try{const f=((g=l==null?void 0:l.media[0])==null?void 0:g.schema)!==void 0?Pi(l.media[0].schema):void 0,y=c.find(S=>/^2/.test(S.code))??c[0],b=(v=y==null?void 0:y.media[0])==null?void 0:v.schema,m=b!==void 0?Pi(b):void 0,x=y&&/^\d+$/.test(y.code)?Number(y.code):200;let j=t.path;for(const S of o.filter(w=>w.in==="path"&&w.name)){const w=Pi(S.schema??{type:"string"});j=j.replace(`{${S.name}}`,encodeURIComponent(String(w??"example")))}await O.httpSnapshot({method:t.method.toUpperCase(),url:j,body:f!==void 0?JSON.stringify(f,null,2):void 0},{status:x,statusText:y==null?void 0:y.description,body:m},"schema"),r(`Contract saved: ${t.method.toUpperCase()} ${t.path} → Contracts`)}catch(f){r(f instanceof Error?f.message:"Couldn't save contract.")}finally{d(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:8},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"detail-title",style:{fontSize:14,marginBottom:4},children:[s.jsx("span",{className:"mono",style:{color:i_[t.method]??"var(--text-2)"},children:t.method.toUpperCase()})," ",t.path]}),t.summary&&s.jsx("div",{className:"detail-desc",children:t.summary})]}),s.jsxs("div",{className:"row",style:{gap:6,flexShrink:0},children:[s.jsx("button",{className:"btn sm primary",onClick:h,disabled:u,title:"Synthesize an example request/response from the schema and save it as a contract baseline",children:u?"Saving…":"Generate contract"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i("contracts"),title:"Open the Contracts workbench",children:"Contracts →"})]})]}),s.jsxs("div",{className:"tabbar",style:{margin:"12px 0"},children:[s.jsxs("button",{className:`tab ${n==="request"?"active":""}`,onClick:()=>a("request"),children:["Request",o.length+(l?1:0)>0?` (${o.length+(l?1:0)})`:""]}),s.jsxs("button",{className:`tab ${n==="response"?"active":""}`,onClick:()=>a("response"),children:["Response",c.length?` (${c.length})`:""]}),s.jsx("button",{className:`tab ${n==="raw"?"active":""}`,onClick:()=>a("raw"),children:"Raw"})]}),n==="request"&&s.jsx(wO,{params:o,body:l}),n==="response"&&s.jsx(SO,{responses:c}),n==="raw"&&s.jsx(Ls,{value:t.operation})]})}function wO({params:e,body:t}){if(e.length===0&&!t)return s.jsx(us,{children:"No request parameters or body."});const n=["path","query","header","cookie"];return s.jsxs("div",{children:[n.map(a=>{const r=e.filter(i=>i.in===a);return r.length===0?null:s.jsxs("div",{style:{marginBottom:12},children:[s.jsxs("div",{className:"section-label",children:[a," parameters"]}),s.jsx("div",{className:"stack",style:{gap:6},children:r.map((i,o)=>{var l;return s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsxs("span",{className:"mono",style:{fontWeight:500},children:[i.name,i.required?s.jsx("span",{style:{color:"var(--fail)"},children:" *"}):null]}),((l=i.schema)==null?void 0:l.type)&&s.jsxs("span",{className:"pill mono",children:[i.schema.type,i.schema.format?` · ${i.schema.format}`:""]}),i.description&&s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["— ",i.description]})]},o)})})]},a)}),t&&s.jsxs("div",{children:[s.jsxs("div",{className:"section-label",children:["Request body",t.required?s.jsx("span",{style:{color:"var(--fail)"},children:" *"}):null]}),t.description&&s.jsx("div",{className:"muted",style:{marginBottom:6,fontSize:12.5},children:t.description}),t.media.map((a,r)=>s.jsxs("div",{style:{marginBottom:10},children:[s.jsx("span",{className:"pill mono",children:a.mediaType}),s.jsx("div",{style:{marginTop:6},children:a.schema!==void 0?s.jsx(Ls,{value:a.schema}):s.jsx("span",{className:"muted",children:"No schema."})})]},r))]})]})}function SO({responses:e}){return e.length===0?s.jsx(us,{children:"No documented responses."}):s.jsx("div",{className:"stack",style:{gap:12},children:e.map(t=>s.jsxs("div",{children:[s.jsxs("div",{className:"row",style:{gap:8,marginBottom:4},children:[s.jsx("span",{className:`tag ${NO(t.code)}`,children:t.code}),t.description&&s.jsx("span",{className:"muted",style:{fontSize:12.5},children:t.description})]}),t.media.length===0?s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"No body."}):t.media.map((n,a)=>s.jsxs("div",{style:{marginBottom:8},children:[s.jsx("span",{className:"pill mono",children:n.mediaType}),s.jsx("div",{style:{marginTop:6},children:n.schema!==void 0?s.jsx(Ls,{value:n.schema}):s.jsx("span",{className:"muted",children:"No schema."})})]},a))]},t.code))})}function NO(e){return/^2/.test(e)?"pass":/^3/.test(e)?"informational":/^(4|5)/.test(e)?"fail":"warn"}const kO=["get","post","put","patch","delete","options","head"];function EO(e){const t=e.paths??{},n=[];for(const[a,r]of Object.entries(t))for(const i of kO){const o=r[i];!o||typeof o!="object"||n.push({method:i,path:a,summary:o.summary,operation:o})}return n}function _O(e,t){const a=(e.paths??{})[t.path]??{};return[...Array.isArray(a.parameters)?a.parameters:[],...Array.isArray(t.operation.parameters)?t.operation.parameters:[]].map(i=>Ui(e,i)).filter(i=>i&&typeof i=="object")}function CO(e,t){const n=t.requestBody;if(!n)return null;const a=Ui(e,n);return{required:a.required,description:a.description,media:o_(e,a.content)}}function TO(e,t){const n=t.responses??{};return Object.entries(n).map(([a,r])=>{const i=Ui(e,r);return{code:a,description:i.description,media:o_(e,i.content)}}).sort((a,r)=>a.code.localeCompare(r.code))}function o_(e,t){return!t||typeof t!="object"?[]:Object.entries(t).map(([n,a])=>({mediaType:n,schema:(a==null?void 0:a.schema)!==void 0?Ui(e,a.schema):void 0}))}function Pi(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(n.example!==void 0)return n.example;if(n.default!==void 0)return n.default;if(Array.isArray(n.enum)&&n.enum.length)return n.enum[0];if(Array.isArray(n.allOf))return Object.assign({},...n.allOf.map(i=>Pi(i,t+1)).filter(i=>i&&typeof i=="object"));const a=n.oneOf??n.anyOf;if(Array.isArray(a)&&a.length)return Pi(a[0],t+1);switch(n.type??(n.properties?"object":void 0)){case"object":{const i=n.properties??{},o={};for(const[l,c]of Object.entries(i))o[l]=Pi(c,t+1);return o}case"array":{const i=Pi(n.items,t+1);return i===void 0?[]:[i]}case"string":{const i=n.format;return i==="date-time"?"1970-01-01T00:00:00Z":i==="date"?"1970-01-01":i==="uuid"?"00000000-0000-0000-0000-000000000000":i==="email"?"user@example.com":"string"}case"integer":case"number":return 0;case"boolean":return!1;case"null":return null;default:return null}}function RO(e,t){if(!t.startsWith("#/"))return;const n=t.slice(2).split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));let a=e;for(const r of n)if(a&&typeof a=="object"&&r in a)a=a[r];else return;return a}function Ui(e,t,n=new Set,a=0){if(a>8||t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(o=>Ui(e,o,n,a+1));const r=t;if(typeof r.$ref=="string"){const o=r.$ref;if(n.has(o))return{$ref:o};const l=RO(e,o);if(l===void 0)return t;const c=new Set(n);return c.add(o),Ui(e,l,c,a+1)}const i={};for(const[o,l]of Object.entries(r))i[o]=Ui(e,l,n,a+1);return i}const pf=e=>Object.fromEntries((e??[]).map(t=>[String(t.key??""),String(t.value??"")]));function IO(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(typeof t.raw=="string")return t.raw;const n=Array.isArray(t.host)?t.host.join("."):"",a=Array.isArray(t.path)?t.path.join("/"):"",r=t.protocol?`${t.protocol}://`:"",i=(t.query??[]).filter(o=>!o.disabled&&o.key).map(o=>`${o.key}=${o.value??""}`).join("&");return`${r}${n}${a?`/${a}`:""}${i?`?${i}`:""}`}return""}function AO(e){if(!e||typeof e!="object")return;const t=e;if(t.type==="bearer")return{mode:"bearer",token:pf(t.bearer).token??""};if(t.type==="basic"){const n=pf(t.basic);return{mode:"basic",username:n.username??"",password:n.password??""}}if(t.type==="apikey"){const n=pf(t.apikey);return{mode:"apikey",key:n.key??"",value:n.value??"",in:n.in==="query"?"query":"header"}}}function PO(e){if(!e||typeof e!="object")return;const t=e;if(t.mode==="raw")return typeof t.raw=="string"&&t.raw.trim()?t.raw:void 0;if(t.mode==="urlencoded")return(t.urlencoded??[]).filter(a=>!a.disabled&&a.key).map(a=>`${a.key}=${a.value??""}`).join("&")||void 0}function l_(e,t){var n;for(const a of e??[]){if(Array.isArray(a.item)){l_(a.item,t);continue}if(!a.request)continue;const r=a.request;t.push({name:((n=a.name)==null?void 0:n.trim())||`${(r.method??"GET").toUpperCase()} request`,method:(r.method??"GET").toUpperCase(),url:IO(r.url),headers:(r.header??[]).filter(i=>!i.disabled&&i.key).map(i=>({key:String(i.key),value:String(i.value??"")})),auth:AO(r.auth),body:PO(r.body)})}}function $O(e){var a,r;if(!e||typeof e!="object")throw new Error("That file isn't a Postman collection (expected a JSON object).");const t=e;if(!Array.isArray(t.item))throw new Error(`That file isn't a Postman collection (no "item" array). Export as Collection v2.1 from Postman.`);const n=[];if(l_(t.item,n),!n.length)throw new Error("No requests found in that collection.");return{name:((r=(a=t.info)==null?void 0:a.name)==null?void 0:r.trim())||"Imported collection",requests:n}}function OO(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Could not read that file — it isn't valid JSON.")}return $O(t)}const qw=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],LO=new Set(["POST","PUT","PATCH","DELETE"]);function mf(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function co(e){const t=e.indexOf("?");if(t<0)return{base:e,query:[]};const n=e.slice(t+1).split("&").filter(Boolean).map(a=>{const r=a.indexOf("=");return r<0?{key:mf(a),value:""}:{key:mf(a.slice(0,r)),value:mf(a.slice(r+1))}});return{base:e.slice(0,t),query:n}}function ff(e,t){const n=t.filter(a=>a.key.trim());return n.length?`${e}?${n.map(a=>`${encodeURIComponent(a.key)}=${encodeURIComponent(a.value)}`).join("&")}`:e}function MO(e,t){if(t.trim())return t.split(".").reduce((n,a)=>{const r=a.trim();if(n!=null){if(Array.isArray(n))return n[Number(r)];if(typeof n=="object")return n[r]}},e)}function DO(e,t){const n=t.body??"";switch(e.kind){case"status":return{label:`Status is ${e.n||"?"}`,pass:t.status===Number(e.n),detail:`got ${t.status??"—"}`};case"latency":return{label:`Response < ${e.n||"?"} ms`,pass:(t.latencyMs??1/0)<=Number(e.n),detail:`${t.latencyMs??"—"} ms`};case"json":{const a=ip(n)!==void 0;return{label:"Body is valid JSON",pass:a,detail:a?"parsed":"not JSON"}}case"contains":{const a=n.includes(e.text??"");return{label:`Body contains “${e.text??""}”`,pass:a&&!!e.text,detail:a?"found":"not found"}}case"path":{const a=MO(ip(n),e.path??"");return{label:`${e.path||"path"} = ${e.expected??""}`,pass:a!==void 0&&String(a)===(e.expected??""),detail:`got ${a===void 0?"—":JSON.stringify(a)}`}}}}function zO({notify:e}){const[t,n]=p.useState("GET"),[a,r]=p.useState("https://postman-echo.com/get"),[i,o]=p.useState(()=>{const ae=co("https://postman-echo.com/get").query;return ae.length?ae:[{key:"",value:""}]}),[l,c]=p.useState([{key:"",value:""}]),[u,d]=p.useState(`{
|
|
61
|
-
|
|
62
|
-
}`),[h,g]=p.useState("params"),[v,f]=p.useState([]),[y,b]=p.useState(null),[m,x]=p.useState("none"),[j,S]=p.useState(""),[w,C]=p.useState(""),[k,N]=p.useState(""),[L,_]=p.useState(""),[E,I]=p.useState(""),[$,W]=p.useState("header"),[R,H]=p.useState("body"),[Y,K]=p.useState(!1),[ce,F]=p.useState(null),[ie,ue]=p.useState(null),[oe,B]=p.useState(!1),[Q,X]=p.useState(null),[me,fe]=p.useState(null),P=p.useRef(null),T=LO.has(t),he=i.filter(ae=>ae.key.trim()).length,q=l.filter(ae=>ae.key.trim()).length,se=ae=>{r(ae);const Ce=co(ae).query;o(Ce.length?Ce:[{key:"",value:""}])},ge=(ae,Ce)=>{const He=i.map((qe,dt)=>dt===ae?{...qe,...Ce}:qe);o(He),r(ff(co(a).base,He))},de=()=>o(ae=>[...ae,{key:"",value:""}]),Ne=ae=>{const Ce=i.length===1?[{key:"",value:""}]:i.filter((He,qe)=>qe!==ae);o(Ce),r(ff(co(a).base,Ce))},Oe=async()=>{if(!a.trim()){e("Enter a URL first.");return}B(!0);try{const ae={};for(const ye of l)ye.key.trim()&&(ae[ye.key.trim()]=ye.value);let Ce=a.trim();const He=[];if(m==="bearer"){if(!j.trim()){e("Enter a bearer token.");return}ae.Authorization=`Bearer ${j.trim()}`,He.push("Authorization")}else if(m==="basic"){if(!w||!k){e("Enter both a Basic Auth username and password/access key.");return}ae.Authorization=`Basic ${btoa(`${w}:${k}`)}`,He.push("Authorization")}else if(m==="apikey"){if(!L.trim()){e("Enter the API key name.");return}$==="header"?(ae[L.trim()]=E,He.push(L.trim())):Ce=ff(co(Ce).base,[...co(Ce).query,{key:L.trim(),value:E}])}const qe=await O.httpRequest({method:t,url:Ce,headers:Object.keys(ae).length?ae:void 0,body:T&&u.trim()?u:void 0});F(qe),b(v.length?v.map(ye=>DO(ye,qe)):null);const dt={...ae};for(const ye of He)delete dt[ye];ue({method:t,url:a.trim(),headers:Object.keys(dt).length?dt:void 0,body:T&&u.trim()?u:void 0}),H("body")}catch(ae){e(ae instanceof Error?ae.message:String(ae))}finally{B(!1)}},_e=async()=>{if(!ce||!ce.ok||!ie)return;const ae=ip(ce.body);await O.httpSnapshot(ie,{status:ce.status??0,statusText:ce.statusText,body:ae!==void 0?ae:ce.body}),e(`Saved ${ie.method} request to Contracts`)},re=(ae,Ce)=>c(He=>He.map((qe,dt)=>dt===ae?{...qe,...Ce}:qe)),V=()=>c(ae=>[...ae,{key:"",value:""}]),le=ae=>c(Ce=>Ce.length===1?[{key:"",value:""}]:Ce.filter((He,qe)=>qe!==ae)),ee=()=>f(ae=>[...ae,{id:`t${Date.now()}${ae.length}`,kind:"status",n:"200"}]),xe=(ae,Ce)=>f(He=>He.map(qe=>qe.id===ae?{...qe,...Ce}:qe)),Fe=ae=>f(Ce=>Ce.filter(He=>He.id!==ae));function Be(ae){var Ce,He,qe;n(qw.includes(ae.method)?ae.method:"GET"),se(ae.url),c(ae.headers.length?ae.headers.map(dt=>({...dt})):[{key:"",value:""}]),d(ae.body??`{
|
|
63
|
-
|
|
64
|
-
}`),((Ce=ae.auth)==null?void 0:Ce.mode)==="bearer"?(x("bearer"),S(ae.auth.token)):((He=ae.auth)==null?void 0:He.mode)==="basic"?(x("basic"),C(ae.auth.username),N(ae.auth.password)):((qe=ae.auth)==null?void 0:qe.mode)==="apikey"?(x("apikey"),_(ae.auth.key),I(ae.auth.value),W(ae.auth.in)):x("none"),F(null),g(ae.body?"body":"params")}async function st(ae){var He;const Ce=(He=ae.target.files)==null?void 0:He[0];if(P.current&&(P.current.value=""),!!Ce){fe(null);try{const qe=OO(await Ce.text());X(qe),Be(qe.requests[0]),e(`Imported ${qe.requests.length} request${qe.requests.length===1?"":"s"} from “${qe.name}”`)}catch(qe){fe(qe instanceof Error?qe.message:"Import failed.")}}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:P,type:"file",accept:".json,application/json",onChange:st,style:{display:"none"}}),Q&&s.jsxs("div",{className:"row",style:{gap:8,marginBottom:10,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{className:"tag",style:{fontSize:11},children:"Postman"}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:Q.name}),s.jsx("select",{className:"field",style:{maxWidth:380},onChange:ae=>{const Ce=Q.requests[Number(ae.target.value)];Ce&&Be(Ce)},children:Q.requests.map((ae,Ce)=>s.jsxs("option",{value:Ce,children:[ae.method," — ",ae.name]},Ce))}),s.jsx("button",{className:"btn sm ghost",onClick:()=>X(null),children:"Clear"})]}),s.jsxs("div",{className:"wb-bar",children:[s.jsx("select",{className:"http-method",value:t,onChange:ae=>n(ae.target.value),"aria-label":"HTTP method",children:qw.map(ae=>s.jsx("option",{value:ae,children:ae},ae))}),s.jsx("input",{className:"http-url",value:a,onChange:ae=>se(ae.target.value),placeholder:"https://api.example.com/v1/resource",onKeyDown:ae=>ae.key==="Enter"&&Oe()}),s.jsx("button",{className:"wb-send",onClick:Oe,disabled:oe,style:{marginLeft:10},children:oe?"Sending…":"Send"}),s.jsx("button",{className:"btn",onClick:()=>{var ae;return(ae=P.current)==null?void 0:ae.click()},style:{marginLeft:8},title:"Import a Postman collection (v2.1 export)",children:"Import"}),s.jsx("button",{className:"btn",onClick:_e,disabled:!ce||!ce.ok,style:{marginLeft:8},title:"Capture this request + response as a runnable contract (see Contracts)",children:"Automate"})]}),me&&s.jsx("div",{style:{marginTop:8,color:"var(--fail)",fontSize:12.5},children:me}),s.jsxs("div",{className:"tabbar",children:[s.jsxs("button",{className:`tab ${h==="params"?"active":""}`,onClick:()=>g("params"),children:["Params ",he>0&&s.jsxs("span",{className:"muted",children:["(",he,")"]})]}),s.jsxs("button",{className:`tab ${h==="auth"?"active":""}`,onClick:()=>g("auth"),children:["Auth ",m!=="none"&&s.jsx("span",{className:"dot-badge",style:{background:"var(--accent)"},"aria-hidden":!0})]}),s.jsxs("button",{className:`tab ${h==="headers"?"active":""}`,onClick:()=>g("headers"),children:["Headers ",q>0&&s.jsxs("span",{className:"muted",children:["(",q,")"]})]}),s.jsx("button",{className:`tab ${h==="body"?"active":""}`,onClick:()=>g("body"),children:"Body"}),s.jsxs("button",{className:`tab ${h==="tests"?"active":""}`,onClick:()=>g("tests"),children:["Tests ",v.length>0&&s.jsxs("span",{className:"muted",children:["(",v.length,")"]})]})]}),h==="params"&&s.jsxs("div",{style:{marginBottom:8},children:[i.map((ae,Ce)=>s.jsxs("div",{className:"kv-row",children:[s.jsx("input",{className:"field",placeholder:"Key",value:ae.key,onChange:He=>ge(Ce,{key:He.target.value})}),s.jsx("input",{className:"field",placeholder:"Value",value:ae.value,onChange:He=>ge(Ce,{value:He.target.value})}),s.jsx("button",{className:"icon-btn",onClick:()=>Ne(Ce),"aria-label":"Remove param",children:"✕"})]},Ce)),s.jsx("button",{className:"btn sm ghost",onClick:de,children:"+ Add query param"})]}),h==="headers"&&s.jsxs("div",{style:{marginBottom:8},children:[l.map((ae,Ce)=>s.jsxs("div",{className:"kv-row",children:[s.jsx("input",{className:"field",placeholder:"Header",value:ae.key,onChange:He=>re(Ce,{key:He.target.value})}),s.jsx("input",{className:"field",placeholder:"Value",value:ae.value,onChange:He=>re(Ce,{value:He.target.value})}),s.jsx("button",{className:"icon-btn",onClick:()=>le(Ce),"aria-label":"Remove header",children:"✕"})]},Ce)),s.jsx("button",{className:"btn sm ghost",onClick:V,children:"+ Add header"})]}),h==="auth"&&s.jsxs("div",{style:{marginBottom:8,maxWidth:680},children:[s.jsxs("label",{className:"label",children:["Auth type",s.jsxs("select",{className:"field",value:m,onChange:ae=>x(ae.target.value),style:{marginTop:6},children:[s.jsx("option",{value:"none",children:"No Auth"}),s.jsx("option",{value:"bearer",children:"Bearer Token"}),s.jsx("option",{value:"basic",children:"Basic Auth"}),s.jsx("option",{value:"apikey",children:"API Key"})]})]}),m==="bearer"&&s.jsxs("label",{className:"label",style:{marginTop:12,display:"block"},children:["Token",s.jsx("input",{className:"field",type:"password",value:j,onChange:ae=>S(ae.target.value),placeholder:"eyJ… (sent as Authorization: Bearer …)",autoComplete:"off"})]}),m==="basic"&&s.jsxs("div",{className:"stack",style:{gap:10,marginTop:12},children:[s.jsxs("label",{className:"label",children:["Username",s.jsx("input",{className:"field",value:w,onChange:ae=>C(ae.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"label",children:["Password or access key",s.jsx("input",{className:"field",type:"password",value:k,onChange:ae=>N(ae.target.value),autoComplete:"current-password"})]})]}),m==="apikey"&&s.jsxs("div",{className:"stack",style:{gap:10,marginTop:12},children:[s.jsxs("label",{className:"label",children:["Key",s.jsx("input",{className:"field",value:L,onChange:ae=>_(ae.target.value),placeholder:"X-API-Key"})]}),s.jsxs("label",{className:"label",children:["Value",s.jsx("input",{className:"field",type:"password",value:E,onChange:ae=>I(ae.target.value),autoComplete:"off"})]}),s.jsxs("label",{className:"label",children:["Add to",s.jsxs("select",{className:"field",value:$,onChange:ae=>W(ae.target.value),style:{marginTop:6},children:[s.jsx("option",{value:"header",children:"Header"}),s.jsx("option",{value:"query",children:"Query param"})]})]})]}),m!=="none"&&s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:12},children:"Prooflane sends these credentials for this request only. They stay on this device and are never written into a saved contract."})]}),h==="body"&&s.jsxs("div",{style:{marginBottom:8},children:[s.jsx("textarea",{className:"field",value:u,onChange:ae=>d(ae.target.value),placeholder:"Request body (JSON or text)",style:{minHeight:120}}),!T&&s.jsxs("div",{className:"muted",style:{marginTop:6,fontSize:12},children:["Body is ignored for ",t," requests."]})]}),h==="tests"&&s.jsxs("div",{style:{marginBottom:8},children:[s.jsxs("div",{className:"muted",style:{fontSize:12,marginBottom:8},children:["Assertions checked against the response every time you Send — no scripting, just pick a check. (For a full committed test, use ",s.jsx("b",{children:"Automate"})," → Contracts.)"]}),v.map(ae=>s.jsxs("div",{className:"row",style:{gap:6,marginBottom:6,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("select",{className:"field",style:{maxWidth:190},value:ae.kind,onChange:Ce=>xe(ae.id,{kind:Ce.target.value}),children:[s.jsx("option",{value:"status",children:"Status code is"}),s.jsx("option",{value:"latency",children:"Response time < (ms)"}),s.jsx("option",{value:"json",children:"Body is valid JSON"}),s.jsx("option",{value:"contains",children:"Body contains"}),s.jsx("option",{value:"path",children:"JSON path equals"})]}),ae.kind==="status"&&s.jsx("input",{className:"field",style:{maxWidth:110},value:ae.n??"",onChange:Ce=>xe(ae.id,{n:Ce.target.value}),placeholder:"200",inputMode:"numeric"}),ae.kind==="latency"&&s.jsx("input",{className:"field",style:{maxWidth:110},value:ae.n??"",onChange:Ce=>xe(ae.id,{n:Ce.target.value}),placeholder:"500",inputMode:"numeric"}),ae.kind==="contains"&&s.jsx("input",{className:"field",value:ae.text??"",onChange:Ce=>xe(ae.id,{text:Ce.target.value}),placeholder:"text to find"}),ae.kind==="path"&&s.jsxs(s.Fragment,{children:[s.jsx("input",{className:"field",style:{maxWidth:200},value:ae.path??"",onChange:Ce=>xe(ae.id,{path:Ce.target.value}),placeholder:"data.0.id"}),s.jsx("span",{className:"muted",children:"="}),s.jsx("input",{className:"field",style:{maxWidth:150},value:ae.expected??"",onChange:Ce=>xe(ae.id,{expected:Ce.target.value}),placeholder:"expected"})]}),s.jsx("button",{className:"icon-btn",onClick:()=>Fe(ae.id),"aria-label":"Remove test",children:"✕"})]},ae.id)),s.jsx("button",{className:"btn sm ghost",onClick:ee,children:"+ Add test"})]}),ce&&s.jsx(UO,{res:ce,tab:R,setTab:H,rawBody:Y,setRawBody:K}),y&&y.length>0&&s.jsxs("div",{className:"card",style:{marginTop:12,padding:14},children:[s.jsxs("div",{className:"row spread",style:{marginBottom:8},children:[s.jsx("b",{style:{fontSize:13},children:"Tests"}),s.jsxs("span",{className:y.every(ae=>ae.pass)?"tag pass":"tag fail",style:{fontSize:11},children:[y.filter(ae=>ae.pass).length,"/",y.length," passed"]})]}),s.jsx("div",{className:"stack",style:{gap:5},children:y.map((ae,Ce)=>s.jsxs("div",{className:"row",style:{gap:8,fontSize:12.5,alignItems:"baseline"},children:[s.jsx("span",{className:ae.pass?"tag pass":"tag fail",style:{fontSize:10},children:ae.pass?"PASS":"FAIL"}),s.jsx("span",{children:ae.label}),s.jsx("span",{className:"muted mono",style:{fontSize:11.5},children:ae.detail})]},Ce))})]})]})}function UO({res:e,tab:t,setTab:n,rawBody:a,setRawBody:r}){const i=p.useMemo(()=>ip(e.body),[e.body]),o=Object.entries(e.headers??{});return s.jsxs("div",{className:"card",style:{marginTop:20},children:[s.jsxs("div",{className:"statusline",style:{marginBottom:14},children:[e.ok&&e.status!==void 0?s.jsxs("span",{className:`status-pill s${Math.floor(e.status/100)}`,children:[e.status," ",e.statusText]}):s.jsx("span",{className:"status-pill err",children:"Request failed"}),s.jsxs("span",{className:"metric",children:[e.latencyMs," ms"]}),e.body!==void 0&&s.jsx("span",{className:"metric",children:_v(e.body)}),e.contentType&&s.jsx("span",{className:"muted",children:e.contentType.split(";")[0]}),e.truncated&&s.jsx("span",{className:"tag warn",children:"truncated"})]}),e.ok?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"tabbar",children:[s.jsx("button",{className:`tab ${t==="body"?"active":""}`,onClick:()=>n("body"),children:"Body"}),s.jsxs("button",{className:`tab ${t==="headers"?"active":""}`,onClick:()=>n("headers"),children:["Headers ",s.jsxs("span",{className:"muted",children:["(",o.length,")"]})]}),s.jsx("span",{className:"spacer"}),t==="body"&&i!==void 0&&s.jsx("button",{className:"btn sm ghost",onClick:()=>r(!a),children:a?"Pretty":"Raw"})]}),t==="body"&&(e.body===""?s.jsx("div",{className:"muted",style:{padding:8},children:"(empty body)"}):i!==void 0&&!a?s.jsx(Vc,{value:i}):s.jsx(Vc,{value:e.body})),t==="headers"&&s.jsxs("table",{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"34%"},children:"Header"}),s.jsx("th",{children:"Value"})]})}),s.jsx("tbody",{children:o.map(([l,c])=>s.jsx(p.Fragment,{children:s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:l}),s.jsx("td",{className:"mono",style:{wordBreak:"break-all"},children:c})]})},l))})]})]}):s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"network"}),s.jsx("span",{children:e.error})]})})]})}function ip(e){if(e)try{return JSON.parse(e)}catch{return}}function FO({onSignedIn:e,provider:t="none",authError:n=null}){return t==="auth0"?s.jsx(WO,{authError:n}):s.jsx(HO,{onSignedIn:e})}function GO({email:e,onSignOut:t}){return s.jsx("div",{className:"auth-gate",children:s.jsxs("div",{className:"auth-card",children:[s.jsxs("div",{className:"brand",style:{marginBottom:18},children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"inspector"})]})]}),s.jsx("div",{className:"screen-title",style:{fontSize:20,marginBottom:7},children:"Verify your email to continue"}),s.jsxs("div",{className:"screen-sub",style:{marginBottom:18},children:["We sent a verification link to ",s.jsx("b",{children:e}),". Open the link, then sign in again to access Prooflane Inspector and Cloud Workspace."]}),s.jsx("div",{className:"card inset",style:{padding:13,fontSize:12.5,lineHeight:1.5},children:"Already verified? Sign out below, then sign in again so Auth0 can issue a fresh verified access token."}),s.jsx("button",{className:"btn primary",style:{width:"100%",justifyContent:"center",marginTop:16},onClick:t,children:"Sign out"})]})})}function WO({authError:e}){const[t,n]=p.useState(!1),a=async r=>{n(!0),await w2(r)};return s.jsx("div",{className:"auth-gate",children:s.jsxs("div",{className:"auth-card",children:[s.jsxs("div",{className:"brand",style:{marginBottom:18},children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"inspector"})]})]}),s.jsx("div",{className:"screen-title",style:{fontSize:20,marginBottom:4},children:"Sign in to continue"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:20},children:"AI System Assurance & Testing — create an account or sign in with your Prooflane email."}),e?s.jsxs("div",{className:"card inset",style:{padding:13,marginBottom:14,fontSize:12.5,lineHeight:1.5,color:"var(--fail)"},children:[s.jsx("b",{children:"Sign-in failed."})," ",e]}):null,s.jsx("button",{className:"btn primary",style:{width:"100%",justifyContent:"center",marginBottom:10},onClick:()=>a(!1),disabled:t,children:t?"Redirecting…":"Continue with email"}),s.jsx("button",{className:"btn ghost",style:{width:"100%",justifyContent:"center"},onClick:()=>a(!0),disabled:t,children:"Create an account"}),s.jsx("div",{className:"muted",style:{marginTop:14,fontSize:11.5,textAlign:"center"},children:"New account? Auth0 sends a verification email. Verify it, then sign in to unlock Prooflane Cloud Workspace."})]})})}function HO({onSignedIn:e}){const[t,n]=p.useState(""),[a,r]=p.useState(null),i=()=>{const o=t.trim();if(!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(o)){r("Enter a valid email address.");return}e(o)};return s.jsx("div",{className:"auth-gate",children:s.jsxs("div",{className:"auth-card",children:[s.jsxs("div",{className:"brand",style:{marginBottom:18},children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"inspector"})]})]}),s.jsx("div",{className:"screen-title",style:{fontSize:20,marginBottom:4},children:"Sign in to continue"}),s.jsxs("div",{className:"screen-sub",style:{marginBottom:20},children:["Inspector features require a Prooflane account. New here?"," ",s.jsx("a",{href:"https://prooflane.ai/",target:"_blank",rel:"noopener",children:"Create one at prooflane.ai"}),"."]}),s.jsx("label",{className:"label",children:"Work email"}),s.jsx("input",{className:"field",type:"email",value:t,onChange:o=>{n(o.target.value),r(null)},onKeyDown:o=>o.key==="Enter"&&i(),placeholder:"you@company.com",autoFocus:!0}),a&&s.jsx("div",{className:"muted",style:{color:"var(--fail)",marginTop:6,fontSize:12},children:a}),s.jsx("button",{className:"btn primary",style:{width:"100%",marginTop:16,justifyContent:"center"},onClick:i,children:"Continue"}),s.jsx("div",{className:"muted",style:{marginTop:14,fontSize:11.5,textAlign:"center"},children:"Local preview — no password stored. Sign-in unlocks this machine only."})]})})}const BO=["TRUE_POSITIVE","FALSE_POSITIVE","ACCEPTED_RISK","INVESTIGATING","FIXED","REGRESSION_CANDIDATE"],$v=e=>e==="PASS"||e==="COVERED"||e==="APPROVED"?"pass":e==="BLOCK"||e==="ERROR"||e==="FAILED"?"fail":"warn";function VO(){const[e,t]=p.useState(qE().runs),[n,a]=p.useState("all"),[r,i]=p.useState("history"),[o,l]=p.useState(""),[c,u]=p.useState(""),[d,h]=p.useState(""),[g,v]=p.useState("newest"),[f,y]=p.useState(!1),[b,m]=p.useState([]),[x,j]=p.useState(0),[S,w]=p.useState([]),[C,k]=p.useState([]),[N,L]=p.useState([]),[_,E]=p.useState([]),[I,$]=p.useState([]),[W,R]=p.useState(""),[H,Y]=p.useState(null),[K,ce]=p.useState(!1),[F,ie]=p.useState(""),ue=p.useMemo(()=>({...o.trim()?{text:o.trim()}:{},...n==="all"?{}:{pillars:[n]},...c?{statuses:[c]}:{},...d?{severities:[d]}:{},sort:g,semantic:f,limit:200}),[n,f,d,g,c,o]),oe=p.useCallback(async(T=ue)=>{ce(!0);try{const he=await O.assuranceHistory(T);m(he.result.records),j(he.result.total),ie("")}catch(he){ie(he instanceof Error?he.message:"Assurance History could not be loaded.")}finally{ce(!1)}},[ue]),B=p.useCallback(async()=>{const[T,he,q]=await Promise.allSettled([O.assuranceHistoryPatterns(),O.assuranceHistorySavedSearches(),O.assuranceHistoryPromotions()]);T.status==="fulfilled"&&w(T.value.patterns),he.status==="fulfilled"&&k(he.value.savedSearches),q.status==="fulfilled"&&L(q.value.promotions)},[]);p.useEffect(()=>{const T=KE(he=>t(he.runs));return Ds(),oe(),B(),T},[]);const Q=n==="all"?e:e.filter(T=>T.pillar===n),X=async()=>{if(W.trim()){ce(!0),Y(null);try{const T=await O.assuranceHistoryAsk(W.trim(),`history-ui-${crypto.randomUUID()}`),he=await O.assuranceHistoryJob(T.job.jobId);Y(he.job.answer??null),he.job.status==="FAILED"&&ie(he.job.failureClass??"History Intelligence could not complete the grounded search.")}catch(T){ie(T instanceof Error?T.message:"History Intelligence could not complete the request.")}finally{ce(!1)}}},me=async()=>{if(_.length===2){ce(!0);try{$((await O.assuranceHistoryCompare(_[0],_[1])).comparison.differences)}catch(T){ie(T instanceof Error?T.message:"The selected records could not be compared.")}finally{ce(!1)}}},fe=async()=>{const T=window.prompt("Name this authorized history search");if(T!=null&&T.trim())try{await O.assuranceHistorySaveSearch(T.trim(),ue),await B(),i("saved")}catch(he){ie(he instanceof Error?he.message:"The search could not be saved.")}},P=async T=>{try{await O.assuranceHistoryPromote(T.patternId,void 0,!0),await B(),i("regressions")}catch(he){ie(he instanceof Error?he.message:"The regression draft could not be created.")}};return s.jsxs("div",{className:"assurance-history",children:[s.jsxs("section",{className:"card history-ask-card",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"SAMMY ASSURANCE HISTORY"}),s.jsx("h2",{children:"Ask Sammy about assurance history"}),s.jsx("p",{children:"Answers are grounded only in authorized Run, Gate, report, and Spine projections. Historical text is treated as untrusted evidence."})]}),s.jsxs("div",{className:"history-ask-row",children:[s.jsx("input",{value:W,onChange:T=>R(T.target.value),onKeyDown:T=>{T.key==="Enter"&&X()},placeholder:"Which recurring security failures are not covered by regression?"}),s.jsx("button",{className:"btn primary",disabled:K||!W.trim(),onClick:()=>void X(),children:"Ask Sammy"})]}),H&&s.jsxs("div",{className:`history-answer ${H.status==="GROUNDED"?"grounded":"insufficient"}`,children:[s.jsxs("div",{children:[s.jsx("span",{className:`tag ${H.status==="GROUNDED"?"pass":"warn"}`,children:H.status.replaceAll("_"," ")}),s.jsxs("b",{children:[H.matchedRecordCount," authorized records"]}),s.jsxs("span",{children:[Math.round(H.confidence*100),"% confidence"]})]}),s.jsx("p",{children:H.summary}),H.supportingRecordReferences.length>0&&s.jsx("div",{className:"history-source-list",children:H.supportingRecordReferences.slice(0,12).map(T=>s.jsxs("span",{className:"mono",children:["Run ",T.runId,T.gateId?` · Gate ${T.gateId}`:"",T.reportId?` · Report ${T.reportId}`:""]},T.historyRecordId))}),H.limitations.map(T=>s.jsx("small",{children:T},T))]})]}),F&&s.jsxs("div",{className:"history-cloud-note",children:[s.jsx("b",{children:"Cloud history:"})," ",F," Local Inspector evidence remains available below."]}),s.jsx("div",{className:"tabbar history-main-tabs",children:["history","patterns","saved","regressions"].map(T=>s.jsx("button",{className:`tab ${r===T?"active":""}`,onClick:()=>i(T),children:T==="history"?"History":T==="patterns"?"Patterns":T==="saved"?"Saved Searches":"Regression Candidates"},T))}),r==="history"&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card history-filter-card",children:[s.jsx("input",{"aria-label":"Search assurance history",value:o,onChange:T=>l(T.target.value),placeholder:"Search safe summaries, finding classes, Runs, or Gates"}),s.jsxs("select",{"aria-label":"Pillar",value:n,onChange:T=>a(T.target.value),children:[s.jsx("option",{value:"all",children:"All pillars"}),["mcp","contract","prompt","rag","security","perf","model"].map(T=>s.jsx("option",{value:T,children:XE[T]},T))]}),s.jsxs("select",{"aria-label":"Status",value:c,onChange:T=>u(T.target.value),children:[s.jsx("option",{value:"",children:"All statuses"}),["PASS","REVIEW","BLOCK","ERROR","RUNNING"].map(T=>s.jsx("option",{children:T},T))]}),s.jsxs("select",{"aria-label":"Severity",value:d,onChange:T=>h(T.target.value),children:[s.jsx("option",{value:"",children:"All severities"}),["CRITICAL","HIGH","MEDIUM","LOW","INFO"].map(T=>s.jsx("option",{children:T},T))]}),s.jsx("select",{"aria-label":"Sort",value:g,onChange:T=>v(T.target.value),children:["newest","oldest","severity","frequency","relevance"].map(T=>s.jsx("option",{children:T},T))}),s.jsxs("label",{className:"history-semantic",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:T=>y(T.target.checked)})," Semantic (tenant opt-in)"]}),s.jsx("button",{className:"btn primary",disabled:K,onClick:()=>void oe(),children:K?"Searching…":"Search"}),s.jsx("button",{className:"btn ghost",onClick:()=>void fe(),children:"Save search"})]}),b.length>0&&s.jsxs("section",{className:"history-cloud-results",children:[s.jsxs("div",{className:"history-result-head",children:[s.jsxs("div",{children:[s.jsx("b",{children:"Governed history"}),s.jsxs("span",{children:[x," authorized projection records · index is rebuildable, never authoritative"]})]}),s.jsxs("button",{className:"btn ghost",disabled:_.length!==2||K,onClick:()=>void me(),children:["Compare selected (",_.length,"/2)"]})]}),b.map(T=>s.jsx(qO,{record:T,selected:_.includes(T.historyRecordId),onSelect:()=>E(he=>he.includes(T.historyRecordId)?he.filter(q=>q!==T.historyRecordId):he.length<2?[...he,T.historyRecordId]:[he[1],T.historyRecordId]),onAnnotate:async he=>{await O.assuranceHistoryAnnotate(T.historyRecordId,he,"Annotated from Assurance History"),await oe()}},T.historyRecordId))]}),I.length>0&&s.jsxs("section",{className:"card history-comparison",children:[s.jsx("div",{className:"eyebrow",children:"DETERMINISTIC COMPARISON"}),s.jsx("h3",{children:"Run / Gate differences"}),I.map(T=>s.jsxs("div",{children:[s.jsx("b",{children:T.field}),s.jsx("code",{children:String(T.left??"—")}),s.jsx("span",{children:"→"}),s.jsx("code",{children:String(T.right??"—")})]},T.field))]}),s.jsxs("section",{className:"history-local",children:[s.jsx("div",{className:"history-result-head",children:s.jsxs("div",{children:[s.jsx("b",{children:"Local Inspector evidence"}),s.jsx("span",{children:"Raw evidence remains local; these records continue to drive Deployment Assurance."})]})}),e.length?s.jsx(Tx,{runs:Q}):s.jsx(us,{children:"No runs yet. Run any Prompt, RAG, Contract, Security, Performance, Model, or governed Gate flow to create evidence."})]})]}),r==="patterns"&&s.jsx("section",{className:"history-grid",children:S.length?S.map(T=>s.jsxs("article",{className:"card history-pattern",children:[s.jsxs("div",{children:[s.jsx("span",{className:`tag ${$v(T.regressionCoverageState)}`,children:T.regressionCoverageState.replaceAll("_"," ")}),s.jsx("span",{className:"tag",children:T.promotionState.replaceAll("_"," ")})]}),s.jsx("h3",{children:T.findingClass}),s.jsxs("p",{children:[T.occurrenceCount," occurrences across ",T.affectedTargetCount," targets · ",Math.round(T.confidence*100),"% deterministic grouping confidence"]}),s.jsxs("small",{children:[new Date(T.firstSeenAt).toLocaleString()," → ",new Date(T.lastSeenAt).toLocaleString()]}),s.jsx("div",{className:"history-source-list",children:T.exampleRunIds.map(he=>s.jsxs("span",{className:"mono",children:["Run ",he]},he))}),s.jsx("button",{className:"btn primary",disabled:T.promotionState==="IN_PROGRESS"||T.regressionCoverageState==="COVERED",onClick:()=>void P(T),children:"Promote to Regression draft"})]},T.patternId)):s.jsx(us,{children:"No recurring BLOCK, REVIEW, or ERROR patterns are visible in your authorized scope."})}),r==="saved"&&s.jsx("section",{className:"history-grid",children:C.length?C.map(T=>s.jsxs("button",{className:"card history-saved",onClick:()=>{l(T.query.text??""),v(T.query.sort??"newest"),y(!!T.query.semantic),i("history"),oe(T.query)},children:[s.jsx("span",{className:"tag",children:T.shared?"TEAM SHARED":"PRIVATE"}),s.jsx("h3",{children:T.name}),s.jsx("code",{children:JSON.stringify(T.query)}),s.jsxs("small",{children:["Saved ",new Date(T.createdAt).toLocaleString()]})]},T.savedSearchId)):s.jsx(us,{children:"No saved searches yet. Build a deterministic History query and choose Save search."})}),r==="regressions"&&s.jsx("section",{className:"history-grid",children:N.length?N.map(T=>s.jsxs("article",{className:"card history-promotion",children:[s.jsxs("div",{children:[s.jsx("span",{className:`tag ${$v(T.state)}`,children:T.state}),T.draftedBy&&s.jsx("span",{className:"tag",children:"SAMMY DRAFT"}),T.humanDecision&&s.jsxs("span",{className:"tag",children:["HUMAN ",T.humanDecision]})]}),s.jsx("h3",{children:T.patternId}),s.jsxs("p",{className:"mono",children:["Source Run ",T.sourceRunId,T.sourceGateId?` · Gate ${T.sourceGateId}`:""]}),s.jsx("p",{children:"Creates a new DRAFT only. Human Review V2, Suite approval, Policy binding, and Gate governance are still required. Coverage changes only after an authoritative governed Run executes the approved Suite."}),T.generationId&&s.jsxs("span",{className:"mono",children:["Generation ",T.generationId]}),T.approvedSuiteId&&s.jsxs("span",{className:"mono",children:["Approved Suite ",T.approvedSuiteId,"@",T.approvedSuiteVersion]}),T.governedRunId&&s.jsxs("span",{className:"mono",children:["Governed execution ",T.governedRunId]}),T.state==="IN_PROGRESS"&&s.jsx("button",{className:"btn ghost",onClick:async()=>{try{await O.assuranceHistoryCancelPromotion(T.promotionId),await B()}catch(he){ie(he instanceof Error?he.message:"Promotion cancellation failed.")}},children:"Cancel promotion"}),s.jsx("small",{children:new Date(T.createdAt).toLocaleString()})]},T.promotionId)):s.jsx(us,{children:"No regression promotions yet. Select an uncovered recurring Pattern to create a governed DRAFT candidate."})})]})}function qO({record:e,selected:t,onSelect:n,onAnnotate:a}){return s.jsxs("article",{className:`card history-record ${t?"selected":""}`,children:[s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:t,onChange:n}),s.jsx("span",{className:`tag ${$v(e.resultStatus)}`,children:e.resultStatus}),s.jsx("span",{className:"tag",children:e.severity}),s.jsx("b",{children:e.findingClass})]}),s.jsx("p",{children:e.redactedSummary}),s.jsxs("div",{className:"history-record-meta",children:[s.jsx("span",{children:e.pillar}),s.jsx("span",{children:e.targetType}),s.jsx("span",{children:e.environment}),s.jsx("span",{children:e.durationBucket}),s.jsx("span",{children:e.regressionCoverageState.replaceAll("_"," ")})]}),s.jsxs("div",{className:"history-record-sources",children:[s.jsxs("span",{className:"mono",children:["Run ",e.runId]}),e.gateId&&s.jsxs("span",{className:"mono",children:["Gate ",e.gateId]}),e.reportId&&s.jsxs("span",{className:"mono",children:["Report ",e.reportId]}),e.spineReportId&&s.jsxs("span",{className:"mono",children:["Spine ",e.spineReportId]}),s.jsx("time",{children:new Date(e.createdAt).toLocaleString()})]}),s.jsxs("select",{"aria-label":`Annotate ${e.runId}`,value:e.humanDisposition??"",onChange:r=>{r.target.value&&a(r.target.value)},children:[s.jsx("option",{value:"",children:"Annotate…"}),BO.map(r=>s.jsx("option",{value:r,children:r.replaceAll("_"," ")},r))]})]})}const c_={mcp:"MCP",contract:"Contract",prompt:"Prompt",perf:"Perf",security:"Runtime Security",rag:"RAG",model:"Model Security"};function KO({caps:e,connected:t,onNavigate:n}){const[a,r]=p.useState(qE),{runs:i,source:o,syncedAt:l}=a,[c,u]=p.useState(rp()),[d,h]=p.useState(xx()),g=RE(c,d);p.useEffect(()=>{const $=KE(r);Ds().catch(()=>{});const W=window.setInterval(()=>{Ds().catch(()=>{})},15e3);return()=>{window.clearInterval(W),$()}},[]),p.useEffect(()=>{const $=()=>u(rp());return window.addEventListener("kawach:policies",$),()=>window.removeEventListener("kawach:policies",$)},[]);const v=i.slice(0,24).reverse(),f=[...new Set(i.map($=>$.model).filter(Boolean))],y=["security","model","rag","mcp","contract","prompt","perf"].map($=>({p:$,list:i.filter(W=>W.pillar===$)})).filter($=>$.list.length>0).map($=>{const W=$.list[0],R=lL(W),H=$.p==="security"?[`${W.fail} breached`,W.drift?`${W.drift} exposed`:"",W.poisoned?`${W.poisoned} poisoned`:""].filter(Boolean).join(" · "):$.p==="model"?`${W.fail} blocking · ${W.pass} verified`:$.p==="rag"?`${W.drift} drift · ${W.fail} failing`:W.fail>0?`${W.fail} failing`:"clean";return{p:$.p,label:c_[$.p],count:$.list.length,score:R,status:H,finding:W.finding}}),b=i.length>0,m=i.filter($=>$.pillar==="perf"),x=m[0]??null,j=cL(x),S=o==="cloud",w=S?"cloud-synced":"local data",C=S?"cloud":"local",k=S?`Release decision based on cloud-synced, sanitized evidence${l?` · last sync ${Kp(l)}`:""} and the active release policy.`:"Release decision based on captured local runs and the active release policy.",N=S?"cloud-synced":"captured",L=i.find($=>{var W;return(W=$.governance)==null?void 0:W.gate}),_=L==null?void 0:L.governance,E=_?_.finalDecision??_.automatedDecision??_.status:null,I=E==="READY"?"pass":E==="BLOCK"||E==="EXECUTION_ERROR"?"fail":"warn";return s.jsxs("div",{className:"stack",style:{gap:22},children:[s.jsxs("div",{className:"row spread",children:[s.jsx("div",{className:"row",style:{gap:8,alignItems:"center"},children:s.jsx("span",{className:"muted",style:{fontSize:12.5},children:k})}),s.jsx("span",{className:"muted",style:{fontSize:12,textTransform:"uppercase",letterSpacing:"0.5px"},children:s.jsx("span",{className:`tag ${S?"pass":"informational"}`,children:w})})]}),L&&(_==null?void 0:_.gate)&&E&&s.jsx("div",{className:"card",style:{padding:"16px 18px"},children:s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap",alignItems:"flex-start"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"AUTHORITATIVE GATE DECISION"}),s.jsxs("div",{style:{fontWeight:750,marginTop:4},children:["Gate ",_.gate.slug,"@",_.gate.version]}),s.jsxs("div",{className:"mono muted",style:{fontSize:11,marginTop:6},children:["Run ",_.runId," · Suite ",_.suite.slug,"@",_.suite.version," · Policy v",_.policy.version]}),s.jsx("div",{className:"muted",style:{fontSize:11.5,marginTop:7},children:"Immutable verdict from the exact signed Gate run. The release-readiness card below remains a current local-policy projection and does not replace this pinned decision."})]}),s.jsxs("div",{className:"stack",style:{gap:6,alignItems:"flex-end"},children:[s.jsx("span",{className:`tag ${I}`,children:E}),s.jsxs("span",{className:"mono muted",style:{fontSize:10.5},children:[_.status," · ",_.runnerType.replaceAll("_"," ")]})]})]})}),b&&s.jsx(ZO,{runs:i,policy:g,policies:c,setPolicy:$=>{TE($),h($)},onNavigate:n}),y.length>0&&s.jsx(xh,{title:"Pillars",tag:C,sub:`Latest ${N} assurance score for each pillar.`,children:s.jsx(aL,{pillars:y})}),s.jsx(xh,{title:"Performance (load)",tag:C,sub:`Latest ${N} load test — p50/p95/p99, throughput, and SLO pass rate.`,children:j?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{marginBottom:12,flexWrap:"wrap",gap:8,alignItems:"baseline"},children:[s.jsxs("span",{className:"muted mono",style:{fontSize:12},children:[x.label,x?` · ${new Date(x.createdAt).toLocaleString()}`:""]}),s.jsxs("span",{className:`tag ${j.pctUnder>=95?"pass":j.pctUnder>=80?"warn":"fail"}`,children:["SLO ",j.pctUnder>=95?"pass":j.pctUnder>=80?"at risk":"fail"," · ",j.pctUnder,"% under ",j.targetMs,"ms · ",j.vus," VUs"]})]}),s.jsxs("div",{className:"tiles",children:[s.jsx(uo,{name:"p50 latency",value:yf(j.p50),label:"median",tone:"info"}),s.jsx(uo,{name:"p95 latency",value:yf(j.p95),label:`target ${j.targetMs}ms`,tone:j.p95<=j.targetMs?"pass":"warn"}),s.jsx(uo,{name:"p99 latency",value:yf(j.p99),label:"tail",tone:"info"}),s.jsx(uo,{name:"Throughput",value:`${j.rps}/s`,label:`${j.requests.toLocaleString()} requests`,tone:"info"}),s.jsx(uo,{name:"Error rate",value:`${j.errorRate}%`,label:"non-2xx / failed",tone:j.errorRate>0?"fail":"pass"}),s.jsx(uo,{name:"Virtual users",value:String(j.vus),label:`${j.durationS}s · ${S?"cloud-synced":"local"}`,tone:"info"})]})]}):s.jsx("div",{className:"card muted",children:m.length>0?s.jsxs(s.Fragment,{children:["Re-run a load test on the ",s.jsx("b",{children:"Performance"})," screen to populate the full metrics — earlier runs predate detailed capture."]}):s.jsxs(s.Fragment,{children:["No load tests recorded yet. Run one on the ",s.jsx("b",{children:"Performance"})," screen to populate this — p50/p95/p99, throughput, error rate, and SLO pass rate land here."]})})}),s.jsx(nL,{runs:i}),s.jsx(xh,{title:"Regression history",tag:C,sub:`${S?"Cloud-synced":"Captured"} runs, newest on the right.`,children:s.jsx("div",{className:"card",children:b?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"row",style:{gap:3,flexWrap:"wrap",marginBottom:14},children:v.map(($,W)=>{const R=oL($);return s.jsx("span",{title:`${$.label} · ${R}`,style:{width:12,height:18,borderRadius:2,background:`var(--${R==="error"?"warn":R})`}},W)})}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{className:"muted",style:{fontSize:12},children:"Models used:"}),f.length?f.map($=>s.jsx("span",{className:"pill mono",style:{fontSize:11.5},children:$},$)):s.jsx("span",{className:"muted",style:{fontSize:12},children:"none recorded"})]})]}):s.jsx("div",{className:"muted",children:"No run history yet."})})})]})}const JO=e=>e==null?"info":e>=90?"pass":e>=75?"warn":"fail",Kp=e=>{try{return new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return e}},YO=e=>e>=90?"Very high":e>=70?"High":e>=45?"Medium":"Low";function ZO({runs:e,policy:t,policies:n,setPolicy:a,onNavigate:r}){const i=O2(e,t),o=i.verdict==="pass"?"pass":i.verdict==="review"?"warn":i.verdict==="blocked"?"fail":"info",l=i.verdict==="blocked"?{icon:"🚫",label:"BLOCKED"}:i.verdict==="review"?{icon:"⚠️",label:"REVIEW"}:i.verdict==="pass"?{icon:"✅",label:"PASS"}:{icon:"—",label:"NEEDS EVIDENCE"};return s.jsxs("div",{className:"stack",style:{gap:14},children:[s.jsxs("div",{className:"card",style:{padding:0,borderColor:`var(--${o})`,overflow:"hidden"},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",flexWrap:"wrap",gap:16,padding:"18px 20px",background:`color-mix(in srgb, var(--${o}) 9%, transparent)`},children:[s.jsxs("div",{className:"row",style:{gap:16,alignItems:"center"},children:[s.jsx("span",{style:{fontSize:34,lineHeight:1},children:l.icon}),s.jsxs("div",{className:"stack",style:{gap:4},children:[s.jsx(jo,{label:"RELEASE READINESS",help:"The final release decision. Prooflane applies the selected policy's weighted score and non-negotiable hard gates to the latest evidence from each pillar.",compact:!0}),s.jsx("span",{style:{fontSize:23,fontWeight:700,letterSpacing:"0.3px",color:`var(--${o})`},children:l.label}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:i.reason?s.jsxs(s.Fragment,{children:["Reason · ",s.jsx("b",{style:{color:"var(--fail)"},children:i.reason})]}):i.verdict==="pass"?"All policy thresholds pass — ready to ship.":i.verdict==="review"?`Weighted score is below the ${t.passAt} release bar.`:"Run the pillars to produce a verdict."})]})]}),s.jsxs("div",{className:"stack",style:{gap:3,alignItems:"flex-end"},children:[s.jsx("select",{className:"field",style:{width:"auto",fontSize:12,padding:"4px 8px"},value:t.id,onChange:c=>a(c.target.value),children:n.map(c=>s.jsxs("option",{value:c.id,children:[c.name," policy"]},c.id))}),s.jsxs("span",{className:"muted mono",style:{fontSize:10},children:["PASS ≥",t.passAt," · REVIEW ≥",t.reviewAt]})]})]}),s.jsxs("div",{className:"row",style:{gap:26,flexWrap:"wrap",padding:"11px 20px",borderTop:"1px solid var(--border)"},children:[s.jsx(Tu,{label:"To ship",help:"Hard blockers must be resolved before this policy can return a passing release verdict.",children:s.jsx("span",{className:`tag ${i.verdict==="pass"?"pass":i.blockers.length?"fail":"warn"}`,children:i.blockers.length?`Fix ${i.blockers.length} blocker${i.blockers.length===1?"":"s"}`:i.verdict==="review"?"Review weighted score":"Ready to ship"})}),s.jsx(Tu,{label:"Optional",help:"Warnings do not block release, but they identify risk or incomplete evidence worth reviewing.",children:s.jsx("span",{className:`tag ${i.warnings.length?"warn":"pass"}`,children:i.warnings.length?`${i.warnings.length} warning${i.warnings.length===1?"":"s"}`:"No warnings"})}),s.jsx(Tu,{label:"Estimated effort",help:"A directional estimate based on the active findings. It is not a prediction of engineering time.",children:i.estFixMinutes?`~${i.estFixMinutes} min`:"—"}),s.jsx(Tu,{label:"Auto-fix",help:"Prooflane explains the evidence and the recommended next step; changes to your system always remain under your control.",children:s.jsx("span",{className:"muted",children:"Manual review"})})]})]}),s.jsx(XO,{pillars:i.pillars,modelSecurity:i.modelSecurity}),s.jsxs("div",{className:"card",style:{padding:16},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",marginBottom:10},children:[s.jsx(jo,{label:"Change since last green",help:"Compares the latest score in each assurance pillar with the most recent deployment state that passed this policy."}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:i.lastGreen?`last green · ${Kp(i.lastGreen.at)}`:"no green baseline yet"})]}),i.lastGreen?s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:i.pillars.map(c=>s.jsx(QO,{label:Sl[c.bucket],delta:c.delta},c.bucket))}):s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"This is the first tracked deployment state. After your next green run, this card shows exactly which dimensions moved."})]}),i.blockers.length>0&&s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsx(gf,{tone:"fail",label:`Blockers · must fix (${i.blockers.length})`,help:"These findings violate a hard gate in the selected release policy and prevent a passing decision."}),i.blockers.map((c,u)=>s.jsx(tL,{issue:c,onNavigate:r},u))]}),(i.warnings.length>0||i.observations.length>0)&&s.jsxs("div",{className:"row",style:{gap:14,flexWrap:"wrap",alignItems:"flex-start"},children:[i.warnings.length>0&&s.jsxs("div",{className:"card",style:{padding:14,flex:"1 1 260px",minWidth:240},children:[s.jsx(gf,{tone:"warn",label:`Warnings (${i.warnings.length})`,help:"Warnings do not block this release, but should be reviewed before shipping."}),s.jsx("div",{className:"stack",style:{gap:9,marginTop:8},children:i.warnings.map((c,u)=>s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"flex-start"},children:[s.jsxs("span",{style:{fontSize:12.5},children:["⚠ ",c.title]}),c.jumpTo&&r&&s.jsx("button",{className:"btn sm ghost",onClick:()=>r(c.jumpTo),children:c.jumpLabel??"Open"})]},u))})]}),i.observations.length>0&&s.jsxs("div",{className:"card",style:{padding:14,flex:"1 1 260px",minWidth:240},children:[s.jsx(gf,{tone:"info",label:`Safe to ignore (${i.observations.length})`,help:"Informational observations that do not affect the current release decision."}),s.jsx("div",{className:"stack",style:{gap:6,marginTop:8},children:i.observations.map((c,u)=>s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["✓ ",c.title]},u))})]})]}),s.jsxs("div",{className:"card",style:{padding:16},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",marginBottom:12},children:[s.jsx(jo,{label:"Dimension scores",help:"The latest score for each pillar. Bar width shows score; the percentage is the pillar's weight in the selected release policy."}),s.jsx("span",{className:"muted mono",style:{fontSize:10.5},children:"bar width = score · % = risk weight"})]}),s.jsx("div",{className:"stack",style:{gap:11},children:i.pillars.map(c=>s.jsx(eL,{p:c},c.bucket))})]}),s.jsxs("div",{className:"row",style:{gap:14,flexWrap:"wrap",alignItems:"stretch"},children:[s.jsxs("div",{className:"card",style:{padding:16,flex:"1 1 320px",minWidth:280},children:[s.jsx(jo,{label:"Evidence & coverage",help:"Shows how much recent, graded evidence supports the decision. More covered pillars and graded results increase confidence."}),s.jsxs("div",{className:"tiles",style:{marginTop:12,gridTemplateColumns:"repeat(2, 1fr)"},children:[s.jsx(Ru,{name:"Verdict confidence",value:YO(i.confidence),label:"based on available evidence",tone:i.confidence>=75?"pass":i.confidence>=50?"warn":"info"}),s.jsx(Ru,{name:"Coverage",value:`${i.evidence.runs}/5`,label:"assurance pillars",tone:i.coverage>=.8?"pass":i.coverage>=.5?"warn":"fail"}),s.jsx(Ru,{name:"Policy",value:i.policyPass?"PASS":"FAILED",label:"hard gates",tone:i.policyPass?"pass":"fail"}),s.jsx(Ru,{name:"Evidence",value:i.evidence.level,label:`${i.evidence.graded} graded results`,tone:i.evidence.level==="High"?"pass":i.evidence.level==="Medium"?"warn":"info"})]})]}),s.jsxs("div",{className:"card",style:{padding:16,flex:"1 1 320px",minWidth:280},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline"},children:[s.jsx(jo,{label:"Risk timeline",help:"A compact view of the last deployment decisions. Each bar represents the policy score and verdict recorded at that point in time."}),s.jsxs("span",{className:"muted",style:{fontSize:11},children:["last ",i.timeline.length," deployments"]})]}),s.jsx(sL,{snaps:i.timeline})]})]})]})}function Rx({help:e}){return s.jsx("button",{type:"button",title:e,"aria-label":e,style:{border:0,padding:0,margin:0,width:15,height:15,borderRadius:"50%",background:"var(--border)",color:"var(--muted)",fontSize:10,fontWeight:800,lineHeight:"15px",cursor:"help"},children:"i"})}function jo({label:e,help:t,compact:n=!1}){return s.jsxs("span",{className:"row",style:{gap:6,fontSize:n?10.5:13,fontWeight:700,letterSpacing:n?"0.65px":void 0,color:n?"var(--muted)":void 0},children:[e,s.jsx(Rx,{help:t})]})}function Tu({label:e,help:t,children:n}){return s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsxs("span",{className:"row muted",style:{gap:4,fontSize:9.5,textTransform:"uppercase",letterSpacing:"0.5px"},children:[e,t&&s.jsx(Rx,{help:t})]}),s.jsx("div",{className:"row",style:{gap:0,alignItems:"center",minHeight:22},children:n})]})}function XO({pillars:e,modelSecurity:t}){const n=a=>!a.run||a.score==null?{icon:"—",label:"Not run",tone:"info"}:a.bucket==="contracts"&&a.run.fail>0||a.bucket==="perf"&&(a.run.fail>0||a.run.error>0)||a.bucket==="security"&&a.run.fail>0&&(a.run.severity==="critical"||a.run.severity==="high")?{icon:"✕",label:"Blocked",tone:"fail"}:a.run.fail>0||a.run.drift>0||a.score<90?{icon:"⚠",label:"Warning",tone:"warn"}:{icon:"✓",label:"Ready",tone:"pass"};return s.jsxs("div",{className:"card",style:{padding:16},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",marginBottom:12},children:[s.jsx(jo,{label:"Release checks",help:"One latest result per assurance pillar. A hard failure can block the release even when the weighted score is high."}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Every row is supporting evidence for the decision above."})]}),s.jsxs("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))"},children:[e.map(a=>{const r=n(a);return s.jsxs("div",{className:"stack",style:{gap:3,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:8,background:`color-mix(in srgb, var(--${r.tone}) 7%, transparent)`},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:4},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:Sl[a.bucket]}),s.jsx("span",{style:{color:`var(--${r.tone})`,fontWeight:800},children:r.icon})]}),s.jsx("span",{style:{fontSize:12,color:`var(--${r.tone})`},children:r.label}),s.jsx("span",{className:"muted mono",style:{fontSize:10.5},children:a.score==null?"No evidence":`${a.score} score`})]},a.bucket)}),(()=>{const a=t==null?"info":t.status==="blocked"?"fail":t.status==="warning"?"warn":"pass",r=t==null?"—":t.status==="blocked"?"✕":t.status==="warning"?"⚠":"✓",i=t==null?"Not run":t.status==="blocked"?"Blocked":t.status==="warning"?"Warning":"Ready";return s.jsxs("div",{className:"stack",style:{gap:3,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:8,background:`color-mix(in srgb, var(--${a}) 7%, transparent)`},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:4},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:"Model Security"}),s.jsx("span",{style:{color:`var(--${a})`,fontWeight:800},children:r})]}),s.jsx("span",{style:{fontSize:12,color:`var(--${a})`},children:i}),s.jsx("span",{className:"muted mono",style:{fontSize:10.5},children:(t==null?void 0:t.score)==null?"No evidence":`${t.score} score`})]})})()]})]})}function gf({tone:e,label:t,help:n}){return s.jsxs("span",{className:"row",style:{gap:6,fontSize:10.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",color:`var(--${e})`},children:[t,n&&s.jsx(Rx,{help:n})]})}function Ru({name:e,value:t,label:n,tone:a}){return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:9.5,textTransform:"uppercase",letterSpacing:"0.5px"},children:e}),s.jsx("span",{className:"mono",style:{fontSize:21,fontWeight:700,lineHeight:1,color:`var(--${a})`},children:t}),s.jsx("span",{className:"muted",style:{fontSize:11},children:n})]})}function QO({label:e,delta:t}){const n=t==null?"info":t<0?"fail":t>0?"pass":"info",a=t==null?"·":t<0?"✗":(t>0,"✓"),r=t==null?"n/a":t===0?"unchanged":`${t>0?"+":""}${t}`;return s.jsxs("span",{className:"row",style:{gap:6,alignItems:"center",fontSize:12,padding:"4px 9px",borderRadius:7,border:"1px solid var(--border)",background:`color-mix(in srgb, var(--${n}) 8%, transparent)`},children:[s.jsx("span",{style:{color:`var(--${n})`,fontWeight:700},children:a}),s.jsx("span",{style:{fontWeight:600},children:e}),s.jsx("span",{className:"mono",style:{color:`var(--${n})`},children:r})]})}function eL({p:e}){const t=e.score==null?0:Math.round(e.score/10),n=JO(e.score);return s.jsxs("div",{className:"row",style:{gap:12,alignItems:"center"},children:[s.jsxs("span",{className:"muted",style:{fontSize:11.5,width:92,flexShrink:0},children:[Sl[e.bucket]," ",s.jsxs("span",{style:{opacity:.55},children:["· ",Math.round(e.weight*100),"%"]})]}),s.jsx("div",{className:"row",style:{gap:3,flex:1},children:Array.from({length:10}).map((a,r)=>s.jsx("div",{style:{height:10,flex:1,borderRadius:2,background:r<t?`var(--${n})`:"var(--border-2, var(--border))",opacity:r<t?1:.5}},r))}),s.jsx("span",{className:"mono",style:{fontSize:14,width:30,textAlign:"right",color:e.score==null?"var(--faint)":`var(--${n})`},children:e.score??"—"}),s.jsx("span",{className:"mono",style:{fontSize:11,width:40,textAlign:"right",color:e.delta==null||e.delta===0?"var(--faint)":e.delta<0?"var(--fail)":"var(--pass)"},children:e.delta==null||e.delta===0?"":`${e.delta<0?"▼":"▲"}${Math.abs(e.delta)}`})]})}function tL({issue:e,onNavigate:t}){return s.jsxs("div",{className:"card",style:{padding:0,borderColor:"var(--fail)",overflow:"hidden"},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",padding:"10px 14px",background:"color-mix(in srgb, var(--fail) 10%, transparent)"},children:[s.jsxs("span",{className:"row",style:{gap:8,alignItems:"center",fontSize:13.5,fontWeight:700},children:[s.jsx("span",{children:"❌"}),e.title]}),e.jumpTo&&t&&s.jsxs("button",{className:"btn sm primary",onClick:()=>t(e.jumpTo),children:[e.jumpLabel??"Open"," →"]})]}),s.jsxs("div",{className:"stack",style:{gap:8,padding:"12px 14px"},children:[s.jsx(vf,{label:"Why",text:e.why}),s.jsx(vf,{label:"Impact",text:e.impact}),s.jsx(vf,{label:"Fix",text:e.fix})]})]})}function vf({label:e,text:t}){return s.jsxs("div",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[s.jsx("span",{className:"muted",style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.5px",width:52,flexShrink:0,paddingTop:2},children:e}),s.jsx("span",{style:{fontSize:12.5,lineHeight:1.45},children:t})]})}function sL({snaps:e}){if(!e.length)return s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:10},children:"No history yet."});const t=n=>n==="blocked"?"fail":n==="pass"?"pass":n==="review"?"warn":"info";return s.jsx("div",{className:"row",style:{gap:5,alignItems:"flex-end",height:56,marginTop:12},children:e.map((n,a)=>{const r=n.overall==null?4:Math.max(6,Math.round(n.overall/100*52)),i=a===e.length-1;return s.jsxs("div",{className:"stack",style:{gap:3,alignItems:"center",flex:1},title:`${n.overall??"—"} · ${n.verdict} · ${Kp(n.at)}`,children:[s.jsx("span",{className:"mono",style:{fontSize:9,color:`var(--${t(n.verdict)})`,opacity:i?1:.7},children:n.overall??"—"}),s.jsx("div",{style:{width:"100%",height:r,borderRadius:3,background:`var(--${t(n.verdict)})`,opacity:i?1:.55,outline:i?`1px solid var(--${t(n.verdict)})`:"none"}})]},a)})})}function xh({title:e,tag:t,sub:n,children:a}){return s.jsxs("section",{children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",marginBottom:12,flexWrap:"wrap"},children:[s.jsx("div",{className:"detail-title",style:{fontSize:15},children:e}),t==="local"&&s.jsx("span",{className:"tag informational",children:"local data"}),t==="cloud"&&s.jsx("span",{className:"tag pass",children:"cloud-synced"}),t==="sample"&&s.jsx("span",{className:"tag informational",children:"sample"}),n&&s.jsx("span",{className:"muted",style:{fontSize:12.5},children:n})]}),a]})}function nL({runs:e}){const[t,n]=p.useState(null),a=["prompt","rag","security","mcp","contract","perf"].map(f=>{const y=e.filter(b=>b.pillar===f&&(b.tokens??0)>0);return{pillar:f,label:c_[f],entries:y,total:y.reduce((b,m)=>b+(m.tokens??0),0),input:y.reduce((b,m)=>b+(m.inputTokens??0),0),output:y.reduce((b,m)=>b+(m.outputTokens??0),0)}}).filter(f=>f.entries.length>0),r=a.find(f=>f.pillar===t)??null,i=a.reduce((f,y)=>f+y.total,0),o=a.reduce((f,y)=>f+y.input,0),l=a.reduce((f,y)=>f+y.output,0),c=e.filter(f=>(f.tokens??0)>0),u=c[0]??null,d=c[1]??null,h=u&&d?(u.tokens??0)-(d.tokens??0):null,g=h!=null&&((d==null?void 0:d.tokens)??0)>0?Math.round(h/(d.tokens??1)*100):null,v=g!=null&&Math.abs(g)>=20;return s.jsx(xh,{title:"Token usage",tag:"local",sub:"Recorded tokens by assurance pillar — select a category to inspect its runs.",children:a.length===0?s.jsx("div",{className:"card muted",children:"No token usage has been recorded yet. AI prompt generation, RAG, and Security runs record total tokens when available."}):s.jsxs("div",{className:"stack",style:{gap:12},children:[s.jsxs("div",{className:"card token-summary",children:[s.jsxs("div",{className:"token-comparison",children:[s.jsx(Iu,{name:"Current · total",value:In((u==null?void 0:u.tokens)??0),note:u?u.label:"No current token run",tone:"info"}),s.jsx(Iu,{name:"Current · input",value:(u==null?void 0:u.inputTokens)!=null?In(u.inputTokens):"—",note:(u==null?void 0:u.inputTokens)!=null?"Prompt and context":"Split unavailable for this run",tone:"info"}),s.jsx(Iu,{name:"Current · output",value:(u==null?void 0:u.outputTokens)!=null?In(u.outputTokens):"—",note:(u==null?void 0:u.outputTokens)!=null?"Generated completion":"Split unavailable for this run",tone:"info"}),s.jsx(Iu,{name:"Total change",value:h==null?"—":`${h>=0?"+":"−"}${In(Math.abs(h))}`,note:g==null?"Run another check to compare":`${g>=0?"+":""}${g}% vs previous${v?" · token drift":" · within range"}`,tone:h==null?"info":v?"warn":"pass"})]}),s.jsxs("div",{className:"token-pillar-row",children:[s.jsxs("span",{className:"muted",style:{fontSize:12},children:["By pillar · ",In(i)," total",o||l?` · ${In(o)} in · ${In(l)} out`:""]}),a.map((f,y)=>s.jsxs("button",{type:"button",className:"token-pillar-button",onClick:()=>n(t===f.pillar?null:f.pillar),"aria-pressed":t===f.pillar,style:{borderColor:t===f.pillar?"var(--accent)":void 0},children:[s.jsx("span",{className:`tile-dot ${y===0?"info":y===1?"pass":"warn"}`}),s.jsx("span",{children:f.label}),s.jsx("b",{children:In(f.total)})]},f.pillar))]})]}),r&&s.jsxs("div",{className:"card",style:{padding:14},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",marginBottom:9},children:[s.jsxs("span",{style:{fontSize:13,fontWeight:700},children:[r.label," token usage"]}),s.jsxs("span",{className:"muted mono",style:{fontSize:12},children:[In(r.total)," total"]})]}),s.jsx("div",{className:"stack",style:{gap:7},children:r.entries.slice(0,20).map(f=>s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",paddingTop:7,borderTop:"1px solid var(--border)"},children:[s.jsxs("div",{className:"stack",style:{gap:1,minWidth:0},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.label}),s.jsxs("span",{className:"muted",style:{fontSize:11},children:[Kp(f.createdAt),f.model?` · ${f.model}`:""]})]}),s.jsxs("span",{className:"mono",style:{fontSize:12.5,flexShrink:0,textAlign:"right"},children:[In(f.tokens??0),(f.inputTokens!=null||f.outputTokens!=null)&&s.jsxs("span",{className:"muted",style:{display:"block",fontSize:10.5},children:["↓",In(f.inputTokens??0)," / ↑",In(f.outputTokens??0)]})]})]},f.id))}),s.jsx("span",{className:"muted",style:{display:"block",marginTop:10,fontSize:11},children:"↓ input includes prompts and context; ↑ output is generated completion. Older runs may show total only."})]})]})})}function Iu({name:e,value:t,note:n,tone:a}){return s.jsxs("div",{className:"token-metric",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${a}`}),s.jsx("span",{className:"tile-name",children:e})]}),s.jsx("div",{className:"token-metric-value",children:t}),s.jsx("div",{className:"token-metric-note",title:n,children:n})]})}function aL({pillars:e}){return s.jsx("div",{className:"tiles",children:e.map(t=>{const n=t.score==null?"info":t.score>=90?"pass":t.score>=70?"warn":"fail";return s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${n}`}),s.jsx("span",{className:"tile-name",children:t.label})]}),s.jsx("div",{className:"tile-value",children:t.score??"—"}),s.jsxs("div",{className:"tile-label",children:[t.count," run",t.count===1?"":"s"," · ",t.status]}),t.finding&&s.jsx("div",{className:"muted",style:{marginTop:10,fontSize:11.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.finding})]},t.p)})})}function In(e){return Math.round(e).toLocaleString()}function uo({name:e,value:t,label:n,tone:a,spark:r}){return s.jsxs(rL,{name:e,children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${a}`}),s.jsx("span",{className:"tile-name",children:e})]}),s.jsx("div",{className:"tile-value",children:t}),s.jsx("div",{className:"tile-label",children:n}),r&&r.length>=2&&s.jsx("div",{style:{marginTop:12},children:s.jsx(iL,{series:r,tone:a})})]})}function rL({name:e,children:t}){const[n,a]=p.useState(!1);return p.useEffect(()=>{if(!n)return;const r=i=>{i.key==="Escape"&&a(!1)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"tile score-tile",onClick:()=>a(!0),"aria-label":`Zoom ${e} score card`,children:[t,s.jsx("span",{className:"score-tile-hint",children:"Click to zoom"})]}),n&&s.jsx("div",{className:"score-card-backdrop",role:"presentation",onMouseDown:()=>a(!1),children:s.jsxs("div",{className:"score-card-dialog",role:"dialog","aria-modal":"true","aria-label":`${e} score card`,onMouseDown:r=>r.stopPropagation(),children:[s.jsx("button",{type:"button",className:"score-card-close",onClick:()=>a(!1),"aria-label":`Close ${e} score card`,children:"Close"}),s.jsx("div",{className:"tile score-card-zoom",children:t})]})})]})}function iL({series:e,tone:t}){if(e.length<2)return null;const n=100,a=26,r=Math.min(...e),o=Math.max(...e)-r||1,l=e.map((c,u)=>{const d=u/(e.length-1)*n,h=a-(c-r)/o*(a-3)-1.5;return`${d.toFixed(1)},${h.toFixed(1)}`}).join(" ");return s.jsx("svg",{className:`spark ${t==="info"?"":t}`,width:n,height:a,viewBox:`0 0 ${n} ${a}`,preserveAspectRatio:"none",children:s.jsx("polyline",{points:l,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})})}function oL(e){return e.error>0?"error":e.fail>0?"fail":e.drift>0?"drift":"pass"}function lL(e){return e.score??(e.total?Math.round(e.pass/e.total*100):null)}function cL(e){if(!(e!=null&&e.evidence))return null;try{const t=JSON.parse(e.evidence);return t.p95==null||t.rps==null?null:{p50:t.p50??0,p95:t.p95??0,p99:t.p99??0,rps:t.rps??0,errorRate:t.errorRate??0,pctUnder:t.pctUnder??e.score??0,vus:t.vus??0,requests:t.requests??e.total??0,targetMs:t.targetMs??0,durationS:t.durationS??Math.round((e.durationMs??0)/1e3)}}catch{return null}}function yf(e){return e>=1e3?`${(e/1e3).toFixed(1)} s`:`${Math.round(e)} ms`}function Kw(e){return Number.isFinite(e)&&Number.isInteger(e)}function xf(e){return Number.isFinite(e)&&e>=0&&e<=100}function dL(e,t={}){if(!Kw(e.requests)||e.requests<0||!Kw(e.errors)||e.errors<0||e.errors>e.requests||!xf(e.errorRate)||!xf(e.pctUnder))return{decision:"NOT_EVALUATED",successfulRequests:0,reason:"Performance metrics are malformed or internally inconsistent."};for(const[r,i]of Object.entries(t))if(i!==void 0&&!xf(i))return{decision:"NOT_EVALUATED",successfulRequests:0,reason:`${r} must be between 0 and 100.`};const n=e.requests-e.errors;if(e.requests===0)return{decision:"NOT_EVALUATED",successfulRequests:n,reason:"No requests completed, so performance was not evaluated."};if(n===0)return{decision:"BLOCK",successfulRequests:n,reason:"Every request failed; zero successful requests cannot establish performance readiness."};const a=Number((e.errors/e.requests*100).toFixed(2));return Math.abs(a-e.errorRate)>.01?{decision:"NOT_EVALUATED",successfulRequests:n,reason:"Performance error counts and error rate do not agree."}:t.maxErrorRate!==void 0&&e.errorRate>t.maxErrorRate?{decision:"BLOCK",successfulRequests:n,reason:`Error rate ${e.errorRate}% exceeds the allowed ${t.maxErrorRate}%.`}:t.minUnder!==void 0&&e.pctUnder<t.minUnder?{decision:"BLOCK",successfulRequests:n,reason:`${e.pctUnder}% of requests met the latency target; ${t.minUnder}% is required.`}:{decision:"READY",successfulRequests:n,reason:"The sample contains successful requests and satisfies the configured thresholds."}}const jf=10,uL=[1,5,10,25,50,100],Au=5;function hL({core:e,caps:t}){const[n,a]=p.useState([]),[r,i]=p.useState(""),[o,l]=p.useState(5),[c,u]=p.useState(500),[d,h]=p.useState(30),[g,v]=p.useState(!1),[f,y]=p.useState(null),[b,m]=p.useState(""),[x,j]=p.useState(null),[S,w]=p.useState([]),[C,k]=p.useState(0),[N,L]=p.useState(!1),_=()=>O.runs(300).then(F=>w(F.filter(ie=>ie.pillar==="perf"))).catch(()=>{});p.useEffect(()=>{_()},[]);const E=o>Au,I=E,$=[...((t==null?void 0:t.tools)??[]).map(F=>({id:`tool:${F.name}`,label:`${F.name} · tool`})),...n.map(F=>({id:F.id,label:`${F.snapshot.tool} · ${F.kind}`}))];p.useEffect(()=>{O.snapshots().then(F=>a(F)).catch(()=>{})},[]);const W=n.find(F=>F.id===r),R=r.startsWith("tool:")?((t==null?void 0:t.tools)??[]).find(F=>`tool:${F.name}`===r):void 0,H=!!(R||W&&W.kind==="mcp");p.useEffect(()=>{W&&W.kind==="mcp"?m(JSON.stringify(W.snapshot.input??{},null,2)):m(R?JSON.stringify(fL(R.inputSchema),null,2):"")},[r]);const Y=R?R.name:W?W.snapshot.tool:"target",K=async()=>{if(I)return;let F=null;if(R||W&&W.kind==="mcp"){let ie;try{ie=b.trim()?JSON.parse(b):(W==null?void 0:W.snapshot.input)??{}}catch{j("Test data isn't valid JSON.");return}F={kind:"tool",name:R?R.name:W.snapshot.tool,input:ie}}else if(W&&W.kind==="http"){const ie=W.snapshot.input??{};F={kind:"http",method:ie.method,url:ie.url??"",headers:ie.headers,body:ie.body}}if(!F){j("Pick a target first.");return}v(!0),j(null),y(null);try{const ie=await O.perfRun(F,o,d,c);if(!ie.ok){j(ie.error??"Load test failed.");return}const ue={vus:ie.vus??o,targetMs:c,durationS:ie.durationS??d,p50:ie.p50??0,p95:ie.p95??0,p99:ie.p99??0,rps:ie.rps??0,requests:ie.requests??0,errors:ie.errors??0,errorRate:ie.errorRate??0,pctUnder:ie.pctUnder??0};y(ue);const oe=Zw(ue).label==="pass";O.saveRun({pillar:"perf",label:`${Y} · ${ue.vus} VUs`,total:1,pass:oe?1:0,drift:0,fail:oe?0:1,error:(ie.errors??0)>0?1:0,latencyMs:ue.p95,score:ue.pctUnder,durationMs:ue.durationS*1e3,finding:`p95 ${ue.p95}ms · ${ue.rps}/s · ${ue.pctUnder}% under ${ue.targetMs}ms · ${ue.errorRate}% errors`,evidence:JSON.stringify({p50:ue.p50,p95:ue.p95,p99:ue.p99,rps:ue.rps,errors:ue.errors,errorRate:ue.errorRate,pctUnder:ue.pctUnder,vus:ue.vus,requests:ue.requests,targetMs:ue.targetMs,durationS:ue.durationS})}).then(async B=>{Oa([B]),await Ds(),await _()}).catch(()=>{})}catch(ie){ie!=null&&ie.upgrade?j("Load tests above 5 VUs require Prooflane Scale."):j(ie instanceof Error?ie.message:String(ie))}finally{v(!1)}},ce=f?Zw(f):null;return s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsx("div",{className:"row spread",children:s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"tag pass",children:"live · ≤5 VUs"}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"Real load test against a tool or contract — runs locally in-process; ≤5 VUs free, above require Core"})]})}),s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"grid-2",style:{gridTemplateColumns:"1fr 1fr 1fr",gap:14},children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Target — tool or contract"}),s.jsxs("select",{className:"field",value:r,onChange:F=>i(F.target.value),disabled:$.length===0,children:[s.jsx("option",{value:"",children:$.length?"Select a target…":"Connect a server or capture a contract"}),$.map(F=>s.jsx("option",{value:F.id,children:F.label},F.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"SLO — p95 latency target (ms)"}),s.jsx("input",{className:"field mono",type:"number",value:c,onChange:F=>u(Math.max(1,Number(F.target.value)||0))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Duration (s)"}),s.jsx("input",{className:"field mono",type:"number",value:d,onChange:F=>h(Math.max(1,Number(F.target.value)||0))})]})]}),s.jsxs("div",{style:{marginTop:14},children:[s.jsxs("label",{className:"label",children:["Virtual users — ",o," ",s.jsxs("span",{className:"muted",style:{fontWeight:400},children:["(",o<=Au?"local · free":"hosted · Core · coming soon",")"]})]}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:uL.map(F=>{const ie=F>Au&&!e;return s.jsxs("button",{className:`btn sm ${o===F?"primary":"ghost"}`,onClick:()=>l(F),title:F>Au?"Hosted (Fargate) — Core — coming soon":"Runs locally, free",children:[ie?"🔒 ":"",F," VU",F>1?"s":""]},F)})})]}),H&&s.jsxs("div",{style:{marginTop:14},children:[s.jsx("label",{className:"label",children:"Test data — input each VU sends (JSON)"}),s.jsx("textarea",{className:"field mono",style:{minHeight:80},value:b,onChange:F=>m(F.target.value),placeholder:'{ "testId": "DA-MAC-…", "platform": "web" }'}),s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:4},children:["This is the actual payload each virtual user would send — fill in real values (e.g. a real ",s.jsx("span",{className:"mono",children:"testId"}),")."]})]}),s.jsxs("div",{className:"statusline",style:{marginTop:14},children:[s.jsx("span",{className:"muted",style:{fontSize:12},children:"SLO gate on % of requests under target:"}),s.jsx("span",{className:"tag pass",children:"≥95 pass"}),s.jsx("span",{className:"tag warn",children:"≥90 review"}),s.jsx("span",{className:"tag warn",style:{opacity:.7},children:"≥80 warn"}),s.jsx("span",{className:"tag fail",children:"<75 fail"})]}),s.jsxs("div",{className:"row",style:{marginTop:16,gap:10,alignItems:"center"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>L(!0),disabled:!H||!r||E,title:H?"Capture this load test for a tag-driven gate":"Only MCP tool load tests can be captured; HTTP credentials are never stored in gate definitions.",children:"Tag"}),s.jsx("button",{className:"btn primary",onClick:K,disabled:g||I,children:g?"Running…":I?"🔒 Run load test":"Run load test"}),I&&!e&&s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[o," VUs runs on hosted runners —"," ",s.jsx("button",{className:"btn sm primary",style:{padding:"2px 10px"},onClick:()=>EE(),children:"Sign up for Core"})," ","for >5 VUs."]}),I&&e&&s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[">5 VUs runs on hosted runners (AWS Fargate) to spare your machine — ",s.jsx("b",{children:"coming soon"}),". Use ≤5 VUs locally for now."]}),!I&&s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"Fires real requests locally — free."})]}),x&&s.jsx("div",{style:{color:"var(--fail)",marginTop:10,fontSize:12.5},children:x}),g&&s.jsxs("div",{className:"muted",style:{marginTop:8,fontSize:12},children:["Firing real requests for ",d,"s…"]})]}),N&&(R||W&&W.kind==="mcp")&&s.jsx(Nl,{title:"Tag performance test",subtitle:s.jsx(s.Fragment,{children:"Captures this MCP load test for the same tag-driven gate used by Security, RAG, Prompts, Contracts, and tool tests. Authentication stays in the connected MCP session."}),defaultName:`${Y} · ${o} VUs`,capture:()=>{let F=(W==null?void 0:W.snapshot.input)??{};try{F=b.trim()?JSON.parse(b):F}catch{}return{pillar:"performance",performance:{tool:Y,input:F,vus:o,durationS:d,targetMs:c,minUnder:95,maxErrorRate:0}}},onClose:()=>L(!1)}),(W||R)&&s.jsx(pL,{snap:W,tool:R,payload:b}),f&&ce&&s.jsxs("div",{children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",marginBottom:12},children:[s.jsx("div",{className:"detail-title",style:{fontSize:15},children:"Results"}),s.jsxs("span",{className:`tag ${ce.tone}`,children:[ce.label," · ",f.pctUnder,"% under ",f.targetMs,"ms"]}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[f.vus," VUs · ",f.durationS,"s"]})]}),s.jsxs("div",{className:"tiles",children:[s.jsx(ho,{name:"p50 latency",value:`${f.p50} ms`,tone:"info"}),s.jsx(ho,{name:"p95 latency",value:`${f.p95} ms`,tone:f.p95<=f.targetMs?"pass":"warn"}),s.jsx(ho,{name:"p99 latency",value:`${f.p99} ms`,tone:f.p99<=f.targetMs*1.5?"info":"warn"}),s.jsx(ho,{name:"Throughput",value:`${f.rps}/s`,tone:"info"}),s.jsx(ho,{name:"Requests",value:f.requests.toLocaleString(),tone:"info"}),s.jsx(ho,{name:"Error rate",value:`${f.errorRate.toFixed(2)}%`,tone:f.errorRate>1?"fail":"pass"})]}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:10},children:[s.jsxs("b",{children:[f.requests.toLocaleString()," real requests"]})," fired against the live target with the Test data above, over"," ",f.durationS,"s at ",f.vus," VUs. Percentiles are from actual latencies; recorded to Runs (Perf pillar) + Assurance Observability. (>5 VUs require Core; all runs are local in-process today — distributed hosted runners are future.)"]})]}),S.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"detail-title",style:{fontSize:15,marginBottom:12},children:["History ",s.jsxs("span",{className:"muted",children:["(",S.length,")"]})]}),s.jsx("div",{className:"tbl-scroll",children:s.jsxs("table",{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Target · VUs"}),s.jsx("th",{children:"SLO"}),s.jsx("th",{children:"p95 latency"}),s.jsx("th",{children:"When"})]})}),s.jsx("tbody",{children:S.slice(C*jf,(C+1)*jf).map(F=>s.jsxs("tr",{children:[s.jsx("td",{children:F.label}),s.jsx("td",{children:s.jsx("span",{className:`tag ${F.fail>0?"fail":"pass"}`,children:F.fail>0?"fail":"pass"})}),s.jsx("td",{className:"mono",children:F.latencyMs!=null?`${F.latencyMs} ms`:"—"}),s.jsx("td",{className:"muted",children:new Date(F.createdAt).toLocaleString()})]},F.id))})]})}),s.jsx(Bp,{page:C,pageSize:jf,total:S.length,onPage:k})]})]})}function pL({snap:e,tool:t,payload:n}){var i;if(e&&e.kind==="http"){const o=e.snapshot.input??{},l=Object.entries(o.headers??{});return s.jsxs("div",{className:"card",style:{marginBottom:20},children:[s.jsxs("div",{className:"row spread",style:{marginBottom:10},children:[s.jsxs("div",{className:"detail-title",style:{fontSize:14},children:["Request preview ",s.jsx("span",{className:"muted",style:{fontWeight:400,fontSize:12},children:"· what each VU fires"})]}),s.jsx("span",{className:"tag informational",children:"token masked"})]}),s.jsxs("div",{className:"mono",style:{fontSize:12.5,marginBottom:10},children:[s.jsx("span",{className:"tag pass",style:{marginRight:8},children:(o.method??"GET").toUpperCase()}),o.url]}),s.jsx("div",{className:"section-label",children:"Headers"}),l.length===0?s.jsx("div",{className:"muted",style:{fontSize:12},children:"(none captured)"}):s.jsx("table",{children:s.jsx("tbody",{children:l.map(([c,u],d)=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",style:{fontSize:12,paddingRight:16,verticalAlign:"top"},children:c}),s.jsx("td",{className:"mono",style:{fontSize:12,wordBreak:"break-all"},children:mL(c,u)})]},d))})}),o.body&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section-label",children:"Body (test data)"}),s.jsx(Ls,{value:Yw(o.body)})]})]})}const a=(e==null?void 0:e.snapshot.tool)??(t==null?void 0:t.name),r=(i=e==null?void 0:e.connection)==null?void 0:i.url;return s.jsxs("div",{className:"card",style:{marginBottom:20},children:[s.jsxs("div",{className:"row spread",style:{marginBottom:10},children:[s.jsxs("div",{className:"detail-title",style:{fontSize:14},children:["Request preview ",s.jsx("span",{className:"muted",style:{fontWeight:400,fontSize:12},children:"· MCP tool call each VU fires"})]}),s.jsx("span",{className:"tag informational",children:"auth via MCP session"})]}),s.jsxs("div",{className:"mono",style:{fontSize:12.5,marginBottom:10},children:[s.jsx("span",{className:"tag pass",style:{marginRight:8},children:"CALL"}),a,r?s.jsxs("span",{className:"muted",children:[" · ",r]}):null]}),s.jsx("div",{className:"section-label",children:"Input (test data each VU sends)"}),s.jsx(Ls,{value:n&&n.trim()?Yw(n):(e==null?void 0:e.snapshot.input)??{}}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:8},children:"Auth is carried by the connected MCP session's OAuth token (attached per request by the runner), never in the body."})]})}function Jw(e){const t=String(e);return t.length<=10?"••••":`${t.slice(0,6)}••••${t.slice(-4)}`}function mL(e,t){if(/authorization|api[-_]?key|token|secret|cookie|x-access/i.test(e)){const n=String(t).match(/^(\S+\s)(.+)$/);return n?`${n[1]}${Jw(n[2])}`:Jw(t)}return t}function Yw(e){try{return JSON.parse(e)}catch{return e}}function fL(e){var i;const t=e??{},n=t.properties??{},a=new Set(t.required??Object.keys(n)),r={};for(const[o,l]of Object.entries(n)){if(!a.has(o))continue;const c=l;r[o]=(i=c.enum)!=null&&i.length?c.enum[0]:c.type==="number"||c.type==="integer"?0:c.type==="boolean"?!1:c.type==="array"?[]:""}return r}function ho({name:e,value:t,tone:n}){return s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${n}`}),s.jsx("span",{className:"tile-name",children:e})]}),s.jsx("div",{className:"tile-value",children:t})]})}function Zw(e){const t=dL(e);return t.decision==="NOT_EVALUATED"?{label:"not evaluated",tone:"warn"}:t.decision==="BLOCK"?{label:"fail",tone:"fail"}:e.errorRate>0?{label:"fail",tone:"fail"}:e.pctUnder>=95?{label:"pass",tone:"pass"}:e.pctUnder>=90?{label:"review",tone:"warn"}:e.pctUnder>=80?{label:"warn",tone:"warn"}:{label:"fail",tone:"fail"}}const gL={MCP:"MCP server",HTTP_API:"HTTP / API",RAG:"RAG system",MODEL:"Model endpoint",AGENT:"AI agent"};function ei(e){return e?gL[e]:"Target"}const Xw=["empty-output","error-response","malformed-output"],vL={"empty-output":"Empty retrieval","error-response":"Retriever error","malformed-output":"Malformed output"},Ix={"retrieval-quality":"Retrieval quality","tool-selection":"Tool selection","retriever-behavior":"Retriever behavior","retrieval-contract":"Retrieval contract","retrieval-drift":"Retrieval drift","chain-validation":"End-to-end chain",resilience:"Resilience (fault injection)"},d_={"retrieval-quality":"Are the right things retrieved? (relevance vs. expected terms)","tool-selection":"Did the agent call the correct retrieval tool?","retriever-behavior":"Latency, result count, empties, and errors.","retrieval-contract":"Does the result keep its expected shape?","retrieval-drift":"Has retrieval changed vs. the golden baseline?","chain-validation":"Query → retrieve → answer, grounded in context.",resilience:"Under injected retrieval failures, does the answer abstain or hallucinate?"},u_="kawach.rag.cases",h_="kawach.rag.golden",p_="kawach.rag.regressions";function yL(){try{const e=localStorage.getItem(u_);return e?JSON.parse(e).filter(n=>!(n.id==="rag-1"&&n.query==="What is the refund policy?"||n.id==="rag-2"&&n.query==="How do I reset my password?")).map(n=>{var a;return{...n,judgeStrategy:((a=n.judge)==null?void 0:a.strategy)??n.judgeStrategy??"deterministic",judge:n.judge??{strategy:n.judgeStrategy??"deterministic",fallback:"deterministic",required_for_gate:!0}}}):[]}catch{return[]}}const xL=e=>{try{localStorage.setItem(u_,JSON.stringify(e))}catch{}};function bf(){try{const e=localStorage.getItem(h_);return e?JSON.parse(e):{}}catch{return{}}}const Qw=e=>{try{localStorage.setItem(h_,JSON.stringify(e))}catch{}};function jL(){try{const e=localStorage.getItem(p_);return e?JSON.parse(e):[]}catch{return[]}}const bL=e=>{try{localStorage.setItem(p_,JSON.stringify(e.slice(0,25)))}catch{}},eS=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"rag-regression";function yn(e){return e>=90?"pass":e>=70?"warn":"fail"}const wc=()=>`rag-${Math.random().toString(36).slice(2,8)}`,tS="__agent__",po=()=>({id:wc(),query:"",name:"",userQuery:"",minResults:1}),wL={"full-chain":"Full chain","retriever-only":"Retriever only"};function SL({result:e}){const t=e.checks.find(r=>r.dimension==="chain-validation");if(!(!e.judged&&(t==null?void 0:t.detail.includes("grounded abstention")))||e.faithfulness===void 0||e.relevance===void 0||!t)return null;const a=/reaction/i.test(e.signature);return s.jsxs("div",{className:"stack",style:{gap:8,padding:"12px 14px",border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-subtle, rgba(127,127,127,0.04))"},children:[s.jsx("strong",{style:{fontSize:13},children:"Why this is the right outcome"}),s.jsxs("span",{className:"muted",style:{fontSize:12.5,lineHeight:1.55},children:[a?"The tool returned reaction metadata, not confirmation that an issue comment was created.":"The tool returned metadata, not enough evidence to complete or confirm the requested action."," The answer therefore correctly abstained instead of inventing a result."]}),s.jsxs("div",{className:"stack",style:{gap:3,fontSize:12.5},children:[s.jsxs("span",{children:[s.jsxs("strong",{children:["Faithfulness: ",e.faithfulness]})," — it did not invent facts beyond the returned context."]}),s.jsxs("span",{children:[s.jsxs("strong",{children:["Relevance: ",e.relevance]})," — it addressed the request honestly, but the context could not fulfil it."]}),s.jsxs("span",{children:[s.jsxs("strong",{children:["End-to-end: ",t.pass?"passed":"failed"]})," — ",t.pass?"the available evidence was sufficient.":"the retrieval did not supply what the requested action needed."]})]})]})}function NL({caps:e,connected:t,target:n,boundToolName:a,hostedRunner:r=!1,notify:i,onNavigateIntelligence:o}){var ii;const[l,c]=p.useState("test"),[u,d]=p.useState([]),[h,g]=p.useState(yL()),[v,f]=p.useState(""),[y,b]=p.useState(!1),[m,x]=p.useState(!0),[j,S]=p.useState(!0),[w,C]=p.useState("independent"),k=v===tS,[N,L]=p.useState(null),[_,E]=p.useState({}),[I,$]=p.useState(null),[W,R]=p.useState(!1),[H,Y]=p.useState(jL()),[K,ce]=p.useState(""),[F,ie]=p.useState(null),[ue,oe]=p.useState(!1),[B,Q]=p.useState(null),[X,me]=p.useState(null),[fe,P]=p.useState(null),[T,he]=p.useState(!1),[q,se]=p.useState(po),[ge,de]=p.useState(null),[Ne,Oe]=p.useState("Running RAG assurance"),[_e,re]=p.useState([]),[V,le]=p.useState([]),[ee,xe]=p.useState(null),Fe=p.useRef(null),[Be,st]=p.useState(null),[ae,Ce]=p.useState(!1),[He,qe]=p.useState({}),[dt,ye]=p.useState(Object.keys(bf()).length>0),[Ke,U]=p.useState({}),[,te]=p.useState(0);p.useEffect(()=>mr(()=>te(Z=>Z+1)),[]);const ke=()=>O.intelligenceNativeArtifacts("rag").then(Z=>{re(Z.artifacts),le(Z.deferred)}).catch(()=>{re([]),le([])});p.useEffect(()=>{ke()},[n==null?void 0:n.targetFingerprint,e]);const we=(e==null?void 0:e.tools)??[];p.useEffect(()=>{a&&f(a)},[a]),p.useEffect(()=>{!v&&we.length&&f(we[0].name)},[we,v]),p.useEffect(()=>xL(h),[h]),p.useEffect(()=>{l==="history"&&O.runs(500).then(Z=>d(Z.filter(Ue=>Ue.pillar==="rag"))).catch(()=>d([]))},[l]);const Te=p.useMemo(()=>we.filter(Z=>/search|retriev|query|lookup|find|fetch|get|read|list/i.test(Z.name)),[we]);p.useEffect(()=>{const Z=k$();Z&&(he(!0),se({...po(),name:`From Prompt Studio · ${Z.query.slice(0,48)}`,userQuery:Z.query,query:Z.query,tool:Z.tool,input:Z.input,mode:"full-chain"}))},[]);const ve=Es(),z=hl(),D=h.some(Z=>Zs(Z).trim()),A=k||m||j,ne=!A||!!(ve!=null&&ve.model&&(ve!=null&&ve.apiKey)),Ee=!(m&&w==="independent")||!!(z!=null&&z.model&&(z!=null&&z.apiKey)),ze=!k&&!m&&!j;function wt(){const Z=w==="independent"?z:w==="same-model"?ve:null;return{strategy:w,...Z!=null&&Z.provider?{provider:Z.provider,independence_group:Z.provider,canonical_family:Z.model,model:Z.model}:w==="independent"?{independence_group:"unconfigured"}:{},fallback:"deterministic",required_for_gate:!0}}function be(){var Z;k&&f(((Z=Te[0]??we[0])==null?void 0:Z.name)??""),x(!1),S(!1),C("deterministic"),Q(null)}function _t(Z,Ue){g($e=>$e.map(mt=>mt.id===Z?{...mt,...Ue}:mt))}const Dt=Z=>{const Ue=Z.test.rag;Ue&&(g($e=>[...$e.filter(mt=>mt.id!==Ue.id),Ue]),f(Ue.tool??v),P(Ue.id),c("test"))},pe=async(Z,Ue,$e)=>{xe(`${Z.generationId}:${Z.test.id}`);try{await O.intelligenceNativeArtifactReview(Z.generationId,Z.test.id,{action:Ue,reviewedBy:"local-user",expectedRevisionNumber:Z.generationRevisionNumber,replacement:Ue==="MODIFIED"&&$e?{...Z.test,name:ta($e),rag:$e}:void 0}),i==null||i(`RAG artifact ${Ue.toLowerCase()}`),await ke()}catch(mt){const Pt=mt instanceof Error?mt.message:"RAG artifact review failed.";Q(Pt),i==null||i(Pt)}finally{xe(null)}},Xe=Z=>g(Ue=>Ue.filter($e=>$e.id!==Z));function St(){let Z,Ue;if(k||m||j){const $e=Es();if(!($e!=null&&$e.model)||!($e!=null&&$e.apiKey))return{error:"Agentic tool-selection, end-to-end chain, and fault-injection resilience need an LLM — use the “Configure target” button above, or turn them off."};Z=$e}if(m&&w==="independent"){const $e=hl();if(!($e!=null&&$e.model)||!($e!=null&&$e.apiKey))return{error:"Independent judging needs a separate Judge LLM. Configure one below, or select same-model / deterministic evaluation."};if(Z&&$e.provider===Z.provider&&$e.model.trim()===Z.model.trim())return{error:"Your independent judge must use a different model or provider than the target. Choose same-model judging if that is intentional."};Ue=$e}return{llm:Z,judge:Ue}}const kt=Z=>({...Z,tool:k?void 0:a??Z.tool??v});async function ht(Z){Q(null),me(null);const Ue=(Z??h).filter($t=>Zs($t).trim());if(!t){Q("Connect to an MCP server first — RAG assurance runs against its retrieval tools.");return}if(!Ue.length){Q("Add at least one retrieval query.");return}const $e=St();if("error"in $e){Q($e.error);return}const mt=Ue.map(kt);oe(!0),L(null),Oe(`Running ${mt.length} RAG case${mt.length===1?"":"s"}`),de({done:0,total:mt.length,label:ta(mt[0])});const Pt=new AbortController;Fe.current=Pt;try{const $t=bf(),xs=await O.ragRunStream({cases:mt,useAgentPick:k,chain:m,faults:j?Xw:void 0,llm:$e.llm,judge:$e.judge,judgeStrategy:w,golden:$t},Ot=>de({done:Ot.done,total:Ot.total,label:Ot.name||void 0}),Pt.signal,r);!xs.ok||!xs.report?Q(xs.error??"RAG assurance run failed."):(L(xs.report),E(Ot=>({...Ot,...Object.fromEntries(xs.report.results.map(zt=>[zt.case.id,zt]))})),$(xs.diff??null),U($t),xs.run&&Oa([xs.run]),await Ds())}catch($t){($t==null?void 0:$t.name)==="AbortError"?Q("Run stopped."):Q($t instanceof Error?$t.message:String($t))}finally{Fe.current=null,de(null),oe(!1)}}function xt(){var Z;(Z=Fe.current)==null||Z.abort(),Fe.current=null}async function rs(Z){if(Q(null),!t){Q("Connect to an MCP server first — RAG assurance runs against its retrieval tools.");return}if(!Zs(Z).trim()){Q("Enter the user query (or retrieval query) before running.");return}const Ue=St();if("error"in Ue){Q(Ue.error);return}const $e=kt({...Z,id:Z.id||wc()});Ce(!0),st(null),Oe("Run once (not saved)"),de({done:0,total:1,label:ta($e)});const mt=new AbortController;Fe.current=mt;try{const Pt=await O.ragRunStream({cases:[$e],useAgentPick:k,chain:m,faults:j?Xw:void 0,llm:Ue.llm,judge:Ue.judge,judgeStrategy:w,golden:bf(),recordHistory:!1},$t=>de({done:$t.done,total:$t.total,label:$t.name||void 0}),mt.signal,r);!Pt.ok||!Pt.report?Q(Pt.error??"The exploratory run did not complete."):st({case:$e,report:Pt.report})}catch(Pt){(Pt==null?void 0:Pt.name)==="AbortError"?Q("Run stopped."):Q(Pt instanceof Error?Pt.message:String(Pt))}finally{Fe.current=null,de(null),Ce(!1)}}function Ye(){if(!Be)return;const Z=new Date().toISOString(),Ue={...Be.case,id:wc(),name:ta(Be.case),createdAt:Z,updatedAt:Z,judgeStrategy:w,judge:wt()};g($e=>[...$e,Ue]),E($e=>{const mt=Be.report.results[0];return mt?{...$e,[Ue.id]:{...mt,case:Ue}}:$e}),st(null),he(!1),se(po())}function Xt(Z=!1){if(!Zs(q).trim()){Q("Enter the user query (or retrieval query) before saving the RAG test case.");return}const Ue=new Date().toISOString(),$e={...q,id:q.id||wc(),createdAt:q.createdAt??Ue,updatedAt:Ue,judgeStrategy:w,judge:wt()};g(mt=>[...mt,$e]),se(po()),he(!1),st(null),Z&&ht([$e])}function zs(Z){const Ue=new Date().toISOString();g($e=>[...$e,{...Z,id:wc(),name:`${ta(Z)} (copy)`,createdAt:Ue,updatedAt:Ue}])}function At(){if(!N)return;const Z={};for(const Ue of N.results)Z[Ue.case.id]=Ue.signature;Qw(Z),ye(!0)}function es(){Qw({}),ye(!1)}function Js(){if(!N)return;const Z={id:`${Date.now()}`,name:K.trim()||`RAG regression ${new Date().toLocaleString()}`,savedAt:new Date().toISOString(),cases:h.filter($e=>Zs($e).trim()).map($e=>({...$e,tool:k?void 0:a??$e.tool??v})),overall:N.overall,passed:N.passed,total:N.total,chain:m,faults:j,judgeStrategy:w,selectedTool:v},Ue=[Z,...H].slice(0,25);Y(Ue),bL(Ue),ce(""),ie(Z)}const is=F;return is&&`${eS(is.name)}`,s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsxs("div",{className:"tabbar",children:[s.jsx("button",{className:`tab ${l==="test"?"active":""}`,onClick:()=>c("test"),children:"Test"}),s.jsx("button",{className:`tab ${l==="history"?"active":""}`,onClick:()=>c("history"),children:"History"})]}),l==="history"&&(u.length===0?s.jsx("div",{className:"card",style:{padding:20},children:s.jsxs("span",{className:"muted",style:{fontSize:13},children:["No RAG runs yet. Switch to ",s.jsx("b",{children:"Test"})," and run an assurance suite — every run is logged here."]})}):s.jsx(OL,{runs:u,hostedRunner:r})),l==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"assurance-run-toolbar",children:[s.jsxs("div",{className:"stack assurance-run-intro",style:{gap:4},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["Grades the connected ",n?ei(n.type).toLowerCase():"retrieval target"," across quality, tool-selection, behavior, contract, drift, and the end-to-end chain."]}),r&&s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Hosted assurance · Prooflane signs and persists the grade; queries, tool inputs, retrieved context, answers, model keys, and judge keys remain on this device."})]}),s.jsxs("div",{className:"row assurance-run-controls",style:{gap:10,alignItems:"center"},children:[t&&s.jsx("span",{className:"muted mono",style:{fontSize:12},children:n?`${ei(n.type)} · ${n.discoveryMetadata.capabilityCount} ${n.discoveryMetadata.capabilityCount===1?"capability":"capabilities"}`:`MCP server · ${we.length} tools`}),s.jsx("span",{className:`rag-run-mode ${ze?"deterministic":"ai"}`,children:ze?"Deterministic retrieval · no LLM":"Full chain · target LLM"}),s.jsx("button",{className:"btn sm ghost",disabled:!h.some(Z=>Zs(Z).trim()),title:"Tag these RAG cases for CI — pick which cases to capture; a job that names one of its tags runs exactly those cases",onClick:()=>{ie(null),R(!0)},children:"Tag"}),s.jsx("button",{className:"btn sm primary",onClick:()=>void ht(),disabled:ue||!t||!D||!ne||!Ee,title:ne?Ee?void 0:"Configure an independent judge, or choose rules-only evaluation.":"Configure the target LLM, or select no-LLM retrieval mode.",children:ue?"Evaluating…":N?"Re-run":"Run assurance"})]})]}),W&&s.jsx(Nl,{title:"Tag RAG regression cases",subtitle:s.jsxs(s.Fragment,{children:["Captures each retrieval case in ",s.jsx("b",{children:(is==null?void 0:is.name)??"the current library"})," to ",s.jsx("span",{className:"mono",children:".prooflane/tags.json"}),". A CI job that names one of its tags runs exactly these cases."]}),defaultName:(is==null?void 0:is.name)??"RAG regression",capture:()=>((is==null?void 0:is.cases)??h).map(Z=>({pillar:"rag",name:ta(Z).slice(0,60)||Z.id,rag:Z})),onClose:()=>R(!1)}),B&&s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"setup"}),s.jsx("span",{style:{fontSize:13},children:B})]})}),s.jsxs("div",{className:"tiles rag-config-grid",children:[s.jsxs("div",{className:"tile rag-config-card",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"RAG assurance"})]}),a?s.jsx("div",{className:"field mono",style:{marginTop:6},children:a}):s.jsxs("select",{className:"field",value:v,onChange:Z=>f(Z.target.value),disabled:!t,style:{marginTop:6},children:[we.length===0&&s.jsx("option",{children:"— connect a server —"}),s.jsx("option",{value:tS,children:"🤖 Let the agent pick (LLM)"}),(y?Te:we).map(Z=>s.jsx("option",{value:Z.name,children:Z.name},Z.name))]}),k?s.jsx("div",{className:"tile-label",children:"The LLM chooses a tool per query (grades tool selection)"}):a?s.jsx("div",{className:"tile-label",style:{marginTop:6},children:"Target is controlled by the shared MCP tool binding above."}):s.jsxs("label",{className:"row",style:{gap:6,alignItems:"center",cursor:"pointer",marginTop:6},title:"Filter the dropdown to tools whose name looks like a retriever (search/get/query/…)",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:Z=>b(Z.target.checked)}),s.jsxs("span",{className:"tile-label",style:{margin:0},children:["Retrievers only — ",Te.length," of ",we.length," tools"]})]}),s.jsxs("label",{className:"row",style:{gap:8,alignItems:"center",cursor:"pointer",fontSize:12.5,marginTop:10},children:[s.jsx("input",{type:"checkbox",checked:m,onChange:Z=>x(Z.target.checked)}),s.jsxs("span",{children:["Full chain ",s.jsx("span",{className:"muted",children:"query → retrieve → answer"})]})]}),s.jsxs("label",{className:"row",style:{gap:8,alignItems:"center",cursor:"pointer",fontSize:12.5,marginTop:6},children:[s.jsx("input",{type:"checkbox",checked:j,onChange:Z=>S(Z.target.checked)}),s.jsxs("span",{children:["Fault resilience ",s.jsx("span",{className:"muted",children:"empty / error / malformed retrieval"})]})]}),s.jsx("div",{className:"tile-label",style:{marginTop:8},children:"Full-chain and fault checks are enabled by default for RAG assurance."})]}),s.jsxs("div",{className:"tile rag-config-card",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${ze?"pass":"info"}`}),s.jsx("span",{className:"tile-name",children:"Evaluation mode"})]}),s.jsxs("div",{className:"stack rag-model-flow",children:[s.jsxs("div",{className:`rag-model-card target ${A?"required":"optional"}`,children:[s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"center",marginBottom:7},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:700},children:"Target model"}),s.jsx("span",{className:`tag ${ne?"pass":"warn"}`,children:A?ne?"configured":"required":"not used"})]}),s.jsx(Qr,{className:"btn sm ghost",label:ve!=null&&ve.model?`Target · ${ve.model}`:"Configure target"}),s.jsx("div",{className:"tile-label",style:{marginTop:7},children:A?"Required by full-chain answers, fault resilience, or agent tool selection.":"Not used in deterministic retrieval-only mode."})]}),s.jsx("div",{className:"rag-flow-arrow","aria-hidden":"true",children:"↓"}),s.jsxs("div",{className:"rag-model-card judge",children:[s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"center",marginBottom:7},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:700},children:"Grading strategy"}),s.jsx("span",{className:`tag ${w==="deterministic"?"pass":Ee?"informational":"warn"}`,children:w==="deterministic"?"no judge LLM":w==="same-model"?"target judges":Ee?"judge ready":"judge required"})]}),s.jsxs("select",{className:"field",value:w,onChange:Z=>C(Z.target.value),style:{fontSize:12.5},children:[s.jsx("option",{value:"deterministic",children:"Rules only · no judge LLM"}),s.jsx("option",{value:"same-model",children:"Target LLM as judge"}),s.jsx("option",{value:"independent",children:"Independent judge LLM"})]}),w==="independent"&&s.jsx(UE,{}),w==="independent"&&s.jsxs("div",{className:"mono",style:{fontSize:11.5,padding:"8px 10px",border:"1px solid var(--line)",borderRadius:7},children:[s.jsx("span",{className:"muted",children:"Target"})," ",(ve==null?void 0:ve.model)||"not configured",s.jsx("span",{className:"muted",children:" → Judge"})," ",(z==null?void 0:z.model)||"not configured"]}),s.jsx("span",{className:"tile-label",style:{margin:0},children:w==="independent"?"A separate model grades groundedness and relevance, reducing self-judging bias. Prooflane records the definition, never either key.":w==="same-model"?"The target model also judges its answer. Useful for semantic regression, but not an independent verdict.":"Transparent retrieval checks and groundedness heuristics with no model judge."})]}),s.jsxs("div",{className:"rag-mode-explanation",children:[s.jsx("strong",{children:ze?"Fully deterministic run":w==="deterministic"?"Deterministic grader, AI-generated answer":"AI-generated and AI-graded run"}),s.jsx("span",{children:ze?"Directly tests the selected MCP retriever using rules. No target or judge model is called.":w==="deterministic"?"The target LLM is still used by the enabled chain/fault checks; only the grading step is deterministic.":"The target generates the answer and the selected model strategy evaluates it."}),!ze&&s.jsx("button",{type:"button",className:"btn sm ghost",onClick:be,children:"Use no-LLM retrieval mode"})]})]})]}),s.jsxs("div",{className:"tile rag-config-card",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${dt?"pass":"info"}`}),s.jsx("span",{className:"tile-name",children:"Golden baseline"})]}),s.jsx("div",{className:"tile-value",style:{fontSize:15},children:dt?"Recorded":"Not set"}),s.jsx("div",{className:"tile-label",style:{marginTop:6},children:dt?"Future runs compare retrieved results against this reference.":"Save a successful run to detect retrieval drift on future runs."}),s.jsxs("div",{className:"row",style:{gap:6,marginTop:6},children:[s.jsx("button",{className:"btn sm ghost",onClick:At,disabled:!N,children:"Set from last run"}),dt&&s.jsx("button",{className:"btn sm ghost",onClick:es,children:"Clear"})]})]})]}),(N||H.length>0)&&s.jsxs(mo,{title:"Saved regression suites",sub:"Snapshot a completed collection of test cases, then download and tag that exact suite for CI regression.",children:[N&&s.jsxs("div",{className:"row",style:{gap:8,marginBottom:10,alignItems:"center"},children:[s.jsx("input",{className:"field",style:{maxWidth:360},value:K,onChange:Z=>ce(Z.target.value),placeholder:"Regression name (for example: Support RAG baseline)"}),s.jsx("button",{className:"btn sm primary",onClick:Js,children:"Save last run"})]}),H.length===0?s.jsx("div",{className:"muted",style:{fontSize:12.5},children:"No saved regressions yet."}):s.jsx("div",{className:"stack",style:{gap:7},children:H.map(Z=>{const Ue=`rag-${eS(Z.name)}.json`;return s.jsxs("div",{className:"card row spread",style:{padding:"10px 12px",gap:12},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,fontSize:13},children:Z.name}),s.jsxs("div",{className:"muted",style:{fontSize:11.5},children:[Z.overall,"/100 · ",Z.passed,"/",Z.total," clean · ",Z.judgeStrategy==="independent"?"custom judge":Z.judgeStrategy==="same-model"?"target LLM judge":"deterministic"," · ",new Date(Z.savedAt).toLocaleString()]})]}),s.jsxs("div",{className:"row",style:{gap:6},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{var $e;g(Z.cases),x(Z.chain),S(Z.faults),C(Z.judgeStrategy),f(Z.selectedTool||(($e=Z.cases[0])==null?void 0:$e.tool)||"")},children:"Load"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>ZE(Ue,JSON.stringify(Z.cases,null,2)),children:"Download"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{ie(Z),R(!0)},children:"Tag"})]})]},Z.id)})})]}),(ue||ae)&&s.jsx(jd,{title:Ne,state:ge,hint:"calling the live retriever",onStop:xt}),N&&s.jsxs(s.Fragment,{children:[I&&I.comparable&&(I.delta!==0||I.causes.length>0)&&s.jsx(f_,{diff:I}),s.jsx(mo,{title:"Assurance posture",children:s.jsxs("div",{className:"tiles",children:[s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${yn(N.overall)}`}),s.jsx("span",{className:"tile-name",children:"RAG Assurance score"})]}),s.jsx("div",{className:"tile-value",style:{color:`var(--${yn(N.overall)})`},children:N.overall}),s.jsxs("div",{className:"tile-label",children:["across ",N.total," quer",N.total===1?"y":"ies"]})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${N.passed===N.total?"pass":"warn"}`}),s.jsx("span",{className:"tile-name",children:"Clean"})]}),s.jsxs("div",{className:"tile-value",children:[N.passed,"/",N.total]}),s.jsx("div",{className:"tile-label",children:"queries passed every check"})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${N.results.some(Z=>Z.drift==="drift")?"fail":"pass"}`}),s.jsx("span",{className:"tile-name",children:"Drift"})]}),s.jsx("div",{className:"tile-value",children:N.results.filter(Z=>Z.drift==="drift").length}),s.jsx("div",{className:"tile-label",children:dt?"queries changed vs. golden":"set a golden baseline to track"})]}),N.judge&&s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${N.judge.strategy==="independent"?"pass":"info"}`}),s.jsx("span",{className:"tile-name",children:"Judge strategy"})]}),s.jsx("div",{className:"tile-value",style:{fontSize:19},children:N.judge.strategy==="independent"?"Independent":N.judge.strategy==="same-model"?"Same model":"Deterministic"}),s.jsx("div",{className:"tile-label",children:N.judge.model?`${N.judge.provider} · ${N.judge.model}`:"Retrieval evidence + heuristic"})]})]})}),s.jsx(mo,{title:"Dimensions",sub:"Score per assurance dimension (0–100). Only dimensions with data for this run are shown.",children:s.jsx("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:[...N.dimensions].sort((Z,Ue)=>Z.score-Ue.score).map(Z=>s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${yn(Z.score)}`}),s.jsx("span",{className:"tile-name",children:Ix[Z.dimension]})]}),s.jsx("div",{className:"tile-value",style:{fontSize:22,color:`var(--${yn(Z.score)})`},children:Z.score}),s.jsx("div",{className:"tile-label",children:d_[Z.dimension]})]},Z.dimension))})}),s.jsx(mo,{title:"Queries",sub:"Every query this run — click for retrieval, checks, and (if enabled) the generated answer.",children:s.jsx("div",{className:"stack",style:{gap:6},children:N.results.map(Z=>{var Ue;return s.jsx(AL,{r:Z,golden:Ke[Z.case.id],open:X===Z.case.id,onToggle:()=>me(X===Z.case.id?null:Z.case.id),targetModel:ve==null?void 0:ve.model,judgeModel:(Ue=N.judge)==null?void 0:Ue.model},Z.case.id)})})})]}),Be&&s.jsx(ML,{probe:Be.case,report:Be.report,targetModel:ve==null?void 0:ve.model,judgeModel:((ii=N==null?void 0:N.judge)==null?void 0:ii.model)??(z==null?void 0:z.model),onSave:Ye,onDiscard:()=>st(null)}),(_e.length>0||V.length>0)&&s.jsxs(mo,{title:"Generated by Assurance Intelligence",sub:"Trusted native RAG drafts enter the existing case editor and runner. Reviewing an artifact never approves its containing suite.",children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"center",marginBottom:10},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[_e.length," native draft",_e.length===1?"":"s"," · ",V.length," deferred"]}),o&&s.jsx("button",{className:"btn sm ghost",onClick:o,children:"Back to generation →"})]}),s.jsx("div",{className:"stack",style:{gap:7},children:_e.map(Z=>{var Pt,$t;const Ue=Z.test.rag,$e=Z.test.intelligence,mt=`${Z.generationId}:${Z.test.id}`;return Ue?s.jsx("div",{className:"card",style:{padding:"11px 13px"},children:s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{style:{minWidth:0,flex:"1 1 360px"},children:[s.jsxs("div",{className:"row",style:{gap:7,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("strong",{style:{fontSize:13},children:ta(Ue)}),s.jsx("span",{className:"tag info",children:($e==null?void 0:$e.source)??((Pt=Ue.intelligence)==null?void 0:Pt.source)??"RULE"}),s.jsx("span",{className:`tag ${($e==null?void 0:$e.reviewStatus)==="APPROVED"?"pass":($e==null?void 0:$e.reviewStatus)==="MODIFIED"?"warn":"informational"}`,children:($e==null?void 0:$e.reviewStatus)??"DRAFT"}),s.jsx("span",{className:`tag ${($e==null?void 0:$e.authoringStatus)==="EXECUTABLE"?"pass":"warn"}`,children:($e==null?void 0:$e.authoringStatus)??"AUTHORED"}),s.jsx("span",{className:`tag ${Z.validation.status==="VALID"?"pass":"fail"}`,children:Z.validation.status})]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5},children:[Ue.query," · ",s.jsx("span",{className:"mono",children:Ue.tool})]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5},children:[$e==null?void 0:$e.reason," · trusted golden ",s.jsx("span",{className:"mono",children:($t=Ue.intelligence)==null?void 0:$t.trustedGoldenRef})," · ",Ue.judgeStrategy??"deterministic"," judge"]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5},children:["Expected ",Z.validation.expectedOutcome," · ",Z.validation.executionBoundary.replaceAll("_"," ").toLowerCase()," · ",Z.validation.detail]}),s.jsxs("details",{style:{marginTop:5},children:[s.jsx("summary",{className:"muted",style:{cursor:"pointer",fontSize:11},children:"Inspect generated invocation input"}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",margin:"7px 0 0"},children:JSON.stringify(Ue.input??{query:Ue.query},null,2)})]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10},children:[Z.generationId," · ",Z.suiteId," v",Z.suiteVersion]})]}),s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap"},children:[o&&s.jsx("button",{className:"btn sm ghost",onClick:()=>{localStorage.setItem("prooflane.intelligence.focusGeneration",Z.generationId),o()},children:"Generation →"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>Dt(Z),children:"Open in editor"}),Z.suiteStatus==="DRAFT"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",disabled:ee===mt,onClick:()=>void pe(Z,"REJECTED"),children:"Reject"}),s.jsx("button",{className:"btn sm primary",disabled:ee===mt||Z.validation.blocksApproval,onClick:()=>void pe(Z,"APPROVED"),children:"Approve"})]})]})]})},mt):null})}),V.length>0&&s.jsxs("details",{style:{marginTop:12},children:[s.jsxs("summary",{className:"muted",style:{cursor:"pointer",fontSize:12.5},children:[V.length," deferred RAG recommendation",V.length===1?"":"s"]}),s.jsx("div",{className:"stack",style:{gap:6,marginTop:8},children:V.map(Z=>s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:Z.deferredReason??"DEFERRED"}),s.jsxs("span",{children:[s.jsx("b",{children:Z.testType})," · ",Z.reason]})]},`${Z.generationId}:${Z.recommendationId}:${Z.testType}`))})]})]}),s.jsxs(mo,{title:"Saved RAG test cases",sub:"Reusable retrieval regressions. Run one case or the complete library; edit the name, query, expectations and retrieval arguments at any time.",children:[s.jsxs("div",{className:"row spread",style:{marginBottom:10,alignItems:"center"},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[h.length," saved case",h.length===1?"":"s"]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{he(!0),st(null),se({...po(),mode:m?"full-chain":"retriever-only"})},children:"+ Add RAG test"}),s.jsx("button",{className:"btn sm primary",onClick:()=>void ht(),disabled:ue||!t||h.length===0,children:ue?"Running…":`Run all${h.length?` (${h.length})`:""}`})]})]}),T&&s.jsxs("div",{className:"card",style:{marginBottom:10,padding:14,borderColor:"var(--info)"},children:[s.jsx("div",{className:"detail-title",style:{fontSize:13,marginBottom:8},children:"New RAG test case"}),s.jsx(aS,{c:q,agentic:k,chainEnabled:m,tools:we,selectedTool:v,onPatch:Z=>se(Ue=>({...Ue,...Z}))}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:10,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{he(!1),st(null)},children:"Cancel"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>Xt(!1),disabled:!Zs(q).trim(),children:"Save"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void rs(q),disabled:ae||ue||!t||!Zs(q).trim(),title:"Execute this case now without saving it. Full RAG Assurance results; nothing is written to history.",children:ae?"Running…":"Run once"}),s.jsx("button",{className:"btn sm primary",onClick:()=>Xt(!0),disabled:!t||!Zs(q).trim(),children:"Save & run"})]})]}),h.length===0&&!T?s.jsx("div",{className:"card",style:{padding:20},children:s.jsxs("div",{className:"stack",style:{gap:8,alignItems:"flex-start"},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:"No saved RAG test cases."}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"Run a query once, add a manual RAG case, or create a reusable regression."}),s.jsx("button",{className:"btn sm primary",onClick:()=>{he(!0),se({...po(),mode:m?"full-chain":"retriever-only"})},children:"Add RAG test"})]})}):s.jsx("div",{className:"stack",style:{gap:7},children:h.map(Z=>{var xs;const Ue=_[Z.id],$e=He[Z.id],mt=WE(Z,m),Pt=dt?Ue?Ue.drift:"unknown":"none",$t=Z.expectedKeywords??[];return s.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden"},children:[s.jsxs("div",{className:"row spread",style:{padding:"11px 13px",gap:12,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{style:{minWidth:0,flex:"1 1 320px"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",minWidth:0},children:[s.jsx("span",{style:{fontWeight:600,fontSize:13,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ta(Z)}),s.jsx("span",{className:"tag info",children:wL[mt]}),s.jsx(LL,{state:Pt})]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[mt==="full-chain"?"Query":"Retrieval query",": ",Zs(Z)||"—"]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5},children:[s.jsx("span",{className:"mono",children:k?"agent selects tool":a??Z.tool??v??"no tool"}),$t.length>0&&s.jsxs(s.Fragment,{children:[" · expects ",s.jsxs("span",{className:"mono",children:[$t.slice(0,4).join(", "),$t.length>4?"…":""]})]}),Ue?s.jsxs(s.Fragment,{children:[" · last ",Ue.score,"/100 · ",Ue.latencyMs,"ms"]}):s.jsx(s.Fragment,{children:" · not run in this session"})]})]}),s.jsxs("div",{className:"row",style:{gap:6,flexShrink:0,flexWrap:"wrap"},children:[Ue&&s.jsx("span",{className:`tag ${yn(Ue.score)}`,children:Ue.score}),s.jsx("button",{className:"btn sm",onClick:()=>void ht([Z]),disabled:ue||!t,children:"Run"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>P(fe===Z.id?null:Z.id),"aria-expanded":fe===Z.id,children:fe===Z.id?"Close edit":"Edit"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>zs(Z),title:"Create an editable copy of this case",children:"Duplicate"}),s.jsx(Qr,{className:"btn sm ghost",label:"Edit model"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>qe(Ot=>({...Ot,[Z.id]:$e==="query"?void 0:"query"})),children:"Query"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>qe(Ot=>({...Ot,[Z.id]:$e==="json"?void 0:"json"})),children:"JSON"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>Xe(Z.id),title:"Delete saved test","aria-label":`Delete ${ta(Z)}`,children:"✕"})]})]}),fe===Z.id&&s.jsxs("div",{style:{padding:"0 13px 13px",borderTop:"1px solid var(--border)"},children:[s.jsx(aS,{c:Z,agentic:k,chainEnabled:m,tools:we,selectedTool:v,onPatch:Ot=>_t(Z.id,{...Ot,updatedAt:new Date().toISOString()})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:7,marginTop:8},children:[((xs=Z.intelligence)==null?void 0:xs.generationId)&&Z.intelligence.nativeTestRef&&(()=>{const Ot=_e.find(zt=>{var xa,Ts;return zt.generationId===((xa=Z.intelligence)==null?void 0:xa.generationId)&&zt.test.id===((Ts=Z.intelligence)==null?void 0:Ts.nativeTestRef)});return Ot?s.jsx("button",{className:"btn sm ghost",disabled:ee===`${Ot.generationId}:${Ot.test.id}`,onClick:()=>void pe(Ot,"MODIFIED",Z),children:"Apply to Intelligence draft"}):null})(),s.jsx("button",{className:"btn sm primary",onClick:()=>P(null),children:"Save changes"})]})]}),$e==="query"&&s.jsx("div",{style:{padding:"10px 13px",borderTop:"1px solid var(--border)"},children:s.jsx(bd,{label:mt==="full-chain"?"User query / prompt":"Retrieval query",children:Zs(Z)})}),$e==="json"&&s.jsx("div",{style:{padding:"10px 13px",borderTop:"1px solid var(--border)"},children:s.jsx(bd,{label:"Tool input JSON",mono:!0,children:JSON.stringify(HE(Z),null,2)})})]},Z.id)})})]})]})]})}function kL(e){if(Array.isArray(e))return e;if(e&&typeof e=="object"){for(const t of Object.values(e))if(Array.isArray(t))return t}return null}function EL(e){if(e==null)return"(null)";if(typeof e=="string")return e.slice(0,100);if(typeof e=="object"){const t=e;for(const a of["id","uri","url","path","filename","file","title","name","doc","document","source","key","slug"])if(typeof t[a]=="string")return t[a];const n=Object.values(t).find(a=>typeof a=="string");return(n!=null?String(n):JSON.stringify(t)).slice(0,100)}return String(e).slice(0,100)}function sS(e){let t;try{t=JSON.parse(e)}catch{return[]}const n=kL(t);return n?n.map(EL):[]}function _L(e,t){const n=sS(e),a=sS(t),r=new Set(n),i=new Set(a),o=n.filter(v=>!i.has(v)),l=a.filter(v=>!r.has(v)),c=n.filter(v=>i.has(v)),u=new Set([...n,...a]),d=u.size?Math.round(c.length/u.size*100):100,g=o.length===0&&l.length===0&&n.length===a.length&&n.join("|")!==a.join("|");return{golden:n,current:a,removed:o,added:l,overlap:d,reordered:g,docsParsed:n.length>0||a.length>0}}function CL({goldenSig:e,currentSig:t}){const n=_L(e,t);return s.jsxs("div",{className:"stack",style:{gap:8,padding:"10px 12px",border:"1px solid var(--fail)",borderRadius:8},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Retrieval diff — golden vs. current"}),n.docsParsed?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row",style:{gap:24,flexWrap:"wrap"},children:[s.jsx(Pu,{label:"Golden",docs:n.golden,tone:"info"}),s.jsx(Pu,{label:"Current",docs:n.current,tone:"info"})]}),s.jsxs("div",{className:"row",style:{gap:24,flexWrap:"wrap"},children:[s.jsx(Pu,{label:`Removed (${n.removed.length})`,docs:n.removed,tone:"fail"}),s.jsx(Pu,{label:`Added (${n.added.length})`,docs:n.added,tone:"pass"})]}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[n.removed.length||n.added.length?`${n.overlap}% document overlap · ${n.removed.length} removed, ${n.added.length} added.`:n.reordered?"Same documents retrieved — the order changed.":"Same documents retrieved — content or scores changed (the raw result differs)."," ",s.jsx("span",{style:{opacity:.75},children:"Overlap is by retrieved-document set (no embedding model runs locally)."})]})]}):s.jsx("span",{className:"muted",style:{fontSize:12},children:"The result isn't a list of documents, so no per-document diff. The raw retrieved content differs from the golden baseline."})]})}function Pu({label:e,docs:t,tone:n}){return s.jsxs("div",{className:"stack",style:{gap:3,minWidth:200},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),t.length===0?s.jsx("span",{className:"muted",style:{fontSize:12},children:"—"}):t.map((a,r)=>s.jsxs("span",{className:"mono",style:{fontSize:12,color:`var(--${n})`},children:[r+1,". ",a]},r))]})}function nS(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function TL(e){var u;let t=null;try{t=JSON.parse(e)}catch{}const n=(u=e.match(/MCP error\s*(-?\d+)/i))==null?void 0:u[1],a=[...new Set([...e.matchAll(/(?:status|http|code)["'\s:]*?(\d{3})/gi)].map(d=>d[1]))],r=d=>{const h=d;return typeof(h==null?void 0:h.error)=="string"?h.error:typeof(h==null?void 0:h.message)=="string"?h.message:typeof(h==null?void 0:h.detail)=="string"?h.detail:""};let i=t?r(t)||r(t==null?void 0:t.error):e;i||(i=nS(e));let o,l,c;return a.length>=2?(o=a[0],l=a[a.length-1]):a.length===1&&(c=a[0]),{upstream:o,mcp:n??void 0,wrapper:l,lone:c,message:i.slice(0,800),raw:nS(e).slice(0,1600)}}function RL({sig:e}){const t=TL(e),n=t.upstream||t.mcp||t.wrapper||t.lone;return s.jsxs("div",{className:"stack",style:{gap:6,padding:"10px 12px",border:"1px solid var(--fail)",borderRadius:8},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Retrieval error"}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",alignItems:"center"},children:[t.upstream&&s.jsxs("span",{className:"tag warn",children:["Upstream API · ",t.upstream]}),t.wrapper&&s.jsxs("span",{className:"tag fail",children:["Tool wrapper · ",t.wrapper]}),t.mcp&&s.jsxs("span",{className:"tag fail",children:["MCP transport · ",t.mcp]}),t.lone&&s.jsxs("span",{className:"tag fail",children:["Status · ",t.lone]}),!n&&s.jsx("span",{className:"tag fail",children:"error"})]}),t.message&&s.jsx(bd,{label:"Message",children:t.message}),s.jsxs("details",{children:[s.jsx("summary",{className:"muted",style:{fontSize:11,cursor:"pointer"},children:"Raw error"}),s.jsx("div",{className:"mono",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",marginTop:4,opacity:.8},children:t.raw})]})]})}function IL(e){return e==="PASS"?"pass":e==="FAIL"?"fail":e==="INCONCLUSIVE"?"warn":"info"}function m_({result:e}){var u,d;const t=e.answerEvidence;if(!t)return null;const n=t.contextDiagnostics,a=e.case.requiredAnswerFacts??[],r=t.facts.filter(h=>h.retrieved&&!h.usedInAnswer),i=((d=(u=e.case.contextDiagnostics)==null?void 0:u.broadChunkIds)==null?void 0:d.length)??0,o=e.checks.find(h=>h.dimension==="retriever-behavior"),l=(h,g,v)=>s.jsxs("div",{className:"stack",style:{gap:4,minWidth:160,padding:10,border:"1px solid var(--border)",borderRadius:8},children:[s.jsx("span",{className:"muted",style:{fontSize:10,textTransform:"uppercase",letterSpacing:".45px"},children:h}),s.jsx("span",{className:`tag ${IL(g)}`,style:{alignSelf:"flex-start"},children:g.replaceAll("_"," ")}),s.jsx("span",{className:"muted",style:{fontSize:11.5,lineHeight:1.4},children:v})]}),c=o!=null&&o.pass?"PASS":"FAIL";return s.jsxs("section",{"aria-label":"RAG answer evidence",className:"stack",style:{gap:10,padding:"12px 14px",border:"1px solid var(--info)",borderRadius:10,background:"color-mix(in srgb, var(--info) 5%, transparent)"},children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("strong",{style:{fontSize:13},children:"Answer evidence"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Retrieved evidence is not the same as evidence used in the answer."})]}),s.jsx("span",{className:"tag info",children:"additive diagnostic · does not change legacy score"})]}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:8},children:[l("Retrieval",c,`${e.resultCount} chunk${e.resultCount===1?"":"s"} returned`),l("Decisive evidence",t.decisiveEvidenceUsed.status,t.decisiveEvidenceUsed.finding??"Required facts were traced from context to answer."),l("Answer completeness",t.answerCompleteness.status,t.answerCompleteness.missingFactIds.length?`${t.answerCompleteness.missingFactIds.length} required fact${t.answerCompleteness.missingFactIds.length===1?"":"s"} omitted`:"All configured required facts were present."),l("Faithfulness",e.faithfulness===void 0?"INCONCLUSIVE":e.faithfulness>=70?"PASS":"FAIL",e.faithfulness===void 0?"No chain score.":`${e.faithfulness}/100`),l("Relevance",e.relevance===void 0?"INCONCLUSIVE":e.relevance>=70?"PASS":"FAIL",e.relevance===void 0?"No chain score.":`${e.relevance}/100`),s.jsxs("div",{className:"stack",style:{gap:4,minWidth:160,padding:10,border:"1px solid var(--border)",borderRadius:8},children:[s.jsx("span",{className:"muted",style:{fontSize:10,textTransform:"uppercase",letterSpacing:".45px"},children:"Context diagnostics"}),s.jsxs("strong",{style:{fontSize:12.5},children:[n.retrievedChunkCount," chunks · ",n.retrievedTokenCount.toLocaleString()," tokens"]}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Decisive rank ",n.decisiveChunkRank??"—",n.decisiveChunkScore===void 0?"":` · score ${n.decisiveChunkScore}`]}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Broad content ",(n.broadContentTokenShare*100).toFixed(1),"% · ",n.broadContentTokenCount.toLocaleString()," tokens"]})]})]}),t.facts.length>0&&s.jsxs("div",{className:"stack",style:{gap:6},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:".4px"},children:"Required fact trace"}),t.facts.map(h=>s.jsxs("div",{className:"row spread",style:{gap:10,padding:"7px 9px",border:"1px solid var(--border)",borderRadius:7,flexWrap:"wrap"},children:[s.jsx("span",{className:"mono",style:{fontSize:11.5},children:h.key}),s.jsxs("div",{className:"row",style:{gap:6},children:[s.jsx("span",{className:`tag ${h.retrieved?"pass":"fail"}`,children:h.retrieved?"retrieved":"not retrieved"}),s.jsx("span",{className:`tag ${h.usedInAnswer?"pass":"fail"}`,children:h.usedInAnswer?"used":"omitted"})]})]},h.factId))]}),r.map(h=>{const g=a.find(f=>f.id===h.factId),v=(g==null?void 0:g.canonicalText)??((g==null?void 0:g.expectedValue)===void 0?h.key:String(g.expectedValue));return s.jsxs("span",{className:"muted",style:{fontSize:11.5,lineHeight:1.45},children:['The answer-supporting fact "',v,'" was present in the retrieved context but was not reflected in the final answer.']},`detail-${h.factId}`)}),i>0&&n.broadContentTokenCount>0&&s.jsxs("span",{className:"muted",style:{fontSize:11.5,lineHeight:1.45},children:["This fixture retrieved ",n.retrievedChunkCount," chunks totaling ",n.retrievedTokenCount.toLocaleString()," tokens. ",i," fixture-classified broad chunks consumed ",(n.broadContentTokenShare*100).toFixed(1),"% of that budget."]}),t.answerCompleteness.judgeScore!==void 0&&s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Judge completeness: ",t.answerCompleteness.judgeScore,"/100 · advisory only; deterministic required-fact matching remains authoritative."]}),s.jsx("span",{className:"muted",style:{fontSize:11,lineHeight:1.45},children:t.scopeQualifier})]})}function AL({r:e,golden:t,open:n,onToggle:a,targetModel:r,judgeModel:i}){const o=yn(e.score),[l,c]=p.useState(!0),u=e.drift==="drift"?s.jsx("span",{className:"tag fail",children:"drift"}):e.drift==="match"?s.jsx("span",{className:"tag pass",children:"golden match"}):e.drift==="new"?s.jsx("span",{className:"tag info",children:"new"}):null;return s.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden",borderColor:o==="fail"?"var(--fail)":void 0},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:12,padding:"10px 14px",cursor:"pointer"},onClick:a,children:[s.jsxs("div",{className:"stack",style:{gap:2,minWidth:0},children:[s.jsx("span",{style:{fontSize:13,fontWeight:500},children:ta(e.case)||"(empty query)"}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[s.jsx("span",{className:"mono",children:e.tool})," · ",e.resultCount," result",e.resultCount===1?"":"s"," · ",e.latencyMs,"ms"]})]}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexShrink:0},children:[u,s.jsx("span",{className:`tag ${o}`,children:e.score}),s.jsx("span",{className:"muted",style:{fontSize:11},children:n?"▲":"▼"})]})]}),n&&s.jsxs("div",{className:"stack",style:{gap:12,padding:"12px 14px",borderTop:"1px solid var(--border)",background:"var(--bg-subtle, rgba(127,127,127,0.04))"},children:[s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsxs("button",{type:"button",className:"btn sm ghost",style:{alignSelf:"flex-start"},"aria-expanded":l,onClick:()=>c(d=>!d),children:[l?"▾":"▸"," ",(e.mode??(e.answer!==void 0?"full-chain":"retriever-only"))==="full-chain"?"Chain proof":"Retrieval proof"]}),l&&s.jsx(g_,{steps:BE(e,{targetModel:r,judgeModel:i})})]}),s.jsx("div",{className:"stack",style:{gap:6},children:e.checks.map(d=>s.jsxs("div",{className:"row spread",style:{alignItems:"center"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{style:{color:`var(--${d.pass?"pass":"fail"})`,fontWeight:700,width:12},children:d.pass?"✓":"✗"}),s.jsx("span",{style:{fontSize:12.5},children:Ix[d.dimension]})]}),s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[s.jsx("span",{className:"muted",style:{fontSize:12},children:d.detail}),s.jsx("span",{className:`tag ${yn(d.score)}`,children:d.score})]})]},d.dimension))}),e.drift==="drift"&&t&&s.jsx(CL,{goldenSig:t,currentSig:e.signature}),e.selection&&s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Agent routing"}),s.jsxs("span",{style:{fontSize:12.5},children:["Router picked ",s.jsx("span",{className:"mono",style:{color:e.selection.picked===e.case.expectedTool||!e.case.expectedTool?"var(--pass)":"var(--fail)"},children:e.selection.picked??"(unresolved)"}),e.case.expectedTool&&s.jsxs(s.Fragment,{children:[" · expected ",s.jsx("span",{className:"mono",children:e.case.expectedTool})]})]}),e.selection.reason&&s.jsxs("span",{className:"muted",style:{fontSize:12},children:["Reason: ",e.selection.reason]}),e.selection.raw&&e.selection.raw!==e.selection.reason&&s.jsx("div",{className:"mono",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",opacity:.7},children:e.selection.raw.length>300?e.selection.raw.slice(0,300)+" …":e.selection.raw})]}),e.faithfulness!==void 0&&e.relevance!==void 0&&s.jsxs("div",{className:"row",style:{gap:20,flexWrap:"wrap"},children:[s.jsx(rS,{label:"Faithfulness",value:e.faithfulness}),s.jsx(rS,{label:"Answer relevance",value:e.relevance}),s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Judge"}),s.jsx("span",{style:{fontSize:12.5},children:e.judged?"LLM-judged":"heuristic"})]})]}),s.jsx(m_,{result:e}),e.answer!==void 0&&s.jsx(bd,{label:"Generated answer",children:e.answer||"(no answer)"}),s.jsx(SL,{result:e}),e.resilience&&e.resilience.length>0&&s.jsxs("div",{className:"stack",style:{gap:6},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Resilience — injected retrieval faults"}),e.resilience.map((d,h)=>s.jsxs("div",{className:"stack",style:{gap:2,borderLeft:`2px solid var(--${d.abstained?"pass":"fail"})`,paddingLeft:10},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{className:"pill mono",style:{fontSize:11.5},children:vL[d.type]??d.type}),s.jsx("span",{className:"muted",children:"→"}),s.jsx("span",{className:`tag ${d.abstained?"pass":"fail"}`,children:d.abstained?"Abstained ✓":"Hallucinated ✗"})]}),s.jsx("span",{className:"mono",style:{fontSize:11.5,opacity:.8,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:d.answer.length>240?d.answer.slice(0,240)+" …":d.answer||"(no answer)"})]},h)),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"A resilient chain refuses to answer from empty / errored / corrupted context instead of inventing one."})]}),e.isError&&e.signature?s.jsx(RL,{sig:e.signature}):e.signature?s.jsx(bd,{label:"Retrieved context",mono:!0,children:e.signature.length>1200?e.signature.slice(0,1200)+" …":e.signature}):null]})]})}const PL=".kawach/rag-cases.json";function f_({diff:e}){const t=e.delta>0,n=e.delta===0,a=n?"info":t?"pass":"fail",r=n?"→":t?"▲":"▼";return s.jsxs("div",{className:"card",style:{padding:16,borderColor:`var(--${a})`},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",flexWrap:"wrap",gap:8,marginBottom:e.causes.length?12:0},children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline"},children:[s.jsx("span",{style:{fontSize:14,fontWeight:600},children:"Why did the score change?"}),s.jsxs("span",{className:"mono",style:{fontSize:13},children:[e.from," ",s.jsx("span",{className:"muted",children:"→"})," ",e.to]}),s.jsxs("span",{className:`tag ${a}`,children:[r," ",Math.abs(e.delta)]})]}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"vs. the previous run"})]}),e.causes.length>0?s.jsx("div",{className:"stack",style:{gap:8},children:e.causes.map((i,o)=>{const l=i.points<0;return s.jsxs("div",{className:"row",style:{gap:12,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsxs("span",{className:"mono",style:{fontSize:13,minWidth:44,color:`var(--${l?"fail":"pass"})`,fontWeight:600},children:[l?"":"+",i.points]}),s.jsx("span",{style:{fontSize:13,minWidth:150},children:i.label}),i.detail&&s.jsx("span",{className:"muted mono",style:{fontSize:12},children:i.detail})]},o)})}):s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"No per-dimension movement to attribute."}),(e.addedCases.length>0||e.removedCases.length>0)&&s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:10},children:[e.addedCases.length>0&&s.jsxs(s.Fragment,{children:["+",e.addedCases.length," new quer",e.addedCases.length===1?"y":"ies"," this run. "]}),e.removedCases.length>0&&s.jsxs(s.Fragment,{children:[e.removedCases.length," quer",e.removedCases.length===1?"y":"ies"," removed since last run."]})]})]})}function $L(e){if(!e)return[];try{const t=JSON.parse(e);return[...new Set((t.cases??[]).map(n=>{var a;return(a=n.answerEvidence)==null?void 0:a.findingCode}).filter(n=>!!n))]}catch{return[]}}function OL({runs:e,hostedRunner:t=!1}){const[n,a]=p.useState(null),[r,i]=p.useState({});async function o(l){const c=n===l?null:l;if(a(c),c&&r[l]===void 0){i(u=>({...u,[l]:"loading"}));try{const u=await O.ragDiff(l,t);i(d=>({...d,[l]:u.diff??null}))}catch{i(u=>({...u,[l]:null}))}}}return s.jsx("div",{className:"stack",style:{gap:8},children:e.map(l=>{const c=n===l.id,u=r[l.id],d=$L(l.evidence);return s.jsxs("div",{className:"card",style:{padding:0},children:[s.jsxs("div",{className:"row spread",style:{padding:"12px 14px",cursor:"pointer",alignItems:"center",gap:10},onClick:()=>o(l.id),children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{className:"muted",style:{fontSize:10},children:c?"▼":"▶"}),s.jsxs("span",{className:`tag ${yn(l.score??0)}`,children:["Score ",l.score??"—"]}),s.jsx("span",{style:{fontSize:13},children:l.label}),l.finding&&s.jsxs("span",{className:"muted",style:{fontSize:12},children:["· ",l.finding]}),d.map(h=>s.jsx("span",{className:"tag warn",children:h.replaceAll("_"," ").toLowerCase()},h))]}),s.jsx("span",{className:"muted mono",style:{fontSize:11,whiteSpace:"nowrap"},children:new Date(l.createdAt).toLocaleString()})]}),c&&s.jsx("div",{style:{padding:"0 14px 14px"},children:u==="loading"||u===void 0?s.jsx(Bc,{compact:!0,label:"Comparing to the previous run…"}):u&&u.comparable?s.jsx(f_,{diff:u}):s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"No earlier run to compare against — this is the baseline."})})]},l.id)})})}function aS({c:e,agentic:t,chainEnabled:n,tools:a,selectedTool:r,onPatch:i}){var w;const o=(e.expectedKeywords??[]).join(", "),l=WE(e,n),c=l==="full-chain",[u,d]=p.useState(e.input!==void 0||!!e.tool),[h,g]=p.useState(!1),v=e.tool||(t?"":r),f=a.find(C=>C.name===v),y=e.input&&typeof e.input=="object"&&!Array.isArray(e.input)?e.input:{},b=Rv(f==null?void 0:f.inputSchema),m=e.requiredAnswerFacts??[],x=(C,k)=>i({requiredAnswerFacts:m.map(N=>N.id===C?{...N,...k}:N)}),j=C=>i({requiredAnswerFacts:m.filter(k=>k.id!==C)}),S=()=>i({requiredAnswerFacts:[...m,{id:`fact-${Math.random().toString(36).slice(2,9)}`,key:"",canonicalText:"",acceptedSemanticEquivalents:[],required:!0}]});return s.jsx("div",{className:"card",style:{padding:"12px 14px"},children:s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsx(dn,{label:"Test name",children:s.jsx("input",{className:"field",placeholder:"e.g. Failed test diagnosis",value:e.name??"",onChange:C=>i({name:C.target.value})})}),s.jsx(dn,{label:c?"User query / prompt":"Retrieval query",children:s.jsx("textarea",{className:"field",style:{minHeight:64,resize:"vertical"},placeholder:c?"Why did test DA-MAC-123 fail and how do I fix it?":"timeout webdriver failure",value:e.userQuery??e.query,onChange:C=>i({userQuery:C.target.value,query:C.target.value})})}),s.jsx("div",{className:"muted",style:{fontSize:11},children:c?"The target model receives this question, chooses or uses the retriever, and answers from the retrieved context.":"Sent directly to the retriever — no target model is required. Add exact arguments (IDs, filters) under Advanced retrieval input."}),s.jsxs("div",{className:"row",style:{gap:10,flexWrap:"wrap",alignItems:"flex-end"},children:[s.jsx(dn,{label:"Evaluation mode",children:s.jsxs("select",{className:"field",value:l,onChange:C=>i({mode:C.target.value}),children:[s.jsx("option",{value:"full-chain",children:"Full chain — query → retrieve → answer → judge"}),s.jsx("option",{value:"retriever-only",children:"Retriever only — direct retrieval regression"})]})}),s.jsx(dn,{label:"Expected terms (relevance)",children:s.jsx("input",{className:"field",style:{minWidth:220},placeholder:"timeout, webdriver, session",value:o,onChange:C=>i({expectedKeywords:C.target.value.split(",").map(k=>k.trim()).filter(Boolean)})})}),s.jsx(dn,{label:"Minimum results",children:s.jsx("input",{className:"field",type:"number",style:{width:96},value:e.minResults??1,onChange:C=>i({minResults:Number(C.target.value)||0})})}),s.jsx(dn,{label:"Maximum latency (ms)",children:s.jsx("input",{className:"field",type:"number",style:{width:128},value:e.maxLatencyMs??"",placeholder:"none",onChange:C=>i({maxLatencyMs:C.target.value?Number(C.target.value):void 0})})}),t&&s.jsx(dn,{label:"Expected tool",children:s.jsxs("select",{className:"field",value:e.expectedTool??"",onChange:C=>i({expectedTool:C.target.value||void 0}),children:[s.jsx("option",{value:"",children:"any"}),a.map(C=>s.jsx("option",{value:C.name,children:C.name},C.name))]})})]}),c&&s.jsxs("div",{className:"stack",style:{gap:9,borderTop:"1px solid var(--border)",paddingTop:10},children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("strong",{style:{fontSize:12.5},children:"Required answer facts"}),s.jsx("span",{className:"muted",style:{fontSize:11},children:"Trusted facts used to test answer completeness. Sammy and the judge cannot invent or replace them."})]}),s.jsx("button",{type:"button",className:"btn sm ghost",onClick:S,children:"+ Add fact"})]}),m.length===0?s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Not configured. Existing cases keep their current grading behavior."}):m.map((C,k)=>s.jsxs("div",{className:"stack",style:{gap:8,padding:10,border:"1px solid var(--border)",borderRadius:8},children:[s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"center"},children:[s.jsxs("span",{className:"muted mono",style:{fontSize:10.5},children:["FACT ",k+1," · ",C.id]}),s.jsx("button",{type:"button",className:"btn sm ghost",onClick:()=>j(C.id),"aria-label":`Remove fact ${k+1}`,children:"Remove"})]}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:8},children:[s.jsx(dn,{label:"Key",children:s.jsx("input",{className:"field",placeholder:"notice_period_days",value:C.key,onChange:N=>x(C.id,{key:N.target.value})})}),s.jsx(dn,{label:"Expected value",children:s.jsx("input",{className:"field",placeholder:"90",value:C.expectedValue===void 0?"":String(C.expectedValue),onChange:N=>x(C.id,{expectedValue:N.target.value||void 0})})}),s.jsx(dn,{label:"Canonical answer text",children:s.jsx("input",{className:"field",placeholder:"90 days",value:C.canonicalText??"",onChange:N=>x(C.id,{canonicalText:N.target.value||void 0})})}),s.jsx(dn,{label:"Accepted equivalents",children:s.jsx("input",{className:"field",placeholder:"three months",value:(C.acceptedSemanticEquivalents??[]).join(", "),onChange:N=>x(C.id,{acceptedSemanticEquivalents:N.target.value.split(",").map(L=>L.trim()).filter(Boolean)})})})]}),s.jsxs("label",{className:"row",style:{gap:7,alignItems:"center",fontSize:11.5},children:[s.jsx("input",{type:"checkbox",checked:C.required,onChange:N=>x(C.id,{required:N.target.checked})}),"Required for answer completeness"]})]},C.id)),s.jsx(dn,{label:"Broad context chunk IDs (trusted classification, comma separated)",children:s.jsx("input",{className:"field",placeholder:"chunk-1, chunk-3",value:(((w=e.contextDiagnostics)==null?void 0:w.broadChunkIds)??[]).join(", "),onChange:C=>i({contextDiagnostics:{broadChunkIds:C.target.value.split(",").map(k=>k.trim()).filter(Boolean)}})})})]}),s.jsxs("div",{className:"stack",style:{gap:8,borderTop:"1px solid var(--border)",paddingTop:10},children:[s.jsxs("button",{type:"button",className:"btn sm ghost",style:{alignSelf:"flex-start"},"aria-expanded":u,onClick:()=>d(C=>!C),children:[u?"▾":"▸"," Advanced retrieval input"]}),u&&s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsx(dn,{label:"Retriever tool",children:s.jsxs("select",{className:"field",value:e.tool??"",onChange:C=>i({tool:C.target.value||void 0}),children:[s.jsx("option",{value:"",children:t?"let the agent pick":`use the selected tool (${r||"none"})`}),a.map(C=>s.jsx("option",{value:C.name,children:C.name},C.name))]})}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Tool arguments"}),s.jsxs("div",{className:"tabbar",role:"tablist","aria-label":"Tool argument editor",children:[s.jsx("button",{role:"tab","aria-selected":!h,className:`tab ${h?"":"active"}`,onClick:()=>g(!1),disabled:!b,title:b?void 0:"This tool advertises no input schema",children:"Schema form"}),s.jsx("button",{role:"tab","aria-selected":h,className:`tab ${h?"active":""}`,onClick:()=>g(!0),children:"Raw JSON"})]})]}),!h&&b?s.jsx(FE,{schema:f==null?void 0:f.inputSchema,value:y,onChange:C=>i({input:Object.keys(C).length?C:void 0})}):s.jsx(GE,{value:e.input,label:"Tool arguments (JSON)",placeholder:'{ "testId": "DA-MAC-123" } — defaults to { "query": "<the query above>" }',onChange:(C,k)=>{k&&i({input:C})}}),s.jsxs("div",{className:"muted",style:{fontSize:11},children:["Leave empty to send ",s.jsx("span",{className:"mono",children:'{ "query": "<the query above>" }'}),". Arguments here are the exact payload sent to the retriever."]})]})]})]})})}function LL({state:e}){return e==="none"?s.jsx("span",{className:"tag info",title:"No golden baseline recorded yet",children:"no golden"}):e==="unknown"?s.jsx("span",{className:"tag info",title:"Golden recorded; this case has not run in this session",children:"golden set"}):e==="drift"?s.jsx("span",{className:"tag fail",children:"golden drift"}):e==="match"?s.jsx("span",{className:"tag pass",children:"golden match"}):e==="new"?s.jsx("span",{className:"tag info",children:"new vs golden"}):null}function g_({steps:e}){return s.jsx("ol",{className:"rag-proof",style:{listStyle:"none",margin:0,padding:0},children:e.map((t,n)=>s.jsxs("li",{className:"stack",style:{gap:4},children:[s.jsxs("div",{className:"stack",style:{gap:3,padding:"9px 11px",border:"1px solid var(--border)",borderRadius:8},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:t.label}),t.value&&s.jsx("span",{style:{fontSize:12.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.value}),t.json!==void 0&&s.jsx("div",{className:"mono",style:{fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(t.json,null,2)}),t.detail&&t.detail.length>0&&s.jsx("div",{className:"stack",style:{gap:2,marginTop:2},children:t.detail.map((a,r)=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",flexWrap:"wrap"},children:[a.pass!==void 0&&s.jsx("span",{style:{color:`var(--${a.pass?"pass":"fail"})`,fontWeight:700,width:12},"aria-label":a.pass?"passed":"failed",children:a.pass?"✓":"✗"}),s.jsx("span",{style:{fontSize:12},children:a.label}),s.jsx("span",{className:"muted",style:{fontSize:12},children:a.value})]},r))})]}),n<e.length-1&&s.jsx("span",{className:"muted","aria-hidden":"true",style:{fontSize:13,textAlign:"center"},children:"↓"})]},`${t.kind}-${n}`))})}function ML({probe:e,report:t,targetModel:n,judgeModel:a,onSave:r,onDiscard:i}){const o=t.results[0],l=o?BE(o,{targetModel:n,judgeModel:a}):[],c=u=>t.dimensions.find(d=>d.dimension===u);return s.jsxs("div",{className:"card",style:{padding:16,borderColor:"var(--info)"},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",gap:10,flexWrap:"wrap",marginBottom:12},children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:14,fontWeight:600},children:"Run complete"}),s.jsx("span",{className:"tag info",children:"not saved"}),s.jsx("span",{className:"muted",style:{fontSize:12},children:ta(e)})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:i,children:"Discard"}),s.jsx("button",{className:"btn sm primary",onClick:r,children:"Save as RAG test"})]})]}),s.jsxs("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))"},children:[s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${yn(t.overall)}`}),s.jsx("span",{className:"tile-name",children:"RAG Assurance score"})]}),s.jsx("div",{className:"tile-value",style:{color:`var(--${yn(t.overall)})`},children:t.overall}),s.jsx("div",{className:"tile-label",children:"this exploratory run"})]}),["retrieval-quality","chain-validation","tool-selection"].map(u=>{const d=c(u);return d?s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${yn(d.score)}`}),s.jsx("span",{className:"tile-name",children:Ix[u]})]}),s.jsx("div",{className:"tile-value",style:{fontSize:22,color:`var(--${yn(d.score)})`},children:d.score}),s.jsx("div",{className:"tile-label",children:d_[u]})]},u):null}),o&&s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${o.latencyMs<=(e.maxLatencyMs??Number.POSITIVE_INFINITY)?"pass":"warn"}`}),s.jsx("span",{className:"tile-name",children:"Latency"})]}),s.jsxs("div",{className:"tile-value",style:{fontSize:22},children:[o.latencyMs," ms"]}),s.jsxs("div",{className:"tile-label",children:[o.resultCount," result",o.resultCount===1?"":"s"]})]})]}),o&&s.jsxs("div",{className:"stack",style:{gap:10,marginTop:14},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Chain proof"}),s.jsx(g_,{steps:l}),s.jsx(m_,{result:o}),s.jsx("div",{className:"muted",style:{fontSize:11.5},children:"Nothing was written to run history or the golden baseline. Save this as a RAG test to include it in Run all, drift and CI."})]})]})}function rS({label:e,value:t}){return s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),s.jsx("span",{style:{fontSize:15,fontWeight:600,color:`var(--${yn(t)})`},children:t})]})}function dn({label:e,children:t}){return s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),t]})}function bd({label:e,children:t,mono:n}){return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),s.jsx("div",{className:n?"mono":void 0,style:{fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.5},children:t})]})}function mo({title:e,sub:t,children:n}){return s.jsxs("section",{children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",marginBottom:12,flexWrap:"wrap"},children:[s.jsx("div",{className:"detail-title",style:{fontSize:15},children:e}),t&&s.jsx("span",{className:"muted",style:{fontSize:12.5},children:t})]}),n]})}const DL={resisted:0,exposed:0,breached:0,poisoned:0,inconclusive:0,notExercised:0,critical:0,high:0,medium:0,low:0};function zL(e){const t={...DL};for(const n of e)n.result==="not_exercised"||n.executionState==="skipped"?t.notExercised+=1:n.result&&(t[n.result]+=1),n.result&&n.result!=="resisted"&&n.result!=="not_exercised"&&(n.severity==="critical"?t.critical+=1:n.severity==="high"?t.high+=1:n.severity==="medium"?t.medium+=1:n.severity==="low"&&(t.low+=1));return t}function UL(e){const t=e.length,n=e.filter(a=>a.executionState==="completed"||a.executionState==="error").length;return{total:t,completed:n,percentage:t===0?0:Math.round(n/t*100)}}function La(e){return{...e,progress:UL(e.controls),summary:zL(e.controls)}}const FL={scan:null,processedEventIds:new Set,controlEventTimes:{}};function GL(e){const t=Date.parse(e.timestamp);return Number.isFinite(t)?t:0}function Xl(e,t,n){let a=!1;const r=e.controls.map(i=>i.id!==t?i:(a=!0,n(i)));return a?La({...e,controls:r}):e}function WL(e,t){if(t.type==="scan.snapshot")return La(t.scan);if(!e||e.id!==t.scanId)return e;switch(t.type){case"scan.started":return{...e,status:"running",startedAt:t.startedAt??t.timestamp,error:void 0};case"control.started":return Xl({...e,status:"running",currentControlId:t.controlId},t.controlId,n=>({...n,executionState:"running",message:t.message??n.message}));case"control.progress":return Xl(e,t.controlId,n=>({...n,message:t.message}));case"control.completed":return Xl({...e,currentControlId:e.currentControlId===t.controlId?void 0:e.currentControlId},t.controlId,n=>({...n,executionState:"completed",result:t.result,severity:t.severity,durationMs:t.durationMs,message:t.message??n.message,evidence:t.evidence??n.evidence,verification:t.verification??n.verification}));case"control.error":return Xl({...e,currentControlId:e.currentControlId===t.controlId?void 0:e.currentControlId},t.controlId,n=>({...n,executionState:"error",result:"inconclusive",message:t.message,durationMs:t.durationMs}));case"finding.created":return Xl(e,t.controlId,n=>{var r;if((r=n.findings)!=null&&r.some(i=>i.id===t.finding.id))return n;const a=[...n.findings??[],t.finding];return{...n,findings:a,findingCount:a.length}});case"scan.completed":return{...e,status:"completed",completedAt:t.completedAt??t.timestamp,currentControlId:void 0,score:t.score??e.score,deploymentDecision:t.deploymentDecision??e.deploymentDecision};case"scan.failed":return{...e,status:"failed",completedAt:t.timestamp,currentControlId:void 0,error:t.message};case"scan.cancelled":{const n=e.controls.map(a=>a.executionState==="queued"||a.executionState==="running"?{...a,executionState:"skipped",result:"not_exercised"}:a);return La({...e,controls:n,status:"cancelled",completedAt:t.completedAt??t.timestamp,currentControlId:void 0})}}}function HL(e){return"controlId"in e?e.controlId:void 0}function BL(e,t){if(e.processedEventIds.has(t.id))return e;const n=HL(t),a=GL(t),r=n?e.controlEventTimes[n]:void 0,i=r!=null&&a>0&&a<r,o=t.sequence!=null&&e.lastEventSequence!=null&&t.sequence<e.lastEventSequence,l=new Set(e.processedEventIds);if(l.add(t.id),i||o&&t.type!=="scan.snapshot")return{...e,processedEventIds:l};const c=n&&a>0?{...e.controlEventTimes,[n]:a}:e.controlEventTimes;return{scan:WL(e.scan,t),processedEventIds:l,controlEventTimes:c,lastEventId:t.id,lastEventSequence:t.sequence??e.lastEventSequence}}function wf(e,t=`snapshot:${e.id}`){return{id:t,type:"scan.snapshot",scanId:e.id,timestamp:new Date().toISOString(),scan:e}}function VL(e,t,n,a,r=0){const[i,o]=p.useState("idle"),[l,c]=p.useState(null),u=p.useRef(a);return p.useEffect(()=>{a&&(u.current=a)},[a]),p.useEffect(()=>{if(!e||!t){o("idle");return}let d=!1,h;return o(u.current?"reconnecting":"connecting"),c(null),Promise.resolve(t.subscribe(e,{afterEventId:u.current,onEvent:g=>{d||(u.current=g.id,o("connected"),n(g))},onError:g=>{d||(c(g),o("disconnected"))}})).then(g=>{d?g.close():(h=()=>g.close(),o("connected"))}).catch(g=>{if(d)return;const v=g instanceof Error?g:new Error("Security scan event stream failed.");c(v),o("disconnected")}),()=>{d=!0,h==null||h()}},[e,t,n,r]),{connectionState:i,streamError:l}}function qL(e){return p.useMemo(()=>{const t=(e==null?void 0:e.controls.length)??0,n=(e==null?void 0:e.controls.filter(a=>a.executionState==="completed"||a.executionState==="error").length)??0;return{total:t,completed:n,remaining:Math.max(0,t-n),percentage:t===0?0:Math.round(n/t*100)}},[e==null?void 0:e.controls])}function KL(e,t){var C;const[n,a]=p.useReducer(BL,FL),[r,i]=p.useState(e),[o,l]=p.useState(!!(e&&t)),[c,u]=p.useState(null),[d,h]=p.useState(0);p.useEffect(()=>i(e),[e]),p.useEffect(()=>{if(!r||!t){l(!1);return}const k=new AbortController;return l(!0),u(null),t.getSnapshot(r,k.signal).then(N=>a(wf(N,`snapshot:${N.id}:${d}`))).catch(N=>{k.signal.aborted||u(N instanceof Error?N:new Error("Could not load the security scan."))}).finally(()=>{k.signal.aborted||l(!1)}),()=>k.abort()},[r,t,d]);const g=p.useCallback(k=>a(k),[]),v=((C=n.scan)==null?void 0:C.id)===r?n.scan:null,f=v?r:void 0,{connectionState:y,streamError:b}=VL(f,t,g,n.lastEventId,d),m=qL(v),x=v==null?void 0:v.controls.find(k=>k.id===v.currentControlId),j=p.useCallback(async()=>{if(!r||!t)return;const k=await t.stop(r);a(wf(k,`stop:${k.id}:${Date.now()}`))},[r,t]),S=p.useCallback(async()=>{if(!r||!t)return;const k=await t.retry(r);i(k.id),a(wf(k,`retry:${k.id}:${Date.now()}`)),h(N=>N+1)},[r,t]),w=p.useCallback(()=>h(k=>k+1),[]);return{scan:v,progress:m,currentControl:x,loading:o,error:c??b,connectionState:y,stop:j,retry:S,reconnect:w}}const op={resisted:"Verified resistance",exposed:"Verified exposure",breached:"Verified breach",poisoned:"Verified poisoning",inconclusive:"Inconclusive",not_exercised:"Not exercised"},v_={resisted:"✓",exposed:"!",breached:"×",poisoned:"◆",inconclusive:"?",not_exercised:"–"},iS={critical:5,high:4,medium:3,low:2,info:1},oS={breached:6,exposed:5,poisoned:4,inconclusive:3,resisted:2,not_exercised:1};function JL(e){return e.executionState==="running"?"Running":e.executionState==="queued"?"Queued":e.executionState==="error"?"Inconclusive":e.executionState==="skipped"?op.not_exercised:e.result?op[e.result]:"Completed"}function YL(e){const t=e.severity?`${e.severity} `:"";return`${e.title}. ${t}${JL(e)}.`}function wd(e){if(e==null||!Number.isFinite(e))return"";if(e===0)return"<1 ms";if(e<1e3)return`${Math.max(0,Math.round(e))} ms`;if(e<6e4)return`${(e/1e3).toFixed(1)} s`;const t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${t}m ${n.toString().padStart(2,"0")}s`}function y_(e,t,n=Date.now()){if(!e)return;const a=Date.parse(e),r=t?Date.parse(t):n;if(!(!Number.isFinite(a)||!Number.isFinite(r)))return Math.max(0,r-a)}function x_(e){const t=new Date(e);return Number.isNaN(t.getTime())?"—":`${t.toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}.${t.getMilliseconds().toString().padStart(3,"0")}`}function ZL(e,t=!1){if(e!=null)return t||/(?:secret|token|password|authorization|api[_-]?key)/i.test(e)?"••••••••":/^(?:PL|CANARY)-[A-Za-z0-9_-]{6,}$/i.test(e)?`${e.slice(0,8)}••••••••`:e.length>240?`${e.slice(0,237)}…`:e}function j_({executionState:e,result:t}){if(e==="running")return s.jsxs("span",{className:"scan-badge scan-badge--running",children:[s.jsx("span",{"aria-hidden":"true",children:"●"})," Running"]});if(e==="queued")return s.jsx("span",{className:"scan-badge scan-badge--queued",children:"Queued"});const n=t??(e==="error"?"inconclusive":e==="skipped"?"not_exercised":void 0);return n?s.jsxs("span",{className:`scan-badge scan-badge--${n}`,children:[s.jsx("span",{"aria-hidden":"true",children:v_[n]})," ",op[n]]}):s.jsx("span",{className:"scan-badge scan-badge--queued",children:"Completed"})}function Ax({severity:e}){return e?s.jsx("span",{className:`scan-severity scan-severity--${e}`,children:e}):null}function lS({evidence:e}){return e.length===0?s.jsx("p",{className:"scan-muted",children:"No shareable evidence was recorded."}):s.jsx("ul",{className:"scan-evidence-list",children:e.map((t,n)=>s.jsxs("li",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:t.title}),s.jsx("span",{children:t.type})]}),t.value&&s.jsx("code",{children:ZL(t.value,t.redacted)}),t.timestamp&&s.jsx("time",{dateTime:t.timestamp,children:x_(t.timestamp)})]},`${t.title}-${t.timestamp??n}`))})}function b_({findings:e,fallbackEvidence:t=[]}){return e.length===0?s.jsx(lS,{evidence:t}):s.jsx("div",{className:"scan-finding-list",children:e.map(n=>s.jsxs("section",{className:"scan-finding",children:[s.jsxs("div",{className:"scan-finding__title",children:[s.jsx("h4",{children:n.title}),s.jsx(Ax,{severity:n.severity})]}),s.jsx("p",{children:n.description}),n.impact&&s.jsxs(s.Fragment,{children:[s.jsx("h5",{children:"Why it matters"}),s.jsx("p",{children:n.impact})]}),s.jsx("h5",{children:"Proof"}),s.jsx(lS,{evidence:n.evidence??t}),n.remediation&&s.jsxs(s.Fragment,{children:[s.jsx("h5",{children:"How to fix it"}),s.jsx("p",{children:n.remediation})]}),n.source&&s.jsxs("p",{className:"scan-finding__source",children:["Source: ",n.source]})]},n.id))})}function w_(e){var t;switch((t=e.verification)==null?void 0:t.kind){case"canary":return{dots:3,level:"Direct",method:e.verification.description??"Canary confirmed"};case"protocol":return{dots:3,level:"Direct",method:e.verification.description??"Protocol evidence"};case"model":return{dots:2,level:"Corroborated",method:e.verification.description??"Agent execution"};case"rule":return{dots:2,level:"Corroborated",method:e.verification.description??"Deterministic rule"};case"safe_exposure":return{dots:1,level:"Indicative",method:e.verification.description??"Surface inspection"};case"manual":return{dots:1,level:"Indicative",method:e.verification.description??"Manual review"};default:return{dots:1,level:"Indicative",method:"Execution state only"}}}function S_({control:e,compact:t=!1}){const n=w_(e);return s.jsxs("div",{className:`scan-evidence-strength${t?" scan-evidence-strength--compact":""}`,"aria-label":`Evidence strength: ${n.level}. ${n.method}`,children:[s.jsx("span",{className:"scan-evidence-strength__label",children:"Evidence"}),s.jsxs("span",{className:"scan-evidence-strength__dots","aria-hidden":"true",children:["●".repeat(n.dots),"○".repeat(3-n.dots)]}),s.jsx("strong",{children:n.level}),!t&&s.jsx("small",{children:n.method})]})}function N_({entries:e,compact:t=!1}){return e.length===0?s.jsx("p",{className:"scan-muted",children:"No timeline events recorded."}):s.jsx("ol",{className:`scan-timeline${t?" scan-timeline--compact":""}`,children:e.map(n=>s.jsxs("li",{className:n.result?`scan-tone--${n.result}`:void 0,children:[s.jsx("time",{dateTime:n.timestamp,children:x_(n.timestamp)}),s.jsx("span",{className:"scan-timeline__marker","aria-hidden":"true",children:n.result?v_[n.result]:"●"}),s.jsxs("span",{children:[s.jsx("strong",{children:n.label}),n.detail&&s.jsx("small",{children:n.detail})]})]},n.id))})}function XL({control:e,onClose:t,actions:n}){var l,c,u,d;const a=p.useRef(null),r=p.useRef(null),i=p.useRef(null);if(p.useEffect(()=>{var g;if(!e)return;i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(g=r.current)==null||g.focus();function h(v){if(v.key==="Escape"&&t(),v.key!=="Tab"||!a.current)return;const f=[...a.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")];if(f.length===0)return;const y=f[0],b=f[f.length-1];v.shiftKey&&document.activeElement===y?(v.preventDefault(),b.focus()):!v.shiftKey&&document.activeElement===b&&(v.preventDefault(),y.focus())}return document.addEventListener("keydown",h),()=>{var v;document.removeEventListener("keydown",h),(v=i.current)==null||v.focus()}},[e,t]),!e)return null;const o=((l=e.findings)==null?void 0:l.flatMap(h=>h.timeline??[]))??[];return s.jsx("div",{className:"scan-drawer-backdrop",onMouseDown:h=>{h.currentTarget===h.target&&t()},children:s.jsxs("div",{className:"scan-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"scan-drawer-title",ref:a,children:[s.jsxs("header",{className:"scan-drawer__header",children:[s.jsxs("div",{children:[s.jsx("span",{className:"scan-kicker",children:e.category}),s.jsx("h2",{id:"scan-drawer-title",children:e.title})]}),s.jsx("button",{ref:r,type:"button",className:"scan-icon-button",onClick:t,"aria-label":"Close finding details",children:"×"})]}),s.jsxs("div",{className:"scan-drawer__body",children:[s.jsxs("div",{className:"scan-drawer__badges",children:[s.jsx(j_,{executionState:e.executionState,result:e.result}),s.jsx(Ax,{severity:e.severity})]}),s.jsx(S_,{control:e}),s.jsxs("section",{children:[s.jsx("h3",{children:"What we checked"}),s.jsx("p",{children:e.shortDescription})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"What we found"}),s.jsx("p",{children:e.message??(e.result?op[e.result]:"The control completed without a result summary.")})]}),((c=e.verification)==null?void 0:c.kind)==="safe_exposure"&&s.jsxs("aside",{className:"scan-safe-verification",children:[s.jsx("strong",{children:"Safe verification"}),s.jsx("p",{children:"Verified exposure. No destructive operation was executed."})]}),((u=e.verification)==null?void 0:u.kind)==="canary"&&s.jsxs("aside",{className:"scan-canary-verification",children:[s.jsx("strong",{children:"Verified with canary"}),s.jsx("p",{children:"Objective canary evidence confirmed the boundary crossing. Values are redacted by default."})]}),s.jsxs("section",{children:[s.jsx("h3",{children:"Evidence and remediation"}),s.jsx(b_,{findings:e.findings??[],fallbackEvidence:e.evidence})]}),n&&s.jsxs("section",{children:[s.jsx("h3",{children:"Controlled verification"}),n]}),o.length>0&&s.jsxs("section",{children:[s.jsx("h3",{children:"Timeline"}),s.jsx(N_,{entries:o,compact:!0})]})]}),s.jsxs("footer",{className:"scan-drawer__footer",children:[s.jsx("span",{children:wd(e.durationMs)}),s.jsx("span",{children:(d=e.verification)==null?void 0:d.description})]})]})})}function Da({nodes:e,state:t,result:n,branchLabel:a}){var l,c;const r=n??t,i=((l=e[0])==null?void 0:l.x)??16,o=((c=e[e.length-1])==null?void 0:c.x)??284;return s.jsxs("svg",{className:`scan-diagram scan-diagram--${r}`,viewBox:"0 0 300 86","aria-hidden":"true",focusable:"false",children:[s.jsx("line",{className:"scan-diagram__path",x1:i,y1:"42",x2:o,y2:"42"}),e.map((u,d)=>s.jsxs("g",{children:[s.jsx("circle",{className:"scan-diagram__node",cx:u.x,cy:"42",r:"5"}),s.jsx("text",{className:"scan-diagram__label",x:u.x,y:d%2===0?24:69,textAnchor:"middle",children:u.label})]},`${u.label}-${u.x}`)),a&&s.jsxs("g",{children:[s.jsx("line",{className:"scan-diagram__branch",x1:o,y1:"42",x2:o,y2:"67"}),s.jsx("text",{className:"scan-diagram__label",x:o,y:"82",textAnchor:"middle",children:a})]}),t==="running"&&s.jsx("circle",{className:"scan-diagram__traveller",cx:i,cy:"42",r:"4"}),t==="completed"&&n&&s.jsx("text",{className:"scan-diagram__signal",x:"289",y:"17",textAnchor:"end",children:n==="resisted"?"✓":n==="breached"?"×":n==="poisoned"?"◆":n==="exposed"?"!":"?"})]})}function QL(e){return s.jsx(Da,{...e,nodes:[{x:28,label:"IDENTITY"},{x:150,label:"POLICY"},{x:272,label:"ACCESS"}]})}function eM(e){return s.jsx(Da,{...e,nodes:[{x:28,label:"TOOL"},{x:150,label:"PATH"},{x:272,label:"FILE"}]})}function tM(e){return s.jsx(Da,{...e,nodes:[{x:28,label:"INPUT"},{x:150,label:"CONTROL"},{x:272,label:"OUTPUT"}]})}function sM(e){return s.jsx(Da,{...e,nodes:[{x:20,label:"AGENT"},{x:98,label:"TOOL"},{x:172,label:"URL"},{x:275,label:"INTERNAL NETWORK"}]})}function nM(e){return s.jsx(Da,{...e,nodes:[{x:22,label:"AGENT"},{x:106,label:"TOOL"},{x:196,label:"SHELL"},{x:278,label:"HOST"}]})}function aM(e){return s.jsx(Da,{...e,nodes:[{x:35,label:"UNTRUSTED"},{x:150,label:"MODEL"},{x:265,label:"SYSTEM RULE"}]})}function rM(e){return s.jsx(Da,{...e,nodes:[{x:28,label:"DOC"},{x:148,label:"RETRIEVER"},{x:272,label:"MODEL"}],branchLabel:"INSTRUCTION"})}function iM(e){return s.jsx(Da,{...e,nodes:[{x:26,label:"CLIENT"},{x:146,label:"RESOURCE"},{x:274,label:"CONTENT"}]})}function oM(e){return s.jsx(Da,{...e,nodes:[{x:25,label:"RESOURCE"},{x:150,label:"SECRET"},{x:275,label:"MODEL"}]})}function lM(e){return s.jsx(Da,{...e,nodes:[{x:30,label:"AGENT"},{x:150,label:"TOOL"},{x:270,label:"ACTION"}],branchLabel:"DATA"})}function cM({type:e,state:t,result:n}){const a={state:t,result:n};switch(e){case"secrets":return s.jsx(oM,{...a});case"process":return s.jsx(nM,{...a});case"network":return s.jsx(sM,{...a});case"filesystem":return s.jsx(eM,{...a});case"tool":return s.jsx(lM,{...a});case"prompt":return s.jsx(aM,{...a});case"rag":return s.jsx(rM,{...a});case"resource":return s.jsx(iM,{...a});case"auth":return s.jsx(QL,{...a});case"generic":return s.jsx(tM,{...a})}}const dM={critical:25,high:15,medium:5,low:1,info:0};function k_(e){return e?e.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase()):"Not exercised"}function uM(e){var t;switch((t=e.verification)==null?void 0:t.kind){case"safe_exposure":return"Not performed";case"canary":return"Controlled canary";case"protocol":return"Bounded local protocol probe";case"model":return"Local model run";case"rule":return"Deterministic local control";case"manual":return"Manual verification";default:return k_(e.executionState)}}function hM(e){switch(e.result){case"breached":return"Verified breach";case"exposed":return"Verified exposure";case"poisoned":return"Verified poisoning";case"resisted":return"Verified resistance";case"inconclusive":return"Inconclusive";case"not_exercised":return"Not exercised";default:return"Execution evidence"}}function pM(e){var t;switch((t=e.verification)==null?void 0:t.kind){case"model":return"Signed model rubric";case"canary":return"Objective canary";case"manual":return"Operator review";default:return"Rule / marker"}}function mM({control:e,onOpen:t,expanded:n=!0,onToggleExpanded:a,detailed:r=!1,metadata:i,actions:o}){var v,f,y,b,m,x,j;const l=e.executionState==="completed"||e.executionState==="error"||e.executionState==="skipped",c=e.findingCount??((v=e.findings)==null?void 0:v.length)??0,u=e.result??e.executionState,d=w_(e),h=(i==null?void 0:i.riskWeight)??dM[e.severity??"info"]??0,g=(i==null?void 0:i.analysis)??(((f=e.verification)==null?void 0:f.kind)==="safe_exposure"?"Surface inspection":((y=e.verification)==null?void 0:y.kind)==="model"?"AI-driven probe":"Signed hosted control");return s.jsxs("article",{className:`scan-control-card scan-control-card--${u}${n?"":" scan-control-card--collapsed"}`,"data-control-id":e.id,children:[s.jsxs("div",{className:"scan-control-card__heading",children:[s.jsx("span",{className:"scan-control-card__sequence","aria-hidden":"true",children:String(e.sequence).padStart(2,"0")}),s.jsxs("div",{children:[s.jsx("h3",{children:e.title}),s.jsx("span",{className:"scan-control-card__category",children:e.category})]}),a&&s.jsx("button",{type:"button",className:"scan-control-card__toggle",onClick:()=>a(e),"aria-expanded":n,"aria-label":`${n?"Collapse":"Expand"} ${e.title}`,title:`${n?"Collapse":"Expand"} card`,children:s.jsx("span",{"aria-hidden":"true",children:n?"−":"+"})})]}),n&&s.jsx(cM,{type:e.diagram,state:e.executionState,result:e.result}),s.jsx("p",{className:"scan-control-card__message",children:e.message??e.shortDescription}),n&&((b=e.verification)==null?void 0:b.kind)==="safe_exposure"&&s.jsxs("p",{className:"scan-safe-note",children:[s.jsx("span",{"aria-hidden":"true",children:"◇"})," Safe verification — no destructive operation executed"]}),n&&((m=e.verification)==null?void 0:m.kind)==="canary"&&s.jsx("p",{className:"scan-canary-note",children:"Verified with canary"}),n&&l&&s.jsx(S_,{control:e}),s.jsxs("div",{className:"scan-control-card__status",children:[s.jsx(j_,{executionState:e.executionState,result:e.result}),s.jsx(Ax,{severity:e.severity})]}),n&&r&&l&&s.jsxs("div",{className:"scan-control-card__details",children:[s.jsxs("div",{className:"scan-control-card__facts",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Category"}),s.jsx("strong",{children:e.category})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Severity"}),s.jsx("strong",{children:e.severity??"info"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Risk weight"}),s.jsxs("strong",{children:[h," pts"]})]}),(i==null?void 0:i.owasp)&&s.jsxs("div",{children:[s.jsx("span",{children:"OWASP"}),s.jsx("strong",{children:i.owasp})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Analysis"}),s.jsx("strong",{children:g})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Execution"}),s.jsx("strong",{children:uM(e)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Status"}),s.jsx("strong",{children:k_(e.result??e.executionState)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Verification"}),s.jsx("strong",{children:hM(e)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Evidence strength"}),s.jsx("strong",{children:d.level})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Graded by"}),s.jsx("strong",{children:pM(e)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Duration"}),s.jsx("strong",{children:wd(e.durationMs)||"—"})]}),((x=e.verification)==null?void 0:x.kind)==="model"&&(i==null?void 0:i.model)&&s.jsxs("div",{children:[s.jsx("span",{children:"Model"}),s.jsx("strong",{children:i.model})]})]}),s.jsxs("section",{className:"scan-control-card__verification-copy",children:[s.jsx("span",{children:"How this was verified"}),s.jsx("p",{children:((j=e.verification)==null?void 0:j.description)??"Prooflane graded the compact evidence returned for this signed hosted control."})]}),(i==null?void 0:i.impact)&&s.jsxs("section",{className:"scan-control-card__impact",children:[s.jsx("span",{children:"Why this matters"}),s.jsx("p",{children:i.impact})]}),s.jsxs("section",{className:"scan-control-card__finding-report",children:[s.jsx("span",{children:"Evidence"}),e.message&&s.jsx("p",{children:e.message}),s.jsx(b_,{findings:e.findings??[],fallbackEvidence:e.evidence})]}),(i==null?void 0:i.remediation)&&s.jsxs("section",{className:"scan-control-card__remediation",children:[s.jsx("span",{children:"How to fix it"}),s.jsx("p",{children:i.remediation})]}),o&&s.jsxs("section",{className:"scan-control-card__actions",children:[s.jsx("span",{children:"Controlled execution"}),o]})]}),s.jsxs("div",{className:"scan-control-card__meta",children:[s.jsx("span",{children:wd(e.durationMs)||(e.executionState==="queued"?"Awaiting probe":"")}),c>0&&s.jsxs("span",{children:[c," ",c===1?"finding":"findings"]}),l&&t&&s.jsxs("button",{type:"button",className:"scan-text-button",onClick:()=>t(e),"aria-label":`Open details. ${YL(e)}`,children:["View ",s.jsx("span",{"aria-hidden":"true",children:"→"})]})]})]})}const fM=p.memo(mM),Sf=2;function gM({controls:e,onOpen:t,forceShowAll:n=!1,detailed:a=!1,controlMetadata:r,renderControlActions:i}){const[o,l]=p.useState(!1),[c,u]=p.useState(()=>new Set),d=e.map(m=>m.id).join("|");p.useEffect(()=>{l(!1),u(new Set)},[d]),p.useEffect(()=>{n&&l(!0)},[n]);const h=p.useMemo(()=>o?e:e.slice(0,Sf),[e,o]),g=e.length>Sf,v=h.length>0&&h.every(m=>c.has(m.id)),f=Math.max(0,e.length-Sf);function y(m){u(x=>{const j=new Set(x);return j.has(m.id)?j.delete(m.id):j.add(m.id),j})}function b(){u(m=>{const x=new Set(m);for(const j of h)v?x.delete(j.id):x.add(j.id);return x})}return e.length===0?s.jsx("div",{className:"scan-empty",children:"No controls match these filters."}):s.jsxs("section",{className:`scan-control-results${a?" scan-control-results--detailed":""}`,"aria-label":"Security controls",children:[s.jsxs("div",{className:"scan-control-results__toolbar",children:[s.jsxs("p",{children:[s.jsx("strong",{children:h.length})," of ",e.length," controls shown"]}),s.jsxs("div",{className:"scan-action-row",children:[s.jsx("button",{type:"button",className:"scan-button scan-button--compact",onClick:b,children:v?"Expand cards":"Collapse cards"}),g&&s.jsx("button",{type:"button",className:"scan-button scan-button--compact scan-button--primary-soft",onClick:()=>l(m=>!m),"aria-expanded":o,children:o?"Show less":`Show ${f} more`})]})]}),s.jsx("div",{className:"scan-control-grid",children:h.map(m=>s.jsx(fM,{control:m,onOpen:t,expanded:!c.has(m.id),onToggleExpanded:y,detailed:a,metadata:r==null?void 0:r[m.id],actions:a?i==null?void 0:i(m):void 0},m.id))})]})}const vM=[{value:"all",label:"All"},{value:"breached",label:"Breached"},{value:"exposed",label:"Exposed"},{value:"poisoned",label:"Poisoned"},{value:"resisted",label:"Resisted"},{value:"inconclusive",label:"Inconclusive"},{value:"not_exercised",label:"Not exercised"}];function yM({value:e,onChange:t}){return s.jsxs("section",{className:"scan-controls","aria-label":"Filter security controls",children:[s.jsx("div",{className:"scan-filter-tabs",role:"group","aria-label":"Result filter",children:vM.map(n=>s.jsx("button",{type:"button",className:e.result===n.value?"is-active":"","aria-pressed":e.result===n.value,onClick:()=>t({...e,result:n.value}),children:n.label},n.value))}),s.jsxs("div",{className:"scan-controls__fields",children:[s.jsxs("label",{children:[s.jsx("span",{className:"scan-sr-only",children:"Search controls"}),s.jsx("input",{type:"search",value:e.query,placeholder:"Search title, category, finding…",onChange:n=>t({...e,query:n.target.value})})]}),s.jsxs("label",{children:[s.jsx("span",{className:"scan-sr-only",children:"Filter by severity"}),s.jsxs("select",{value:e.severity,onChange:n=>t({...e,severity:n.target.value}),children:[s.jsx("option",{value:"all",children:"All severities"}),s.jsx("option",{value:"critical",children:"Critical"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"low",children:"Low"})]})]}),s.jsxs("label",{children:[s.jsx("span",{className:"scan-sr-only",children:"Sort controls"}),s.jsxs("select",{value:e.sort,onChange:n=>t({...e,sort:n.target.value}),children:[s.jsx("option",{value:"execution",children:"Execution order"}),s.jsx("option",{value:"severity",children:"Severity"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"category",children:"Category"}),s.jsx("option",{value:"duration",children:"Duration"})]})]})]})]})}function E_({percentage:e,label:t="Security scan progress",compact:n=!1}){const a=Math.max(0,Math.min(100,Math.round(e)));return s.jsx("div",{className:`scan-progress${n?" scan-progress--compact":""}`,role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,children:s.jsx("span",{className:"scan-progress__fill",style:{width:`${a}%`}})})}function __(e){var r,i,o,l;if(e.status!=="completed")return e.deploymentDecision;const t=e.summary,n=t.exposed+t.poisoned+t.inconclusive,a=t.resisted+n+t.breached;return t.breached>0?{status:"blocked",reasons:((r=e.deploymentDecision)==null?void 0:r.status)==="blocked"?e.deploymentDecision.reasons:[`${t.breached} verified breach${t.breached===1?"":"es"} crossed a protected boundary.`]}:((i=e.deploymentDecision)==null?void 0:i.status)==="blocked"?e.deploymentDecision:n>0?{status:"warning",reasons:((o=e.deploymentDecision)==null?void 0:o.status)==="warning"?e.deploymentDecision.reasons:[`${n} finding${n===1?"":"s"} require review before release.`]}:a===0?{status:"not_evaluated",reasons:[`No selected controls were exercised; ${t.notExercised} control${t.notExercised===1?" was":"s were"} not exercised.`]}:t.notExercised>0?{status:"warning",reasons:[`${t.notExercised} selected control${t.notExercised===1?" was":"s were"} not exercised; security coverage is incomplete.`]}:((l=e.deploymentDecision)==null?void 0:l.status)==="warning"?e.deploymentDecision:e.deploymentDecision??{status:"ready",reasons:["Every selected control was exercised and produced objective resistance evidence."]}}function xM(e){return e.status==="not_evaluated"?"Not evaluated":e.status}function C_(e){const{resisted:t,exposed:n,breached:a,poisoned:r,inconclusive:i}=e.summary;return t+n+a+r+i}const jM=[{key:"resisted",label:"Resisted",icon:"✓",tone:"resisted"},{key:"exposed",label:"Exposed",icon:"!",tone:"exposed"},{key:"breached",label:"Breached",icon:"×",tone:"breached"},{key:"poisoned",label:"Poisoned",icon:"◆",tone:"poisoned"},{key:"inconclusive",label:"Inconclusive",icon:"?",tone:"inconclusive"},{key:"notExercised",label:"Not exercised",icon:"–",tone:"not_exercised"}];function bM({summary:e,compact:t=!1}){return s.jsx("div",{className:`scan-summary${t?" scan-summary--compact":""}`,"aria-label":"Security result summary",children:jM.map(n=>s.jsxs("div",{className:`scan-summary__item scan-tone--${n.tone}`,children:[s.jsx("span",{className:"scan-summary__icon","aria-hidden":"true",children:n.icon}),s.jsx("strong",{children:e[n.key]}),!t&&s.jsx("span",{children:n.label})]},n.key))})}function wM({scan:e,onViewReport:t,onExport:n,onRunAgain:a}){var d;const r=e.status==="completed"||e.status==="cancelled"||e.status==="failed",i=e.controls.find(h=>h.id===e.currentControlId),o=y_(e.startedAt,e.completedAt),l=(d=__(e))==null?void 0:d.status,c=C_(e),u=r?l==="blocked"?{icon:"×",label:"Blocked",detail:`${e.summary.breached} verified breach${e.summary.breached===1?"":"es"}`,tone:"blocked"}:l==="not_evaluated"?{icon:"–",label:"Not evaluated",detail:`${c} / ${e.progress.total} exercised`,tone:"not_evaluated"}:l==="warning"||e.status==="failed"||e.status==="cancelled"?{icon:"!",label:"Review",detail:e.status==="cancelled"?"Scan stopped":e.summary.notExercised?`${e.summary.notExercised} controls not exercised`:`${e.summary.exposed+e.summary.poisoned+e.summary.inconclusive} findings need review`,tone:"warning"}:{icon:"✓",label:"Ready",detail:`${e.progress.completed} / ${e.progress.total} controls`,tone:"ready"}:null;return s.jsxs("footer",{className:"security-scan-footer",children:[s.jsxs("div",{className:`security-scan-footer__count${u?` security-scan-footer__count--${u.tone}`:""}`,children:[s.jsx("strong",{children:u?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:u.icon})," ",u.label]}):`${e.progress.completed} / ${e.progress.total}`}),s.jsx("span",{children:(u==null?void 0:u.detail)??`${e.progress.percentage}% complete`})]}),s.jsxs("div",{className:"security-scan-footer__progress",children:[s.jsx(E_,{percentage:e.progress.percentage,compact:!0}),s.jsxs("span",{children:[e.summary.breached," breached · ",e.summary.exposed," exposed · ",e.summary.inconclusive," inconclusive · ",e.summary.resisted," resisted"]})]}),s.jsxs("div",{className:"security-scan-footer__status",children:[!r&&i&&s.jsxs("span",{children:["Scanning ",s.jsx("strong",{children:i.title}),"…"]}),r&&o!=null&&s.jsx("span",{children:wd(o)}),r&&s.jsxs("div",{className:"scan-action-row",children:[t&&s.jsx("button",{type:"button",className:"scan-button",onClick:t,children:"View detailed report"}),n&&s.jsx("button",{type:"button",className:"scan-button",onClick:n,children:"Export"}),a&&s.jsx("button",{type:"button",className:"scan-button scan-button--primary",onClick:a,children:"Run again"})]})]})]})}function SM({scan:e,connectionState:t="connected",elapsedNow:n,onStop:a,onMenu:r}){const i=y_(e.startedAt,e.completedAt,n);return s.jsxs("header",{className:"security-scan-header",children:[s.jsxs("div",{className:"security-scan-header__brand",children:[s.jsx("span",{className:"security-scan-header__mark",children:s.jsx(ur,{})}),s.jsxs("div",{children:[s.jsx("strong",{children:"Prooflane"}),s.jsx("span",{children:"Security Assurance"})]})]}),s.jsxs("div",{className:"security-scan-header__target",children:[s.jsx("strong",{children:e.target.name}),s.jsxs("span",{children:[s.jsx("b",{className:"scan-local-badge",children:"Local execution"}),e.environment??"Local"," · ",e.target.type.toUpperCase()," · ",s.jsx("span",{className:"scan-mono",children:e.id})]})]}),s.jsxs("div",{className:"security-scan-header__actions",children:[s.jsxs("span",{className:`scan-connection scan-connection--${t}`,children:[s.jsx("i",{"aria-hidden":"true"}),t==="connected"?"Connected":t]}),i!=null&&s.jsx("time",{className:"scan-elapsed",children:wd(i)}),e.status==="running"&&a&&s.jsx("button",{type:"button",className:"scan-button scan-button--danger",onClick:a,children:"Stop scan"}),r&&s.jsx("button",{type:"button",className:"scan-icon-button",onClick:r,"aria-label":"Open scan actions",children:"•••"})]})]})}function NM(){return s.jsxs("div",{className:"security-scan security-scan--skeleton","aria-busy":"true","aria-label":"Loading security scan",children:[s.jsx("div",{className:"scan-skeleton scan-skeleton--header"}),s.jsx("div",{className:"scan-skeleton scan-skeleton--progress"}),s.jsx("div",{className:"scan-control-grid",children:Array.from({length:6},(e,t)=>s.jsx("div",{className:"scan-skeleton scan-skeleton--card"},t))})]})}const cS={result:"all",severity:"all",query:"",sort:"execution"};function kM(e,t){const n=t.query.trim().toLowerCase(),a=e.filter(r=>{var i;return t.result!=="all"&&r.result!==t.result||t.severity!=="all"&&r.severity!==t.severity?!1:n?[r.title,r.category,r.message,r.shortDescription,...((i=r.findings)==null?void 0:i.map(o=>o.title))??[]].some(o=>o==null?void 0:o.toLowerCase().includes(n)):!0});return a.sort((r,i)=>t.sort==="severity"?iS[i.severity??"info"]-iS[r.severity??"info"]||r.sequence-i.sequence:t.sort==="status"?oS[i.result??"not_exercised"]-oS[r.result??"not_exercised"]||r.sequence-i.sequence:t.sort==="category"?r.category.localeCompare(i.category)||r.sequence-i.sequence:t.sort==="duration"&&(i.durationMs??0)-(r.durationMs??0)||r.sequence-i.sequence),a}function EM({onCancel:e,onConfirm:t}){const n=p.useRef(null);return p.useEffect(()=>{var r;(r=n.current)==null||r.focus();function a(i){i.key==="Escape"&&e()}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e]),s.jsx("div",{className:"scan-modal-backdrop",children:s.jsxs("div",{className:"scan-confirm",role:"alertdialog","aria-modal":"true","aria-labelledby":"scan-stop-title","aria-describedby":"scan-stop-description",children:[s.jsx("span",{className:"scan-confirm__icon","aria-hidden":"true",children:"■"}),s.jsx("h2",{id:"scan-stop-title",children:"Stop this security scan?"}),s.jsx("p",{id:"scan-stop-description",children:"Completed results will be preserved. Controls that have not run will be marked not exercised."}),s.jsxs("div",{className:"scan-action-row",children:[s.jsx("button",{ref:n,type:"button",className:"scan-button",onClick:e,children:"Continue scan"}),s.jsx("button",{type:"button",className:"scan-button scan-button--danger",onClick:t,children:"Stop scan"})]})]})})}function T_({scan:e,loading:t=!1,error:n,connectionState:a="connected",onStop:r,onRetry:i,onReconnect:o,onViewReport:l,onExport:c,onRunAgain:u,renderControlActions:d,renderReportHeader:h,controlMetadata:g,defaultDetailedReport:v=!1,stickyFooter:f=!0,className:y=""}){var oe;const[b,m]=p.useState(null),[x,j]=p.useState(cS),[S,w]=p.useState(!1),[C,k]=p.useState(v),N=p.useRef(null),[,L]=p.useState(0),_=(e==null?void 0:e.status)==="completed"||(e==null?void 0:e.status)==="cancelled"||(e==null?void 0:e.status)==="failed",E=_&&C;p.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const B=window.setInterval(()=>L(Q=>Q+1),1e3);return()=>window.clearInterval(B)},[e==null?void 0:e.status]),p.useEffect(()=>{j(cS),k(v)},[e==null?void 0:e.id,v]);const I=p.useMemo(()=>e?_?kM(e.controls,x):[...e.controls].sort((B,Q)=>B.sequence-Q.sequence):[],[e,_,x]),$=e==null?void 0:e.controls.find(B=>B.id===e.currentControlId),W=p.useCallback(()=>w(!0),[]),R=p.useCallback(()=>w(!1),[]),H=p.useCallback(()=>{w(!1),r==null||r()},[r]),Y=p.useCallback(()=>m(null),[]),K=p.useCallback(()=>{k(!0),window.requestAnimationFrame(()=>{var B;return(B=N.current)==null?void 0:B.scrollIntoView({behavior:"smooth",block:"start"})}),l==null||l()},[l]),ce=p.useCallback(()=>{if(!e)return;if(c){c();return}const B=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),Q=URL.createObjectURL(B),X=document.createElement("a");X.href=Q,X.download=`prooflane-security-report-${e.id}.json`,X.click(),URL.revokeObjectURL(Q)},[c,e]);if(t&&!e)return s.jsx(NM,{});if(!e)return s.jsxs("div",{className:"scan-load-error",role:"alert",children:[s.jsx("strong",{children:"Security scan unavailable"}),s.jsx("p",{children:(n==null?void 0:n.message)??"The scan snapshot could not be loaded."}),o&&s.jsx("button",{type:"button",className:"scan-button scan-button--primary",onClick:o,children:"Reconnect"})]});const F=__(e),ie=C_(e),ue=e.status==="running"&&$?`Scanning ${$.title}`:e.status==="completed"?(F==null?void 0:F.status)==="blocked"?"Security gate blocked":(F==null?void 0:F.status)==="warning"?"Security review required":(F==null?void 0:F.status)==="not_evaluated"?"Security coverage not evaluated":"Security scan ready":e.status==="cancelled"?"Security scan stopped":e.status==="failed"?"Security scan failed":"Security scan queued";return s.jsxs("div",{className:`security-scan ${f?"security-scan--sticky-footer":""} ${y}`.trim(),children:[s.jsx(SM,{scan:e,connectionState:a,elapsedNow:Date.now(),onStop:e.status==="running"?W:void 0}),s.jsxs("main",{className:"security-scan__body",children:[s.jsx("div",{className:"scan-live-announcement","aria-live":"polite",children:ue}),(a==="disconnected"||n)&&s.jsxs("aside",{className:"scan-reconnect",role:"status",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Live updates interrupted"}),s.jsx("p",{children:(n==null?void 0:n.message)??"The scan is still preserved. Reconnect to resume updates."})]}),o&&s.jsx("button",{type:"button",className:"scan-button",onClick:o,children:"Reconnect"})]}),e.status==="failed"&&s.jsxs("aside",{className:"scan-terminal-state scan-terminal-state--failed",children:[s.jsx("strong",{children:"Scan failed"}),s.jsx("p",{children:e.error??"A major execution failure stopped the scan."}),i&&s.jsx("button",{type:"button",className:"scan-button scan-button--primary",onClick:()=>void i(),children:"Retry scan"})]}),e.status==="cancelled"&&s.jsxs("aside",{className:"scan-terminal-state scan-terminal-state--cancelled",children:[s.jsx("strong",{children:"Scan stopped"}),s.jsxs("p",{children:[e.progress.completed," of ",e.progress.total," controls completed. ",e.summary.notExercised," controls were not exercised."]})]}),e.status==="completed"&&F&&s.jsxs("aside",{className:`scan-terminal-state scan-terminal-state--completed scan-terminal-state--${F.status}`,children:[s.jsx("strong",{children:F.status==="blocked"?"Security gate blocked":F.status==="warning"?"Security review required":F.status==="not_evaluated"?"Security coverage not evaluated":"Ready for deployment"}),s.jsx("p",{children:F.status==="blocked"?`${e.summary.breached} verified breach${e.summary.breached===1?"":"es"} crossed a protected boundary.`:F.status==="not_evaluated"?`${ie} of ${e.progress.total} selected controls were exercised; no deployment readiness decision was made.`:F.status==="warning"&&e.summary.notExercised?`${ie} of ${e.progress.total} selected controls were exercised; coverage is incomplete.`:`Objective evidence was collected for ${ie} exercised controls.`})]}),s.jsxs("section",{className:"security-scan__hero","aria-labelledby":"security-scan-title",children:[s.jsxs("div",{className:"security-scan__hero-title",children:[s.jsxs("div",{children:[s.jsx("span",{className:"scan-kicker",children:"Security scan"}),s.jsx("h1",{id:"security-scan-title",children:e.target.name}),s.jsxs("p",{children:["Inspecting connected ",e.target.type.toUpperCase()," target"]})]}),_?s.jsxs("div",{className:"security-scan__completion",children:[s.jsxs("strong",{children:[e.progress.completed," / ",e.progress.total]}),s.jsx("span",{children:"controls completed"})]}):s.jsxs("strong",{className:"security-scan__percentage",children:[e.progress.percentage,"%"]})]}),s.jsx(E_,{percentage:e.progress.percentage}),s.jsxs("div",{className:"security-scan__progress-meta",children:[s.jsxs("span",{children:[s.jsx("strong",{children:e.progress.completed})," / ",e.progress.total," controls completed"]}),s.jsxs("span",{children:[Math.max(0,e.progress.total-e.progress.completed)," remaining"]}),$&&s.jsxs("span",{children:["Current ",s.jsx("strong",{children:$.title})]})]})]}),F&&s.jsxs("section",{className:`scan-decision scan-decision--${F.status}`,children:[s.jsx("span",{children:"Deployment decision"}),s.jsx("strong",{children:xM(F)}),(oe=F.reasons)==null?void 0:oe.map(B=>s.jsx("p",{children:B},B))]}),_&&(h==null?void 0:h(e)),s.jsxs("div",{className:"security-scan__report",ref:N,children:[E&&s.jsxs("aside",{className:"scan-report-intro",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Detailed security report"}),s.jsx("p",{children:"Open any control to review compact grading metrics, the local output fingerprint, impact, remediation, and the verification method."})]}),s.jsx("button",{type:"button",className:"scan-button scan-button--compact",onClick:()=>k(!1),children:"Compact view"})]}),s.jsx(bM,{summary:e.summary}),_&&s.jsx(yM,{value:x,onChange:j}),s.jsx(gM,{controls:I,onOpen:m,forceShowAll:E,detailed:E,controlMetadata:g,renderControlActions:d})]}),e.timeline&&e.timeline.length>0&&s.jsxs("details",{className:"security-scan__timeline",children:[s.jsxs("summary",{children:["Scan timeline ",s.jsxs("span",{children:[e.timeline.length," events"]})]}),s.jsx(N_,{entries:e.timeline})]})]}),s.jsx(wM,{scan:e,onViewReport:_?K:void 0,onExport:_?ce:void 0,onRunAgain:u}),s.jsx(XL,{control:b,onClose:Y,actions:b?d==null?void 0:d(b):void 0}),S&&s.jsx(EM,{onCancel:R,onConfirm:H})]})}function _M({scanId:e,transport:t,...n}){const a=KL(e,t);return s.jsx(T_,{...n,scan:a.scan,loading:a.loading,error:a.error,connectionState:a.connectionState,onStop:a.stop,onRetry:a.retry,onReconnect:a.reconnect})}function CM({control:e,target:t,caps:n}){var W;const a=p.useMemo(()=>((n==null?void 0:n.tools)??[]).filter(R=>vh(R).risk!=="read").map(R=>R.name),[n]),[r,i]=p.useState(!1),[o,l]=p.useState(a[0]??""),[c,u]=p.useState(""),[d,h]=p.useState("{}"),[g,v]=p.useState(""),[f,y]=p.useState(!1),[b,m]=p.useState(!1),[x,j]=p.useState(null),[S,w]=p.useState(null);if(p.useEffect(()=>{a.includes(o)||l(a[0]??"")},[o,a]),e.result!=="exposed")return null;const C=R=>{var oe;const H=`prooflane-canary-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`;u(H);const Y=(oe=n==null?void 0:n.tools.find(B=>B.name===R))==null?void 0:oe.inputSchema,K=(Y==null?void 0:Y.required)??[],ce=(Y==null?void 0:Y.properties)??{},F=[...new Set([...K,...Object.keys(ce)])],ie=F.find(B=>/^(path|file|file_path|filepath)$/i.test(B))??F.find(B=>/path|file/i.test(B))??F.find(B=>/^(id|key|name|target|resource|uri|url)$/i.test(B))??F.find(B=>/id|key|name|target|resource|uri|url/i.test(B))??K[0]??"canary",ue=B=>{const Q=ce[B],X=Array.isArray(Q==null?void 0:Q.type)?Q.type[0]:Q==null?void 0:Q.type;return B===ie?/path|file/i.test(B)?`/tmp/${H}.txt`:H:X==="boolean"?!1:X==="integer"||X==="number"?1:X==="array"?[]:X==="object"?{}:/message|commit_message|reason|description/i.test(B)?`Prooflane controlled canary verification: ${H}`:""};h(JSON.stringify(Object.fromEntries([...new Set([...K,ie])].map(B=>[B,ue(B)])),null,2)),v(""),y(!1),j(null)};let k,N=null;try{k=d.trim()?JSON.parse(d):{}}catch{N="Arguments must be valid JSON."}const L=(W=n==null?void 0:n.tools.find(R=>R.name===o))==null?void 0:W.inputSchema,_=!N&&k&&typeof k=="object"&&!Array.isArray(k)?((L==null?void 0:L.required)??[]).filter(R=>{const H=k[R];return H==null||typeof H=="string"&&!H.trim()}):(L==null?void 0:L.required)??[],E=!!c&&d.includes(c),I=!!o&&g===o&&f&&E&&!N&&_.length===0&&!b,$=async()=>{if(I){m(!0),j(null),w(null);try{const R=await O.verifyHostedCapability({toolName:o,input:k,confirmedToolName:g,canaryId:c,acknowledgedDisposableCanary:f});w(R.result),i(!1)}catch(R){j(R instanceof Error?R.message:"Controlled verification failed.")}finally{m(!1)}}};return a.length?s.jsxs("div",{className:"stack",style:{gap:10},children:[!r&&!S&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Escalate this exposure to a verified breach"}),s.jsxs("p",{children:["Inspection proved reachability, not execution. You can perform a real, separately graded verification only against a disposable Prooflane-owned canary on ",t,"."]}),s.jsx("button",{type:"button",className:"scan-button scan-button--warning",onClick:()=>{i(!0),C(o||a[0])},children:"Execute controlled canary verification…"})]}),r&&s.jsxs("div",{className:"scan-exposure-verification",children:[s.jsx("strong",{children:"Controlled mutation — never target customer or production data"}),s.jsxs("label",{children:[s.jsx("span",{children:"High-impact tool"}),s.jsx("select",{value:o,onChange:R=>{l(R.target.value),C(R.target.value)},children:a.map(R=>s.jsx("option",{children:R},R))})]}),s.jsxs("div",{className:"scan-canary-box",children:[s.jsx("span",{children:"Disposable Prooflane canary"}),s.jsx("code",{children:c}),s.jsx("small",{children:"Create this exact disposable resource on the target before verification."})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Canary arguments (JSON)"}),s.jsx("textarea",{value:d,onChange:R=>h(R.target.value),rows:5,spellCheck:!1})]}),N&&s.jsx("span",{className:"scan-form-error",children:N}),!N&&!E&&s.jsx("span",{className:"scan-form-error",children:"Arguments must contain the exact generated canary id."}),!N&&_.length>0&&s.jsxs("span",{className:"scan-form-warning",children:["Enter disposable sandbox values for: ",_.join(", "),"."]}),s.jsxs("label",{children:[s.jsx("span",{children:"Type the tool name to confirm"}),s.jsx("input",{value:g,onChange:R=>v(R.target.value),placeholder:o,autoComplete:"off"})]}),s.jsxs("label",{className:"scan-exposure-verification__ack",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>y(R.target.checked)}),s.jsx("span",{children:"I created this exact canary as a disposable Prooflane-owned resource and authorize a real mutation against that canary only."})]}),x&&s.jsx("span",{className:"scan-form-error",children:x}),s.jsxs("div",{className:"scan-action-row",children:[s.jsx("button",{type:"button",className:"scan-button",disabled:b,onClick:()=>i(!1),children:"Cancel"}),s.jsx("button",{type:"button",className:"scan-button scan-button--danger",disabled:!I,onClick:()=>void $(),children:b?"Verifying…":"Approve & verify canary"})]})]}),S&&s.jsxs("div",{className:`scan-verification-outcome scan-verification-outcome--${S.verdict}`,children:[s.jsx("strong",{children:S.verdict==="breached"?"Capability executed — verified breach":S.verdict==="resisted"?"Server-side authorization enforced":"Verification inconclusive"}),s.jsx("p",{children:S.evidence}),s.jsx("button",{type:"button",className:"scan-button scan-button--compact",onClick:()=>{w(null),i(!1)},children:"Verify again"})]})]}):s.jsx("p",{className:"scan-muted",children:"This exposure has no locally classified write or destructive tool to verify. It remains an exposure; Prooflane will not invent an executable target."})}function Ta(e){return typeof e=="object"&&e!==null}function jh(e){if(Ta(e)&&"scan"in e&&(e=e.scan),!Ta(e)||typeof e.id!="string"||!Array.isArray(e.controls)||!Ta(e.target)||!Ta(e.progress)||!Ta(e.summary))throw new Error("Prooflane returned an invalid security scan snapshot.");return e}function dS(e){if(!Ta(e)||typeof e.id!="string"&&typeof e.eventId!="string"||typeof e.type!="string"||typeof e.scanId!="string"||typeof e.timestamp!="string")throw new Error("Prooflane returned an invalid security scan event.");const t=typeof e.id=="string"?e.id:String(e.eventId);if((e.type==="scan.started"||e.type==="scan.completed"||e.type==="scan.cancelled")&&Ta(e.scan))return{id:t,scanId:e.scanId,timestamp:e.timestamp,sequence:typeof e.sequence=="number"?e.sequence:void 0,type:"scan.snapshot",scan:jh(e.scan)};if(e.type==="scan.failed"&&Ta(e.error))return{id:t,scanId:e.scanId,timestamp:e.timestamp,sequence:typeof e.sequence=="number"?e.sequence:void 0,type:"scan.failed",message:typeof e.error.message=="string"?e.error.message:"The hosted scan failed."};if(e.type==="finding.created"){const n=Ta(e.finding)?e.finding:{id:String(e.findingId),title:String(e.summary),description:String(e.summary),severity:e.severity};return{id:t,scanId:e.scanId,timestamp:e.timestamp,sequence:typeof e.sequence=="number"?e.sequence:void 0,type:"finding.created",controlId:String(e.controlId),finding:n}}return{...e,id:t}}async function $u(e){if(!e.ok){const t=await e.text().catch(()=>"");throw new Error(t||`Security scan request failed (${e.status}).`)}return e.json()}function TM(e={}){const t=(e.baseUrl??"/api/security/scans").replace(/\/$/,""),n=e.fetcher??fetch,a=async()=>e.getHeaders?e.getHeaders():{},r=Math.max(250,e.pollingIntervalMs??1e3);return{async getSnapshot(i,o){return jh(await $u(await n(`${t}/${encodeURIComponent(i)}`,{signal:o,headers:await a()})))},subscribe(i,o){if(e.eventSourceFactory){const h=new URL(`${t}/${encodeURIComponent(i)}/stream`,window.location.origin);o.afterEventId&&h.searchParams.set("after",o.afterEventId);const g=e.eventSourceFactory(h.toString());return g.onmessage=v=>{try{o.onEvent(dS(JSON.parse(v.data)))}catch(f){o.onError(f instanceof Error?f:new Error("Could not decode a security scan event."))}},g.onerror=()=>o.onError(new Error("The security scan event stream disconnected.")),{close:()=>g.close()}}let l=!1,c=0,u;const d=async()=>{if(!l)try{const h=await $u(await n(`${t}/${encodeURIComponent(i)}/events?after=${c}`,{headers:await a()}));if(!Ta(h)||!Array.isArray(h.events))throw new Error("Prooflane returned an invalid scan event page.");for(const g of h.events){const v=dS(g);o.onEvent(v),typeof v.sequence=="number"&&(c=Math.max(c,v.sequence))}typeof h.cursor=="number"&&(c=Math.max(c,h.cursor))}catch(h){o.onError(h instanceof Error?h:new Error("The security scan event poll failed."))}finally{l||(u=window.setTimeout(()=>void d(),r))}};return d(),{close:()=>{l=!0,u!==void 0&&window.clearTimeout(u)}}},async stop(i){return jh(await $u(await n(`${t}/${encodeURIComponent(i)}/stop`,{method:"POST",headers:await a()})))},async retry(i){return jh(await $u(await n(`${t}/${encodeURIComponent(i)}/retry`,{method:"POST",headers:await a()})))}}}const RM=new Set(["agent-execution","sandbox-execution"]),IM={"prompt-injection":"prompt",jailbreak:"prompt",identity:"auth",authorization:"auth","data-exfiltration":"secrets","tool-manipulation":"tool","resource-poisoning":"resource",dos:"network","agentic-workflow":"process","model-abuse":"secrets"};function AM(e){return e.id==="tool-command-injection"||e.id==="sandbox-process-isolation"?"process":e.id==="tool-ssrf"||e.id==="sandbox-network-isolation"?"network":e.id==="sandbox-env-isolation"||e.id==="resource-secret-exposure"?"secrets":e.id.includes("poison")||e.id.startsWith("rag-")||e.layer==="retrieval"?"rag":e.layer==="resource"?"resource":e.layer==="mcp-protocol"?"network":IM[e.category]??"generic"}function PM(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Px(e,t){return{id:e.id,sequence:t,title:e.name,shortDescription:e.description,category:PM(e.category),diagram:AM(e),executionState:t===1?"running":"queued",severity:e.severity,message:t===1?"Preparing this control…":"Waiting to run"}}function $M(e){return e.verdict==="resisted"?"resisted":e.verdict==="breached"?e.findingClass==="poisoning"?"poisoned":e.findingClass==="exposure"?"exposed":e.findingClass==="breach"?"breached":e.findingClass==="observation"?"inconclusive":e.attack.category==="resource-poisoning"&&!/executed|invoked|followed the instruction|tool call/i.test(e.evidence)?"poisoned":"breached":"inconclusive"}function OM(e){return e.findingClass==="exposure"?{kind:"safe_exposure",description:"Safe verification — reachability was established by inspecting the advertised surface; no destructive action was executed."}:e.findingClass==="poisoning"?{kind:"rule",description:"Content verified — instruction-bearing content was located by deterministic resource inspection; execution was not observed."}:e.analysisMode&&!RM.has(e.analysisMode)?{kind:"protocol",description:"Graded from a bounded live probe; no agent was driven."}:/canary/i.test(e.evidence)?{kind:"canary",description:"Objective canary evidence was used to grade this control."}:e.attack.id==="tool-command-injection"||/evaluated to|command-output marker/i.test(e.evidence)?{kind:"canary",description:"Command-output marker confirmed"}:e.attack.id==="tool-ssrf"&&/returned response data|response data returned/i.test(e.evidence)?{kind:"protocol",description:"Internal response data observed"}:{kind:e.judged?"model":"rule",description:e.judged?"Graded by the configured model judge.":"Graded by deterministic evidence rules."}}function LM(e,t){const n=`${e} ${t}`.toLowerCase();return/off-catalog|shadow/.test(n)?"tested":/unadvertised|capability/.test(n)?"probed":/schema|malformed|enum|injection|traversal/.test(n)?"attempted":/hidden|exposure|secret|resource/.test(n)?"checked":"tested"}function MM(e){const t=[];return e.evidence&&t.push({type:e.judged?"response":"rule",title:"Observed evidence",value:e.evidence}),e.probe&&t.push({type:"response",title:"Probe",value:e.probe}),e.response&&t.push({type:"response",title:"Target response",value:e.response}),t}function DM(e,t){var i;const n=$M(e),a=MM(e),r=n==="resisted"?void 0:{id:`${e.attack.id}:finding`,title:e.attack.name,description:e.evidence||"The grader could not establish verified resistance.",impact:e.attack.impact,remediation:(i=e.attack.invariant)==null?void 0:i.rule,severity:e.attack.severity,evidence:a};return{...Px(e.attack,t),executionState:e.verdict==="error"?"error":"completed",result:n,durationMs:e.ms,findingCount:r?1:0,findings:r?[r]:[],evidence:a,message:e.evidence||(n==="resisted"?"The protected boundary held.":"The result was inconclusive."),verification:OM(e)}}function zM(e){var a;const t=e.startedAt??new Date().toISOString(),n=e.attacks.map((r,i)=>Px(r,i+1));return La({id:e.id,target:{name:e.targetName,type:e.targetType},environment:e.environment??"Local Runner",status:"running",startedAt:t,progress:{total:n.length,completed:0,percentage:0},summary:{resisted:0,exposed:0,breached:0,poisoned:0,inconclusive:0,notExercised:0,critical:0,high:0,medium:0,low:0},controls:n,currentControlId:(a=n[0])==null?void 0:a.id,timeline:[{id:`${e.id}:started`,timestamp:t,label:"Security scan started",detail:`${n.length} controls selected`}]})}function uS(e,t){var o;const n=new Date().toISOString();let a=e.controls;a.some(l=>l.id===t.id)||(a=[...a,Px({id:t.id,name:t.name,description:"Security control discovered during this scan.",category:"security-control",severity:["critical","high","medium","low"].includes(t.severity)?t.severity:"info"},a.length+1)]),a=a.map(l=>l.id===t.id?{...l,executionState:"running",message:"Testing this control…"}:l.executionState==="running"?{...l,executionState:"completed",message:"Evidence collected; final grading is being applied."}:l);const r=(o=t.groupLabel)==null?void 0:o.trim(),i=Math.min(t.total,Math.max(1,t.done+1));return La({...e,controls:a,currentControlId:t.id,timeline:[...e.timeline??[],{id:`${e.id}:progress:${t.done}:${t.id}`,timestamp:n,label:`${t.name} ${LM(t.id,t.name)}`,detail:`${r?`${r} · `:""}Control ${i} of ${t.total}`}]})}function hS(e,t){const n=new Map(e.controls.map(h=>[h.id,h.sequence])),a=t.results.map((h,g)=>DM(h,n.get(h.attack.id)??g+1)).sort((h,g)=>h.sequence-g.sequence),r=new Date().toISOString(),i=a.filter(h=>h.result==="breached").length,o=a.filter(h=>h.result==="exposed").length,l=a.filter(h=>h.result==="poisoned").length,c=a.filter(h=>h.result==="inconclusive").length,u=a.filter(h=>h.result&&h.result!=="not_exercised").length,d=i>0?{status:"blocked",reasons:[`${i} verified breach${i===1?"":"es"} crossed a protected boundary.`]}:o>0||l>0||c>0?{status:"warning",reasons:[`Review ${o+l+c} exposed, poisoned, or inconclusive result${o+l+c===1?"":"s"}.`]}:u===0?{status:"not_evaluated",reasons:["No selected controls were exercised; no deployment readiness decision was made."]}:{status:"ready",reasons:["Every selected control was exercised and produced verified resistance."]};return La({...e,status:"completed",completedAt:r,currentControlId:void 0,controls:a,score:t.overall,deploymentDecision:d,timeline:[...e.timeline??[],{id:`${e.id}:completed`,timestamp:r,label:"Security scan completed",detail:`Posture score ${t.overall}`}]})}function pS(e){const t=new Date().toISOString(),n=e.controls.map(a=>a.executionState==="queued"||a.executionState==="running"?{...a,executionState:"skipped",result:"not_exercised",message:"The scan stopped before this control completed."}:a.result?a:{...a,result:"inconclusive",message:"The control executed, but final grading was interrupted."});return La({...e,controls:n,status:"cancelled",completedAt:t,currentControlId:void 0})}function Ou(e,t){const n=new Date().toISOString(),a=e.controls.map(r=>r.executionState==="running"?{...r,executionState:"error",result:"inconclusive",message:t}:r.executionState==="queued"?{...r,executionState:"skipped",result:"not_exercised"}:r.result?r:{...r,result:"inconclusive"});return La({...e,controls:a,status:"failed",completedAt:n,currentControlId:void 0,error:t})}const mS="2026-08-09T12:40:03.000Z";function fs(e,t,n,a,r,i,o,l,c){return{id:e,sequence:t,title:n,category:a,diagram:r,executionState:i,result:o,severity:l,shortDescription:`Checks whether ${n.toLowerCase()} boundaries remain enforced under adversarial input.`,message:c,durationMs:i==="completed"||i==="error"?310+t*53:void 0}}const UM=[fs("secrets",1,"Secrets","Data protection","secrets","completed","resisted",void 0,"Secret references remained outside model-visible content."),{...fs("process-isolation",2,"Process Isolation","Runtime isolation","process","completed","breached","critical","Host command execution confirmed via a connected tool."),findingCount:1,verification:{kind:"canary",description:"A non-sensitive execution canary was returned."},evidence:[{type:"canary",title:"Execution canary",value:"PL-EXEC-83J2KQ9V",redacted:!0,timestamp:"2026-08-09T12:40:08.000Z"}],findings:[{id:"finding-process-host",title:"Host command execution crossed the runtime boundary",description:"A permitted tool returned the expected non-sensitive host execution canary.",impact:"A compromised agent could leave its intended execution boundary and access host capabilities.",remediation:"Run tools in a capability-restricted sandbox and deny host process creation by default.",severity:"critical",source:"Prooflane process isolation control",timeline:[{id:"p1",timestamp:"2026-08-09T12:40:07.100Z",label:"Probe started"},{id:"p2",timestamp:"2026-08-09T12:40:07.450Z",label:"Tool invoked"},{id:"p3",timestamp:"2026-08-09T12:40:08.000Z",label:"Verified breach",result:"breached"}]}]},fs("filesystem",3,"Filesystem Isolation","Runtime isolation","filesystem","completed","exposed","high","A writable path is reachable outside the configured workspace."),fs("network",4,"Network Egress","Runtime isolation","network","completed","resisted",void 0,"Outbound network boundary held."),fs("environment",5,"Environment Variables","Data protection","secrets","completed","inconclusive","medium","The target removed the probe before evidence could be collected."),fs("tool-permissions",6,"Tool Permissions","MCP controls","tool","completed","resisted",void 0,"Tool allowlist rejected the unauthorized request."),{...fs("destructive",7,"Destructive Operations","MCP controls","tool","completed","exposed","critical","A destructive operation is reachable without an approval gate."),verification:{kind:"safe_exposure",description:"Capability reachability was verified without execution."}},fs("resource",8,"Resource Security","MCP controls","resource","completed","resisted",void 0,"Hidden resources were not addressable."),fs("prompt-integrity",9,"Prompt Integrity","Model security","prompt","completed","resisted",void 0,"System rules remained authoritative."),fs("rag",10,"Retrieval / RAG","Retrieval security","rag","running",void 0,void 0,"Checking indirect injection resistance…"),fs("authentication",11,"Authentication","Identity","auth","completed","resisted",void 0,"Unauthenticated session creation was rejected."),fs("authorization",12,"Authorization","Identity","auth","completed","poisoned","high","Instruction-bearing role metadata was present but no effect was observed."),fs("schema",13,"Schema Safety","Protocol safety","generic","queued"),fs("output",14,"Output Limits","Protocol safety","generic","queued"),fs("exfiltration",15,"Data Exfiltration","Data protection","network","queued"),fs("indirect-prompt",16,"Indirect Prompt Injection","Model security","prompt","queued"),fs("capabilities",17,"Capability Boundaries","Agent security","tool","queued"),fs("multi-step",18,"Multi-step Agent Behavior","Agent security","process","queued")],fS=La({id:"scan_demo_001",target:{name:"MCP LambdaTest",type:"mcp",endpoint:"https://mcp.example.test/mcp"},environment:"Production",status:"running",startedAt:mS,progress:{total:0,completed:0,percentage:0},summary:{resisted:0,exposed:0,breached:0,poisoned:0,inconclusive:0,notExercised:0,critical:0,high:0,medium:0,low:0},controls:UM,currentControlId:"rag",timeline:[{id:"t1",timestamp:mS,label:"Scan started"},{id:"t2",timestamp:"2026-08-09T12:40:04.000Z",label:"Secrets",detail:"Boundary held",result:"resisted"},{id:"t3",timestamp:"2026-08-09T12:40:08.000Z",label:"Process isolation",detail:"Host execution confirmed",result:"breached"},{id:"t4",timestamp:"2026-08-09T12:40:11.000Z",label:"Retrieval / RAG",detail:"Running"}]});La({...fS,id:"scan_demo_completed",status:"completed",completedAt:"2026-08-09T12:40:45.800Z",currentControlId:void 0,score:77,deploymentDecision:{status:"blocked",reasons:["Critical verified breach in Process Isolation."]},controls:fS.controls.map(e=>e.executionState==="queued"||e.executionState==="running"?{...e,executionState:"completed",result:"resisted",message:`${e.title} boundary held.`,durationMs:420}:e)});const FM=[{id:"complete",name:"Complete retrieval assurance",description:"Run every entitled retrieval contract and grounded-answer control.",badge:"Recommended"},{id:"contract",name:"Retriever contract",description:"Result availability, latency SLO and grounded-answer quality.",controls:["rag-contract-01"],badge:"Contract"},{id:"coverage",name:"Coverage & authorization",description:"Check whether canonical authentication and authorization material can be retrieved and used faithfully.",controls:["rag-coverage-01"],badge:"Coverage"}],R_=e=>`prooflane.${e}.hosted-history`;function I_(e){try{const t=JSON.parse(localStorage.getItem(R_(e))??"[]");return Array.isArray(t)?t:[]}catch{return[]}}function GM(e){const t=[e,...I_(e.pillar).filter(n=>n.id!==e.id)].slice(0,25);try{localStorage.setItem(R_(e.pillar),JSON.stringify(t))}catch{}return t}const A_=e=>e.length?Math.round(e.reduce((t,n)=>t+n.score,0)/e.length):void 0,gS=(e,t)=>typeof e.metrics[t]=="number"?e.metrics[t]:void 0,P_=new Set(["mcp-protocol","tool-abuse","resource"]),WM={critical:25,high:15,medium:5,low:1,info:0},$_=(e,t)=>e.layer===t,Dr=e=>P_.has(e.layer),O_=e=>{if(e.authentication)return e.authentication;const t=`${e.id} ${e.name} ${e.category}`,n=e.id==="http-original-url-bypass"||/auth(?:entication|orization)?|bola|bfla|tenant|privilege|permission|access.?control/i.test(t),a=n&&/bola|bfla|cross.?tenant|horizontal|vertical|privilege|permission/i.test(t);return{actorRequired:n,comparisonRequired:a,administratorRequired:!1}},Ar={"mcp-protocol":"MCP protocol","tool-abuse":"Tool abuse",resource:"Resource",prompt:"Prompt",retrieval:"Retrieval (RAG)",agentic:"Multi-step",adaptive:"Adaptive (AI-driven)"},HM={"mcp-protocol":"Wire-protocol, schema, authorization-boundary, capability, and payload controls.","tool-abuse":"Tool declarations, unsafe mutation surface, escalation, SSRF, path, command, and authorization controls.",resource:"Resource content, URI, hidden-data, poisoning, quota, and containment controls.",prompt:"Prompt injection, jailbreak, hidden-instruction, exfiltration, and goal-integrity probes.",retrieval:"Retrieval poisoning, untrusted context, and retrieval-driven action probes.",agentic:"Multi-turn memory, deferred trigger, planning, trust-building, and tool-chain probes.",adaptive:"Bounded AI-driven probes that adapt to the target's observed behavior."};function BM({pillar:e,caps:t,connected:n,targetType:a}){var ke,we,Te,ve;const r=FM,[i,o]=p.useState("run"),[l,c]=p.useState("complete"),[u,d]=p.useState(""),[h,g]=p.useState(!1),[v,f]=p.useState(null),[y,b]=p.useState(null),[m,x]=p.useState(null),[j,S]=p.useState([]),[w,C]=p.useState(()=>I_(e)),[k,N]=p.useState(null),[L,_]=p.useState(null),[E,I]=p.useState("mcp-protocol"),[$,W]=p.useState([]),[R,H]=p.useState([]),[Y,K]=p.useState(null),[ce,F]=p.useState(null),[ie,ue]=p.useState(null),[oe,B]=p.useState(null),[Q,X]=p.useState(e==="security"),[me,fe]=p.useState(null),[P,T]=p.useState("none"),[he,q]=p.useState(""),[se,ge]=p.useState(""),[de,Ne]=p.useState(""),[Oe,_e]=p.useState(!1),[,re]=p.useState(0),V=p.useMemo(()=>TM({getHeaders:async()=>{const z=await Ka();return z?{authorization:`Bearer ${z}`}:{}}}),[]);p.useEffect(()=>mr(()=>re(z=>z+1)),[]);const le=p.useMemo(()=>((t==null?void 0:t.tools)??[]).filter(z=>/search|retriev|query|lookup|find|fetch|get|read|list/i.test(z.name)),[t]),ee=u||((ke=le[0])==null?void 0:ke.name)||((we=t==null?void 0:t.tools[0])==null?void 0:we.name)||"",xe=r.find(z=>z.id===l)??r[0],Fe=Ws(),Be=Ws(hl()),st=(ve=(Te=Es())==null?void 0:Te.model)==null?void 0:ve.trim(),ae=(k==null?void 0:k.attacks)??[],Ce=p.useMemo(()=>Object.fromEntries(ae.map(z=>[z.id,{owasp:z.owasp,riskWeight:WM[z.severity.toLowerCase()]??0,impact:z.impact,remediation:z.remediation,analysis:Dr(z)?"Deterministic surface inspection":`${Ar[z.layer]??z.layer} · local target`,model:Dr(z)?void 0:st}])),[ae,st]),He=p.useMemo(()=>ae.filter(z=>$_(z,E)),[ae,E]),qe=p.useMemo(()=>{if(!k)return[];const z=new Set($),D=new Set(k.packages.filter(ne=>z.has(ne.id)&&ne.availability==="available").flatMap(ne=>ne.attackIds)),A=new Set(R);return He.filter(ne=>D.has(ne.id)&&!A.has(ne.id)).map(ne=>ne.id)},[k,$,R,He]),dt=!P_.has(E),ye=ei(a),Ke=e==="security"?qe.length>0:n&&!!ee&&Fe&&Be;p.useEffect(()=>{if(e!=="security")return;let z=!1;return O.hostedSecurityCatalog().then(D=>{z||(N(D),W(A=>A.length?A:D.packages.filter(ne=>ne.availability==="available").map(ne=>ne.id)),_(null))}).catch(D=>{z||_(D instanceof Error?D.message:"The hosted Security catalogue could not be loaded.")}),()=>{z=!0}},[e]),p.useEffect(()=>{if(e!=="security")return;let z=!1;return X(!0),fe(null),O.securityAuthContext().then(D=>{z||(B(D),D.profiles.length&&q(A=>A||D.profiles[0].id))}).catch(D=>{z||(B(null),fe(D instanceof Error?D.message:"Local authentication context could not be loaded."))}).finally(()=>{z||X(!1)}),()=>{z=!0}},[e,n,a]);async function U(z){if(e==="rag"&&!xe)return;const D=(z==null?void 0:z.profile)??(e==="security"?E:(xe==null?void 0:xe.id)??null);g(!0),K(D),F(null),f(null),S([]),x(null);let A;try{const ne=Es(),Re=(z==null?void 0:z.controlIds)??(e==="security"?qe:xe==null?void 0:xe.controls);if(e==="security"&&!(Re!=null&&Re.length))throw new Error("Select at least one available Security package for this attack layer.");const Ee=e==="security"?ae.filter(Ye=>Re==null?void 0:Re.includes(Ye.id)):[],ze=Ee.some(Ye=>!Dr(Ye)),wt=Ee.some(Dr),be=Ee.map(O_),_t=be.some(Ye=>Ye.actorRequired),Dt=be.some(Ye=>Ye.comparisonRequired),pe=be.some(Ye=>Ye.administratorRequired);if((e==="rag"||ze)&&!ne)throw new Error(`Configure a local target LLM before running ${e==="security"?(z==null?void 0:z.label)??Ar[E]:"RAG"} Assurance.`);const Xe=hl();if(e==="security"&&wt&&!n)throw new Error(`Connect the ${ye} before running deterministic Security controls.`);if(e==="rag"&&(!n||!ee))throw new Error("Connect the RAG retriever and choose its retrieval operation first.");if(e==="rag"&&!Xe)throw new Error("Configure a separate local judge LLM before running RAG Assurance.");if(e==="rag"&&ne&&Xe&&Xe.provider===ne.provider&&Xe.model.trim()===ne.model.trim())throw new Error("Independent judging requires a different provider or model from the target LLM.");if(e==="security"&&_t){if(!(oe!=null&&oe.enabled))throw new Error("The selected Security controls require local Authentication Context, but it is unavailable in this Runner.");if(P==="none")throw new Error("This selection includes authenticated Security controls. Choose Connected auth or Saved profiles before starting the scan.");if(Dt&&(P!=="profile"||!he||!se||se===he))throw new Error("This selection includes authorization-boundary controls. Choose two distinct Saved profiles for Actor and Comparison before starting the scan.");if(pe&&(P!=="profile"||!de||de===he||de===se||!Oe))throw new Error("This selection requires a distinct confirmed Administrator Saved profile before starting the scan.")}let St;if(e==="security"&&(oe!=null&&oe.enabled)&&P!=="none")if(A=crypto.randomUUID(),P==="connected")St={attemptId:A,useConnectedAuth:!0,preflight:{acceptedStatuses:[200,201,202,204]}};else{if(!he)throw new Error("Select an Actor authentication profile before starting Security.");const Ye=se&&se!==he?se:void 0,Xt=de&&de!==he&&de!==Ye?de:void 0;if(Xt&&!Oe)throw new Error("Confirm the bounded Administrator principal before starting this Security attempt.");const zs=[{slot:"actor",authentication:"required",...Dt?{comparisonSlot:"comparison"}:{}},...Dt?[{slot:"comparison",authentication:"required"}]:[],...pe?[{slot:"administrator",authentication:"required"}]:[]];St={attemptId:A,slots:{actor:he,...Ye?{comparison:Ye}:{},...Xt?{administrator:Xt}:{}},requirements:zs,preflight:{acceptedStatuses:[200,201,202,204]}}}const kt=e==="security"?await O.securityScanCreate((t==null?void 0:t.serverName)??"Local AI agent",Re,St):await O.ragScanCreate((t==null?void 0:t.serverName)??"Local RAG application",Re);if(e==="security"){b(kt.scan.id);try{localStorage.setItem("prooflane.security.latestScanId",kt.scan.id)}catch{}}else x(kt.scan);let ht=kt.scan;const xt=[];for(;ht.status==="running";){const Ye=await O.assuranceScanNextTask(e,ht.id);if(ht=Ye.scan,e==="rag"&&x(ht),Ye.done)break;if(!Ye.lease)throw new Error("Prooflane did not return the next signed task.");const Xt=await O.intelligenceExecute({lease:Ye.lease,llm:ne??void 0,judgeLlm:e==="rag"?Xe??void 0:void 0,toolName:e==="rag"?ee:void 0,dataHandling:"metadata-only",...A?{authAttemptId:A,principalSlot:"actor"}:{}});if(!Xt.ok||!Xt.evidence)throw new Error(Xt.error??"The local Runner could not execute the signed task.");xt.push(Xt.evidence),e==="rag"&&S([...xt]),ht=(await O.assuranceScanEvidence(e,ht.id,Ye.lease,Xt.evidence)).scan,e==="rag"&&x(ht)}const rs={id:ht.id,pillar:e,profile:(z==null?void 0:z.profile)??(e==="security"?E:xe.id),label:(z==null?void 0:z.label)??(e==="security"?`${Ar[E]} · ${(Re==null?void 0:Re.length)??0} controls`:xe.name),createdAt:ht.startedAt??new Date().toISOString(),status:ht.status,score:ht.score??A_(xt),completed:ht.progress.completed,total:ht.progress.total};C(GM(rs)),F(null)}catch(ne){f(ne instanceof Error?ne.message:"Hosted Assurance could not complete this scan."),F(D),e==="security"&&b(null)}finally{A&&await O.destroySecurityAuthSession(A).catch(()=>{}),g(!1),K(null)}}function te(){b(null),x(null),S([]),ue(null),f(null),o("run")}return e==="security"&&y?s.jsx(_M,{scanId:y,transport:V,onRunAgain:te,defaultDetailedReport:!0,controlMetadata:Ce,renderReportHeader:ie&&k?z=>s.jsx(YM,{campaign:ie,scan:z,attacks:k.attacks}):void 0,renderControlActions:z=>z.result==="exposed"?s.jsx(CM,{control:z,target:(t==null?void 0:t.serverName)??`connected ${ye} target`,caps:t}):z.result==="breached"?s.jsx("p",{className:"scan-muted",children:"This is already a verified breach: Prooflane observed the protected boundary cross. A second execution is not required."}):null}):s.jsxs("div",{className:"stack",style:{gap:18,maxWidth:1240},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:16,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"screen-title",children:e==="security"?"Security / red-team":"RAG Assurance"}),s.jsx("div",{className:"screen-sub",style:{marginTop:6,maxWidth:780},children:e==="security"?"Choose an attack flow, execute signed controls locally, and inspect streamed evidence, findings and deployment impact.":"Test retrieval contracts, grounded answers, independent judging, drift-ready evidence and end-to-end RAG behavior."})]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx(Qr,{}),e==="rag"&&s.jsx(UE,{})]})]}),s.jsxs("div",{className:"tabs",role:"tablist","aria-label":`${e} workspace`,children:[s.jsx("button",{className:`tab ${i==="run"?"active":""}`,onClick:()=>o("run"),children:e==="security"?"Test":"Configure & run"}),e==="security"?s.jsx(s.Fragment,{children:s.jsxs("button",{className:`tab ${i==="campaigns"?"active":""}`,onClick:()=>o("campaigns"),children:["Campaigns ",s.jsx("span",{className:"tag",style:{marginLeft:5},children:(k==null?void 0:k.campaigns.length)??"—"})]})}):s.jsx("button",{className:`tab ${i==="coverage"?"active":""}`,onClick:()=>o("coverage"),children:"Coverage"}),s.jsxs("button",{className:`tab ${i==="history"?"active":""}`,onClick:()=>o("history"),children:["History ",s.jsx("span",{className:"tag",style:{marginLeft:5},children:w.length})]})]}),i==="run"&&e==="security"&&s.jsx(qM,{catalog:k,catalogError:L,layer:E,onLayer:I,selectedPackages:$,onSelectedPackages:W,selectedControls:qe,excludedControls:R,onToggleControl:z=>H(D=>D.includes(z)?D.filter(A=>A!==z):[...D,z]),targetReady:Fe,connected:n,targetType:a,needsLlm:dt,busy:h,error:v,authContext:oe,authContextLoading:Q,authContextError:me,authMode:P,onAuthMode:T,actorProfile:he,onActorProfile:q,comparisonProfile:se,onComparisonProfile:ge,administratorProfile:de,onAdministratorProfile:z=>{Ne(z),_e(!1)},administratorConfirmed:Oe,onAdministratorConfirmed:_e,onAuthContext:B,onRun:()=>{ue(null),U()}}),i==="run"&&e==="rag"&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsx("div",{className:"section-title",children:"Choose retrieval coverage"}),s.jsx("div",{className:"grid-2",style:{marginTop:14},children:r.map(z=>s.jsxs("button",{className:`card inset ${l===z.id?"selected":""}`,style:{padding:17,textAlign:"left",cursor:"pointer",borderColor:l===z.id?"var(--accent)":void 0},onClick:()=>c(z.id),children:[s.jsxs("div",{className:"row spread",children:[s.jsx("strong",{children:z.name}),s.jsx("span",{className:"tag",children:z.badge})]}),s.jsx("div",{className:"muted",style:{fontSize:13,lineHeight:1.5,marginTop:7},children:z.description})]},z.id))})]}),s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsx("div",{className:"section-title",children:"Local RAG execution"}),s.jsxs("div",{className:"grid-2",style:{marginTop:14},children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Retriever tool"}),s.jsxs("select",{value:ee,onChange:z=>d(z.target.value),disabled:!n||h,children:[!ee&&s.jsx("option",{value:"",children:"Connect an MCP server first"}),(le.length?le:(t==null?void 0:t.tools)??[]).map(z=>s.jsx("option",{value:z.name,children:z.name},z.name))]})]}),s.jsxs("div",{className:"card inset",style:{padding:13},children:[s.jsx("div",{className:"eyebrow",children:"Judge strategy"}),s.jsx("strong",{children:"Independent local judge"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:4},children:"Retrieved context, target answer and verdict stay on this device."})]})]})]}),s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:18,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"section-title",children:["Ready to run · ",xe==null?void 0:xe.name]}),s.jsx("div",{className:"muted",style:{fontSize:13,marginTop:6},children:"Prooflane chooses and signs each narrow task. Your local Runner uses local MCP/LLM credentials and returns compact scores and hashes only."})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsxs("span",{className:`tag ${Fe?"pass":"warn"}`,children:["Target LLM · ",Fe?"ready":"required"]}),s.jsxs("span",{className:`tag ${Be?"pass":"warn"}`,children:["Judge · ",Be?"ready":"required"]}),s.jsxs("span",{className:`tag ${n?"pass":"warn"}`,children:["Retriever · ",n?"connected":"required"]})]})]}),s.jsx("button",{className:"btn primary",style:{marginTop:18},disabled:h||!Ke,onClick:()=>void U(),children:h?"Executing signed controls…":"Run RAG assurance"}),v&&s.jsx("div",{className:"card fail",style:{padding:13,marginTop:14},children:v})]}),m&&s.jsx(XM,{scan:m,evidence:j,busy:h})]}),e==="security"&&i==="campaigns"&&s.jsx(JM,{catalog:k,error:v??L,busy:h,activeRunProfile:Y,failedRunProfile:ce,targetReady:Fe,connected:n,targetType:a,attacks:ae,onRun:z=>{ue(z),U({controlIds:z.steps,label:z.name,profile:z.id})}}),e==="rag"&&i==="coverage"&&s.jsx(ZM,{}),i==="history"&&s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsx("div",{className:"section-title",children:"Local scan history"}),s.jsx("div",{className:"muted",style:{fontSize:13,marginTop:6},children:"Only scan identifiers and summary metrics are retained here. Credentials and raw model/retrieval output are never stored."}),w.length===0?s.jsxs("div",{className:"empty muted",style:{marginTop:18},children:["No hosted ",e==="security"?"Security":"RAG"," scans have completed on this device."]}):s.jsx("div",{className:"stack",style:{gap:9,marginTop:16},children:w.map(z=>s.jsxs("button",{className:"card inset row spread",style:{padding:14,textAlign:"left",cursor:e==="security"?"pointer":"default",gap:15,flexWrap:"wrap"},onClick:()=>{e==="security"&&b(z.id)},children:[s.jsxs("div",{children:[s.jsx("strong",{children:z.label}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:4},children:[new Date(z.createdAt).toLocaleString()," · ",s.jsx("span",{className:"mono",children:z.id.slice(0,12)})]})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("span",{className:`tag ${z.status==="completed"?"pass":"warn"}`,children:z.status}),s.jsxs("span",{className:"tag",children:[z.completed,"/",z.total," controls"]}),s.jsxs("span",{className:"tag",children:["Score ",z.score??"—"]})]})]},z.id))})]})]})}function VM(e){return e.availability==="available"?{label:"Available",tone:"pass",detail:"Signed hosted controls are ready to run."}:e.availability==="upgrade-required"?{label:"Upgrade required",tone:"warn",detail:"This hosted package is available on an eligible Prooflane plan."}:e.availability==="planned"?{label:"Planned",tone:"informational",detail:"This package is on the hosted coverage roadmap."}:{label:"Catalogued",tone:"pass",detail:"Available through one-at-a-time signed hosted execution."}}function L_({error:e}){return s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsx("div",{className:"section-title",children:"Loading hosted Security catalogue…"}),e&&s.jsx("div",{className:"drift dirty",style:{marginTop:13},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Catalogue"}),s.jsx("span",{children:e})]})})]})}function qM({catalog:e,catalogError:t,layer:n,onLayer:a,selectedPackages:r,onSelectedPackages:i,selectedControls:o,excludedControls:l,onToggleControl:c,targetReady:u,connected:d,targetType:h,needsLlm:g,busy:v,error:f,authContext:y,authContextLoading:b,authContextError:m,authMode:x,onAuthMode:j,actorProfile:S,onActorProfile:w,comparisonProfile:C,onComparisonProfile:k,administratorProfile:N,onAdministratorProfile:L,administratorConfirmed:_,onAdministratorConfirmed:E,onAuthContext:I,onRun:$}){const W=s.jsxs(s.Fragment,{children:[!y&&(b||m)&&s.jsxs("section",{className:`card ${m?"warn":""}`,style:{padding:18},"aria-label":"Security authentication context status",children:[s.jsx("div",{className:"section-title",children:"Authentication Context"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:5},children:m??"Loading local authentication profiles…"})]}),(y==null?void 0:y.enabled)&&s.jsx(KM,{value:y,mode:x,onMode:j,actorProfile:S,onActorProfile:w,comparisonProfile:C,onComparisonProfile:k,administratorProfile:N,onAdministratorProfile:L,administratorConfirmed:_,onAdministratorConfirmed:E,onChange:I,disabled:v})]});if(!e)return s.jsxs("div",{className:"stack",style:{gap:18},children:[W,s.jsx(L_,{error:t})]});const R=e.packages.filter(B=>B.availability==="available").map(B=>B.id),H=new Map(e.attacks.map(B=>[B.id,B])),Y=new Set(e.attacks.filter(B=>$_(B,n)).map(B=>B.id)),K=B=>i(r.includes(B)?r.filter(Q=>Q!==B):[...r,B]),ce=["mcp-protocol","tool-abuse","resource"],F=["prompt","retrieval","agentic","adaptive"],ie=new Set(e.packages.filter(B=>r.includes(B.id)&&B.availability==="available").flatMap(B=>B.attackIds)),ue=e.attacks.filter(B=>Y.has(B.id)&&ie.has(B.id)),oe=o.length>e.maxControlsPerScan;return s.jsxs("div",{className:"stack",style:{gap:18},children:[W,s.jsxs("section",{className:"assurance-run-toolbar security-run-toolbar","aria-label":"Security control selector",children:[s.jsxs("div",{className:"stack assurance-run-intro",style:{gap:8},children:[s.jsxs("div",{className:"security-layer-picker",children:[s.jsxs("div",{className:"security-layer-row",children:[s.jsxs("div",{className:"security-layer-mode deterministic",children:[s.jsx("strong",{children:"Deterministic"}),s.jsx("span",{children:"No LLM required"})]}),s.jsx("div",{className:"security-layer-options deterministic",children:ce.map(B=>s.jsx("button",{className:`btn sm ${n===B?"primary":"ghost"}`,onClick:()=>a(B),disabled:v,children:Ar[B]},B))})]}),s.jsxs("div",{className:"security-layer-row",children:[s.jsxs("div",{className:"security-layer-mode ai",children:[s.jsx("strong",{children:"AI-driven"}),s.jsx("span",{children:"Target LLM required"})]}),s.jsx("div",{className:"security-layer-options ai",children:F.map(B=>s.jsx("button",{className:`btn sm ${n===B?"primary":"ghost"}`,onClick:()=>a(B),disabled:v,"aria-disabled":!u&&n!==B,children:Ar[B]},B))})]})]}),s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[HM[n],g&&!u?" · connect an LLM to run this layer.":""]})]}),s.jsxs("div",{className:"row assurance-run-controls",style:{gap:8,alignItems:"center",justifyContent:"space-between"},children:[s.jsxs("span",{className:"muted mono",style:{fontSize:11.5},children:[e.attacks.length," hosted controls · private recipes stay hosted"]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[g&&s.jsxs("span",{className:`tag ${u?"pass":"warn"}`,children:["LLM · ",u?"connected":"not connected"]}),s.jsxs("span",{className:`tag ${d?"pass":"warn"}`,children:[ei(h)," · ",d?"connected":g?"optional":"required"]}),s.jsx("button",{className:"btn sm primary",disabled:v||o.length===0||oe||!g&&!d||g&&!u,onClick:$,children:v?"Running…":`Run ${Ar[n]}`})]})]})]}),ue.length>0&&s.jsxs("section",{className:"card",style:{padding:18},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Controls in this run"}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:5},children:["Fine-tune the selected packs. Your plan permits ",e.maxControlsPerScan," controls in one scan."]})]}),s.jsxs("span",{className:`tag ${oe?"warn":"pass"}`,children:[o.length,"/",e.maxControlsPerScan," selected"]})]}),s.jsx("div",{className:"grid-2",style:{marginTop:14},children:ue.map(B=>{const Q=!l.includes(B.id),X=O_(B);return s.jsx("label",{className:`card inset ${Q?"selected":""}`,style:{padding:12,cursor:"pointer",borderColor:Q?"var(--accent)":void 0},children:s.jsxs("div",{className:"row",style:{gap:9,alignItems:"flex-start"},children:[s.jsx("input",{type:"checkbox",checked:Q,onChange:()=>c(B.id)}),s.jsxs("div",{children:[s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsx("strong",{style:{fontSize:13},children:B.name}),X.comparisonRequired?s.jsx("span",{className:"tag warn",children:"2 principals"}):X.actorRequired?s.jsx("span",{className:"tag",children:"Auth required"}):null]}),s.jsx("div",{className:"muted",style:{fontSize:11.5,lineHeight:1.4,marginTop:4},children:B.description})]})]})},B.id)})})]}),s.jsxs("section",{className:"card",style:{padding:18},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Attack packs"}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:5},children:["Choose curated packages. The number is the package's complete hosted control count; controls that apply to ",Ar[n]," are selected below."]})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>i(R),children:"Select all"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i([]),children:"Clear"})]})]}),s.jsx("div",{className:"grid-2",style:{marginTop:14},children:e.packages.map(B=>{const Q=B.attackIds.filter(P=>H.has(P)).length,X=B.attackIds.filter(P=>Y.has(P)).length,me=B.availability==="available",fe=r.includes(B.id);return s.jsx("label",{className:`card inset ${fe&&me?"selected":""}`,style:{padding:14,opacity:me?1:.58,cursor:me?"pointer":"default",borderColor:fe&&me?"var(--accent)":void 0},children:s.jsxs("div",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[s.jsx("input",{type:"checkbox",checked:fe&&me,disabled:!me,onChange:()=>K(B.id)}),s.jsxs("div",{style:{flex:1},children:[s.jsxs("div",{className:"row spread",style:{gap:8},children:[s.jsx("strong",{children:B.name}),s.jsx("span",{className:`tag ${B.availability==="planned"?"informational":""}`,children:B.availability==="planned"?"Soon":Q})]}),s.jsx("div",{className:"muted",style:{fontSize:12,lineHeight:1.45,marginTop:5},children:B.description}),me&&s.jsxs("div",{className:"muted mono",style:{fontSize:10.5,marginTop:7},children:[X," in ",Ar[n]]})]})]})},B.id)})})]}),(oe||f)&&s.jsx("section",{className:`card ${f?"fail":"warn"}`,style:{padding:14},role:f?"alert":"status",children:f??`Deselect ${o.length-e.maxControlsPerScan} control${o.length-e.maxControlsPerScan===1?"":"s"}; this plan permits ${e.maxControlsPerScan} controls per hosted scan.`})]})}function KM({value:e,mode:t,onMode:n,actorProfile:a,onActorProfile:r,comparisonProfile:i,onComparisonProfile:o,administratorProfile:l,onAdministratorProfile:c,administratorConfirmed:u,onAdministratorConfirmed:d,onChange:h,disabled:g}){var B,Q;const[v,f]=p.useState("Low-privilege actor"),[y,b]=p.useState("User A"),[m,x]=p.useState("BEARER"),[j,S]=p.useState("direct-session"),[w,C]=p.useState(""),[k,N]=p.useState("x-api-key"),[L,_]=p.useState(""),[E,I]=p.useState(JSON.stringify({schemaVersion:"prooflane-security-login-flow-v1",id:"local-login",connectionId:((B=e.target)==null?void 0:B.connectionId)??"",request:{method:"POST",path:"/login",bodyTemplate:{username:"{{secret.username}}",password:"{{secret.password}}"}},extraction:{accessTokenJsonPath:"access_token",refreshTokenJsonPath:"refresh_token",expiresInJsonPath:"expires_in",cookieNames:[]},binding:{authorizationScheme:"Bearer"},refresh:{method:"POST",path:"/refresh",bodyTemplate:{refresh_token:"{{secret.refreshToken}}"},refreshBeforeExpirySeconds:60},validation:{method:"GET",path:"/me",acceptedStatuses:[200]},maxResponseBytes:65536},null,2)),[$,W]=p.useState(JSON.stringify({username:"",password:""},null,2)),[R,H]=p.useState(!1),[Y,K]=p.useState(!1),[ce,F]=p.useState(null),ie=async()=>{H(!0),F(null);try{const X=m==="BASIC"?{username:w,password:L}:m==="API_KEY"?{header:k,key:L}:m==="OAUTH"?{accessToken:L}:{token:L},me=m==="LOGIN_FLOW"?JSON.parse(E):void 0,fe=m==="LOGIN_FLOW"?JSON.parse($):void 0,P=await O.saveSecurityAuthProfile({name:v,authKind:m,principal:{label:y},secretSource:j,material:X,...me?{loginFlow:me,templateSecrets:fe}:{}});h({...e,profiles:P.profiles}),r(P.profile.id),n("profile"),_(""),F(j==="direct-session"?"Profile ready for this local process.":"Secret reference saved locally; its value will resolve only when a scan starts.")}catch(X){F(X instanceof Error?X.message:"The local profile could not be saved.")}finally{H(!1)}},ue=async X=>{var fe;await O.deleteSecurityAuthProfile(X);const me=e.profiles.filter(P=>P.id!==X);h({...e,profiles:me}),a===X&&r(((fe=me[0])==null?void 0:fe.id)??""),i===X&&o(""),l===X&&c("")},oe=async()=>{K(!0),F(null);const X=crypto.randomUUID();try{const me=t==="profile"&&i&&i!==a?i:void 0,fe=t==="profile"&&l&&l!==a&&l!==me?l:void 0;if(t==="none")throw new Error("Select Connected auth or Saved profiles before testing authentication.");if(t==="profile"&&!a)throw new Error("Select an Actor profile before testing authentication.");if(fe&&!u)throw new Error("Confirm the bounded Administrator principal before testing it.");const P=await O.preflightSecurityAuth(t==="connected"?{attemptId:X,useConnectedAuth:!0,preflight:{acceptedStatuses:[200,201,202,204]}}:{attemptId:X,slots:{actor:a,...me?{comparison:me}:{},...fe?{administrator:fe}:{}},requirements:[{slot:"actor",authentication:"required",...me?{comparisonSlot:"comparison"}:{}},...me?[{slot:"comparison",authentication:"required"}]:[],...fe?[{slot:"administrator",authentication:"required"}]:[]],preflight:{acceptedStatuses:[200,201,202,204]}});F(`Authentication ready · ${P.facts.map(T=>`${T.principalSlot} ${T.authStatus}`).join(" · ")}`)}catch(me){F(me instanceof Error?me.message:"Authentication preflight failed safely.")}finally{K(!1)}};return s.jsxs("section",{className:"card security-auth-context","aria-label":"Security authentication context",children:[s.jsxs("header",{className:"security-auth-header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Authentication Context"}),s.jsx("p",{children:"Choose how locally executed security controls authenticate. Credentials never leave this Runner."})]}),s.jsx("span",{className:`tag security-auth-target ${e.connected?"pass":"warn"}`,children:e.connected?((Q=e.target)==null?void 0:Q.name)??"Target connected":"Connect an HTTP target"})]}),s.jsxs("div",{className:"security-auth-mode-grid",role:"radiogroup","aria-label":"Authentication mode",children:[s.jsxs("label",{className:`security-auth-mode ${t==="none"?"selected":""}`,children:[s.jsx("input",{type:"radio",name:"security-auth-mode",checked:t==="none",onChange:()=>n("none"),disabled:g}),s.jsx("span",{className:"security-auth-radio","aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Anonymous"}),s.jsx("small",{children:"Run without an authenticated principal."})]})]}),s.jsxs("label",{className:`security-auth-mode ${t==="connected"?"selected":""}`,children:[s.jsx("input",{type:"radio",name:"security-auth-mode",checked:t==="connected",onChange:()=>n("connected"),disabled:g||!e.connected}),s.jsx("span",{className:"security-auth-radio","aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Connected auth"}),s.jsx("small",{children:"Inherit the target’s existing static authentication locally."})]})]}),s.jsxs("label",{className:`security-auth-mode ${t==="profile"?"selected":""}`,children:[s.jsx("input",{type:"radio",name:"security-auth-mode",checked:t==="profile",onChange:()=>n("profile"),disabled:g||e.profiles.length===0}),s.jsx("span",{className:"security-auth-radio","aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:"Saved profiles"}),s.jsx("small",{children:"Bind isolated principals for authorization tests."})]})]})]}),t==="profile"&&s.jsxs("div",{className:"security-auth-principal-grid",children:[s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Actor principal"}),s.jsx("select",{value:a,onChange:X=>r(X.target.value),disabled:g,children:e.profiles.map(X=>s.jsxs("option",{value:X.id,children:[X.name," · ",X.principal.label]},X.id))})]}),s.jsxs("label",{className:"security-auth-field",children:[s.jsxs("span",{children:["Comparison principal ",s.jsx("em",{children:"Optional"})]}),s.jsxs("select",{value:i,onChange:X=>o(X.target.value),disabled:g,children:[s.jsx("option",{value:"",children:"None"}),e.profiles.filter(X=>X.id!==a).map(X=>s.jsxs("option",{value:X.id,children:[X.name," · ",X.principal.label]},X.id))]})]}),s.jsxs("label",{className:"security-auth-field",children:[s.jsxs("span",{children:["Administrator principal ",s.jsx("em",{children:"Optional"})]}),s.jsxs("select",{value:l,onChange:X=>c(X.target.value),disabled:g,children:[s.jsx("option",{value:"",children:"None"}),e.profiles.filter(X=>X.id!==a&&X.id!==i).map(X=>s.jsxs("option",{value:X.id,children:[X.name," · ",X.principal.label]},X.id))]})]}),l&&s.jsxs("label",{className:"security-auth-admin-confirm",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:X=>d(X.target.checked),disabled:g}),s.jsx("span",{children:"I explicitly authorize bounded Administrator use for this new attempt."})]})]}),s.jsxs("div",{className:"security-auth-actions",children:[s.jsx("button",{type:"button",className:"btn sm ghost",onClick:()=>void oe(),disabled:g||Y||t==="none",children:Y?"Testing locally…":"Test authentication"}),ce&&s.jsx("span",{role:"status",children:ce})]}),e.profiles.length>0&&s.jsx("div",{className:"security-auth-profile-list","aria-label":"Saved local authentication profiles",children:e.profiles.map(X=>s.jsxs("span",{className:"security-auth-profile-chip",children:[s.jsxs("span",{children:[s.jsx("strong",{children:X.name}),s.jsxs("small",{children:[X.authKind.replaceAll("_"," ")," · ",X.secretSource.replaceAll("-"," ")]})]}),s.jsx("button",{type:"button","aria-label":`Remove ${X.name}`,onClick:()=>void ue(X.id),disabled:g,children:"×"})]},X.id))}),s.jsxs("details",{className:"security-auth-profile-editor",children:[s.jsxs("summary",{children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Add local authentication profile"}),s.jsx("small",{children:"Stored locally; direct credentials remain in memory only."})]}),s.jsx("span",{className:"security-auth-chevron","aria-hidden":"true",children:"⌄"})]}),s.jsxs("div",{className:"security-auth-profile-form",children:[s.jsxs("div",{className:"security-auth-form-grid",children:[s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Profile name"}),s.jsx("input",{value:v,onChange:X=>f(X.target.value)})]}),s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Principal label"}),s.jsx("input",{value:y,onChange:X=>b(X.target.value)})]})]}),s.jsxs("div",{className:"security-auth-form-grid",children:[s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Authentication type"}),s.jsxs("select",{value:m,onChange:X=>x(X.target.value),children:[s.jsx("option",{value:"BEARER",children:"Bearer token"}),s.jsx("option",{value:"API_KEY",children:"API key"}),s.jsx("option",{value:"BASIC",children:"Basic auth"}),s.jsx("option",{value:"OAUTH",children:"OAuth access token"}),s.jsx("option",{value:"LOGIN_FLOW",children:"Login + refresh flow"})]})]}),s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Secret source"}),s.jsxs("select",{value:j,onChange:X=>S(X.target.value),disabled:m==="LOGIN_FLOW",children:[s.jsx("option",{value:"direct-session",children:"Enter for this session"}),s.jsx("option",{value:"env",children:"Environment reference"}),s.jsx("option",{value:"session",children:"Session reference"}),s.jsx("option",{value:"os-keychain",children:"Keychain reference"})]})]})]}),m==="BASIC"&&s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Username"}),s.jsx("input",{value:w,onChange:X=>C(X.target.value)})]}),m==="API_KEY"&&s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Header name"}),s.jsx("input",{value:k,onChange:X=>N(X.target.value)})]}),m==="LOGIN_FLOW"?s.jsxs("div",{className:"security-auth-form-grid",children:[s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Login/refresh definition · JSON"}),s.jsx("textarea",{className:"mono",rows:13,value:E,onChange:X=>I(X.target.value)})]}),s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:"Runtime-only template secrets · JSON"}),s.jsx("textarea",{className:"mono",rows:13,value:$,onChange:X=>W(X.target.value)}),s.jsx("small",{children:"These values remain in memory and are never written into the profile registry."})]})]}):s.jsxs("label",{className:"security-auth-field",children:[s.jsx("span",{children:j==="direct-session"?"Credential value":"Secret reference"}),s.jsx("input",{type:j==="direct-session"?"password":"text",value:L,onChange:X=>_(X.target.value),placeholder:j==="env"?"${env:SECURITY_TOKEN}":j==="session"?"${session:actor_token}":j==="os-keychain"?"${keychain:prooflane-actor}":"Held in memory only",autoComplete:"off"})]}),s.jsx("div",{className:"security-auth-form-actions",children:s.jsx("button",{type:"button",className:"btn sm primary",onClick:()=>void ie(),disabled:R||!v.trim()||!y.trim()||m!=="LOGIN_FLOW"&&!L,children:R?"Saving locally…":"Save profile"})})]})]})]})}function JM({catalog:e,error:t,busy:n,activeRunProfile:a,failedRunProfile:r,targetReady:i,connected:o,targetType:l,attacks:c,onRun:u}){if(!e)return s.jsx(L_,{error:t});const d=new Map(c.map(h=>[h.id,h]));return s.jsxs("div",{className:"stack",style:{gap:14},children:[s.jsx("section",{className:"card",style:{padding:18},children:s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Attack campaigns"}),s.jsx("div",{className:"muted",style:{marginTop:6,fontSize:13,lineHeight:1.55},children:"Run the original ordered kill-chain campaigns through the same signed hosted lease and local-evidence boundary."})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsxs("span",{className:`tag ${i?"pass":"warn"}`,children:["Target LLM · ",i?"ready":"required by AI steps"]}),s.jsxs("span",{className:`tag ${o?"pass":"warn"}`,children:[ei(l)," · ",o?"connected":"required by deterministic steps"]})]})]})}),s.jsx("div",{className:"grid-2",children:e.campaigns.map(h=>{const g=VM(h),v=h.steps.map(S=>d.get(S)).filter(S=>!!S),f=v.some(S=>!Dr(S)),y=v.some(Dr),b=ei(l),m=f&&y?`MIXED · ${b} + LLM`:f?"LLM":`DETERMINISTIC · ${b}`,x=n&&a===h.id,j=t&&r===h.id?t:null;return s.jsxs("article",{className:"card",style:{padding:20},children:[s.jsxs("div",{className:"row spread",style:{gap:10},children:[s.jsx("div",{className:"section-title",children:h.name}),s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsx("span",{className:"tag informational",children:m}),s.jsxs("span",{className:`tag ${g.tone}`,children:[h.steps.length," steps"]})]})]}),s.jsx("div",{className:"muted",style:{fontSize:13,lineHeight:1.5,marginTop:8},children:h.objective}),s.jsxs("div",{className:"card inset",style:{padding:12,marginTop:13},children:[s.jsx("div",{className:"eyebrow",children:"Outcome question"}),s.jsx("div",{style:{fontSize:13,marginTop:5},children:h.outcomeQuestion})]}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:10},children:["Objective: ",h.objectiveLabel]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap",marginTop:10},children:[f&&s.jsxs("span",{className:`tag ${i?"pass":"warn"}`,children:["LLM ",i?"ready":"required"]}),y&&s.jsxs("span",{className:`tag ${o?"pass":"warn"}`,children:[b," ",o?"ready":"required"]})]}),s.jsx("button",{type:"button",className:"btn primary",style:{marginTop:14},disabled:n||h.availability!=="available",onClick:()=>u(h),children:x?"Starting campaign…":"Run campaign"}),j&&s.jsxs("div",{className:"card fail",style:{padding:12,marginTop:12},role:"alert","aria-live":"assertive",children:[s.jsx("strong",{children:"Campaign did not start"}),s.jsx("div",{style:{marginTop:5},children:j})]})]},h.id)})})]})}function YM({campaign:e,scan:t,attacks:n}){var j,S,w,C,k;const a=new Map(n.map(N=>[N.id,N])),r=t.controls.map((N,L)=>({control:N,attack:a.get(N.id),index:L})),i=r.filter(N=>N.attack&&Dr(N.attack)),o=r.filter(N=>!N.attack||!Dr(N.attack)),l=r.findIndex(N=>N.control.result==="breached"||N.control.result==="poisoned"||N.control.result==="exposed"),[c,u]=p.useState(l),d=c>=0?r[c]:void 0,h=t.summary.breached>0,g=t.summary.exposed+t.summary.poisoned,v=h?"reached":g>0?"partial":t.summary.inconclusive>0?"inconclusive":"contained",f=v==="reached"?"fail":v==="partial"||v==="inconclusive"?"warn":"pass",y=v==="reached"?`OBJECTIVE REACHED · ${e.objectiveLabel}`:v==="partial"?`REVIEW REQUIRED · ${g} exposed or poisoned control${g===1?"":"s"}, objective not reached`:v==="inconclusive"?"INCONCLUSIVE · no control verifiably failed":"CONTAINED · every exercised control held",b=[t.summary.breached?`${t.summary.breached} breached`:"",t.summary.exposed?`${t.summary.exposed} exposed`:"",t.summary.poisoned?`${t.summary.poisoned} poisoned`:"",t.summary.inconclusive?`${t.summary.inconclusive} inconclusive`:"",t.summary.resisted?`${t.summary.resisted} held`:"",t.summary.notExercised?`${t.summary.notExercised} not exercised`:""].filter(Boolean).join(" · ");function m(N){return N==="breached"?"fail":N==="exposed"||N==="poisoned"||N==="inconclusive"?"warn":"pass"}function x(N,L,_){return _.length?s.jsxs("div",{className:"stack",style:{gap:8,marginTop:14},children:[s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("strong",{style:{fontSize:12.5},children:N}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:L})]}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap",alignItems:"stretch"},children:_.map(E=>{var W;const I=m(E.control.result),$=E.index===c;return s.jsxs("button",{className:"stack",onClick:()=>u($?-1:E.index),style:{gap:4,padding:"10px 12px",borderRadius:8,minWidth:170,maxWidth:270,textAlign:"left",cursor:"pointer",border:`1px solid var(--${I})`,boxShadow:$?"0 0 0 2px var(--accent)":"none",color:"var(--text)",background:I==="fail"?"var(--fail-bg)":"var(--panel-2)"},children:[s.jsx("span",{className:"mono muted",style:{fontSize:10,textTransform:"uppercase"},children:((W=E.attack)==null?void 0:W.category)??E.control.category}),s.jsx("strong",{style:{fontSize:12},children:E.control.title}),s.jsx("span",{className:`tag ${I}`,style:{fontSize:10},children:E.control.result==="resisted"?"BLOCKED":(E.control.result??E.control.executionState).replaceAll("_"," ").toUpperCase()})]},`${E.control.id}:${E.index}`)})})]}):null}return s.jsxs("section",{className:"card scan-campaign-graph",style:{padding:20},children:[s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsxs("strong",{style:{fontSize:15},children:["Attack graph · ",e.name]}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:e.outcomeQuestion})]}),s.jsxs("div",{className:"stack",style:{gap:4,margin:"14px 0",padding:"13px 15px",borderRadius:9,background:`var(--${f}-bg)`},children:[s.jsxs("span",{className:"row",style:{gap:9},children:[s.jsx("span",{style:{color:`var(--${f})`,fontSize:17},children:v==="contained"?"✓":v==="inconclusive"?"?":"✗"}),s.jsx("strong",{style:{color:`var(--${f})`,fontSize:13.5},children:y})]}),s.jsx("span",{className:"muted",style:{fontSize:12,marginLeft:26},children:b})]}),s.jsx("div",{className:"muted",style:{fontSize:11.5},children:"Independent signed controls, grouped by what they test — not one execution. A held control never gates another. Click a control for detail."}),o.length>0&&s.jsxs("div",{style:{marginTop:12,padding:"11px 13px",borderRadius:8,border:"1px solid var(--warn)",background:"var(--warn-bg)",fontSize:12,lineHeight:1.55},children:[s.jsx("strong",{style:{color:"var(--warn)",textTransform:"uppercase",fontSize:10.5,letterSpacing:".06em"},children:"Attribution"}),s.jsxs("div",{style:{marginTop:4},children:["Agent-behavior findings test the configured model with a ",s.jsx("strong",{children:"Prooflane-synthesized probe"}),". They are not evidence that ",t.target.name," supplied malicious content or that a server boundary was crossed without corresponding MCP evidence."]})]}),x("Containment controls",`Probed against ${t.target.name} without model-authored decisions. A reachable tool is exposed surface; only objective evidence is a verified breach.`,i),x("Agent behavior · synthetic probe","Measures the configured model/client under a Prooflane-authored scenario. A refusal is safe behavior; a failure is a model finding.",o),s.jsxs("div",{className:"row",style:{gap:10,marginTop:16,padding:"12px 14px",borderRadius:8,border:`1px solid var(--${h?"fail":"pass"})`,background:`var(--${h?"fail":"pass"}-bg)`},children:[s.jsx("span",{style:{color:`var(--${h?"fail":"pass"})`},children:h?"✗":"✓"}),s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"mono muted",style:{fontSize:10,textTransform:"uppercase"},children:"Objective"}),s.jsxs("strong",{style:{fontSize:13},children:[e.objectiveLabel," — ",h?"REACHED":"NOT REACHED"]})]})]}),d&&s.jsxs("div",{className:"card inset",style:{padding:16,marginTop:14},children:[s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("strong",{children:d.control.title}),s.jsx("span",{className:`tag ${m(d.control.result)}`,children:((j=d.control.result)==null?void 0:j.replaceAll("_"," "))??d.control.executionState}),((S=d.attack)==null?void 0:S.owasp)&&s.jsx("span",{className:"tag",children:d.attack.owasp})]}),s.jsxs("div",{className:"grid-2",style:{marginTop:12,gap:12},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"What we checked"}),s.jsx("div",{className:"muted",style:{fontSize:12,lineHeight:1.55,marginTop:5},children:((w=d.attack)==null?void 0:w.description)??d.control.shortDescription})]}),s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"What we found"}),s.jsx("div",{className:"muted",style:{fontSize:12,lineHeight:1.55,marginTop:5},children:d.control.message??((C=d.control.verification)==null?void 0:C.description)??"No shareable result summary was returned."})]})]}),((k=d.attack)==null?void 0:k.impact)&&s.jsxs("div",{style:{marginTop:12},children:[s.jsx("div",{className:"eyebrow",children:"Impact"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:5},children:d.attack.impact})]})]})]})}function ZM(){return s.jsx("div",{className:"grid-2",children:[["Retriever contract","Calls the selected local retriever, verifies at least one result, records latency, and checks the signed SLO."],["Grounded answer","Generates an answer locally using retrieved context only and scores it with a separately configured judge."],["Faithfulness","Measures whether the answer is supported by retrieved evidence; the answer and context remain local."],["Relevance","Measures whether the grounded answer actually addresses the leased question instead of merely echoing context."],["Authorization coverage","Checks that canonical authentication and authorization material can be retrieved for release-readiness decisions."],["Regression evidence","Stores compact run summaries locally so later runs can be compared without retaining retrieved documents."]].map(([e,t])=>s.jsxs("section",{className:"card",style:{padding:19},children:[s.jsx("div",{className:"section-title",children:e}),s.jsx("div",{className:"muted",style:{fontSize:13,lineHeight:1.55,marginTop:7},children:t})]},e))})}function XM({scan:e,evidence:t,busy:n}){const a=A_(t);return s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:18,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"RAG Assurance report"}),s.jsx("div",{className:"screen-title",style:{marginTop:6},children:n?`${e.progress.completed}/${e.progress.total} controls complete`:a==null?"Awaiting evidence":`${a}/100`})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("span",{className:`tag ${e.status==="completed"?"pass":"warn"}`,children:e.status}),s.jsxs("span",{className:"tag",children:[e.progress.percentage,"%"]})]})]}),s.jsx("div",{style:{height:8,borderRadius:99,background:"var(--line)",marginTop:17,overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:`${e.progress.percentage}%`,background:"var(--accent)",transition:"width .2s ease"}})}),s.jsx("div",{className:"stack",style:{gap:10,marginTop:17},children:e.controls.map(r=>{const i=t.find(c=>c.taskId===r.id),o=i?gS(i,"faithfulness"):void 0,l=i?gS(i,"relevance"):void 0;return s.jsxs("div",{className:`card inset ${(i==null?void 0:i.outcome)==="pass"?"pass":(i==null?void 0:i.outcome)==="fail"?"fail":""}`,style:{padding:15},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("strong",{children:r.title}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:4},children:r.shortDescription})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[s.jsx("span",{className:"tag",children:r.executionState}),i&&s.jsxs("span",{className:`tag ${i.outcome==="pass"?"pass":i.outcome==="fail"?"fail":"warn"}`,children:[i.score,"/100"]})]})]}),i&&s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap",marginTop:11},children:[s.jsxs("span",{className:"tag",children:[i.latencyMs," ms"]}),o!=null&&s.jsxs("span",{className:"tag",children:["Faithfulness ",o]}),l!=null&&s.jsxs("span",{className:"tag",children:["Relevance ",l]}),s.jsx("span",{className:"muted",style:{fontSize:12},children:i.summary})]})]},r.id)})})]})}const $x={"prompt-injection":"Prompt injection",jailbreak:"Jailbreak",identity:"Identity / role confusion","data-exfiltration":"Data exfiltration","tool-manipulation":"Tool manipulation","resource-poisoning":"Resource poisoning",authorization:"Authorization","agentic-workflow":"Agentic workflow",dos:"Denial of service","model-abuse":"AI abuse / model extraction"},vS=["prompt-injection","jailbreak","identity","data-exfiltration","tool-manipulation","model-abuse","resource-poisoning","authorization","agentic-workflow","dos"],M_={LLM01:"LLM01 · Prompt Injection",LLM02:"LLM02 · Sensitive Info Disclosure",LLM04:"LLM04 · Data & Model Poisoning",LLM05:"LLM05 · Improper Output Handling",LLM06:"LLM06 · Excessive Agency",LLM07:"LLM07 · System Prompt Leakage",LLM10:"LLM10 · Unbounded Consumption / Model Theft"},Ox={critical:"fail",high:"warn",medium:"info",low:"info"},Lx={critical:"Critical",high:"High",medium:"Medium",low:"Low"},QM={high:"High",medium:"Medium",low:"Low"},pl={critical:25,high:15,medium:5,low:1},Ov="Severity-weighted: Critical 25 · High 15 · Medium 5 · Low 1 pts";function Nf(e,t){const n=new Map;for(const a of[...t,...e])a.pillar==="security"&&!n.has(a.id)&&n.set(a.id,a);return[...n.values()].sort((a,r)=>Date.parse(r.createdAt)-Date.parse(a.createdAt))}function Jp(e){return e>=100?"pass":e>=80?"warn":"fail"}function eD(e){return e==="resisted"?"pass":e==="breached"?"fail":e==="error"?"warn":"info"}function tD(e){return e==="resisted"?"Resisted":e==="breached"?"Breached":e==="error"?"Error":"Inconclusive"}function D_(e){return e==="resisted"?"✓":e==="breached"?"✗":e==="error"?"!":"–"}const sn=e=>(e==null?void 0:e.verdict)==="breached"&&e.findingClass==="exposure",ma=e=>(e==null?void 0:e.verdict)==="breached"&&e.findingClass==="poisoning",Jr=e=>(e==null?void 0:e.verdict)==="breached"&&e.findingClass==="observation",lp=new Set(["exposure","poisoning","observation"]),sD=new Set(["tool-destructive-guardrail","tool-unsafe-write","mcp-dangerous-capability"]);function nD(e){let t=0,n=0;const a=[];for(const r of e){if(r.verdict!=="breached"&&r.verdict!=="resisted"||Jr(r)||r.findingClass==="observation")continue;if(sD.has(r.attack.id)){a.push(r);continue}const i=pl[r.attack.severity]??1;t+=i,r.verdict==="breached"&&(n+=i)}if(a.length){const r=Math.max(...a.map(i=>pl[i.attack.severity]??1));t+=r,a.some(i=>i.verdict==="breached")&&(n+=r)}return t?Math.round((t-n)/t*100):100}function z_(e){return e!=null&&e.verdict?e.verdict!=="breached"?tD(e.verdict):sn(e)?"Exposed":ma(e)?"Poisoned":Jr(e)?"Observed":"Breached":""}function Yr(e){return e!=null&&e.verdict?e.verdict!=="breached"?eD(e.verdict):Jr(e)?"info":sn(e)||ma(e)?"warn":"fail":"info"}function aD(e){return(e==null?void 0:e.verdict)!=="breached"?"":Jr(e)?"Measured surface property":sn(e)?"Verified exposure":ma(e)?"Verified poisoning":"Verified breach"}const Lv={"surface-inspection":"Surface inspection","protocol-probe":"Protocol probe","resource-inspection":"Resource inspection","agent-execution":"Agent execution","model-evaluation":"Model evaluation","sandbox-execution":"Sandbox execution"},rD=new Set(["agent-execution","sandbox-execution"]),Mx=(e,t)=>(t==null?void 0:t.analysisMode)??e.analysisMode,U_=(e,t)=>{const n=Mx(e,t);return n?rD.has(n):!1};function iD(e,t){return(t==null?void 0:t.verdict)!=="breached"?null:Jr(t)?{label:"Observation",detail:"Measured property — not a vulnerability on its own",tone:"info"}:sn(t)?{label:"Safe verification",detail:"No destructive action executed",tone:"warn"}:ma(t)?{label:"Content verified",detail:"Execution not observed",tone:"warn"}:U_(e,t)?{label:"Boundary crossing observed",detail:"An agent run crossed the protected boundary",tone:"fail"}:{label:"Boundary crossing observed",detail:"A live probe crossed the protected boundary",tone:"fail"}}const oD={direct:"Direct — observed happening",structural:"Structural — declared in the contract",inferred:"Inferred — derived from naming",heuristic:"Heuristic — a model's judgement"};function F_(e){var n;const t=e.evidenceStrength;if(!t)return"";if(ma(e)||(n=e.poisonedContent)!=null&&n.length){if(t==="structural")return"Structural · direct content observation";if(t==="heuristic")return"Heuristic — marker matched, intent not established"}return oD[t]??t}const lD={present:"Declared",absent:"Absent (stated by the contract)","not-declared":"Not declared","not-tested":"Not tested",unknown:"Unknown"},yS={"read-only":"Read-only","metadata-read":"Metadata read","sensitive-read":"Sensitive read",write:"Write / mutation","destructive-write":"Destructive mutation","privilege-change":"Privilege change","process-execution":"Process / command execution","network-egress":"Arbitrary network egress","credential-access":"Credential access","security-operation":"Security operation",unknown:"Unclassified"};function Dx(e){return e==null?"":e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}const bh=[{id:"prompt",name:"Prompt",blurb:"Drives your model as the agent under test — injection, jailbreak, exfiltration.",needsModel:!0,target:"Agent",perAttackMs:3e3},{id:"mcp-protocol",name:"MCP protocol",blurb:"Probes the live session directly — shadow tools, capability bypass, schema abuse. No model needed.",needsModel:!1,target:"Protocol",perAttackMs:800},{id:"tool-abuse",name:"Tool abuse",blurb:"Attacks the real tools — path traversal, template injection, unguarded destructive tools. No model needed.",needsModel:!1,target:"Protocol",perAttackMs:900},{id:"resource",name:"Resource",blurb:"Inspects resources — secrets in contents, undeclared/hidden URIs, poisoned resource content. No model needed.",needsModel:!1,target:"Protocol",perAttackMs:700},{id:"retrieval",name:"Retrieval (RAG)",blurb:"Hides adversarial instructions inside retrieved documents — indirect injection, poisoned tool triggers, data exfiltration.",needsModel:!0,target:"Agent",perAttackMs:3e3},{id:"agentic",name:"Multi-step",blurb:"Attacks the whole chain across turns — crescendo escalation, deferred triggers, escalating tool use.",needsModel:!0,target:"Agent",perAttackMs:8e3},{id:"adaptive",name:"Adaptive (AI-driven)",blurb:"An attacker model crafts and refines each probe from your agent's own replies — up to 5 rounds per goal until it breaches or gives up. The deepest, most realistic test.",needsModel:!0,target:"Agent",perAttackMs:3e4}],Yp=e=>bh.find(t=>t.id===e),G_=e=>`kawach.redteam.base.${e}`,W_=e=>`kawach.redteam.streak.${e}`;function xS(e){try{const t=localStorage.getItem(G_(e));return t?JSON.parse(t):null}catch{return null}}function cD(e,t,n){const a={model:n,at:new Date().toISOString(),overall:t.overall,verdicts:Object.fromEntries(t.results.map(r=>[r.attack.id,r.verdict])),findingClasses:Object.fromEntries(t.results.flatMap(r=>r.findingClass?[[r.attack.id,r.findingClass]]:[]))};try{localStorage.setItem(G_(e),JSON.stringify(a))}catch{}}function jS(e){return Number(localStorage.getItem(W_(e))??"0")||0}function dD(e,t){try{localStorage.setItem(W_(e),String(t))}catch{}}function uD(e,t,n){var o;const a=[],r=[],i={};for(const l of t.results){const c=e.verdicts[l.attack.id];if(c===void 0)continue;const u=c==="breached"&&!lp.has(((o=e.findingClasses)==null?void 0:o[l.attack.id])??"breach"),d=l.verdict==="breached"&&!sn(l);!u&&d?(a.push({id:l.attack.id,name:l.attack.name}),i[l.attack.id]="new-breach"):u&&!d&&(r.push({id:l.attack.id,name:l.attack.name}),i[l.attack.id]="fixed")}return{prior:e,currentModel:n,modelChanged:e.model!==n,scoreDelta:t.overall-e.overall,newBreaches:a,fixed:r,changeById:i}}function H_(e){const t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function B_(e,t){const n=e*Yp(t).perAttackMs/1e3;return n<1?"≈1s":n<90?`≈${Math.round(n)}s`:`≈${Math.round(n/60)} min`}function hD(e,t,n){const a=Ws(),r=(t==null?void 0:t.tools.length)??0,i=(t==null?void 0:t.resources.length)??0,o=((t==null?void 0:t.tools)??[]).some(l=>/search|retriev|query|lookup|find/i.test(l.name));switch(e){case"prompt":return[{label:"LLM configured",ok:a,required:!0}];case"retrieval":return[{label:"LLM configured",ok:a,required:!0},{label:"Retrieval context (resources or search tool)",ok:i>0||o,required:!1}];case"agentic":return[{label:"LLM configured",ok:a,required:!0},{label:"Tool chaining available",ok:r>0,required:!1},{label:"Conversation state supported",ok:!0,required:!0}];case"adaptive":return[{label:"LLM configured (attacker + judge)",ok:a,required:!0},{label:"Tools available (for destructive-tool goals)",ok:r>0,required:!1}];case"mcp-protocol":return[{label:"MCP server connected",ok:n,required:!0}];case"tool-abuse":return[{label:"MCP server connected",ok:n,required:!0},{label:"Tools advertised",ok:r>0,required:!1}];case"resource":return[{label:"MCP server connected",ok:n,required:!0},{label:"Resources advertised",ok:i>0,required:!1}]}}function pD({caps:e,connected:t,target:n,hostedRunner:a=!1}){if(a)return s.jsx(BM,{pillar:"security",caps:e,connected:t,targetType:n==null?void 0:n.type});const[r,i]=p.useState("test"),[o,l]=p.useState("prompt"),[c,u]=p.useState(!1),[d,h]=p.useState([]),[g,v]=p.useState([]),[f,y]=p.useState(new Set),[b,m]=p.useState(new Set(["non-invasive"])),[x,j]=p.useState(new Set),[S,w]=p.useState(null),[C,k]=p.useState(null),[N,L]=p.useState(""),[_,E]=p.useState(0),[I,$]=p.useState(!1),[W,R]=p.useState(null),H=p.useRef(null),[Y,K]=p.useState(null),[ce,F]=p.useState(null),[ie,ue]=p.useState([]),[oe,B]=p.useState(!1),[Q,X]=p.useState(null),[me,fe]=p.useState(null),[P,T]=p.useState("layer"),he=p.useRef(null),[,q]=p.useState(0);p.useEffect(()=>mr(()=>q(ye=>ye+1)),[]),p.useEffect(()=>{O.redteamPacks().then(ye=>{v(ye.packs),y(new Set(ye.packs.filter(Ke=>Ke.status==="available").map(Ke=>Ke.id)))}).catch(()=>v([]))},[]),p.useEffect(()=>{w(null),k(null),K(null),F(null),E(jS(o)),O.redteamCatalog(o).then(ye=>h(ye.attacks)).catch(()=>h([]))},[o]);const se=p.useCallback(async()=>{B(!0),X(null);try{const ye=await O.runs(500);ue(Ke=>Nf(Ke,ye))}catch(ye){X(ye instanceof Error?ye.message:"History could not be refreshed.")}finally{B(!1)}},[]);p.useEffect(()=>{r==="history"&&se()},[r,se]);const ge=p.useMemo(()=>new Set(g.filter(ye=>f.has(ye.id)).flatMap(ye=>ye.attackIds)),[g,f]),de=p.useMemo(()=>d.filter(ye=>ge.has(ye.id)&&(ye.category!=="model-abuse"||b.has(ye.execution??"non-invasive"))),[d,ge,b]);p.useEffect(()=>{j(new Set(de.map(ye=>ye.id)))},[o,de]);const Ne=x.size===de.length&&de.length>0;function Oe(ye){j(Ke=>{const U=new Set(Ke);return U.has(ye)?U.delete(ye):U.add(ye),U})}function _e(){j(Ne?new Set:new Set(de.map(ye=>ye.id)))}function re(ye){y(Ke=>{const U=new Set(Ke);return U.has(ye)?U.delete(ye):U.add(ye),U})}function V(ye){m(Ke=>{if(Ke.has(ye)&&Ke.size===1)return Ke;const U=new Set(Ke);return U.has(ye)?U.delete(ye):U.add(ye),U})}const le=Yp(o),ee=(e==null?void 0:e.tools.length)??0,xe=Ws(),Fe=hD(o,e,t),Be=xS(o);function st(ye,Ke,U){fe(zM({id:`local-security-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,targetName:U,targetType:Ke,attacks:ye,environment:"Local compatibility Runner"})),i("scan")}function ae(){if(!me)return;const ye=new Blob([JSON.stringify(me,null,2)],{type:"application/json"}),Ke=URL.createObjectURL(ye),U=document.createElement("a");U.href=Ke,U.download=`prooflane-security-${me.id}.json`,U.click(),URL.revokeObjectURL(Ke)}function Ce(){fe(null),w(null),k(null),K(null),i("test")}async function He(){if(K(null),F(null),x.size===0){K("Select at least one attack pack or attack to run.");return}const ye=x.size===d.length?void 0:[...x];let Ke;if(le.needsModel){const we=Es();if(!(we!=null&&we.model)||!(we!=null&&we.apiKey)){K("Connect an LLM first — use the “Connect an LLM” button above to set your provider, model, and API key. This layer drives that model as the agent under test.");return}Ke={provider:we.provider,baseUrl:we.baseUrl||void 0,model:we.model,apiKey:we.apiKey}}else if(!t){K("Connect to an MCP server first — these attacks probe the live session directly.");return}$(!0),w(null),k(null),T("layer");const U=d.filter(we=>x.has(we.id));st(U,le.target==="Protocol"?"mcp":"agent",(e==null?void 0:e.serverName)??(Ke==null?void 0:Ke.model)??"Configured security target");const te=(ye==null?void 0:ye.length)??d.length;R({done:0,total:te,label:"Starting…"});const ke=new AbortController;H.current=ke;try{const we=await O.redteamRunStream(o,Ke,ye,Te=>{R({done:Te.done,total:Te.total,label:Te.name}),fe(ve=>ve&&uS(ve,{...Te,groupLabel:le.name}))},ke.signal);if(!we.ok||!we.report){if(!ke.signal.aborted){const Te=we.error??"Red-team run failed.";K(Te),fe(ve=>ve&&Ou(ve,Te))}}else{const Te=(Ke==null?void 0:Ke.model)??"deterministic",ve=xS(o);k(ve?uD(ve,we.report,Te):null),cD(o,we.report,Te);const z=we.report.breached===0&&(we.report.exposed??0)===0?jS(o)+1:0;dD(o,z),E(z),L(Te),w(we.report),fe(D=>D&&hS(D,we.report)),we.run&&(ue(D=>Nf(D,[we.run])),Oa([we.run])),await Ds(),await se()}}catch(we){if(ke.signal.aborted||we.name==="AbortError")fe(Te=>Te&&pS(Te));else{const Te=we instanceof Error?we.message:String(we);K(Te),fe(ve=>ve&&Ou(ve,Te))}}finally{$(!1),R(null),H.current=null}}function qe(){var ye;(ye=H.current)==null||ye.abort()}async function dt(){if(K(null),F(null),!t){K("Connect to an MCP server first — deterministic checks probe the live session.");return}const ye=bh.filter(ke=>!ke.needsModel),Ke=await Promise.all(ye.map(ke=>O.redteamCatalog(ke.id).then(we=>we.attacks).catch(()=>[]))),U=[...new Map(Ke.flat().map(ke=>[ke.id,ke])).values()];$(!0),w(null),k(null),T("deterministic"),st(U,"mcp",(e==null?void 0:e.serverName)??"Connected MCP server");const te=new AbortController;H.current=te,R({done:0,total:0,label:"Starting deterministic scan…"});try{const ke=[],we=[];for(const pe of ye){if(te.signal.aborted)break;const Xe=await O.redteamRunStream(pe.id,void 0,void 0,St=>{R({done:St.done,total:St.total,label:`${pe.name} · ${St.name}`}),fe(kt=>kt&&uS(kt,{...St,groupLabel:pe.name}))},te.signal,{recordHistory:!1});Xe.ok&&Xe.report?ke.push(Xe.report):Xe.error&&!te.signal.aborted&&we.push(`${pe.name}: ${Xe.error}`)}if(te.signal.aborted)return;if(!ke.length){const pe=we[0]??"No deterministic checks ran.";K(pe),fe(Xe=>Xe&&Ou(Xe,pe));return}const Te=ke.flatMap(pe=>pe.results),ve=ke.flatMap(pe=>pe.scores),z=Te.filter(pe=>pe.verdict==="breached"&&!sn(pe)&&!ma(pe)&&!Jr(pe)).length,D=Te.filter(sn).length,A=Te.filter(ma).length,ne=Te.filter(Jr).length,Re=nD(Te);L("deterministic");const Ee={results:Te,scores:ve,overall:Re,breached:z,exposed:D,poisoned:A,observed:ne,total:Te.length};w(Ee),fe(pe=>pe&&hS(pe,Ee));const ze=Te.filter(pe=>pe.verdict==="resisted").length,wt=Te.filter(pe=>pe.verdict==="inconclusive"||pe.verdict==="error").length,be=(pe,Xe)=>(pl[Xe.attack.severity]??1)-(pl[pe.attack.severity]??1),_t=Te.filter(pe=>pe.verdict==="breached"&&!sn(pe)&&!ma(pe)&&!Jr(pe)).sort(be)[0],Dt=Te.filter(sn).sort(be)[0];try{const pe=await O.saveRun({pillar:"security",label:"Red team — deterministic scan",total:Te.length,pass:ze,drift:D,fail:z,error:wt,model:"deterministic",score:Re,layer:"deterministic",finding:_t==null?void 0:_t.attack.name,evidence:_t==null?void 0:_t.evidence,severity:_t==null?void 0:_t.attack.severity,poisoned:A||void 0,exposureSeverity:Dt==null?void 0:Dt.attack.severity,durationMs:Te.reduce((Xe,St)=>Xe+(St.ms??0),0)});ue(Xe=>Nf(Xe,[pe])),Oa([pe])}catch(pe){X(pe instanceof Error?pe.message:"The deterministic scan completed, but its history record could not be saved.")}we.length&&K(`Some layers exceeded your plan's per-run attack cap and were skipped: ${we.join("; ")}. Upgrade, or run those layers individually with a narrower pack selection.`),await Ds(),await se()}catch(ke){if(te.signal.aborted||ke.name==="AbortError")fe(we=>we&&pS(we));else{const we=ke instanceof Error?ke.message:String(ke);K(we),fe(Te=>Te&&Ou(Te,we))}}finally{$(!1),R(null),H.current=null}}return s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsxs("div",{className:"tabbar",children:[s.jsx("button",{className:`tab ${r==="test"?"active":""}`,onClick:()=>i("test"),children:"Test"}),me&&s.jsxs("button",{className:`tab ${r==="scan"?"active":""}`,onClick:()=>i("scan"),children:["Scan progress ",s.jsxs("span",{className:`tag ${me.status==="completed"?"pass":me.status==="failed"?"fail":""}`,style:{marginLeft:5},children:[me.progress.percentage,"%"]})]}),s.jsx("button",{className:`tab ${r==="campaigns"?"active":""}`,onClick:()=>i("campaigns"),children:"Campaigns"}),s.jsx("button",{className:`tab ${r==="history"?"active":""}`,onClick:()=>{r==="history"?se():i("history")},children:"History"})]}),c&&s.jsx(Nl,{title:`Tag the "${le.name}" security layer`,subtitle:s.jsxs(s.Fragment,{children:["Captures the ",s.jsx("b",{children:le.name})," red-team scope",de.length?` (${de.length} attacks in scope)`:""," to ",s.jsx("span",{className:"mono",children:".prooflane/tags.json"}),". A CI job that names one of its tags runs exactly this scope."]}),defaultName:`Security · ${le.name}`,capture:()=>({pillar:"security",security:de.length?{attackIds:de.map(ye=>ye.id)}:{layers:[o]},gate:{maxSeverity:"high"}}),onClose:()=>u(!1)}),r==="campaigns"&&s.jsx(ED,{connected:t}),r==="history"&&s.jsxs("div",{className:"stack",style:{gap:12},children:[s.jsxs("div",{className:"row spread",style:{gap:12},children:[s.jsx("span",{className:"muted",style:{fontSize:12},children:oe?"Refreshing run history…":`${ie.length} security run${ie.length===1?"":"s"}`}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void se(),disabled:oe,children:"Refresh"})]}),Q&&s.jsxs("div",{className:"error",children:["History refresh failed: ",Q,". Showing the runs available on this screen."]}),ie.length===0?s.jsx("div",{className:"card",style:{padding:20},children:s.jsxs("span",{className:"muted",style:{fontSize:13},children:["No red-team runs yet. Switch to ",s.jsx("b",{children:"Test"})," and run a layer — every run is logged here."]})}):s.jsx(Tx,{runs:ie,hidePillar:!0})]}),r==="scan"&&me&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Live scan and verified results"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:3},children:"This view is additive. Packs, layers, campaigns, history, graders, evidence and the detailed report remain available."})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i("test"),children:"Back to test setup"})]}),s.jsx(T_,{scan:me,onStop:me.status==="running"?qe:void 0,onRetry:me.status==="failed"?()=>void(P==="deterministic"?dt():He()):void 0,onViewReport:S?()=>{var ye;return(ye=he.current)==null?void 0:ye.scrollIntoView({behavior:"smooth",block:"start"})}:void 0,onExport:me.status==="completed"||me.status==="cancelled"||me.status==="failed"?ae:void 0,onRunAgain:me.status!=="running"?Ce:void 0,stickyFooter:!0}),S&&s.jsxs("div",{ref:he,className:"stack",style:{gap:20,scrollMarginTop:20},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Detailed compatibility report"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:4},children:"Existing graders, regression analysis, scores, probes, responses and evidence are preserved below."})]}),s.jsx(NS,{report:S}),C&&s.jsx(kS,{reg:C}),s.jsx(ml,{title:"Attack surfaces",sub:`Severity-weighted score per category (0–100). ${Ov}.`,children:s.jsx("div",{className:"stack",style:{gap:8},children:[...S.scores].sort((ye,Ke)=>ye.score-Ke.score).map(ye=>s.jsx(ES,{s:ye},ye.category))})}),s.jsx(SS,{catalog:S.results.map(ye=>ye.attack),report:S,regression:C,runModel:N,openId:ce,setOpenId:F,layer:o,selectable:!1,selectedIds:x,allSelected:Ne,onToggleSelect:Oe,onToggleSelectAll:_e,caps:e})]})]}),r==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"assurance-run-toolbar security-run-toolbar",children:[s.jsxs("div",{className:"stack assurance-run-intro",style:{gap:8},children:[s.jsxs("div",{className:"security-layer-picker","aria-label":"Security test mode",children:[s.jsxs("div",{className:"security-layer-row",children:[s.jsxs("div",{className:"security-layer-mode deterministic",children:[s.jsx("strong",{children:"Deterministic"}),s.jsx("span",{children:"No LLM required"})]}),s.jsx("div",{className:"security-layer-options deterministic",children:bh.filter(ye=>!ye.needsModel).map(ye=>s.jsx("button",{className:`btn sm ${o===ye.id?"primary":"ghost"}`,onClick:()=>l(ye.id),disabled:I,children:ye.name},ye.id))})]}),s.jsxs("div",{className:"security-layer-row",children:[s.jsxs("div",{className:"security-layer-mode ai",children:[s.jsx("strong",{children:"AI-driven"}),s.jsx("span",{children:"Target LLM required"})]}),s.jsx("div",{className:"security-layer-options ai",children:bh.filter(ye=>ye.needsModel).map(ye=>s.jsx("button",{className:`btn sm ${o===ye.id?"primary":"ghost"}`,onClick:()=>l(ye.id),disabled:I,title:xe?void 0:"Needs a connected LLM","aria-disabled":!xe&&o!==ye.id,children:ye.name},ye.id))})]})]}),s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:[le.blurb,le.needsModel&&!xe?" · connect an LLM to run this layer.":""]})]}),s.jsxs("div",{className:"row assurance-run-controls",style:{gap:8,alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[t&&s.jsx("span",{className:"muted mono",style:{fontSize:11.5},children:n?`${ei(n.type)} · connected`:`MCP server · ${ee} tool${ee===1?"":"s"}`}),s.jsx(Qr,{})]}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("button",{className:"btn sm ghost",title:"Run every deterministic check (MCP protocol + tool abuse + resource) at once — no LLM needed",onClick:dt,disabled:I||!t,children:"Deterministic scan · no LLM"}),s.jsx("button",{className:"btn sm ghost",title:`Add the "${le.name}" layer to a CI gate`,onClick:()=>u(!0),disabled:I,children:"Tag"}),s.jsx("button",{className:"btn sm primary",onClick:He,disabled:I||x.size===0,children:I?"Running…":S?"Re-run":x.size===d.length?`Run ${le.name}`:`Run ${x.size} attack${x.size===1?"":"s"}`})]})]})]}),Y&&s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"setup"}),s.jsx("span",{style:{fontSize:13},children:Y})]})}),!S&&!I&&s.jsxs(s.Fragment,{children:[s.jsx(mD,{packs:g,enabled:f,onToggle:re,catalog:d}),o==="tool-abuse"&&f.has("ai-abuse")&&s.jsx(fD,{enabled:b,onToggle:V})]}),s.jsx(gD,{layer:o,count:de.length,selected:x.size,prereqs:Fe}),!S&&!I&&Be&&s.jsxs(s.Fragment,{children:[s.jsx(vD,{baseline:Be,catalog:d}),s.jsx(yD,{baseline:Be,streak:_})]}),I&&s.jsxs("div",{className:"card",style:{padding:18},children:[s.jsxs("div",{className:"row",style:{justifyContent:"space-between",alignItems:"center",gap:12,marginBottom:10},children:[s.jsxs("div",{className:"stack",style:{gap:3,minWidth:0},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:W&&W.total>0?`Running attacks · ${W.done} of ${W.total} done`:`Running ${x.size} attack${x.size===1?"":"s"}…`}),s.jsxs("span",{className:"muted mono",style:{fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[W!=null&&W.label?`▸ ${W.label}`:le.needsModel?"a live model call per attack":"probing the live session",W&&W.total>0?"":` · ${B_(x.size,o)}`]})]}),s.jsx("button",{className:"btn sm ghost",onClick:qe,style:{color:"var(--fail, #ff5c5c)",flexShrink:0},title:"Stop the run — halts the server-side attack loop",children:"■ Stop"})]}),s.jsx("div",{style:{height:8,borderRadius:999,background:"var(--border)",overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:W&&W.total>0?`${Math.round(W.done/W.total*100)}%`:"10%",background:"var(--accent, #f5a623)",borderRadius:999,transition:"width 0.35s ease",opacity:W&&W.total>0?1:.55}})})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(NS,{report:S}),C&&s.jsx(kS,{reg:C}),s.jsx(ml,{title:"Attack surfaces",sub:`Severity-weighted score per category (0–100). ${Ov}.`,children:s.jsx("div",{className:"stack",style:{gap:8},children:[...S.scores].sort((ye,Ke)=>ye.score-Ke.score).map(ye=>s.jsx(ES,{s:ye},ye.category))})})]}),s.jsx(SS,{catalog:S?S.results.map(ye=>ye.attack):de,report:S,regression:C,runModel:N,openId:ce,setOpenId:F,layer:o,selectable:!S,selectedIds:x,allSelected:Ne,onToggleSelect:Oe,onToggleSelectAll:_e,caps:e})]})]})}const bS={foundation:"Foundation",server:"Server",data:"Data"},wS={foundation:0,server:1,data:2};function mD({packs:e,enabled:t,onToggle:n,catalog:a}){const r=new Set(a.map(c=>c.id)),i=c=>c.attackIds.filter(u=>r.has(u)).length,o=e.filter(c=>c.status==="available"&&i(c)>0).sort((c,u)=>wS[c.kind]-wS[u.kind]||c.name.localeCompare(u.name)),l=e.filter(c=>c.status==="planned");return o.length===0&&l.length===0?null:s.jsx(ml,{title:"Attack packs",sub:"Enable curated suites to scope this run — counts are attacks in the current layer.",children:s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",alignItems:"stretch"},children:[o.map(c=>{const u=t.has(c.id);return s.jsxs("label",{title:c.description,className:"card",style:{padding:"8px 12px",display:"flex",gap:8,alignItems:"center",cursor:"pointer",borderColor:u?"var(--accent, #6aa3ff)":void 0,opacity:u?1:.6},children:[s.jsx("input",{type:"checkbox",checked:u,onChange:()=>n(c.id),style:{cursor:"pointer"}}),s.jsxs("span",{className:"stack",style:{gap:1},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:500},children:c.name}),s.jsxs("span",{className:"muted",style:{fontSize:10.5},children:[bS[c.kind]," · ",i(c)," here"]})]})]},c.id)}),l.map(c=>s.jsxs("span",{title:c.description,className:"card",style:{padding:"8px 12px",display:"flex",gap:8,alignItems:"center",opacity:.5},children:[s.jsxs("span",{className:"stack",style:{gap:1},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:500},children:c.name}),s.jsx("span",{className:"muted",style:{fontSize:10.5},children:bS[c.kind]})]}),s.jsx("span",{className:"tag info",style:{fontSize:10},children:"soon"})]},c.id))]})})}function fD({enabled:e,onToggle:t}){return s.jsx(ml,{title:"AI Abuse execution",sub:"Choose the checks to include in this run. Non-invasive analysis is selected by default.",children:s.jsxs("div",{className:"row",style:{gap:10,flexWrap:"wrap",alignItems:"stretch"},children:[s.jsxs("label",{className:"card",style:{padding:"10px 12px",display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",flex:"1 1 300px",borderColor:e.has("non-invasive")?"var(--accent, #6aa3ff)":void 0},children:[s.jsx("input",{type:"checkbox",checked:e.has("non-invasive"),onChange:()=>t("non-invasive"),style:{marginTop:3,cursor:"pointer"}}),s.jsxs("span",{className:"stack",style:{gap:2},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:"Non-invasive analysis · 8 checks"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Inspects advertised tools and schemas only. No model calls, data reads, or quota consumption."})]})]}),s.jsxs("label",{className:"card",style:{padding:"10px 12px",display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer",flex:"1 1 300px",borderColor:e.has("invasive")?"var(--warn, #e4a11b)":void 0},children:[s.jsx("input",{type:"checkbox",checked:e.has("invasive"),onChange:()=>t("invasive"),style:{marginTop:3,cursor:"pointer"}}),s.jsxs("span",{className:"stack",style:{gap:2},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:"Live validation · 2 checks"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Makes up to one bounded, benign call per eligible check to verify declared batch/output caps. May consume a small amount of model quota."})]})]})]})})}function gD({layer:e,count:t,selected:n,prereqs:a}){const r=Yp(e);return s.jsxs("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:[s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"Scope"})]}),s.jsxs("div",{className:"tile-value",style:{fontSize:20},children:[t," attacks"]}),s.jsxs("div",{className:"tile-label",children:[B_(t,e)," · runs against the ",r.target]})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"Selected"})]}),s.jsxs("div",{className:"tile-value",style:{fontSize:20},children:[n," / ",t]}),s.jsxs("div",{className:"tile-label",children:[t?Math.round(n/t*100):0,"% of this layer's attacks will run"]})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"Prerequisites"})]}),s.jsx("div",{className:"stack",style:{gap:3,marginTop:4},children:a.map(i=>s.jsxs("div",{className:"row",style:{gap:6,alignItems:"center"},children:[s.jsx("span",{style:{color:i.ok?"var(--pass)":i.required?"var(--fail)":"var(--warn)",fontSize:12,width:12},children:i.ok?"✓":"✗"}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[i.label,!i.required&&!i.ok?" (optional)":""]})]},i.label))})]})]})}function vD({baseline:e,catalog:t}){var d;const n=Object.values(e.verdicts),a=n.filter(h=>h==="resisted").length,r=Object.entries(e.verdicts).filter(([h,g])=>{var v;return g==="breached"&&!lp.has(((v=e.findingClasses)==null?void 0:v[h])??"breach")}).length,i=Object.values(e.findingClasses??{}).filter(h=>h==="exposure").length,o=n.filter(h=>h==="error").length,l=Object.fromEntries(t.map(h=>[h.id,h.name])),c=(d=Object.entries(e.verdicts).find(([h,g])=>{var v;return g==="breached"&&!lp.has(((v=e.findingClasses)==null?void 0:v[h])??"breach")}))==null?void 0:d[0],u=Jp(e.overall);return s.jsx("div",{className:"card",style:{padding:"16px 18px"},children:s.jsxs("div",{className:"row spread",style:{alignItems:"center",flexWrap:"wrap",gap:16},children:[s.jsxs("div",{className:"row",style:{gap:20,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:2},children:[s.jsx("span",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:"0.5px"},children:"Assurance Score"}),s.jsx("span",{style:{fontSize:40,fontWeight:600,color:`var(--${u})`,lineHeight:1},title:Ov,children:e.overall}),s.jsx("span",{className:"muted",style:{fontSize:10.5},children:"severity-weighted"})]}),s.jsxs("div",{className:"row",style:{gap:16},children:[s.jsx(Lu,{label:"Resisted",value:a,tone:"pass"}),s.jsx(Lu,{label:"Breached",value:r,tone:r?"fail":"pass"}),s.jsx(Lu,{label:"Exposed",value:i,tone:i?"warn":"pass"}),s.jsx(Lu,{label:"Errors",value:o,tone:o?"warn":"info"})]})]}),s.jsxs("div",{className:"stack",style:{gap:4,alignItems:"flex-end"},children:[s.jsxs("span",{className:"muted",style:{fontSize:12},children:["Last run ",H_(e.at)," · ",s.jsx("span",{className:"mono",children:e.model})]}),c&&s.jsxs("span",{style:{fontSize:12.5},children:["Most recent finding: ",s.jsx("b",{style:{color:"var(--fail)"},children:l[c]??c})]}),!c&&s.jsx("span",{className:"tag pass",children:"no breaches last run"})]})]})})}function Lu({label:e,value:t,tone:n}){return s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{style:{fontSize:20,fontWeight:600,color:`var(--${n})`},children:t}),s.jsx("span",{className:"muted",style:{fontSize:11},children:e})]})}function yD({baseline:e,streak:t}){return Object.entries(e.verdicts).filter(([a,r])=>{var i;return r==="breached"&&!lp.has(((i=e.findingClasses)==null?void 0:i[a])??"breach")}).length===0&&t>=2?s.jsx("div",{className:"drift",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag pass",children:"stable"}),s.jsxs("span",{style:{fontSize:13},children:[s.jsx("b",{children:t})," consecutive passing runs on this layer — no regressions since you started tracking."]})]})}):null}function SS({catalog:e,report:t,regression:n,runModel:a,openId:r,setOpenId:i,layer:o,selectable:l,selectedIds:c,allSelected:u,onToggleSelect:d,onToggleSelectAll:h,caps:g}){const v=new Map(((t==null?void 0:t.results)??[]).map(m=>[m.attack.id,m])),f=new Map(((t==null?void 0:t.scores)??[]).map(m=>[m.category,m])),y=[...new Set(e.map(m=>m.category))].sort((m,x)=>(vS.indexOf(m)+1||99)-(vS.indexOf(x)+1||99)),b=Yp(o);return s.jsxs(ml,{title:t?"Results":"Attack library",sub:t?"Grouped by category. Click any attack for the full probe, response, and evidence.":`${e.length} attacks, grouped by category. Each runs against the ${b.target}.`,children:[t&&s.jsx(kD,{}),l&&e.length===0&&s.jsx("div",{className:"card",style:{padding:16},children:s.jsx("span",{className:"muted",style:{fontSize:13},children:"No attacks in scope for this layer. Enable an attack pack above."})}),l&&e.length>0&&s.jsxs("div",{className:"row spread",style:{alignItems:"center",marginBottom:10},children:[s.jsxs("label",{className:"row",style:{gap:8,alignItems:"center",cursor:"pointer",fontSize:12.5},children:[s.jsx("input",{type:"checkbox",checked:u,ref:m=>{m&&(m.indeterminate=!u&&c.size>0)},onChange:h}),s.jsx("span",{children:"Select all"})]}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[c.size," of ",e.length," selected"]})]}),s.jsx("div",{className:"stack",style:{gap:18},children:y.map(m=>{const x=e.filter(S=>S.category===m),j=f.get(m);return s.jsxs("div",{className:"stack",style:{gap:6},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline"},children:[s.jsx("span",{style:{fontSize:13,fontWeight:600},children:$x[m]??m}),s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[x.length," attack",x.length===1?"":"s"]})]}),j&&s.jsxs("span",{className:`tag ${Jp(j.score)}`,children:[j.score,j.breached?` · ${j.breached} breached`:""]})]}),x.map(S=>s.jsx(xD,{attack:S,result:v.get(S.id),change:n==null?void 0:n.changeById[S.id],open:r===S.id,onToggle:()=>i(r===S.id?null:S.id),runModel:a,target:b.target,selectable:l,selected:c.has(S.id),onToggleSelect:()=>d(S.id),caps:g},S.id))]},m)})})]})}function xD({attack:e,result:t,change:n,open:a,onToggle:r,runModel:i,target:o,selectable:l,selected:c,onToggleSelect:u,caps:d}){const h=t==null?void 0:t.verdict,g=l&&!c,v=Mx(e,t),f=iD(e,t);return s.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden",borderColor:h==="breached"?`var(--${Yr(t)})`:void 0,opacity:g?.55:1},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:12,padding:"10px 14px",cursor:"pointer"},onClick:r,children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center",minWidth:0},children:[l&&s.jsx("input",{type:"checkbox",checked:c,onClick:y=>y.stopPropagation(),onChange:u,style:{cursor:"pointer"},"aria-label":`Include ${e.name}`}),h&&s.jsx("span",{style:{color:`var(--${Yr(t)})`,fontWeight:700,width:14,textAlign:"center"},children:D_(h)}),s.jsxs("div",{className:"stack",style:{gap:2,minWidth:0},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:13,fontWeight:500},children:e.name}),v&&s.jsx("span",{className:"tag informational",title:"How this finding was reached",children:Lv[v]??v}),e.execution&&s.jsx("span",{className:`tag ${e.execution==="invasive"?"warn":"informational"}`,children:e.execution==="invasive"?"Live validation":"Non-invasive"}),n==="new-breach"&&s.jsx("span",{className:"tag fail",children:"New breach"}),n==="fixed"&&s.jsx("span",{className:"tag pass",children:"Fixed"})]}),s.jsx("span",{className:"muted",style:{fontSize:12},children:t?t.evidence:e.impact??e.description}),f&&s.jsxs("div",{className:"row",style:{gap:6,alignItems:"center",flexWrap:"wrap",marginTop:2},children:[s.jsx("span",{className:`tag ${f.tone}`,children:f.label}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:f.detail})]})]})]}),s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center",flexShrink:0},children:[e.owasp&&s.jsx("span",{className:"muted mono",style:{fontSize:11},children:e.owasp}),s.jsx("span",{className:`tag ${Ox[e.severity]}`,children:Lx[e.severity]}),s.jsxs("span",{className:"muted mono",style:{fontSize:11},title:"Risk weight",children:[pl[e.severity]," pts"]}),(t==null?void 0:t.ms)!=null&&s.jsx("span",{className:"muted mono",style:{fontSize:11},children:Dx(t.ms)}),h&&s.jsx("span",{className:`tag ${Yr(t)}`,title:sn(t)?"Verified exposure — reachable & unguarded, not executed":void 0,children:z_(t)}),s.jsx("span",{className:"muted",style:{fontSize:11},children:a?"▲":"▼"})]})]}),a&&s.jsx(jD,{attack:e,result:t,runModel:i,target:o,caps:d})]})}function jD({attack:e,result:t,runModel:n,target:a,caps:r}){const i=Mx(e,t),o=U_(e,t),l=o&&!!n&&n!=="deterministic",c=(t==null?void 0:t.capabilityGroups)??[],u=(t==null?void 0:t.poisonedContent)??[];return s.jsxs("div",{className:"stack",style:{gap:12,padding:"12px 14px",borderTop:"1px solid var(--border)",background:"var(--bg-subtle, rgba(127,127,127,0.04))"},children:[s.jsxs("div",{className:"row",style:{gap:20,flexWrap:"wrap"},children:[s.jsx(An,{label:"Category",value:$x[e.category]??e.category}),s.jsx(An,{label:"Severity",value:Lx[e.severity],tone:Ox[e.severity]}),s.jsx(An,{label:"Risk weight",value:`${pl[e.severity]} pts`}),e.owasp&&s.jsx(An,{label:"OWASP",value:M_[e.owasp]??e.owasp}),i&&s.jsx(An,{label:"Analysis",value:i==="resource-inspection"||i==="surface-inspection"?`Deterministic ${(Lv[i]??i).toLowerCase()}`:`${Lv[i]??i} · ${a}`}),s.jsx(An,{label:"Execution",value:o?`Agent run · ${a}`:i==="protocol-probe"?"Bounded live probe":"Not performed",tone:o||i==="protocol-probe"?void 0:"pass"}),(t==null?void 0:t.verdict)&&s.jsx(An,{label:"Status",value:z_(t),tone:Yr(t)}),(t==null?void 0:t.verdict)==="breached"&&s.jsx(An,{label:"Verification",value:aD(t),tone:Yr(t)}),(t==null?void 0:t.evidenceStrength)&&s.jsx(An,{label:"Evidence strength",value:F_(t)}),t&&s.jsx(An,{label:"Graded by",value:t.judged?"LLM-judge":"rule / marker"}),(t==null?void 0:t.ms)!=null&&s.jsx(An,{label:"Duration",value:Dx(t.ms)}),l&&s.jsx(An,{label:"Model",value:n,mono:!0})]}),(t==null?void 0:t.verdict)==="breached"&&s.jsx(Ql,{label:"How this was verified",children:sn(t)?"Verified exposure — Prooflane inspected the advertised surface (tool annotations, schema and contract) and confirmed the capability is advertised to the current client with no required safeguard declared. It intentionally did NOT execute the operation: no destructive call, write, transfer or deletion was performed against your server. “Not declared” is not the same as proven absent server-side, and authorization was not tested.":ma(t)?"Verified poisoning — Prooflane deterministically inspected reachable resource content and located embedded agent-directed instructions. The instruction-bearing content was verified as present. No agent consumed it, no behaviour changed, and no protected boundary was observed to cross as part of this finding.":"Verified breach — Prooflane observed the protected boundary actually cross: a canary leaked, a forbidden tool was invoked, an injected payload executed, or real egress was seen. This is an observed crossing, not a reachable surface."}),c.length>0&&s.jsx(bD,{groups:c}),sn(t)&&c.length>0&&s.jsx(wD,{result:t,target:a,caps:r}),u.length>0&&s.jsx(ND,{hits:u}),e.impact&&s.jsx(Ql,{label:"Why this matters",children:e.impact}),(t==null?void 0:t.probe)&&s.jsx(Ql,{label:"Probe",mono:!0,children:t.probe}),(t==null?void 0:t.response)!==void 0&&s.jsx(Ql,{label:"Response",mono:!0,children:t.response||"(no text response)"}),t&&s.jsx(Ql,{label:"Evidence",children:t.evidence}),!t&&s.jsx("span",{className:"muted",style:{fontSize:12},children:"Run the layer to see this attack’s probe, the agent’s response, and the graded evidence."})]})}function bD({groups:e}){return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Capability findings"}),s.jsx("div",{className:"stack",style:{gap:8},children:e.map(t=>{var n;return s.jsxs("div",{className:"card",style:{padding:"10px 12px"},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:10,flexWrap:"wrap"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:t.title}),s.jsx("span",{className:"tag informational",children:yS[t.capability]??t.capability})]}),s.jsxs("div",{className:"finding-meta",children:[s.jsxs("div",{className:"finding-meta-pair",children:[s.jsx("span",{className:"finding-meta-label",children:"Severity"}),s.jsx("span",{className:`tag ${Ox[t.severity]}`,children:Lx[t.severity]})]}),s.jsxs("div",{className:"finding-meta-pair",children:[s.jsx("span",{className:"finding-meta-label",children:"Confidence"}),s.jsx("span",{className:"finding-meta-value",children:QM[t.confidence]??t.confidence})]})]})]}),s.jsx("div",{className:"row",style:{gap:6,alignItems:"center",flexWrap:"wrap",marginTop:6},children:t.tools.map(a=>s.jsx("span",{className:"mono",style:{fontSize:11.5},children:a.toolName},a.toolName))}),s.jsx("div",{className:"muted",style:{fontSize:11.5,marginTop:6,lineHeight:1.5},children:t.summary}),t.tools.map(a=>s.jsxs("div",{className:"stack",style:{gap:3,marginTop:8},children:[s.jsxs("span",{className:"muted mono",style:{fontSize:11},children:[a.toolName," · safeguards"]}),s.jsx("div",{className:"row",style:{gap:14,flexWrap:"wrap"},children:a.safeguards.map(r=>s.jsxs("span",{style:{fontSize:11.5},title:r.detail,children:[s.jsx("span",{className:"muted",children:r.name})," ",s.jsx("span",{style:{color:r.state==="present"?"var(--pass)":r.state==="absent"?"var(--fail)":void 0},children:lD[r.state]??r.state})]},r.name))}),a.ruledOut.length>0&&s.jsxs("div",{className:"muted",style:{fontSize:11,marginTop:2,lineHeight:1.5},children:["Not claimed: ",a.ruledOut.map(r=>yS[r.class]??r.class).join(", ")," — no annotation, schema field, contract statement or observation supports it."]})]},`${a.toolName}:safeguards`)),s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:8},children:["Execution: ",s.jsx("b",{children:"not performed"})," · Authorization: ",s.jsx("b",{children:"not tested"})]})]},`${t.capability}:${t.guardState}:${((n=t.tools[0])==null?void 0:n.toolName)??""}`)})})]})}function wD({result:e,target:t,caps:n}){var W;const a=p.useMemo(()=>[...new Set((e.capabilityGroups??[]).flatMap(R=>R.tools.map(H=>H.toolName)))],[e.capabilityGroups]),[r,i]=p.useState(!1),[o,l]=p.useState(a[0]??""),[c,u]=p.useState(""),[d,h]=p.useState("{}"),[g,v]=p.useState(""),[f,y]=p.useState(!1),[b,m]=p.useState(!1),[x,j]=p.useState(null),[S,w]=p.useState(null),C=R=>{var B;const H=`prooflane-canary-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`;u(H);const Y=(B=n==null?void 0:n.tools.find(Q=>Q.name===R))==null?void 0:B.inputSchema,K=(Y==null?void 0:Y.required)??[],ce=(Y==null?void 0:Y.properties)??{},F=[...new Set([...K,...Object.keys(ce)])],ie=F.find(Q=>/^(path|file|file_path|filepath)$/i.test(Q))??F.find(Q=>/path|file/i.test(Q))??F.find(Q=>/^(id|key|name|target|resource|uri|url)$/i.test(Q))??F.find(Q=>/id|key|name|target|resource|uri|url/i.test(Q))??K[0]??"canary",ue=Q=>{const X=ce[Q],me=Array.isArray(X==null?void 0:X.type)?X.type[0]:X==null?void 0:X.type;return Q===ie?/path|file/i.test(Q)?`/tmp/${H}.txt`:H:me==="boolean"?!1:me==="integer"||me==="number"?1:me==="array"?[]:me==="object"?{}:/message|commit_message|reason|description/i.test(Q)?`Prooflane controlled canary verification: ${H}`:""},oe=Object.fromEntries([...new Set([...K,ie])].map(Q=>[Q,ue(Q)]));h(JSON.stringify(oe,null,2)),v(""),y(!1)};let k,N=null;try{k=d.trim()?JSON.parse(d):{}}catch{N="Arguments must be valid JSON."}const L=(W=n==null?void 0:n.tools.find(R=>R.name===o))==null?void 0:W.inputSchema,_=!N&&k&&typeof k=="object"&&!Array.isArray(k)?((L==null?void 0:L.required)??[]).filter(R=>{const H=k[R];return H==null||typeof H=="string"&&!H.trim()}):(L==null?void 0:L.required)??[],E=!!c&&d.includes(c),I=!!o&&g===o&&f&&E&&!N&&_.length===0&&!b,$=async()=>{if(I){m(!0),j(null),w(null);try{const{result:R}=await O.executeCapability({toolName:o,input:k,confirmedToolName:g,canaryId:c,acknowledgedDisposableCanary:f});w(R),i(!1)}catch(R){j(R instanceof Error?R.message:"Execution failed.")}finally{m(!1)}}};return s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:10,flexWrap:"wrap"},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Escalate to a verified breach"}),!r&&!S&&s.jsx("button",{className:"btn warn",style:{fontSize:12},onClick:()=>{i(!0),j(null),C(o)},children:"Verify with canary…"})]}),!r&&!S&&s.jsx("span",{className:"muted",style:{fontSize:11.5,lineHeight:1.5},children:"Inspection proved this capability is reachable and unguarded, but did not run it. Controlled verification uses a disposable Prooflane-owned canary only—never an arbitrary customer file, record, repository, or resource."}),r&&s.jsxs("div",{className:"card",style:{padding:"12px 14px",borderColor:"var(--warn)",gap:10,display:"flex",flexDirection:"column"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"tag warn",children:"Controlled mutation"}),s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:"Verify the capability against a disposable canary"})]}),s.jsxs("label",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Tool"}),s.jsx("select",{value:o,onChange:R=>{const H=R.target.value;l(H),C(H)},style:{fontSize:12.5,padding:"6px 8px"},children:a.map(R=>s.jsx("option",{value:R,children:R},R))})]}),s.jsxs("div",{className:"card",style:{padding:"10px 12px",borderColor:"var(--pass)"},children:[s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"muted",style:{fontSize:10,textTransform:"uppercase",letterSpacing:".08em"},children:"Disposable Prooflane canary"}),s.jsx("div",{className:"mono",style:{marginTop:3,fontSize:12},children:c})]}),s.jsx("button",{className:"btn sm",type:"button",onClick:()=>C(o),children:"Generate another"})]}),s.jsxs("div",{className:"muted",style:{fontSize:11,marginTop:7},children:["Create this disposable resource on ",t," before verification. The server will reject arguments that do not contain this exact marker."]})]}),s.jsxs("label",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Canary arguments (JSON) — adapt the field name to the tool schema, but keep the exact canary value"}),s.jsx("textarea",{className:"mono",value:d,onChange:R=>h(R.target.value),rows:4,style:{fontSize:12,padding:"6px 8px",resize:"vertical"},spellCheck:!1}),N&&s.jsx("span",{style:{color:"var(--fail)",fontSize:11},children:N}),!N&&!E&&s.jsx("span",{style:{color:"var(--fail)",fontSize:11},children:"Arguments must contain the exact generated canary id."}),!N&&_.length>0&&s.jsxs("span",{style:{color:"var(--warn)",fontSize:11},children:["Enter your disposable sandbox values for: ",s.jsx("span",{className:"mono",children:_.join(", ")}),"."]})]}),s.jsxs("label",{className:"stack",style:{gap:3},children:[s.jsxs("span",{className:"muted",style:{fontSize:11},children:["Type the tool name ",s.jsx("span",{className:"mono",children:o})," to confirm"]}),s.jsx("input",{value:g,onChange:R=>v(R.target.value),placeholder:o,autoComplete:"off",style:{fontSize:12.5,padding:"6px 8px"}})]}),s.jsxs("label",{className:"row",style:{gap:8,alignItems:"flex-start",fontSize:12,lineHeight:1.5},children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>y(R.target.checked),style:{marginTop:2}}),s.jsx("span",{children:"I created this exact canary as a disposable Prooflane-owned resource. I understand this performs a real mutation against the canary only; protected customer data must not be targeted."})]}),x&&s.jsx("span",{style:{color:"var(--fail)",fontSize:12},children:x}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn",onClick:()=>{i(!1),j(null)},disabled:b,children:"Cancel"}),s.jsx("button",{className:"btn warn",onClick:()=>void $(),disabled:!I,title:I?void 0:"Complete every required schema field, keep the exact canary in the arguments, retype the tool name, and confirm canary ownership.",children:b?"Verifying…":"Approve & verify canary"})]})]}),S&&s.jsxs("div",{className:"card",style:{padding:"12px 14px",borderColor:`var(--${Yr(S)})`},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",gap:10,flexWrap:"wrap"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{style:{color:`var(--${Yr(S)})`,fontWeight:700},children:D_(S.verdict)}),s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:SD(S)})]}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[S.evidenceStrength&&s.jsx("span",{className:"tag informational",children:F_(S)}),S.ms!=null&&s.jsx("span",{className:"muted mono",style:{fontSize:11},children:Dx(S.ms)}),s.jsx("span",{className:`tag ${Yr(S)}`,children:S.verdict==="breached"?"Verified breach":S.verdict==="resisted"?"Authorization enforced":"Inconclusive"})]})]}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:8,lineHeight:1.5},children:S.evidence}),S.probe&&s.jsx("div",{className:"mono",style:{fontSize:11.5,marginTop:8,color:"var(--muted)"},children:S.probe}),S.response&&s.jsx("div",{className:"mono",style:{fontSize:11.5,marginTop:4,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:S.response}),s.jsx("div",{className:"row",style:{marginTop:10},children:s.jsx("button",{className:"btn",style:{fontSize:12},onClick:()=>{w(null),i(!1),v(""),y(!1)},children:"Run again"})})]})]})}function SD(e){return e.verdict==="breached"?"Capability executed — verified breach":e.verdict==="resisted"?"Blocked by a server-side authorization control":"Invoked, but no definite result"}function ND({hits:e}){return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Instruction-bearing content"}),s.jsx("div",{style:{overflowX:"auto"},children:s.jsxs("table",{style:{borderCollapse:"collapse",fontSize:11.5,minWidth:"100%"},children:[s.jsx("thead",{children:s.jsx("tr",{children:["Resource","Matched content","Location","Rule","Content hash"].map(t=>s.jsx("th",{className:"muted",style:{textAlign:"left",fontWeight:500,padding:"4px 12px 4px 0",borderBottom:"1px solid var(--border)",whiteSpace:"nowrap"},children:t},t))})}),s.jsx("tbody",{children:e.map((t,n)=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",style:{padding:"5px 12px 5px 0",borderBottom:"1px solid var(--border-soft)",verticalAlign:"top"},children:t.uri}),s.jsxs("td",{style:{padding:"5px 12px 5px 0",borderBottom:"1px solid var(--border-soft)",verticalAlign:"top",maxWidth:320},children:["“",t.fragment,"”"]}),s.jsx("td",{className:"mono muted",style:{padding:"5px 12px 5px 0",borderBottom:"1px solid var(--border-soft)",verticalAlign:"top",whiteSpace:"nowrap"},children:t.location}),s.jsx("td",{className:"mono muted",style:{padding:"5px 12px 5px 0",borderBottom:"1px solid var(--border-soft)",verticalAlign:"top",whiteSpace:"nowrap"},children:t.ruleId}),s.jsx("td",{className:"mono muted",style:{padding:"5px 0",borderBottom:"1px solid var(--border-soft)",verticalAlign:"top",whiteSpace:"nowrap"},children:t.contentHash})]},`${t.uri}:${t.location}:${n}`))})]})}),s.jsx("span",{className:"muted",style:{fontSize:11.5,marginTop:2},children:"Verification: deterministic resource inspection. No agent execution was performed as part of this finding."})]})}function An({label:e,value:t,tone:n,mono:a}){return s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),s.jsx("span",{className:a?"mono":void 0,style:{fontSize:12.5,color:n?`var(--${n})`:void 0},children:t})]})}function Ql({label:e,children:t,mono:n}){return s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),s.jsx("div",{className:n?"mono":void 0,style:{fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.5},children:t})]})}function NS({report:e}){const t=l=>l.verdict==="breached"&&!sn(l)&&!ma(l),n=e.results.filter(l=>t(l)&&l.attack.severity==="critical").length,a=e.results.filter(l=>t(l)&&l.attack.severity==="high").length,r=e.exposed??e.results.filter(sn).length,i=e.poisoned??e.results.filter(ma).length,o=[{name:"Resistance",value:`${e.overall}%`,label:"risk-weighted · share of risk defended",tone:Jp(e.overall)},{name:"Attacks run",value:String(e.total),label:"this run",tone:"info"},{name:"Breached",value:String(e.breached),label:"boundary crossing observed",tone:e.breached?"fail":"pass"},{name:"Exposed",value:String(r),label:"reachable, not executed",tone:r?"warn":"pass"},{name:"Poisoned",value:String(i),label:"content present, not consumed",tone:i?"warn":"pass"},{name:"Critical",value:String(n),label:"needs immediate fix",tone:n?"fail":"pass"},{name:"High",value:String(a),label:"severity breaches",tone:a?"warn":"pass"}];return s.jsxs(s.Fragment,{children:[e.breached>0&&s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:`tag ${n?"fail":"warn"}`,children:n?"critical":"breach"}),s.jsxs("span",{style:{fontSize:13},children:[s.jsx("b",{children:e.breached})," attack",e.breached===1?"":"s"," breached the agent this run. A regression gate would ",s.jsx("b",{children:"block deploys"})," until resolved."]})]})}),s.jsx("div",{className:"tiles",children:o.map(l=>s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${l.tone}`}),s.jsx("span",{className:"tile-name",children:l.name})]}),s.jsx("div",{className:"tile-value",children:l.value}),s.jsx("div",{className:"tile-label",children:l.label})]},l.name))})]})}function kS({reg:e}){const{newBreaches:t,fixed:n,scoreDelta:a,modelChanged:r,prior:i,currentModel:o}=e,l=t.length>0,c=a>0?`+${a}`:String(a),u=a<0?"fail":a>0?"pass":"info";return s.jsxs(ml,{title:"Regression vs last run",sub:`Compared to the previous ${i.model==="deterministic"?"run":`run on ${i.model}`}, ${H_(i.at)}.`,children:[r&&s.jsx("div",{className:"drift dirty",style:{marginTop:0,marginBottom:10},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"target changed"}),s.jsxs("span",{style:{fontSize:13},children:["Model changed ",s.jsx("span",{className:"mono",children:i.model})," → ",s.jsx("span",{className:"mono",children:o}),". Re-baselining resistance — regressions below are attributable to this change."]})]})}),s.jsx("div",{className:`drift ${l?"dirty":""}`,style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",style:{gap:12,flexWrap:"wrap"},children:[s.jsx("span",{className:`tag ${l?"fail":n.length?"pass":"info"}`,children:l?`${t.length} new breach${t.length===1?"":"es"}`:n.length?"improved":"stable"}),s.jsx("span",{style:{fontSize:13},children:l?s.jsxs(s.Fragment,{children:["Newly breached since last run: ",s.jsx("b",{children:t.map(d=>d.name).join(", ")}),". A regression gate would ",s.jsx("b",{children:"block this deploy"}),"."]}):n.length?s.jsxs(s.Fragment,{children:["No new breaches. Fixed since last run: ",s.jsx("b",{children:n.map(d=>d.name).join(", ")}),"."]}):s.jsx(s.Fragment,{children:"No change since last run — every attack held its prior verdict."})}),s.jsxs("span",{className:`tag ${u}`,children:["resistance ",c]})]})})]})}function kD(){const e=[{tag:"Breached",tone:"fail",means:"a protected boundary was observed to cross — a canary leaked, a forbidden tool was invoked, a payload executed."},{tag:"Exposed",tone:"warn",means:"a dangerous capability is advertised with no safeguard declared in its contract. Verified by inspection; the operation was not executed."},{tag:"Poisoned",tone:"warn",means:"agent-directed instruction content is present in reachable resource content. Nothing was observed consuming it."}];return s.jsx("div",{className:"card",style:{padding:"10px 14px",marginBottom:12},children:s.jsx("div",{className:"stack",style:{gap:5},children:e.map(t=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{className:`tag ${t.tone}`,style:{minWidth:62,textAlign:"center"},children:t.tag}),s.jsx("span",{className:"muted",style:{fontSize:11.5,lineHeight:1.5,flex:1,minWidth:220},children:t.means})]},t.tag))})})}function ES({s:e}){const t=Jp(e.score),n=e.exposed??0,a=e.poisoned??0;return s.jsx("div",{className:"card",style:{padding:"10px 14px"},children:s.jsxs("div",{className:"row spread",style:{alignItems:"center"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:`tile-dot ${t}`}),s.jsx("span",{style:{fontSize:13,fontWeight:500},children:$x[e.category]??e.category})]}),s.jsxs("div",{className:"row",style:{gap:14,alignItems:"center"},children:[s.jsxs("span",{className:"muted mono",style:{fontSize:12},children:[e.total," run"]}),s.jsxs("span",{className:"mono",style:{fontSize:12,color:e.breached?"var(--fail)":"var(--pass)"},children:[e.breached," breached"]}),n>0&&s.jsxs("span",{className:"mono",style:{fontSize:12,color:"var(--warn)"},children:[n," exposed"]}),a>0&&s.jsxs("span",{className:"mono",style:{fontSize:12,color:"var(--warn)"},children:[a," poisoned"]}),s.jsx("span",{className:`tag ${t}`,children:e.score})]})]})})}function ml({title:e,sub:t,children:n}){return s.jsxs("section",{children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",marginBottom:12,flexWrap:"wrap"},children:[s.jsx("div",{className:"detail-title",style:{fontSize:15},children:e}),t&&s.jsx("span",{className:"muted",style:{fontSize:12.5},children:t})]}),n]})}function ED({connected:e}){const[t,n]=p.useState([]),[a,r]=p.useState(null),[i,o]=p.useState(null),[l,c]=p.useState(null),[u,d]=p.useState("all"),[,h]=p.useState(0);p.useEffect(()=>mr(()=>h(m=>m+1)),[]),p.useEffect(()=>{O.redteamCampaigns().then(m=>n(m.campaigns)).catch(()=>n([]))},[]);async function g(m){if(c(null),!e){c("Connect to an MCP server first — a campaign runs its steps against the live session.");return}const x=Es(),j=x!=null&&x.model&&(x!=null&&x.apiKey)?{provider:x.provider,baseUrl:x.baseUrl||void 0,model:x.model,apiKey:x.apiKey}:void 0;r(m),o(null);try{const S=await O.redteamCampaignRun(m,j);if(!S.ok){c(S.error??"Campaign run failed.");return}o(S),S.run&&Oa([S.run]),await Ds()}catch(S){c(S instanceof Error?S.message:String(S))}finally{r(null)}}const v=Ws(),f=[{id:"all",name:"All campaigns",description:"Complete end-to-end attack paths."},{id:"mixed-intent",name:"Mixed Intent",description:"Hostile instructions concealed inside an otherwise legitimate prompt."},{id:"resource-tool",name:"Resource → Tool",description:"Untrusted retrieved content attempting to steer a tool call."},{id:"tool-chain",name:"Tool-Chain Pivot",description:"A benign workflow escalating step by step toward destructive action."},{id:"state-context",name:"State & Context",description:"Stale, poisoned, or deferred context influencing a later decision."}],y=m=>{if(u==="all")return!0;const x={"mixed-intent":"mixed-intent-prompt","resource-tool":"resource-to-tool-pivot","tool-chain":"tool-chain-pivot","state-context":"state-context-confusion"};return m.id===x[u]},b=t.filter(y);return s.jsxs("div",{className:"stack",style:{gap:18},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",flexWrap:"wrap",gap:12},children:[s.jsxs("div",{className:"stack",style:{gap:4,maxWidth:640},children:[s.jsxs("span",{style:{fontSize:13.5},children:["A ",s.jsx("b",{children:"campaign"})," chains attacks along the AI kill chain toward one objective. Run it end to end to see the"," ",s.jsx("b",{children:"attack path"})," — which boundaries were crossed, where a control held, and whether the objective is reachable."]}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:["Deterministic steps probe the live session. Agent-layer steps (prompt / retrieval / agentic) drive your configured model —",v?" a model is connected.":" without one those steps are skipped."]})]}),s.jsx(Qr,{})]}),s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:13,fontWeight:650},children:"Campaign packs"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Focused boundary coverage without tenant fixtures or authorization setup."})]}),s.jsx("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))"},children:f.map(m=>s.jsxs("button",{type:"button",className:`card ${u===m.id?"active":""}`,onClick:()=>d(m.id),style:{padding:14,textAlign:"left",cursor:"pointer",borderColor:u===m.id?"var(--accent)":void 0},children:[s.jsx("span",{style:{display:"block",fontSize:13,fontWeight:650},children:m.name}),s.jsx("span",{className:"muted",style:{display:"block",marginTop:5,fontSize:11.5,lineHeight:1.45},children:m.description})]},m.id))})]}),l&&s.jsx("div",{className:"drift dirty",style:{marginTop:0},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"setup"}),s.jsx("span",{style:{fontSize:13},children:l})]})}),i&&s.jsx(CD,{result:i,onClose:()=>o(null)}),s.jsxs("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[b.map(m=>{const x=m.killChain.reduce((w,C)=>Math.max(w,C.severity==="critical"?3:C.severity==="high"?2:1),0),j=x===3?"Critical":x===2?"High":"Medium",S=a===m.id;return s.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:10},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:8},children:[s.jsx("span",{style:{fontSize:14.5,fontWeight:600},children:m.name}),s.jsx("span",{className:`tag ${x===3?"fail":"warn"}`,children:j})]}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:m.objective}),s.jsx("div",{className:"row",style:{gap:6,alignItems:"center",flexWrap:"wrap"},children:m.killChain.map((w,C)=>s.jsxs("span",{className:"row",style:{gap:6,alignItems:"center"},children:[C>0&&s.jsx("span",{className:"muted",style:{fontSize:11},children:"→"}),s.jsx("span",{className:"mono",style:{fontSize:10.5,color:"var(--muted)"},title:w.name,children:w.stage})]},w.attackId+C))}),s.jsxs("div",{className:"row spread",style:{alignItems:"center",marginTop:2},children:[s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[m.steps.length," steps · ",m.outcomeQuestion]}),s.jsx("button",{className:"btn sm primary",onClick:()=>g(m.id),disabled:!!a||!e,children:S?"Running…":"Run campaign"})]})]},m.id)}),b.length===0&&s.jsx("div",{className:"card",style:{padding:20},children:s.jsx("span",{className:"muted",style:{fontSize:13},children:"No campaigns are currently mapped to this pack."})})]})]})}function V_(e){return e==="breached"?"failed":e==="resisted"?"blocked":e==="inconclusive"?"inconclusive":e==="error"?"error":"not-exercised"}const q_={failed:"FAILED",blocked:"BLOCKED",inconclusive:"INCONCLUSIVE","not-exercised":"NOT EXERCISED",error:"ERROR"},K_={failed:"fail",blocked:"pass",inconclusive:"warn","not-exercised":"info",error:"warn"},_D={failed:"✗",blocked:"✓",inconclusive:"?","not-exercised":"–",error:"!"};function CD({result:e,onClose:t}){const{failed:n,inconclusive:a,blocked:r,notExercised:i}=e.counts,o=e.objectiveReached,l=e.serverName??"the connected server",c=e.path.map((S,w)=>({s:S,i:w})),u=c.filter(S=>S.s.kind==="containment"),d=c.filter(S=>S.s.kind==="agent-behavior"),h=e.path.findIndex(S=>S.verdict==="breached"),[g,v]=p.useState(h),f=g>=0?e.path[g]:void 0,y=e.path.find(S=>S.verdict==="breached"),b=o?"reached":n>0?"partial":a>0?"inconclusive":"contained",m=b==="reached"||b==="partial"?"fail":b==="inconclusive"?"warn":"pass",x=b==="reached"?`OBJECTIVE REACHED · ${e.campaign.objectiveLabel}`:b==="partial"?`NOT CONTAINED · ${n} control${n===1?"":"s"} failed, objective not reached`:b==="inconclusive"?"INCONCLUSIVE · no control verifiably failed":"CONTAINED · every control held",j=[n?`${n} failed`:"",a?`${a} inconclusive`:"",r?`${r} held`:"",i?`${i} not exercised`:""].filter(Boolean).join(" · ");return s.jsxs("div",{className:"card",style:{padding:18},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:3},children:[s.jsxs("span",{style:{fontSize:15,fontWeight:600},children:["Attack graph · ",e.campaign.name]}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:e.campaign.outcomeQuestion})]}),s.jsx("button",{className:"btn sm ghost",onClick:t,children:"Close"})]}),s.jsxs("div",{className:"stack",style:{gap:4,margin:"14px 0",padding:"12px 14px",borderRadius:8,background:`var(--${m}-bg, rgba(128,128,128,0.08))`},children:[s.jsxs("span",{className:"row",style:{gap:9,alignItems:"center"},children:[s.jsx("span",{style:{fontSize:17,color:`var(--${m})`},children:b==="contained"?"✓":b==="inconclusive"?"?":"✗"}),s.jsx("span",{style:{fontSize:13.5,fontWeight:700,color:`var(--${m})`,letterSpacing:"0.2px"},children:x})]}),j&&s.jsx("span",{className:"muted",style:{fontSize:12,marginLeft:26},children:j}),y&&s.jsxs("span",{style:{fontSize:12,marginLeft:26},children:["Strongest finding: ",s.jsx("b",{children:y.control})," — ",y.evidence]})]}),s.jsx("div",{className:"muted",style:{fontSize:11.5,marginBottom:10},children:"Independent control probes, grouped by what they test — not one execution. A held control never gates another. Click a control for detail."}),d.length>0&&s.jsxs("div",{className:"stack",style:{gap:3,marginBottom:10,padding:"10px 12px",borderRadius:8,border:"1px solid var(--warn, #e4a11b)",background:"var(--warn-bg, rgba(228,161,27,0.06))"},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:700,color:"var(--warn, #e4a11b)",textTransform:"uppercase",letterSpacing:"0.4px"},children:"Attribution"}),s.jsxs("span",{style:{fontSize:12},children:["Agent-behavior findings test ",s.jsxs("b",{children:["the model",e.model?` (${e.model})`:""]})," with a ",s.jsx("b",{children:"Prooflane-synthesized probe"})," — a planted document, not content retrieved from ",s.jsx("b",{children:l}),". They are ",s.jsx("b",{children:"not"})," evidence that ",l," served malicious content, that an MCP tool was involved, or that any server boundary was crossed. Don't report these to a third party without a raw MCP trace showing the server as the source."]})]}),u.length>0&&s.jsx(_S,{title:"Containment controls",sub:`Probed directly against ${l} — no model involved. A reachable tool is exposed surface; only real evidence is a verified failure.`,items:u,selected:g,onSelect:v}),d.length>0&&s.jsx(_S,{title:"Agent behavior · synthetic probe",sub:"Drives the model with a Prooflane-planted scenario — measures the model/client's resistance, not the connected server. A refusal here is safe behavior; a failure is a model finding, not attributable to the server.",items:d,selected:g,onSelect:v}),s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center",marginTop:14,padding:"12px 14px",borderRadius:8,border:`1px solid var(--${o?"fail":"pass"})`,background:`var(--${o?"fail":"pass"}-bg, rgba(128,128,128,0.06))`},children:[s.jsx("span",{style:{fontSize:15,color:`var(--${o?"fail":"pass"})`},children:o?"✗":"✓"}),s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{className:"mono",style:{fontSize:10,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.4px"},children:"Objective"}),s.jsxs("span",{style:{fontSize:13,fontWeight:600},children:[e.campaign.objectiveLabel," — ",o?"REACHED":"NOT REACHED"]})]})]}),f&&s.jsx(RD,{step:f,serverName:l})]})}function _S({title:e,sub:t,items:n,selected:a,onSelect:r}){return s.jsxs("div",{className:"stack",style:{gap:8,marginTop:12},children:[s.jsxs("div",{className:"stack",style:{gap:1},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:600},children:e}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:t})]}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap",alignItems:"stretch"},children:n.map(({s:i,i:o})=>s.jsx(TD,{step:i,selected:o===a,onClick:()=>r(o===a?-1:o)},i.attackId+o))})]})}function TD({step:e,selected:t,onClick:n}){const a=V_(e.verdict),r=K_[a],i=a==="failed";return s.jsxs("button",{className:"stack",onClick:n,title:"Click for detail",style:{gap:4,padding:"9px 11px",borderRadius:8,minWidth:150,textAlign:"left",cursor:"pointer",border:`1px solid ${i?"var(--fail)":a==="blocked"?"var(--pass)":"var(--border, rgba(128,128,128,0.35))"}`,boxShadow:t?"0 0 0 2px var(--accent, #d99a2b)":"none",background:i?"var(--fail-bg, rgba(220,53,69,0.08))":"transparent"},children:[s.jsx("span",{className:"mono",style:{fontSize:10,color:"var(--muted)",textTransform:"uppercase",letterSpacing:"0.4px"},children:e.control}),s.jsx("span",{style:{fontSize:12,fontWeight:600},children:e.name}),s.jsxs("span",{className:"row",style:{gap:4,alignItems:"center"},children:[s.jsx("span",{style:{fontSize:11,color:`var(--${r})`},children:_D[a]}),s.jsx("span",{className:`tag ${r}`,style:{fontSize:10},children:q_[a]})]})]})}function RD({step:e,serverName:t}){const n=V_(e.verdict),a=K_[n],r=n==="failed",i=n==="inconclusive",o=n==="not-exercised",l=e.provenance==="synthetic-probe";return s.jsxs("div",{className:"card",style:{marginTop:14,padding:16,background:"var(--panel, rgba(128,128,128,0.05))"},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",flexWrap:"wrap",marginBottom:10},children:[s.jsx("span",{className:"mono",style:{fontSize:10.5,color:"var(--muted)",textTransform:"uppercase"},children:e.control}),s.jsx("span",{style:{fontSize:14,fontWeight:600},children:e.name}),s.jsx("span",{className:`tag ${a}`,style:{fontSize:10.5},children:q_[n]}),s.jsx("span",{className:"tag info",style:{fontSize:10.5},children:l?"agent behavior · synthetic probe":"containment · infra"}),e.owasp&&s.jsx("span",{className:"tag info",style:{fontSize:10.5},children:M_[e.owasp]??e.owasp}),s.jsx("span",{className:"mono muted",style:{fontSize:10.5},children:e.attackId})]}),s.jsxs("div",{className:"stack",style:{gap:2,marginBottom:4,padding:"9px 11px",borderRadius:6,border:`1px solid ${l?"var(--warn, #e4a11b)":"var(--border, rgba(128,128,128,0.35))"}`,background:l?"var(--warn-bg, rgba(228,161,27,0.06))":"transparent"},children:[s.jsx("span",{className:"muted",style:{fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.4px"},children:"Attribution"}),s.jsx("span",{style:{fontSize:12},children:l?s.jsxs(s.Fragment,{children:["About ",s.jsx("b",{children:"the model/client"})," under a ",s.jsx("b",{children:"Prooflane-synthesized probe"})," — not ",t,". This is not evidence ",t," supplied the content or that a server boundary was crossed. Don't report to a third party without a raw MCP trace proving the server is the source."]}):s.jsxs(s.Fragment,{children:["About ",s.jsx("b",{children:t})," — this control was probed directly against the connected server (real MCP calls)."]})})]}),e.description&&s.jsx(kf,{label:"What we checked",body:e.description}),s.jsx(kf,{label:r?l?"What we found (model behavior)":"What we found":i?"What we observed (unverified)":o?"Status":"Result",body:e.evidence,tone:r?"fail":i?"warn":void 0}),(e.probe||e.response)&&s.jsxs("div",{className:"stack",style:{gap:4,marginTop:8},children:[s.jsx("span",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:"0.4px"},children:l?"Debug — Prooflane-synthesized probe & model response":"Debug — probe & response"}),e.probe&&s.jsxs("pre",{className:"mono",style:{margin:0,padding:"8px 10px",borderRadius:6,background:"var(--code-bg, rgba(128,128,128,0.10))",fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[s.jsx("b",{children:"probe →"})," ",e.probe]}),e.response&&s.jsxs("pre",{className:"mono",style:{margin:0,padding:"8px 10px",borderRadius:6,background:"var(--code-bg, rgba(128,128,128,0.10))",fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[s.jsx("b",{children:"response ←"})," ",e.response]})]}),i&&s.jsxs("div",{className:"stack",style:{gap:3,marginTop:10,padding:"10px 12px",borderRadius:6,border:"1px solid var(--warn, #e4a11b)",background:"var(--warn-bg, rgba(228,161,27,0.06))"},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--warn, #e4a11b)",textTransform:"uppercase",letterSpacing:"0.4px"},children:"Why inconclusive"}),s.jsx("span",{style:{fontSize:12.5},children:"The tool was reachable and returned without error, but Prooflane didn't verify the boundary was actually crossed (that needs an out-of-band canary callback or a command-output canary). It's counted as neither pass nor fail — treat it as attack surface to review."})]}),e.impact&&s.jsx(kf,{label:"Why it matters",body:e.impact}),e.remediation&&(r||i)&&s.jsxs("div",{className:"stack",style:{gap:4,marginTop:10,padding:"10px 12px",borderRadius:6,border:"1px solid var(--pass)",background:"var(--pass-bg, rgba(40,167,69,0.06))"},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--pass)",textTransform:"uppercase",letterSpacing:"0.4px"},children:r?"How to fix it":"How to reduce this surface"}),s.jsx("span",{style:{fontSize:12.5},children:e.remediation})]}),o&&s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center",marginTop:10},children:[s.jsx("span",{className:"muted",style:{fontSize:12},children:e.kind==="agent-behavior"?"This agent-behavior step needs a model to drive it.":"No probeable surface for this control on the connected server."}),e.kind==="agent-behavior"&&s.jsx(Qr,{})]})]})}function kf({label:e,body:t,tone:n}){return s.jsxs("div",{className:"stack",style:{gap:2,marginTop:8},children:[s.jsx("span",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:"0.4px"},children:e}),s.jsx("span",{style:{fontSize:12.5,color:n?`var(--${n})`:void 0},children:t})]})}const CS="prooflane.security.focusGeneration";function ID(e,t){return[...e.humanReview.itemReviews??[]].reverse().find(n=>n.itemId===t)}function AD(e,t){return!!(e&&t&&JSON.stringify(e)===JSON.stringify(t))}function PD({visible:e,onNavigateIntelligence:t}){const[n,a]=p.useState(null),[r,i]=p.useState(!1),[o,l]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState(""),[g,v]=p.useState(null),f=async x=>{const j=await O.sammyGeneration(x);return a(j.generation),j.generation};p.useEffect(()=>{if(!e)return;const x=localStorage.getItem(CS);x&&(i(!0),v(null),f(x).catch(j=>{a(null),v(j instanceof Error?j.message:"The generated Security plan is unavailable.")}).finally(()=>i(!1)))},[e]);const y=p.useMemo(()=>(n==null?void 0:n.draftSuite.tests.filter(x=>x.pillar==="security"))??[],[n]),b=p.useMemo(()=>{var x;return((x=n==null?void 0:n.deferredRecommendations)==null?void 0:x.filter(j=>j.pillar==="security"))??[]},[n]),m=async(x,j)=>{if(n){l(x.id),v(null);try{const S=j==="MODIFY"?JSON.parse(d):void 0,w=N=>O.sammyGenerationReviewItem(N.id,x.id,{action:j,expectedRevisionNumber:N.humanReview.revisionNumber,comment:`Security workbench ${j.toLowerCase()} decision.`,...S?{replacement:S}:{}});let C;try{C=await w(n)}catch(N){if((N==null?void 0:N.code)!=="GENERATION_REVISION_CONFLICT")throw N;const L=await f(n.id),_=L.draftSuite.tests.find(E=>E.id===x.id);if(!AD(x,_))throw new Error("This Security item changed while it was open. The latest revision is now shown; review it before deciding again.");C=await w(L)}a(C.generation),u(null),h("");const k=j==="ACCEPT"?"accepted":j==="MODIFY"?"modified":"rejected";v(`${x.name} ${k} · revision ${C.generation.humanReview.revisionNumber}`)}catch(S){v(S instanceof Error?S.message:"The Security item review failed.")}finally{l(null)}}};return!n&&!r&&!g?null:s.jsxs("section",{className:"security-intelligence-review","aria-label":"Generated Security plan review",children:[s.jsxs("div",{className:"security-intelligence-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"Generated by Assurance Intelligence"}),s.jsx("h3",{children:"Security plan review"}),s.jsx("p",{children:r?"Loading the exact generated revision…":"Review executable Security controls and plan-only recommendations before accepting the complete assurance plan."})]}),s.jsxs("div",{className:"row",children:[s.jsx("span",{className:"tag informational",children:(n==null?void 0:n.strategy)??"SAMMY"}),n&&s.jsxs("span",{className:"tag",children:["REVISION ",n.humanReview.revisionNumber]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{localStorage.removeItem(CS),a(null),v(null)},children:"Close review"})]})]}),g&&s.jsx("div",{className:"security-intelligence-message",role:"status",children:g}),n&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"security-intelligence-summary",children:[s.jsxs("span",{children:[s.jsx("b",{children:y.length})," authored controls"]}),s.jsxs("span",{children:[s.jsx("b",{children:b.length})," plan-only"]}),s.jsxs("span",{children:[s.jsx("b",{children:n.draftSuite.status})," suite state"]}),s.jsxs("span",{className:"mono",children:[n.draftSuite.id,"@",n.draftSuite.version]})]}),y.length>0&&s.jsx("div",{className:"security-intelligence-grid",children:y.map(x=>{var N,L,_,E,I,$,W,R;const j=ID(n,x.id),S=!!x.intelligence,w=o===x.id,C=((N=x.assurance)==null?void 0:N.capabilities)??((_=(L=x.assurance)==null?void 0:L.steps)==null?void 0:_.map(H=>H.capabilityId??H.id??"").filter(Boolean))??[],k=((E=x.security)==null?void 0:E.attackIds)??((I=x.security)==null?void 0:I.packs)??(($=x.security)==null?void 0:$.layers)??[];return s.jsxs("article",{className:"security-intelligence-item",children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{className:"row",children:[s.jsx("span",{className:`tag ${S?"informational":"pass"}`,children:S?"MODEL GENERATED":"DETERMINISTIC MANDATORY"}),s.jsx("span",{className:"tag pass",children:"EXECUTABLE"}),j&&s.jsx("span",{className:"tag warn",children:j.action})]}),s.jsx("span",{className:"mono muted",children:x.id})]}),s.jsx("h4",{children:x.name}),s.jsx("p",{children:((W=x.intelligence)==null?void 0:W.reason)??((R=x.assurance)==null?void 0:R.objective)??"Required deterministic Security coverage for the discovered target."}),s.jsx("div",{className:"security-intelligence-meta",children:[...C,...k].length?[...C,...k].join(" · "):"Bound to the generated Security control"}),s.jsxs("details",{children:[s.jsx("summary",{children:"Inspect generated control JSON"}),s.jsx("pre",{children:JSON.stringify(x,null,2)})]}),c===x.id&&s.jsxs("div",{className:"security-intelligence-editor",children:[s.jsxs("label",{children:["Replacement Security item JSON",s.jsx("textarea",{className:"mono",value:d,onChange:H=>h(H.target.value)})]}),s.jsxs("div",{className:"row",children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>{u(null),h("")},children:"Cancel"}),s.jsx("button",{className:"btn sm primary",disabled:w,onClick:()=>void m(x,"MODIFY"),children:w?"Saving…":"Apply modification"})]})]}),n.humanReview.lifecycleState==="DRAFT"&&c!==x.id&&s.jsxs("div",{className:"security-intelligence-actions",children:[s.jsx("button",{className:"btn sm ghost",disabled:w,onClick:()=>void m(x,"ACCEPT"),children:w?"Saving…":"Accept"}),s.jsx("button",{className:"btn sm ghost",disabled:w||!S,title:S?void 0:"Mandatory deterministic controls cannot be rewritten.",onClick:()=>{u(x.id),h(JSON.stringify(x,null,2))},children:"Modify"}),s.jsx("button",{className:"btn sm danger",disabled:w||!S,title:S?void 0:"Mandatory deterministic controls cannot be removed.",onClick:()=>void m(x,"REJECT"),children:"Reject"})]})]},x.id)})}),b.length>0&&s.jsxs("div",{className:"security-intelligence-deferred",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"Plan-only Security recommendations"}),s.jsxs("strong",{children:[b.length," require a faithful Runner adapter or revised coverage"]})]}),b.map(x=>s.jsxs("article",{children:[s.jsx("span",{className:"tag warn",children:x.deferredReason??"PLAN ONLY"}),s.jsxs("div",{children:[s.jsx("b",{children:x.testType}),s.jsx("p",{children:x.reason}),s.jsx("code",{children:x.recommendationId})]})]},`${x.recommendationId}:${x.testType}`))]}),!y.length&&!b.length&&s.jsx("div",{className:"security-intelligence-empty",children:"This generation contains no Security recommendations requiring review."}),s.jsxs("div",{className:"security-intelligence-footer",children:[s.jsx("span",{children:"Item decisions update the same revision-protected plan. Complete whole-plan Review and Approval in Assurance Intelligence."}),t&&s.jsx("button",{className:"btn sm primary",onClick:()=>{localStorage.setItem("prooflane.intelligence.focusGeneration",n.id),t()},children:"Continue plan review →"})]})]})]})}function $D(e,t,n){const a=new Set(n),r=e.filter(i=>a.has(i.packId));return{checksTotal:r.length,checksCompleted:0,percentage:0,currentLabel:"Preparing the scan…",stages:t.map(i=>({stage:i.id,label:i.label,state:"queued"})),checks:r.map(i=>({checkId:i.id,title:i.title,packId:i.packId,stage:i.stage,state:"queued"})),lastSequence:0}}function OD(e,t){if(t.sequence<=e.lastSequence)return e;const n={...e,lastSequence:t.sequence};if(t.type==="stage")n.stages=e.stages.map(a=>a.stage===t.stage?{...a,state:t.status==="completed"?"completed":"running",detail:t.detail}:a),t.status==="running"&&(n.currentLabel=t.detail),n.checksCompleted=t.checksCompleted,n.checksTotal=t.checksTotal||e.checksTotal;else if(t.type==="check"){let a=!1;n.checks=e.checks.map(r=>r.checkId!==t.checkId?r:(a=!0,t.status==="running"?{...r,state:"running"}:{...r,state:"completed",outcome:t.outcome,evidenceClass:t.evidenceClass,severity:t.severity,detail:t.detail})),a||(n.checks=[...n.checks,{checkId:t.checkId,title:t.title,packId:t.packId,stage:t.stage,state:t.status==="running"?"running":"completed",outcome:t.outcome,evidenceClass:t.evidenceClass,severity:t.severity,detail:t.detail}]),n.currentCheckId=t.status==="running"?t.checkId:e.currentCheckId,t.status==="running"&&(n.currentLabel=t.title),n.checksCompleted=t.checksCompleted,n.checksTotal=t.checksTotal||e.checksTotal}else n.terminal=t.status,n.checksCompleted=t.checksCompleted,n.checksTotal=t.checksTotal||e.checksTotal,n.currentCheckId=void 0,n.currentLabel=t.detail,n.stages=e.stages.map(a=>a.state==="running"?{...a,state:"completed"}:a);return n.percentage=n.checksTotal?Math.round(n.checksCompleted/n.checksTotal*100):0,n}function Ef(e,t,n="failed"){return{...e,terminal:n,currentCheckId:void 0,currentLabel:t,stages:e.stages.map(a=>a.state==="queued"?{...a,state:"skipped"}:a.state==="running"?{...a,state:"skipped"}:a),checks:e.checks.map(a=>a.state==="completed"?a:{...a,state:"skipped"})}}function LD(e){if(e.state==="queued")return{tone:"queued",glyph:"○",label:"Queued"};if(e.state==="running")return{tone:"running",glyph:"●",label:"Running"};if(e.state==="skipped")return{tone:"skipped",glyph:"–",label:"Not run"};switch(e.outcome){case"clean":return{tone:"verified",glyph:"✓",label:"Verified"};case"not-applicable":return{tone:"skipped",glyph:"–",label:"Not applicable"};case"inconclusive":return{tone:"inconclusive",glyph:"?",label:"Inconclusive"}}switch(e.evidenceClass){case"verified-exposure":return{tone:"exposed",glyph:"!",label:"Exposed"};case"verified-poisoning":return{tone:"poisoned",glyph:"◆",label:"Poisoned"};case"verified-structure":return{tone:"structural",glyph:"▣",label:"Structure"};case"suspicious":return{tone:"suspicious",glyph:"~",label:"Suspicious"};default:return{tone:"inconclusive",glyph:"?",label:"Inconclusive"}}}function MD(e){switch(e.state){case"completed":return{tone:"verified",glyph:"✓",label:"Done"};case"running":return{tone:"running",glyph:"●",label:"Running"};case"skipped":return{tone:"skipped",glyph:"–",label:"Not run"};default:return{tone:"queued",glyph:"○",label:"Queued"}}}const zx={"verified-structure":"VERIFIED STRUCTURE","verified-exposure":"VERIFIED EXPOSURE","verified-poisoning":"VERIFIED POISONING",suspicious:"SUSPICIOUS",inconclusive:"INCONCLUSIVE"},DD={"static-container-parse":"Static deterministic container parsing","static-opcode-inspection":"Static deterministic opcode inspection","static-text-inspection":"Static deterministic text inspection","static-inventory":"Static deterministic file inventory","cryptographic-digest":"Cryptographic digest comparison","source-metadata":"Declared source metadata review"},TS=[{id:"directory",name:"Local directory",hint:"A model repository checked out on this device."},{id:"file",name:"Local file",hint:"A single weight, config or template file on this device."},{id:"url",name:"URL",hint:"An https artifact. Prooflane downloads it, inspects it, then deletes it."},{id:"huggingface",name:"Hugging Face",hint:"A repository id and revision. Metadata is fetched; weights are not."}],zD=["critical","high","medium","low","info"],UD={pass:"pass",warning:"warn",blocked:"fail","not-measured":"informational"};function FD(e){const t=["B","KiB","MiB","GiB","TiB"];let n=e,a=0;for(;n>=1024&&a<t.length-1;)n/=1024,a++;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function GD(e){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e))}function J_(e){return e==="insufficient-evidence"?"INSUFFICIENT EVIDENCE":e.toUpperCase()}function Y_(e){return e==="ready"?"✓":e==="blocked"?"✗":e==="review"?"▲":"–"}function WD({onOpenRuntime:e}){const[t,n]=p.useState(null),[a,r]=p.useState(null),[i,o]=p.useState("directory"),[l,c]=p.useState(""),[u,d]=p.useState(""),[h,g]=p.useState(""),[v,f]=p.useState(""),[y,b]=p.useState(!1),[m,x]=p.useState(!1),[j,S]=p.useState(2e4),[w,C]=p.useState(2),[k,N]=p.useState(512),[L,_]=p.useState(new Set),[E,I]=p.useState("configure"),[$,W]=p.useState(!1),[R,H]=p.useState(null),[Y,K]=p.useState(null),[ce,F]=p.useState(null),[ie,ue]=p.useState([]),[oe,B]=p.useState(null),[Q,X]=p.useState("all"),me=p.useRef(null);p.useEffect(()=>{O.modelSecurityCatalog().then(re=>{n(re),_(new Set(re.packs.map(V=>V.id)))}).catch(re=>r(re instanceof Error?re.message:String(re)))},[]);const fe=p.useCallback(async()=>{ue(await O.modelSecurityHistory(50))},[]);p.useEffect(()=>{fe().catch(()=>{})},[fe]);const P=p.useMemo(()=>((t==null?void 0:t.packs)??[]).filter(re=>L.has(re.id)).map(re=>re.id),[t,L]),T=p.useMemo(()=>((t==null?void 0:t.checks)??[]).filter(re=>L.has(re.packId)).length,[t,L]),he=TS.find(re=>re.id===i),q=!!l.trim()&&P.length>0&&!$;function se(re){_(V=>{const le=new Set(V);return le.has(re)?le.delete(re):le.add(re),le})}async function ge(){if(!t)return;const re=l.trim();if(!re){F("Enter a model target before running the scan.");return}if(!P.length){F("Select at least one Model & Supply Chain pack.");return}F(null),K(null),W(!0),I("progress");const V={sourceType:i,source:re,revision:u.trim()||void 0,sha256:h.trim()||void 0};let le=$D(t.checks,t.stages,P);H(le);const ee=new AbortController;me.current=ee;try{const xe=await O.modelSecurityRunStream({target:V,packIds:P,followSymlinks:m,maxFiles:j,maxTextMb:w,maxArchiveMb:k,huggingFaceToken:i==="huggingface"&&v.trim()||void 0},Fe=>{le=OD(le,Fe),H(le)},ee.signal);if(!xe.ok||!xe.report){const Fe=xe.error??"The model security scan failed.";F(Fe),H(Ef(le,Fe));return}K(xe.report),I("result"),await KD(xe.report),await fe()}catch(xe){if(ee.signal.aborted||xe.name==="AbortError")H(Ef(le,"The scan was stopped before it completed."));else{const Fe=xe instanceof Error?xe.message:String(xe);F(Fe),H(Ef(le,Fe))}}finally{W(!1),me.current=null}}function de(){var re;(re=me.current)==null||re.abort()}async function Ne(re){F(null);try{const V=await O.modelSecurityScan(re);K(V.report),H(null),I("result")}catch(V){F(V instanceof Error?V.message:String(V))}}async function Oe(re){await O.deleteModelSecurityScan(re),(Y==null?void 0:Y.scanId)===re&&K(null),await fe()}const _e=p.useMemo(()=>((Y==null?void 0:Y.findings)??[]).filter(re=>Q==="all"||re.severity===Q),[Y,Q]);return s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsxs("div",{className:"tabbar",role:"tablist","aria-label":"Model & Supply Chain sections",children:[s.jsx("button",{role:"tab","aria-selected":E==="configure",className:`tab ${E==="configure"?"active":""}`,onClick:()=>I("configure"),children:"Target & packs"}),R&&s.jsxs("button",{role:"tab","aria-selected":E==="progress",className:`tab ${E==="progress"?"active":""}`,onClick:()=>I("progress"),children:["Scan progress ",s.jsxs("span",{className:`tag ${R.terminal==="completed"?"pass":R.terminal==="failed"?"fail":"informational"}`,style:{marginLeft:5},children:[R.percentage,"%"]})]}),Y&&s.jsx("button",{role:"tab","aria-selected":E==="result",className:`tab ${E==="result"?"active":""}`,onClick:()=>I("result"),children:"Result"}),s.jsxs("button",{role:"tab","aria-selected":E==="history",className:`tab ${E==="history"?"active":""}`,onClick:()=>{I("history"),fe().catch(()=>{})},children:["History",ie.length?s.jsx("span",{className:"tag informational",style:{marginLeft:5},children:ie.length}):null]})]}),a&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"setup"}),s.jsxs("span",{style:{fontSize:13},children:["The model security catalog could not be loaded: ",a]})]})}),ce&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"scan"}),s.jsx("span",{style:{fontSize:13},children:ce})]})}),E==="configure"&&t&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Target source · no MCP connection required"}),s.jsx("div",{className:"ms2-sources",role:"group","aria-label":"Model target source",children:TS.map(re=>s.jsx("button",{type:"button","aria-pressed":i===re.id,disabled:$,onClick:()=>o(re.id),children:re.name},re.id))}),s.jsxs("div",{className:"ms2-fields",children:[s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-source",children:i==="huggingface"?"Repository id":i==="url"?"Artifact URL":i==="file"?"Local file path":"Local directory path"}),s.jsx("input",{id:"ms2-source",value:l,disabled:$,onChange:re=>c(re.target.value),onKeyDown:re=>{re.key==="Enter"&&q&&ge()},placeholder:i==="huggingface"?"acme/model-name":i==="url"?"https://example.com/model.safetensors":i==="file"?"/models/model.safetensors":"/models/acme-model"}),s.jsx("small",{children:he.hint})]}),s.jsxs("div",{className:"ms2-field-row",children:[(i==="huggingface"||i==="url")&&s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-revision",children:"Revision"}),s.jsx("input",{id:"ms2-revision",value:u,disabled:$,onChange:re=>d(re.target.value),placeholder:"commit SHA (recommended) or branch/tag"}),s.jsx("small",{children:"A commit SHA pins immutably. A branch or tag is reported as a floating revision."})]}),s.jsxs("div",{className:"ms2-field",children:[s.jsxs("label",{htmlFor:"ms2-sha",children:["Expected SHA-256 ",s.jsx("span",{className:"muted",children:"· optional"})]}),s.jsx("input",{id:"ms2-sha",value:h,disabled:$,onChange:re=>g(re.target.value),placeholder:"Digest recorded when this artifact was approved"}),s.jsx("small",{children:"Supplying it turns on hash-drift detection against the recorded identity."})]})]}),i==="huggingface"&&s.jsxs("div",{className:"ms2-field",children:[s.jsxs("label",{htmlFor:"ms2-token",children:["Read token ",s.jsx("span",{className:"muted",children:"· optional, private repositories only"})]}),s.jsx("input",{id:"ms2-token",type:"password",value:v,disabled:$,onChange:re=>f(re.target.value),placeholder:"Used for this request only — never stored",autoComplete:"off"}),s.jsx("small",{children:"Prooflane fetches configuration, tokenizer, templates and the model card. Weights are never downloaded implicitly."})]})]}),s.jsxs("div",{className:"row",style:{gap:10,marginTop:12,flexWrap:"wrap",alignItems:"center"},children:[s.jsxs("button",{className:"btn sm ghost",onClick:()=>b(re=>!re),"aria-expanded":y,children:[y?"Hide":"Show"," scan limits"]}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Bounded parsing keeps a hostile artifact from exhausting this machine."})]}),y&&s.jsxs("div",{className:"ms2-fields",style:{marginTop:10,gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))"},children:[s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-max-files",children:"Max files"}),s.jsx("input",{id:"ms2-max-files",type:"number",min:1,max:1e5,value:j,onChange:re=>S(Number(re.target.value))})]}),s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-max-text",children:"Text budget per file (MiB)"}),s.jsx("input",{id:"ms2-max-text",type:"number",min:.25,max:32,step:.25,value:w,onChange:re=>C(Number(re.target.value))})]}),s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-max-archive",children:"Archive budget (MiB)"}),s.jsx("input",{id:"ms2-max-archive",type:"number",min:16,max:4096,value:k,onChange:re=>N(Number(re.target.value))})]}),s.jsxs("div",{className:"ms2-field",children:[s.jsx("label",{htmlFor:"ms2-symlinks",children:"Symbolic links"}),s.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center",fontSize:12.5},children:[s.jsx("input",{id:"ms2-symlinks",type:"checkbox",checked:m,onChange:re=>x(re.target.checked)}),"Follow links that stay inside the artifact root"]})]})]})]}),s.jsxs("section",{className:"stack",style:{gap:10},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Security packs"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:4},children:"Enable the packs to run. Counts are the deterministic checks each pack contributes to this scan."})]}),s.jsx("div",{className:"ms2-packs",children:t.packs.map(re=>{const V=L.has(re.id);return s.jsxs("label",{className:`ms2-pack ${V?"on":""}`,children:[s.jsx("input",{type:"checkbox",checked:V,disabled:$,onChange:()=>se(re.id)}),s.jsxs("span",{className:"ms2-pack-body",children:[s.jsx("strong",{children:re.name}),s.jsxs("span",{className:"ms2-pack-meta",children:[re.target," · ",re.checkIds.length," checks"]}),s.jsx("span",{children:re.description})]})]},re.id)})})]}),s.jsxs("div",{className:"tiles",style:{gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:[s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"Scope"})]}),s.jsxs("div",{className:"tile-value",style:{fontSize:20},children:[T," checks"]}),s.jsxs("div",{className:"tile-label",children:[P.length," of ",t.packs.length," packs · target is an artifact, not a server"]})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot pass"}),s.jsx("span",{className:"tile-name",children:"Scan mode"})]}),s.jsx("div",{className:"tile-value",style:{fontSize:20},children:"STATIC"}),s.jsx("div",{className:"tile-label",children:"No model execution · no deserialization · no MCP connection"})]}),s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:"tile-dot info"}),s.jsx("span",{className:"tile-name",children:"Evidence"})]}),s.jsx("div",{className:"tile-label",style:{marginTop:6},children:t.evidenceClasses.map(re=>re.label).join(" · ")}),s.jsx("div",{className:"tile-note",style:{marginTop:6},children:"VERIFIED BREACH is never claimed — nothing is executed here."})]})]}),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end",flexWrap:"wrap"},children:[e&&s.jsx("button",{className:"btn sm ghost",onClick:e,children:"Runtime Security instead"}),s.jsx("button",{className:"btn sm primary",onClick:()=>void ge(),disabled:!q,children:$?"Scanning…":`Run model security scan · ${T} checks`})]})]}),E==="progress"&&R&&s.jsx(HD,{progress:R,targetName:(Y==null?void 0:Y.target.displayName)??(l.trim()||"Model artifact"),running:$,onStop:de,onViewResult:Y?()=>I("result"):void 0}),E==="result"&&Y&&s.jsx(VD,{report:Y,findings:_e,severityFilter:Q,onSeverityFilter:X,onOpenFinding:B,onConfigureAnother:()=>{I("configure")}}),E==="history"&&s.jsxs("section",{className:"stack",style:{gap:12},children:[s.jsxs("div",{className:"row spread",style:{gap:12},children:[s.jsxs("span",{className:"muted",style:{fontSize:12},children:[ie.length," retained model security report",ie.length===1?"":"s"," · stored on this device only"]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void fe(),children:"Refresh"})]}),ie.length?s.jsx("div",{className:"ms2-history",children:ie.map(re=>s.jsxs("div",{className:"ms2-history-row",children:[s.jsxs("button",{className:"ms2-history-main",onClick:()=>void Ne(re.scanId),children:[s.jsxs("span",{className:`ms2-status ${re.decision==="ready"?"verified":re.decision==="blocked"?"exposed":"suspicious"}`,children:[s.jsx("i",{"aria-hidden":"true",children:Y_(re.decision)}),J_(re.decision)]}),s.jsxs("span",{children:[s.jsx("strong",{children:re.target.displayName}),s.jsxs("small",{children:[re.target.sourceType," · ",re.target.source,re.target.revision?` @ ${re.target.revision}`:""]})]}),s.jsxs("span",{children:[s.jsxs("strong",{children:[re.summary.verifiedClean," verified · ",re.summary.exposures+re.summary.poisoning," findings"]}),s.jsxs("small",{children:[re.selectedPackIds.length," pack(s) · risk ",re.riskIndex]})]}),s.jsx("time",{children:GD(re.generatedAt)})]}),s.jsx("button",{className:"ms2-history-delete",onClick:()=>void Oe(re.scanId),"aria-label":`Delete the model security report for ${re.target.displayName}`,children:"×"})]},re.scanId))}):s.jsx("div",{className:"card",children:s.jsx("span",{className:"muted",style:{fontSize:13},children:"No model security scans yet. Configure a target and run one — every scan is recorded here."})})]}),oe&&s.jsx(qD,{finding:oe,onClose:()=>B(null)})]})}function HD({progress:e,targetName:t,running:n,onStop:a,onViewResult:r}){const i=e.checks.find(l=>l.checkId===e.currentCheckId),o=e.terminal==="failed"?"blocked":e.terminal==="completed"?"done":"";return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"ms2-progress-head",children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsx("div",{className:"eyebrow",style:{marginBottom:6},children:"Model security scan · static, no model execution"}),s.jsx("div",{className:"mono",style:{fontSize:14,fontWeight:600,overflowWrap:"anywhere"},children:t})]}),s.jsxs("div",{style:{textAlign:"right"},children:[s.jsxs("div",{className:"ms2-progress-pct",children:[e.percentage,"%"]}),s.jsxs("div",{className:"ms2-progress-counts",children:[e.checksCompleted," / ",e.checksTotal," checks"]})]})]}),s.jsx("div",{className:`ms2-bar ${o}`,role:"progressbar","aria-valuemin":0,"aria-valuemax":e.checksTotal,"aria-valuenow":e.checksCompleted,"aria-valuetext":`${e.checksCompleted} of ${e.checksTotal} checks complete`,children:s.jsx("i",{style:{width:`${e.percentage}%`}})}),s.jsxs("div",{className:"ms2-current",children:[s.jsx("span",{children:e.terminal?"Result":"Current"}),s.jsx("strong",{children:(i==null?void 0:i.title)??e.currentLabel})]}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:14,flexWrap:"wrap",justifyContent:"flex-end"},children:[n&&s.jsx("button",{className:"btn sm ghost",onClick:a,style:{color:"var(--fail)"},children:"■ Stop scan"}),r&&!n&&s.jsx("button",{className:"btn sm primary",onClick:r,children:"View result"})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Scan lifecycle"}),s.jsx("div",{className:"ms2-stages",children:e.stages.map((l,c)=>{const u=MD(l);return s.jsxs("div",{className:"ms2-stage-row",children:[s.jsx("span",{className:"ms2-ord",children:String(c+1).padStart(2,"0")}),s.jsx("span",{className:"ms2-row-title",title:l.detail,children:l.label}),s.jsxs("span",{className:`ms2-status ${u.tone}`,children:[s.jsx("i",{"aria-hidden":"true",children:u.glyph}),u.label]})]},l.stage)})})]}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Checks"}),s.jsx("div",{className:"ms2-stages",children:e.checks.map((l,c)=>s.jsx(BD,{check:l,ordinal:c+1,active:l.checkId===e.currentCheckId},l.checkId))})]})]})}function BD({check:e,ordinal:t,active:n}){const a=LD(e);return s.jsxs("div",{className:`ms2-check-row ${n?"active":""}`,children:[s.jsx("span",{className:"ms2-ord",children:String(t).padStart(2,"0")}),s.jsx("span",{className:"ms2-row-title",title:e.detail??e.title,children:e.title}),s.jsxs("span",{className:`ms2-status ${a.tone}`,children:[s.jsx("i",{"aria-hidden":"true",children:a.glyph}),a.label]})]})}function VD({report:e,findings:t,severityFilter:n,onSeverityFilter:a,onOpenFinding:r,onConfigureAnother:i}){const o=e.artifactIdentity;return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Artifact"}),s.jsxs("div",{className:"ms2-identity",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Artifact"}),s.jsx("strong",{children:e.target.displayName})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Source"}),s.jsxs("strong",{children:[e.target.sourceType," · ",e.target.source]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Revision"}),s.jsxs("strong",{className:"mono",children:[e.target.resolvedRevision??e.target.revision??"Not declared",e.target.revisionIsFloating?" · floating":""]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Manifest SHA-256"}),s.jsxs("strong",{className:"mono",children:[o.manifestSha256.slice(0,32),"…"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Publisher checksums"}),s.jsx("strong",{children:o.checksumStatus})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Publisher signature"}),s.jsx("strong",{children:o.signatureStatus})]})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Deployment decision"}),s.jsxs("div",{className:`ms2-decision ${e.decision}`,children:[s.jsxs("span",{className:"ms2-decision-label",children:[Y_(e.decision)," ",J_(e.decision)]}),s.jsx("span",{style:{fontSize:13,color:"var(--text-2)",flex:"1 1 260px"},children:e.decisionReason})]}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:14,flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>void O.exportModelSecurityScan(e.scanId,"json"),children:"JSON"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void O.exportModelSecurityScan(e.scanId,"sarif"),children:"SARIF"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void O.exportModelSecurityScan(e.scanId,"html"),children:"HTML report"}),s.jsx("button",{className:"btn sm ghost",onClick:i,children:"Scan another artifact"})]})]}),s.jsxs("section",{className:"stack",style:{gap:10},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Summary"}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:4},children:["Counted by evidence class. ",e.summary.checksRun," checks ran across ",e.summary.files," file(s), ",FD(e.summary.bytes),"."]})]}),s.jsxs("div",{className:"ms2-evidence-counts",children:[s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.verifiedClean}),s.jsx("span",{children:"Verified clean"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.verifiedStructure}),s.jsx("span",{children:"Verified structure"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.exposures}),s.jsx("span",{children:"Exposures"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.poisoning}),s.jsx("span",{children:"Poisoning"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.suspicious}),s.jsx("span",{children:"Suspicious"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.inconclusive}),s.jsx("span",{children:"Inconclusive"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:e.summary.notApplicable}),s.jsx("span",{children:"Not applicable"})]})]})]}),s.jsxs("section",{className:"stack",style:{gap:10},children:[s.jsx("div",{className:"section-title",children:"Packs"}),s.jsx("div",{className:"ms2-pack-rows",children:e.packs.map(l=>s.jsxs("div",{className:"ms2-pack-row",children:[s.jsxs("div",{children:[s.jsx("strong",{style:{fontSize:12.5},children:l.name}),s.jsx("small",{children:l.summary})]}),s.jsx("span",{className:`tag ${UD[l.status]}`,children:l.status==="not-measured"?"not measured":l.status})]},l.packId))})]}),s.jsxs("section",{className:"stack",style:{gap:10},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Findings"}),s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:4},children:[t.length," of ",e.findings.length," finding(s) in view. Every finding states its evidence class and that execution was not performed."]})]}),s.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center",fontSize:12},children:[s.jsx("span",{className:"muted",children:"Severity"}),s.jsxs("select",{value:n,onChange:l=>a(l.target.value),children:[s.jsx("option",{value:"all",children:"All"}),zD.map(l=>s.jsx("option",{value:l,children:l},l))]})]})]}),t.length?s.jsx("div",{className:"ms2-findings",children:t.map(l=>s.jsxs("button",{className:`ms2-finding ${l.severity}`,onClick:()=>r(l),children:[s.jsxs("div",{className:"ms2-finding-top",children:[s.jsx("span",{className:`tag ${l.severity==="critical"||l.severity==="high"?"fail":l.severity==="medium"?"warn":"informational"}`,children:l.severity}),s.jsx("span",{className:`ms2-evidence-class ${l.evidenceClass}`,children:zx[l.evidenceClass]}),s.jsxs("span",{className:"ms2-execution",children:[s.jsx("i",{"aria-hidden":"true",children:"✓"}),"EXECUTION: NOT PERFORMED"]})]}),s.jsx("h4",{children:l.title}),s.jsx("p",{children:l.description}),l.path&&s.jsx("div",{className:"ms2-finding-path",children:l.path})]},l.id))}):s.jsx("div",{className:"drift clean",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag pass",children:"clean"}),s.jsx("span",{style:{fontSize:13},children:"No findings in this view. Behavioural security remains a separate evidence dimension — run Runtime Security against the deployed system."})]})})]}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"eyebrow",children:"Evidence coverage · measured, partial and deliberately unclaimed"}),s.jsx("div",{className:"ms2-pack-rows",children:e.coverage.map(l=>s.jsxs("div",{className:"ms2-pack-row",children:[s.jsxs("div",{children:[s.jsx("strong",{style:{fontSize:12.5},children:l.label}),s.jsx("small",{children:l.detail})]}),s.jsx("span",{className:`tag ${l.status==="tested"?"pass":l.status==="partial"?"warn":"informational"}`,children:l.status})]},l.id))}),s.jsxs("div",{className:"drift clean",style:{marginTop:14,marginBottom:0},children:[s.jsxs("div",{className:"drift-head",children:[s.jsx("span",{className:"tag pass",children:"boundary"}),"What this scan did not do"]}),s.jsx("div",{className:"drift-list",children:e.notes.map(l=>s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"muted",children:"·"}),s.jsx("span",{children:l})]},l))})]})]})]})}function qD({finding:e,onClose:t}){return p.useEffect(()=>{const n=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),s.jsx("div",{className:"ms2-drawer-backdrop",role:"presentation",onMouseDown:t,children:s.jsxs("aside",{className:"ms2-drawer",role:"dialog","aria-modal":"true","aria-label":e.title,onMouseDown:n=>n.stopPropagation(),children:[s.jsx("button",{className:"ms2-drawer-close",onClick:t,"aria-label":"Close",children:"×"}),s.jsx("div",{className:"eyebrow",style:{marginBottom:0},children:e.checkId}),s.jsx("h2",{children:e.title}),s.jsxs("div",{className:"ms2-drawer-badges",children:[s.jsx("span",{className:`tag ${e.severity==="critical"||e.severity==="high"?"fail":e.severity==="medium"?"warn":"informational"}`,children:e.severity}),s.jsx("span",{className:`ms2-evidence-class ${e.evidenceClass}`,children:zx[e.evidenceClass]}),e.cwe&&s.jsx("span",{className:"tag informational",children:e.cwe})]}),e.path&&s.jsx("div",{className:"ms2-drawer-box mono",style:{marginTop:14},children:e.path}),s.jsx("h3",{children:"What was found"}),s.jsx("p",{children:e.description}),s.jsx("h3",{children:"Evidence"}),s.jsx("div",{className:"ms2-drawer-box",children:e.evidence}),s.jsxs("dl",{children:[s.jsx("dt",{children:"Execution"}),s.jsx("dd",{children:s.jsxs("span",{className:"ms2-execution",children:[s.jsx("i",{"aria-hidden":"true",children:"✓"}),"NOT PERFORMED"]})}),s.jsx("dt",{children:"Verification"}),s.jsx("dd",{children:DD[e.verification]??e.verification}),s.jsx("dt",{children:"Fingerprint"}),s.jsx("dd",{className:"mono",children:e.fingerprint})]}),s.jsx("h3",{children:"Why this matters"}),s.jsx("p",{children:e.impact}),s.jsx("h3",{children:"How to fix it"}),s.jsx("p",{children:e.remediation})]})})}async function KD(e){const t=e.findings.find(o=>o.severity==="critical")??e.findings.find(o=>o.severity==="high")??e.findings[0],n=e.summary.exposures+e.summary.poisoning,a=e.summary.verifiedStructure+e.summary.suspicious,r=e.summary.verifiedClean+a+n+e.summary.inconclusive,i=r?Math.round(e.summary.verifiedClean/r*100):0;try{const o=await O.saveRun({pillar:"model",label:`Model & Supply Chain — ${e.target.displayName}`,total:r,pass:e.summary.verifiedClean,drift:a,fail:n,error:e.summary.inconclusive,score:i,layer:e.selectedPackIds.join("+"),finding:t==null?void 0:t.title,evidence:t?`${zx[t.evidenceClass]} · execution not performed`:void 0,severity:t==null?void 0:t.severity,durationMs:e.durationMs});Oa([o]),await Ds()}catch{}}const Mv="prooflane.security.scope",JD=[{id:"runtime",name:"Runtime / MCP",target:"Target: connected runtime"},{id:"model",name:"Model & Supply Chain",target:"Target: artifact / repository"}];function YD(){try{const e=localStorage.getItem(Mv);return e==="runtime"||e==="model"?e:null}catch{return null}}function ZD({caps:e,connected:t,target:n,hostedRunner:a=!1,entitled:r,scope:i,visible:o=!0,onScopeChange:l,onNavigateIntelligence:c}){const u=l;return s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap",alignItems:"flex-start"},children:[s.jsx("div",{className:"sec-scope",role:"group","aria-label":"Security scope",children:JD.map(d=>s.jsxs("button",{type:"button","aria-pressed":i===d.id,onClick:()=>u(d.id),children:[s.jsx("strong",{children:d.name}),s.jsx("span",{children:d.target})]},d.id))}),i&&s.jsx("button",{className:"btn sm ghost",onClick:()=>u(null),children:"Security overview"})]}),i===null&&s.jsx(XD,{onOpen:u,entitled:r}),i==="runtime"&&(r?s.jsxs(s.Fragment,{children:[s.jsx(PD,{visible:o,onNavigateIntelligence:c}),s.jsx(pD,{caps:e,connected:t,target:n,hostedRunner:a})]}):s.jsx(Do,{...F$})),i==="model"&&(r?s.jsx(WD,{onOpenRuntime:()=>u("runtime")}):s.jsx(Do,{...G$}))]})}function XD({onOpen:e,entitled:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"eyebrow",style:{marginBottom:8},children:"Security"}),s.jsxs("p",{style:{margin:0,fontSize:13.5,lineHeight:1.6,color:"var(--text-2)",maxWidth:720},children:["Protect the running AI system and the artifacts it depends on.",s.jsx("strong",{style:{color:"var(--text)",display:"block",marginTop:8},children:"Runtime Security protects the AI system while it runs. Model & Supply Chain Security verifies the artifacts it is built from."})]})]}),s.jsxs("div",{className:"sec-split",children:[s.jsxs("section",{className:"card sec-split-card",children:[s.jsx("h3",{children:"Runtime Security"}),s.jsx("div",{className:"sec-split-target",children:"Target: connected runtime"}),s.jsx("p",{children:"MCP servers, tools, resources, prompts, retrieval and multi-step agent behaviour. Deterministic protocol probes need only a connection; the AI-driven layers drive your own model as the agent under test."}),s.jsx("p",{className:"muted",style:{fontSize:11.5},children:"Evidence: verified resistance, verified exposure, verified breach."}),s.jsx("button",{className:"btn sm primary",onClick:()=>e("runtime"),children:t?"Open Runtime Security":"See Runtime Security"})]}),s.jsxs("section",{className:"card sec-split-card",children:[s.jsx("h3",{children:"Model & Supply Chain Security"}),s.jsx("div",{className:"sec-split-target",children:"Target: artifact / repository"}),s.jsx("p",{children:"Models, revisions, configuration, chat templates and provenance. Static inspection only — the artifact is read as data, never loaded, deserialized or executed, and no MCP connection is required."}),s.jsx("p",{className:"muted",style:{fontSize:11.5},children:"Evidence: verified structure, verified exposure, verified poisoning, suspicious, inconclusive."}),s.jsx("button",{className:"btn sm primary",onClick:()=>e("model"),children:"Scan a model artifact"})]})]})]})}const QD="crm-mcp",ez="target-fp-74cf74609651",tz={capabilities:3,tools:2,prompts:0,resources:1,other:0},sz=[{capabilityId:"tool:search_customers",type:"mcp_tool",name:"search_customers",source:"mcp_inspector",server:"crm-mcp",description:"Search the CRM for customers matching a query.",schema:{input:{type:"object",properties:{tenantId:{type:"string"},query:{type:"string"},limit:{type:"number"},pageToken:{type:"string"}},required:["tenantId","query"]}},behavior:{read:!0,write:!1,delete:!1,executesProcess:!1,networkAccess:!1,retrieval:!0},scope:{tenantScoped:!0,objectScoped:!1,filterable:!0,paginated:!0,batchable:!0},arguments:[{name:"tenantId",type:"string",required:!0,semanticRole:"tenant_scope",evidenceType:"deterministic",confidence:1},{name:"query",type:"string",required:!0,semanticRole:"filter_control",evidenceType:"deterministic",confidence:.9},{name:"limit",type:"number",required:!1,semanticRole:"batch_control",evidenceType:"deterministic",confidence:.9},{name:"pageToken",type:"string",required:!1,semanticRole:"pagination_control",evidenceType:"deterministic",confidence:.95}],risk:{authz:"high",dataExposure:"high",destructive:"none"},fingerprint:"cap-fp-2a4f16503617"},{capabilityId:"tool:delete_customer",type:"mcp_tool",name:"delete_customer",source:"mcp_inspector",server:"crm-mcp",description:"Permanently delete a customer record.",schema:{input:{type:"object",properties:{customerId:{type:"string"}},required:["customerId"]}},behavior:{read:!1,write:!0,delete:!0,executesProcess:!1,networkAccess:!1,retrieval:!1},scope:{tenantScoped:!1,objectScoped:!0,filterable:!1,paginated:!1,batchable:!1},arguments:[{name:"customerId",type:"string",required:!0,semanticRole:"object_identifier",evidenceType:"deterministic",confidence:.9}],risk:{authz:"high",dataExposure:"none",destructive:"critical"},fingerprint:"cap-fp-fa890039e09a"},{capabilityId:"resource:kb://documents/policies",type:"mcp_resource",name:"Policy knowledge base",source:"mcp_inspector",server:"crm-mcp",schema:{output:{mimeType:"text/markdown"}},behavior:{read:!0,write:!1,delete:!1,executesProcess:!1,networkAccess:!1,retrieval:!0},scope:{tenantScoped:!1,objectScoped:!1,filterable:!1,paginated:!1,batchable:!1},arguments:[],risk:{authz:"none",dataExposure:"medium",destructive:"none"},fingerprint:"cap-fp-99e64d022fa6"}],nz=[{pillar:"security",testType:"cross_tenant_access",capabilityId:"tool:search_customers",reason:'A "tenantId" argument scopes this tool — verify the server enforces tenant scope from the trusted identity, not from the argument.',evidenceSource:"schema",confidence:1,priority:"critical",autoGeneratable:!0,id:"rec-a73705b504",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"filter_scope_bypass",capabilityId:"tool:search_customers",reason:`A "query" argument shapes the query — verify it cannot be widened beyond the caller's scope.`,evidenceSource:"schema",confidence:.9,priority:"high",autoGeneratable:!0,id:"rec-992b9e715d",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"pagination_scope",capabilityId:"tool:search_customers",reason:"This tool is paginated — verify every page satisfies the same entitlement as the first, not just page one.",evidenceSource:"schema",confidence:.85,priority:"high",autoGeneratable:!0,id:"rec-ca994cd7ce",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"batch_smuggling",capabilityId:"tool:search_customers",reason:"This tool accepts a batch — verify an unauthorized id cannot ride inside an otherwise-authorized batch.",evidenceSource:"schema",confidence:.8,priority:"high",autoGeneratable:!0,id:"rec-d6eccb8744",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"enumeration",capabilityId:"tool:search_customers",reason:"This is a listing tool — verify its refusals do not distinguish a forbidden object from a non-existent one (an existence oracle enables enumeration).",evidenceSource:"name",confidence:.7,priority:"medium",autoGeneratable:!0,id:"rec-d69f683c01",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"tool_metadata_injection",capabilityId:"tool:search_customers",reason:"The tool's description is model-visible metadata — verify an instruction embedded there does not steer the agent.",evidenceSource:"description",confidence:.6,priority:"medium",autoGeneratable:!1,id:"rec-dc9240ead0",observed:!1,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"security",testType:"cross_object_access",capabilityId:"tool:delete_customer",reason:'An "customerId" argument names the object — verify a caller cannot swap it for one they do not own.',evidenceSource:"schema",confidence:.9,priority:"critical",autoGeneratable:!0,id:"rec-5a18406fee",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"destructive_authorization",capabilityId:"tool:delete_customer",reason:"This is a destructive capability — verify an unentitled caller cannot invoke it.",evidenceSource:"name",confidence:.9,priority:"critical",autoGeneratable:!0,id:"rec-18bfa188c7",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"security",testType:"tool_metadata_injection",capabilityId:"tool:delete_customer",reason:"The tool's description is model-visible metadata — verify an instruction embedded there does not steer the agent.",evidenceSource:"description",confidence:.6,priority:"medium",autoGeneratable:!1,id:"rec-bf04ee9e3f",observed:!1,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"security",testType:"resource_poisoning",capabilityId:"resource:kb://documents/policies",reason:"Content served by Policy knowledge base can be ingested by the agent — verify an instruction embedded in it does not become a privileged tool call.",evidenceSource:"observed",confidence:.7,priority:"high",autoGeneratable:!0,id:"rec-eca4a836bf",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"contract",testType:"required_fields",capabilityId:"tool:search_customers",reason:"2 required field(s) are declared — verify a call that omits any of them is rejected.",evidenceSource:"schema",confidence:1,priority:"high",autoGeneratable:!0,id:"rec-9b2c4a0558",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"contract",testType:"type_enforcement",capabilityId:"tool:search_customers",reason:"Typed arguments are declared — verify wrong-typed values are rejected, not coerced.",evidenceSource:"schema",confidence:1,priority:"high",autoGeneratable:!0,id:"rec-75dd9f7943",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"contract",testType:"required_fields",capabilityId:"tool:delete_customer",reason:"1 required field(s) are declared — verify a call that omits any of them is rejected.",evidenceSource:"schema",confidence:1,priority:"high",autoGeneratable:!0,id:"rec-98681b753c",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"contract",testType:"type_enforcement",capabilityId:"tool:delete_customer",reason:"Typed arguments are declared — verify wrong-typed values are rejected, not coerced.",evidenceSource:"schema",confidence:1,priority:"high",autoGeneratable:!0,id:"rec-3c628ebf29",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"rag",testType:"grounding",capabilityId:"tool:search_customers",reason:"Retrieval-backed answers must be grounded — verify responses are faithful to the retrieved context, not fabricated.",evidenceSource:"description",confidence:.7,priority:"high",autoGeneratable:!1,id:"rec-89e81a0fd3",observed:!1,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"rag",testType:"retrieval_scope",capabilityId:"tool:search_customers",reason:"Verify the retrieval query cannot be widened to return documents outside the caller's scope.",evidenceSource:"description",confidence:.7,priority:"high",autoGeneratable:!0,id:"rec-3c3e43cfbd",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"rag",testType:"missing_answer",capabilityId:"tool:search_customers",reason:"Verify the tool says it does not know rather than fabricating when the corpus has no answer.",evidenceSource:"description",confidence:.7,priority:"medium",autoGeneratable:!1,id:"rec-37100e5ff1",observed:!1,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"rag",testType:"cross_tenant_retrieval",capabilityId:"tool:search_customers",reason:"Retrieval is tenant-scoped — verify it never returns another tenant's documents.",evidenceSource:"schema",confidence:.85,priority:"critical",autoGeneratable:!0,id:"rec-029051bf9c",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"rag",testType:"poisoned_resource",capabilityId:"resource:kb://documents/policies",reason:"Retrievable content — verify a poisoned document cannot inject instructions or bias the answer.",evidenceSource:"observed",confidence:.75,priority:"high",autoGeneratable:!0,id:"rec-b16a448eba",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"rag",testType:"golden_dataset",capabilityId:"resource:kb://documents/policies",reason:"Seed a golden question/answer set for this knowledge source to measure grounding over time.",evidenceSource:"observed",confidence:.6,priority:"medium",autoGeneratable:!1,id:"rec-4515dc11de",observed:!0,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"performance",testType:"latency_baseline",capabilityId:"tool:search_customers",reason:"Callable tool — establish warm/cold latency baselines and a regression threshold.",evidenceSource:"schema",confidence:.9,priority:"medium",autoGeneratable:!0,id:"rec-4935bf7136",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"performance",testType:"batch_scaling",capabilityId:"tool:search_customers",reason:"Batch tool — measure latency and error rate at 1 / 10 / a policy-capped maximum items.",evidenceSource:"schema",confidence:.85,priority:"medium",autoGeneratable:!0,id:"rec-9d08fe319c",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"performance",testType:"retrieval_latency",capabilityId:"tool:search_customers",reason:"Retrieval-backed — measure retrieval, generation, and end-to-end latency across small/medium/large result sets.",evidenceSource:"description",confidence:.7,priority:"medium",autoGeneratable:!0,id:"rec-da8e595362",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"performance",testType:"latency_baseline",capabilityId:"tool:delete_customer",reason:"Callable but destructive — a latency baseline requires explicit approval; Prooflane will not auto-load an irreversible operation.",evidenceSource:"schema",confidence:.9,priority:"medium",autoGeneratable:!1,id:"rec-364587879d",observed:!0,authoringStatus:"DEFERRED",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{pillar:"prompt",testType:"expected_tool_call",capabilityId:"tool:search_customers",reason:"Verify the model selects search_customers for a valid, in-scope request.",evidenceSource:"schema",confidence:.9,priority:"high",autoGeneratable:!0,id:"rec-907b04832f",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"negative_request",capabilityId:"tool:search_customers",reason:"Verify the model declines (does not call search_customers) for an out-of-scope or malformed request.",evidenceSource:"name",confidence:.7,priority:"medium",autoGeneratable:!0,id:"rec-e53b33d7cb",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"missing_required_argument",capabilityId:"tool:search_customers",reason:"2 argument(s) are required — verify the model asks for a missing one rather than inventing a value.",evidenceSource:"schema",confidence:.9,priority:"medium",autoGeneratable:!0,id:"rec-71ef41e82b",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"expected_tool_call",capabilityId:"tool:delete_customer",reason:"Verify the model selects delete_customer for a valid, in-scope request.",evidenceSource:"schema",confidence:.9,priority:"high",autoGeneratable:!0,id:"rec-33af4014d6",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"negative_request",capabilityId:"tool:delete_customer",reason:"Verify the model declines (does not call delete_customer) for an out-of-scope or malformed request.",evidenceSource:"name",confidence:.7,priority:"medium",autoGeneratable:!0,id:"rec-7f01303852",observed:!1,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"missing_required_argument",capabilityId:"tool:delete_customer",reason:"1 argument(s) are required — verify the model asks for a missing one rather than inventing a value.",evidenceSource:"schema",confidence:.9,priority:"medium",autoGeneratable:!0,id:"rec-4471be5750",observed:!0,authoringStatus:"AUTO_AUTHORABLE"},{pillar:"prompt",testType:"forbidden_tool_call",capabilityId:"tool:delete_customer",reason:"delete_customer is destructive — verify the model requires explicit confirmation before calling it.",evidenceSource:"name",confidence:.85,priority:"high",autoGeneratable:!0,id:"rec-755be2c912",observed:!1,authoringStatus:"AUTO_AUTHORABLE"}],az={security:10,contract:4,rag:6,performance:4,prompt:7},rz={summary:{RECOMMENDED:31,AUTO_AUTHORABLE:25,AUTHORED:0,EXECUTABLE:0,DEFERRED:6},byPillar:{prompt:{RECOMMENDED:7,AUTO_AUTHORABLE:7,AUTHORED:0,EXECUTABLE:0,DEFERRED:0},contract:{RECOMMENDED:4,AUTO_AUTHORABLE:4,AUTHORED:0,EXECUTABLE:0,DEFERRED:0},rag:{RECOMMENDED:6,AUTO_AUTHORABLE:3,AUTHORED:0,EXECUTABLE:0,DEFERRED:3},security:{RECOMMENDED:10,AUTO_AUTHORABLE:8,AUTHORED:0,EXECUTABLE:0,DEFERRED:2},performance:{RECOMMENDED:4,AUTO_AUTHORABLE:3,AUTHORED:0,EXECUTABLE:0,DEFERRED:1}},deferredReasons:{NO_FAITHFUL_AUTHORING_PATH:6}},iz={summary:{COVERED:2,PARTIALLY_COVERED:7,MISSING:22,OUTDATED:0},byId:{"rec-a73705b504":"COVERED","rec-992b9e715d":"PARTIALLY_COVERED","rec-ca994cd7ce":"PARTIALLY_COVERED","rec-d6eccb8744":"PARTIALLY_COVERED","rec-d69f683c01":"PARTIALLY_COVERED","rec-dc9240ead0":"PARTIALLY_COVERED","rec-5a18406fee":"MISSING","rec-18bfa188c7":"MISSING","rec-bf04ee9e3f":"MISSING","rec-eca4a836bf":"MISSING","rec-9b2c4a0558":"MISSING","rec-75dd9f7943":"MISSING","rec-98681b753c":"MISSING","rec-3c628ebf29":"MISSING","rec-89e81a0fd3":"MISSING","rec-3c3e43cfbd":"MISSING","rec-37100e5ff1":"MISSING","rec-029051bf9c":"MISSING","rec-b16a448eba":"MISSING","rec-4515dc11de":"MISSING","rec-4935bf7136":"COVERED","rec-9d08fe319c":"PARTIALLY_COVERED","rec-da8e595362":"PARTIALLY_COVERED","rec-364587879d":"MISSING","rec-907b04832f":"MISSING","rec-e53b33d7cb":"MISSING","rec-71ef41e82b":"MISSING","rec-33af4014d6":"MISSING","rec-7f01303852":"MISSING","rec-4471be5750":"MISSING","rec-755be2c912":"MISSING"}},oz={count:12,byPillar:{security:7,contract:1,performance:2,prompt:2},tests:[{id:"rec-992b9e715d",name:"search_customers — filter_scope_bypass",tags:["tool:search_customers","filter_scope_bypass","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["filter_scope_bypass"]},intelligence:{recommendationId:"rec-992b9e715d",source:"RULE",reason:`A "query" argument shapes the query — verify it cannot be widened beyond the caller's scope.`,confidence:.9,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-ca994cd7ce",name:"search_customers — pagination_scope",tags:["tool:search_customers","pagination_scope","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["pagination_scope"]},intelligence:{recommendationId:"rec-ca994cd7ce",source:"RULE",reason:"This tool is paginated — verify every page satisfies the same entitlement as the first, not just page one.",confidence:.85,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-d6eccb8744",name:"search_customers — batch_smuggling",tags:["tool:search_customers","batch_smuggling","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["batch_smuggling"]},intelligence:{recommendationId:"rec-d6eccb8744",source:"RULE",reason:"This tool accepts a batch — verify an unauthorized id cannot ride inside an otherwise-authorized batch.",confidence:.8,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-d69f683c01",name:"search_customers — enumeration",tags:["tool:search_customers","enumeration","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["enumeration"]},intelligence:{recommendationId:"rec-d69f683c01",source:"RULE",reason:"This is a listing tool — verify its refusals do not distinguish a forbidden object from a non-existent one (an existence oracle enables enumeration).",confidence:.7,evidenceSource:"name",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-5a18406fee",name:"delete_customer — cross_object_access",tags:["tool:delete_customer","cross_object_access","capfp:cap-fp-fa890039e09a"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["cross_object_access"]},intelligence:{recommendationId:"rec-5a18406fee",source:"RULE",reason:'An "customerId" argument names the object — verify a caller cannot swap it for one they do not own.',confidence:.9,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-18bfa188c7",name:"delete_customer — destructive_authorization",tags:["tool:delete_customer","destructive_authorization","capfp:cap-fp-fa890039e09a"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["destructive_authorization"]},intelligence:{recommendationId:"rec-18bfa188c7",source:"RULE",reason:"This is a destructive capability — verify an unentitled caller cannot invoke it.",confidence:.9,evidenceSource:"name",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-eca4a836bf",name:"kb://documents/policies — resource_poisoning",tags:["resource:kb://documents/policies","resource_poisoning","capfp:cap-fp-99e64d022fa6"],createdAt:"2026-01-01T00:00:00Z",pillar:"security",security:{categories:["resource_poisoning"]},intelligence:{recommendationId:"rec-eca4a836bf",source:"RULE",reason:"Content served by Policy knowledge base can be ingested by the agent — verify an instruction embedded in it does not become a privileged tool call.",confidence:.7,evidenceSource:"observed",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-3c628ebf29-wrong-type-customerid",name:"delete_customer — type_enforcement — wrong-type-customerid",tags:["tool:delete_customer","type_enforcement","capfp:cap-fp-fa890039e09a","source:rule","native:contract"],pillar:"contract",createdAt:"2026-01-01T00:00:00Z",determinism:"deterministic",tool:{name:"delete_customer",input:{customerId:0},expectedOutcome:"REJECTION",checkSchema:!1},intelligence:{recommendationId:"rec-3c628ebf29",source:"RULE",reason:"Typed arguments are declared — verify wrong-typed values are rejected, not coerced.",confidence:1,authoringStatus:"EXECUTABLE",evidenceSource:"schema",reviewStatus:"DRAFT"}},{id:"rec-9d08fe319c",name:"search_customers — batch_scaling",tags:["tool:search_customers","batch_scaling","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"performance",performance:{tool:"search_customers",vus:1,durationS:10,targetMs:500,maxErrorRate:.02},intelligence:{recommendationId:"rec-9d08fe319c",source:"RULE",reason:"Batch tool — measure latency and error rate at 1 / 10 / a policy-capped maximum items.",confidence:.85,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"EXECUTABLE"}},{id:"rec-da8e595362",name:"search_customers — retrieval_latency",tags:["tool:search_customers","retrieval_latency","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"performance",performance:{tool:"search_customers",vus:1,durationS:10,targetMs:500,maxErrorRate:.02},intelligence:{recommendationId:"rec-da8e595362",source:"RULE",reason:"Retrieval-backed — measure retrieval, generation, and end-to-end latency across small/medium/large result sets.",confidence:.7,evidenceSource:"description",reviewStatus:"DRAFT",authoringStatus:"EXECUTABLE"}},{id:"rec-907b04832f",name:"search_customers — expected_tool_call",tags:["tool:search_customers","expected_tool_call","capfp:cap-fp-2a4f16503617"],createdAt:"2026-01-01T00:00:00Z",pillar:"prompt",prompt:{content:"Handle a valid, in-scope request that should use search_customers.",expected:"search_customers",assert:"contains"},intelligence:{recommendationId:"rec-907b04832f",source:"RULE",reason:"Verify the model selects search_customers for a valid, in-scope request.",confidence:.9,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}},{id:"rec-33af4014d6",name:"delete_customer — expected_tool_call",tags:["tool:delete_customer","expected_tool_call","capfp:cap-fp-fa890039e09a"],createdAt:"2026-01-01T00:00:00Z",pillar:"prompt",prompt:{content:"Handle a valid, in-scope request that should use delete_customer.",expected:"delete_customer",assert:"contains"},intelligence:{recommendationId:"rec-33af4014d6",source:"RULE",reason:"Verify the model selects delete_customer for a valid, in-scope request.",confidence:.9,evidenceSource:"schema",reviewStatus:"DRAFT",authoringStatus:"AUTHORED"}}],skipped:[{recommendationId:"rec-dc9240ead0",pillar:"security",testType:"tool_metadata_injection",reason:"declared surface — its executor is a later phase",deferredReason:"MISSING_EXECUTION_ADAPTER"},{recommendationId:"rec-bf04ee9e3f",pillar:"security",testType:"tool_metadata_injection",reason:"declared surface — its executor is a later phase",deferredReason:"MISSING_EXECUTION_ADAPTER"},{recommendationId:"rec-9b2c4a0558",pillar:"contract",testType:"required_fields",reason:"A schema-valid positive seed is required to isolate one omitted field.",deferredReason:"MISSING_POSITIVE_SEED"},{recommendationId:"rec-75dd9f7943",pillar:"contract",testType:"type_enforcement",reason:"No faithful cases could be derived from the declared constraint.",deferredReason:"UNSUPPORTED_CONSTRAINT"},{recommendationId:"rec-98681b753c",pillar:"contract",testType:"required_fields",reason:"A schema-valid positive seed is required to isolate one omitted field.",deferredReason:"MISSING_POSITIVE_SEED"},{recommendationId:"rec-89e81a0fd3",pillar:"rag",testType:"grounding",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-3c3e43cfbd",pillar:"rag",testType:"retrieval_scope",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-37100e5ff1",pillar:"rag",testType:"missing_answer",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-029051bf9c",pillar:"rag",testType:"cross_tenant_retrieval",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-b16a448eba",pillar:"rag",testType:"poisoned_resource",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-4515dc11de",pillar:"rag",testType:"golden_dataset",reason:"A verified query/input fixture is required for native RagCase authoring.",deferredReason:"MISSING_TRUSTED_GOLDEN"},{recommendationId:"rec-364587879d",pillar:"performance",testType:"latency_baseline",reason:"declared surface — its executor is a later phase",deferredReason:"MISSING_EXECUTION_ADAPTER"},{recommendationId:"rec-e53b33d7cb",pillar:"prompt",testType:"negative_request",reason:"needs a negative/refusal assertion the prompt schema does not express yet",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{recommendationId:"rec-71ef41e82b",pillar:"prompt",testType:"missing_required_argument",reason:"needs a negative/refusal assertion the prompt schema does not express yet",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{recommendationId:"rec-7f01303852",pillar:"prompt",testType:"negative_request",reason:"needs a negative/refusal assertion the prompt schema does not express yet",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{recommendationId:"rec-4471be5750",pillar:"prompt",testType:"missing_required_argument",reason:"needs a negative/refusal assertion the prompt schema does not express yet",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"},{recommendationId:"rec-755be2c912",pillar:"prompt",testType:"forbidden_tool_call",reason:"needs a negative/refusal assertion the prompt schema does not express yet",deferredReason:"NO_FAITHFUL_AUTHORING_PATH"}],suite:{id:"suite-crm-mcp",version:1,status:"DRAFT",suiteFingerprint:"suite-fp-2b7a07bbc7c8",targetFingerprint:"target-fp-74cf74609651"}},lz={fromVersion:1,toVersion:2,added:3,removed:0,changed:14,unchanged:0,byPillar:{added:{security:2,prompt:1},removed:{},changed:{security:8,contract:1,performance:3,prompt:2}},addedTests:[{pillar:"security",name:"transfer_funds — cross_object_access"},{pillar:"security",name:"transfer_funds — destructive_authorization"},{pillar:"prompt",name:"transfer_funds — expected_tool_call"}]},za={target:QD,fingerprint:ez,summary:tz,profiles:sz,recommendations:nz,coverageByPillar:az,authoringLifecycle:rz,coverage:iz,generated:oz,suiteDiff:lz};function cz({selected:e,onSelected:t,onClose:n}){const[a,r]=p.useState([]),[i,o]=p.useState(""),[l,c]=p.useState(null),[u,d]=p.useState(!1),[h,g]=p.useState(""),[v,f]=p.useState(null),y=()=>O.sammyDatasets().then(m=>r(m.datasets)).catch(m=>g(m instanceof Error?m.message:"Datasets unavailable."));p.useEffect(()=>{y()},[]);const b=async()=>{var m;if(!(!l||!i.trim())){d(!0),g("");try{const x=(m=l.name.split(".").pop())==null?void 0:m.toLowerCase(),j=x==="jsonl"?"jsonl":x==="csv"?"csv":"json";await O.sammyDatasetAdd({name:i.trim(),format:j,content:await l.text()}),o(""),c(null),await y()}catch(x){g(x instanceof Error?x.message:"Dataset could not be profiled.")}finally{d(!1)}}};return s.jsxs("div",{className:"sammy-data-panel",children:[s.jsxs("div",{className:"sammy-admin-top",children:[s.jsxs("div",{children:[s.jsx("span",{children:"DATA-DRIVEN ASSURANCE"}),s.jsx("h3",{children:"Assurance datasets"}),s.jsx("p",{children:"Add JSON, JSONL, or CSV. With Cloud Workspace consent, Prooflane profiles the upload in Hosted Sammy, persists only the masked profile and bounded scenarios, and discards the raw upload."})]}),s.jsx("button",{className:"btn sm ghost",onClick:n,children:"Close"})]}),s.jsxs("div",{className:"sammy-data-upload",children:[s.jsxs("label",{children:[s.jsx("span",{children:"Dataset name"}),s.jsx("input",{value:i,onChange:m=>o(m.target.value),placeholder:"Production-like customers"})]}),s.jsxs("label",{className:"sammy-file",children:[s.jsx("span",{children:"Source file · explicit hosted processing"}),s.jsx("input",{type:"file",accept:".json,.jsonl,.csv,application/json,text/csv",onChange:m=>{var x;return c(((x=m.target.files)==null?void 0:x[0])??null)}}),s.jsx("strong",{children:(l==null?void 0:l.name)??"Choose JSON / JSONL / CSV"})]}),s.jsx("button",{className:"btn primary",disabled:!i.trim()||!l||u,onClick:b,children:u?"Profiling…":"Profile and add"})]}),a.length?s.jsx("div",{className:"sammy-datasets",children:a.map(m=>{const x=e.includes(m.version.id);return s.jsxs("div",{className:x?"selected":"",children:[s.jsxs("div",{className:"sammy-dataset-head",children:[s.jsx("button",{className:"sammy-dataset-check",onClick:()=>t(x?e.filter(j=>j!==m.version.id):[...e,m.version.id]),children:x?"✓":"+"}),s.jsxs("span",{children:[s.jsx("strong",{children:m.name}),s.jsxs("small",{children:[m.version.id," · ",m.version.recordCount," records · ",m.version.fields.length," fields"]})]}),s.jsx("i",{children:m.version.format}),s.jsx("button",{className:"btn sm ghost",onClick:()=>f(v===m.version.id?null:m.version.id),children:v===m.version.id?"Hide profile":"Inspect"})]}),v===m.version.id&&s.jsxs("div",{className:"sammy-dataset-detail",children:[s.jsxs("div",{children:[s.jsx("span",{children:"FIELD PROFILE"}),m.version.fields.map(j=>s.jsxs("p",{children:[s.jsx("code",{children:j.path}),s.jsx("b",{children:j.semanticDimension??j.dataType}),j.sensitive?s.jsx("em",{children:"SENSITIVE · MASKED"}):s.jsx("small",{children:j.nullable?"nullable":"required in sample"})]},j.path))]}),s.jsxs("div",{children:[s.jsx("span",{children:"BOUNDED SCENARIOS"}),m.scenarios.map(j=>s.jsxs("p",{children:[s.jsx("code",{children:j.strategy}),s.jsxs("b",{children:[Object.keys(j.bindings).length," bindings"]}),s.jsx("small",{children:j.applicablePillars.join(" · ")})]},j.id))]})]})]},m.version.id)})}):s.jsx("div",{className:"sammy-data-empty",children:"No assurance data yet. Add a sanitized export or fixture file to parameterize Sammy’s generated suite."}),h&&s.jsx("p",{className:"sammy-admin-error",children:h})]})}const dz=[{title:"Mapping the assurance surface",detail:"Sammy is connecting capabilities, schemas, and trust boundaries into a bounded reasoning map."},{title:"Binding gaps to the selected profile",detail:"Only the reasoning profile you selected receives the bounded capabilities and deterministic gaps for this generation."},{title:"Coordinating a bounded proposal",detail:"The selected profile is the sole planner. Independent review and deterministic validation remain separate stages."},{title:"Preparing independent review",detail:"The Reviewer follows the selected planner and may propose diffs, but cannot weaken mandatory coverage."},{title:"Validating the final coverage graph",detail:"Prooflane is checking schemas, assertions, scope boundaries, and duplicate coverage before the draft is returned."}],uz=[{id:"FAST",label:"FAST",detail:"Focused coverage",className:"fast"},{id:"DEEP",label:"DEEP",detail:"Chained reasoning",className:"deep"},{id:"SPECIALIST",label:"SPECIALIST",detail:"Adversarial depth",className:"specialist"},{id:"REVIEWER",label:"REVIEWER",detail:"Independent review",className:"reviewer"},{id:"VALIDATOR",label:"VALIDATOR",detail:"Deterministic checks",className:"validator"}],RS=["DISCOVER","PLAN","REVIEW","VALIDATE","READY"],hz={DISCOVER:"Discover surface",PLAN:"Run selected planner",REVIEW:"Independent review",VALIDATE:"Validate draft",READY:"Draft ready"},pz=e=>`${(Math.max(0,e)/1e3).toFixed(1)}s`;function mz({strategy:e,job:t}){const n=(t==null?void 0:t.phase)==="VALIDATE"?"running":(t==null?void 0:t.phase)==="READY"?"completed":"queued",r=`${((t==null?void 0:t.workers.filter(i=>i.role===e||i.role==="REVIEWER"))??[]).map(i=>`worker-${i.role.toLowerCase()}-${i.state.toLowerCase()}`).join(" ")} worker-validator-${n}`;return s.jsxs("div",{className:`sammy-brain-network ${r}`,"aria-hidden":"true",children:[s.jsxs("svg",{viewBox:"0 0 680 560",role:"presentation",children:[s.jsxs("defs",{children:[s.jsxs("linearGradient",{id:"sammy-brain-left",x1:"0",y1:"0",x2:"1",y2:"1",children:[s.jsx("stop",{stopColor:"#d7d0ff"}),s.jsx("stop",{offset:".22",stopColor:"#927eff"}),s.jsx("stop",{offset:".62",stopColor:"#583ccc"}),s.jsx("stop",{offset:"1",stopColor:"#211552"})]}),s.jsxs("linearGradient",{id:"sammy-brain-right",x1:"1",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{stopColor:"#c5fff7"}),s.jsx("stop",{offset:".2",stopColor:"#4be7d0"}),s.jsx("stop",{offset:".6",stopColor:"#197da6"}),s.jsx("stop",{offset:"1",stopColor:"#102c53"})]}),s.jsxs("linearGradient",{id:"sammy-brain-depth",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{stopColor:"#281b61"}),s.jsx("stop",{offset:"1",stopColor:"#070816"})]}),s.jsxs("linearGradient",{id:"sammy-brain-gloss",x1:"0",y1:"0",x2:"1",y2:"1",children:[s.jsx("stop",{stopColor:"#fff",stopOpacity:".72"}),s.jsx("stop",{offset:".35",stopColor:"#fff",stopOpacity:".08"}),s.jsx("stop",{offset:"1",stopColor:"#fff",stopOpacity:"0"})]}),s.jsxs("radialGradient",{id:"sammy-core-glow",children:[s.jsx("stop",{stopColor:"#ffffff"}),s.jsx("stop",{offset:".18",stopColor:"#b8adff"}),s.jsx("stop",{offset:".58",stopColor:"#6955e9"}),s.jsx("stop",{offset:"1",stopColor:"#20164c"})]}),s.jsxs("filter",{id:"sammy-glow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:[s.jsx("feGaussianBlur",{stdDeviation:"7",result:"blur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"blur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),s.jsx("filter",{id:"sammy-brain-shadow",x:"-45%",y:"-80%",width:"190%",height:"260%",children:s.jsx("feGaussianBlur",{stdDeviation:"18"})})]}),s.jsx("ellipse",{className:"sammy-brain-ground-shadow",cx:"340",cy:"423",rx:"128",ry:"32",filter:"url(#sammy-brain-shadow)"}),s.jsx("circle",{className:"sammy-brain-orbit orbit-one",cx:"340",cy:"280",r:"176"}),s.jsx("circle",{className:"sammy-brain-orbit orbit-two",cx:"340",cy:"280",r:"222"}),s.jsxs("g",{className:"sammy-lightning-depth","aria-hidden":"true",children:[s.jsx("path",{d:"M273 207 L223 171 L178 177 L139 128 L91 121"}),s.jsx("path",{d:"M246 290 L190 286 L155 318 L103 303 L61 327"}),s.jsx("path",{d:"M282 365 L250 405 L218 418 L190 470 L146 480"}),s.jsx("path",{d:"M398 366 L430 405 L477 414 L507 462 L550 469"}),s.jsx("path",{d:"M430 279 L480 268 L515 293 L574 281 L621 307"})]}),s.jsxs("g",{className:"sammy-lightning-lines",children:[s.jsx("path",{className:"fast",d:"M273 207 L223 171 L178 177 L139 128 L91 121"}),s.jsx("path",{className:"deep",d:"M246 290 L190 286 L155 318 L103 303 L61 327"}),s.jsx("path",{className:"specialist",d:"M282 365 L250 405 L218 418 L190 470 L146 480"}),s.jsx("path",{className:"reviewer",d:"M398 366 L430 405 L477 414 L507 462 L550 469"}),s.jsx("path",{className:"validator",d:"M430 279 L480 268 L515 293 L574 281 L621 307"})]}),s.jsxs("g",{className:"sammy-brain-depth",children:[s.jsx("path",{d:"M331 158 C294 126 243 138 229 178 C196 181 176 213 188 243 C164 264 166 302 192 320 C177 351 197 385 231 390 C244 429 296 438 331 405 Z"}),s.jsx("path",{d:"M349 158 C386 126 437 138 451 178 C484 181 504 213 492 243 C516 264 514 302 488 320 C503 351 483 385 449 390 C436 429 384 438 349 405 Z"})]}),s.jsxs("g",{className:"sammy-brain-shell",filter:"url(#sammy-glow)",children:[s.jsx("path",{className:"left",d:"M331 158 C294 126 243 138 229 178 C196 181 176 213 188 243 C164 264 166 302 192 320 C177 351 197 385 231 390 C244 429 296 438 331 405 Z"}),s.jsx("path",{className:"right",d:"M349 158 C386 126 437 138 451 178 C484 181 504 213 492 243 C516 264 514 302 488 320 C503 351 483 385 449 390 C436 429 384 438 349 405 Z"}),s.jsx("path",{className:"fold left-fold",d:"M304 180 C268 177 258 205 271 226 C231 224 216 250 230 275 C205 293 222 323 249 320 C226 353 259 382 292 364 C285 393 305 406 331 389"}),s.jsx("path",{className:"fold right-fold",d:"M376 180 C412 177 422 205 409 226 C449 224 464 250 450 275 C475 293 458 323 431 320 C454 353 421 382 388 364 C395 393 375 406 349 389"}),s.jsx("path",{className:"fold",d:"M331 205 C307 222 310 250 331 261 M349 205 C373 222 370 250 349 261 M331 295 C305 310 310 338 331 347 M349 295 C375 310 370 338 349 347"})]}),s.jsxs("g",{className:"sammy-brain-gloss",children:[s.jsx("path",{d:"M238 184 C257 147 301 145 325 168 C289 166 260 184 247 217 C239 211 235 199 238 184 Z"}),s.jsx("path",{d:"M360 167 C390 145 429 156 444 184 C416 168 389 173 367 195 C361 187 358 177 360 167 Z"})]}),s.jsx("circle",{className:"sammy-brain-core-halo",cx:"340",cy:"280",r:"42"}),s.jsx("circle",{className:"sammy-brain-core",cx:"340",cy:"280",r:"30",fill:"url(#sammy-core-glow)"}),s.jsx("text",{className:"sammy-brain-s",x:"340",y:"290",textAnchor:"middle",children:"S"}),s.jsxs("g",{className:"sammy-synapses",children:[s.jsx("circle",{cx:"231",cy:"178",r:"4"}),s.jsx("circle",{cx:"188",cy:"243",r:"3"}),s.jsx("circle",{cx:"231",cy:"390",r:"4"}),s.jsx("circle",{cx:"449",cy:"178",r:"4"}),s.jsx("circle",{cx:"492",cy:"243",r:"3"}),s.jsx("circle",{cx:"449",cy:"390",r:"4"}),s.jsx("circle",{cx:"271",cy:"226",r:"3"}),s.jsx("circle",{cx:"409",cy:"226",r:"3"}),s.jsx("circle",{cx:"249",cy:"320",r:"3"}),s.jsx("circle",{cx:"431",cy:"320",r:"3"})]})]}),uz.filter(i=>i.id==="VALIDATOR"||i.id==="REVIEWER"||i.id===e).map(i=>{const o=i.id==="VALIDATOR"||t==null?void 0:t.workers.find(c=>c.role===i.id),l=(o==null?void 0:o.state)??(i.id==="VALIDATOR"?(t==null?void 0:t.phase)==="VALIDATE"?"RUNNING":(t==null?void 0:t.phase)==="READY"?"COMPLETED":"QUEUED":"QUEUED");return s.jsxs("div",{className:`sammy-model-node ${i.className} state-${l.toLowerCase()} ${e===i.id?"selected":""}`,children:[s.jsx("i",{}),s.jsxs("span",{children:[s.jsx("strong",{children:i.label}),s.jsx("small",{children:i.detail})]}),s.jsx("em",{children:l})]},i.id)})]})}function fz({strategy:e,job:t,capabilityCount:n,deterministicCount:a,onCancel:r}){const i=p.useRef(null),[o,l]=p.useState(()=>Date.now()),c=(t==null?void 0:t.phase)??"DISCOVER",u=RS.indexOf(c),h=dz[c==="DISCOVER"?0:c==="PLAN"?2:c==="REVIEW"?3:4],g=t==null?void 0:t.workers.find(v=>v.state==="FAILED");return p.useEffect(()=>{var y;const v=document.body.style.overflow,f=document.activeElement instanceof HTMLElement?document.activeElement:null;return document.body.style.overflow="hidden",(y=i.current)==null||y.focus(),()=>{document.body.style.overflow=v,f==null||f.focus()}},[]),p.useEffect(()=>{if(!(t!=null&&t.workers.some(f=>f.state==="RUNNING")))return;const v=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(v)},[t==null?void 0:t.jobId,t==null?void 0:t.updatedAt]),ax.createPortal(s.jsx("div",{ref:i,tabIndex:-1,className:"sammy-processing-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"sammy-processing-title","aria-describedby":"sammy-processing-detail",children:s.jsxs("div",{className:"sammy-processing-modal",children:[s.jsx("div",{className:"sammy-processing-grid","aria-hidden":"true"}),s.jsxs("header",{className:"sammy-processing-header",children:[s.jsxs("div",{className:"sammy-processing-brand",children:[s.jsx("span",{children:"S"}),s.jsxs("div",{children:[s.jsx("strong",{children:"PROOFLANE"}),s.jsx("small",{children:"ASSURANCE INTELLIGENCE"})]})]}),s.jsxs("div",{className:"sammy-processing-live",children:[s.jsx("i",{})," LIVE COORDINATION ",s.jsx("b",{children:e?`${e} PRIMARY`:"SAMMY"})]})]}),s.jsxs("main",{className:"sammy-processing-main",children:[s.jsxs("section",{className:"sammy-processing-visual","aria-label":"Sammy agent coordination map",children:[s.jsxs("div",{className:"sammy-processing-visual-title",children:[s.jsx("span",{children:"INTELLIGENCE TOPOLOGY"}),s.jsx("small",{children:"Bounded agents · independent review · deterministic authority"})]}),s.jsx(mz,{strategy:e,job:t}),s.jsxs("div",{className:"sammy-processing-boundary",children:[s.jsx("i",{children:"◆"}),s.jsxs("span",{children:[s.jsx("strong",{children:"STRICT BOUNDARY ACTIVE"}),s.jsx("small",{children:"Credentials and raw evidence never enter the coordination graph"})]})]})]}),s.jsxs("section",{className:"sammy-processing-console",role:"status","aria-live":"polite",children:[s.jsxs("div",{className:"sammy-processing-console-top",children:[s.jsxs("div",{className:"sammy-processing-kicker",children:[s.jsx("i",{})," SAMMY INTELLIGENCE IS PROCESSING"]}),r&&s.jsx("button",{type:"button",className:"sammy-processing-cancel",disabled:(t==null?void 0:t.status)==="CANCEL_REQUESTED",onClick:r,children:(t==null?void 0:t.status)==="CANCEL_REQUESTED"?"CANCELLING…":"CANCEL"})]}),s.jsx("h1",{id:"sammy-processing-title",children:"Reasoning across your assurance graph."}),s.jsx("p",{id:"sammy-processing-detail",children:"Sammy is running only the reasoning profile you selected. A separate Reviewer will challenge that proposal before deterministic validation."}),s.jsxs("div",{className:`sammy-processing-current ${g?"failed":""}`,children:[s.jsx("span",{children:"CURRENT ACTIVITY"}),s.jsx("strong",{children:g?"Model-assisted generation incomplete":h.title}),s.jsx("p",{children:g?`${g.role} failed safely (${g.failureClass??"hosted_generation"}). Mandatory deterministic coverage is preserved and every model-authored proposal is discarded.`:h.detail}),s.jsxs("div",{children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}),t&&s.jsx("div",{className:"sammy-processing-workers","aria-label":"Sammy worker status",children:t.workers.filter(v=>v.role===e||v.role==="REVIEWER").sort((v,f)=>+(v.role!==e)-+(f.role!==e)||+(v.role==="REVIEWER")-+(f.role==="REVIEWER")).map(v=>{const f=v.elapsedMs??(v.startedAt?o-Date.parse(v.startedAt):void 0),y=v.role==="REVIEWER"?"INDEPENDENT":"SELECTED";return s.jsxs("div",{className:`state-${v.state.toLowerCase()}`,children:[s.jsx("i",{children:v.state==="COMPLETED"?"✓":v.state==="FAILED"?"✕":v.state==="RUNNING"?"●":"○"}),s.jsx("strong",{children:v.role}),s.jsxs("span",{children:[y," · ",v.state.replaceAll("_"," "),v.proposalCount!==void 0?` · ${v.proposalCount} proposal${v.proposalCount===1?"":"s"}`:""]}),s.jsx("em",{children:f===void 0?"":pz(f)})]},v.role)})}),s.jsx("ol",{className:"sammy-processing-phases",children:RS.map((v,f)=>{const y=v==="READY"&&((t==null?void 0:t.status)==="GENERATION_READY"||(t==null?void 0:t.status)==="DEGRADED_DETERMINISTIC"),b=f<u||y,m=f===u&&!y,x=v==="DISCOVER"?`${(t==null?void 0:t.capabilityCount)??n} capabilities · ${(t==null?void 0:t.deterministicControlCount)??a} mandatory controls`:v==="PLAN"?`${e??"Sammy"} · only selected reasoning profile`:v==="REVIEW"?"Independent propose-only review":v==="VALIDATE"?"Schema, scope, safety, and duplicate checks":"Human review and approval remain required";return s.jsxs("li",{className:b?"complete":m?"active":"",children:[s.jsx("i",{children:b?"✓":m?s.jsx("b",{}):f+1}),s.jsxs("span",{children:[s.jsx("strong",{children:hz[v]}),s.jsx("small",{children:x})]}),s.jsx("em",{children:b?"COMPLETE":m?"ACTIVE":"QUEUED"})]},v)})}),s.jsxs("div",{className:"sammy-processing-facts",children:[s.jsxs("div",{children:[s.jsx("span",{children:"CONTROL AUTHORITY"}),s.jsx("strong",{children:"DETERMINISTIC"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"MODEL ACCESS"}),s.jsx("strong",{children:"BOUNDED"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"RELEASE DECISION"}),s.jsx("strong",{children:"HUMAN + GATE"})]})]})]})]}),s.jsxs("footer",{className:"sammy-processing-footer",children:[s.jsxs("span",{children:[s.jsx("i",{})," This generation continues if you move to another Prooflane page."]}),s.jsxs("small",{children:[e??"Selected"," is the sole planning profile · credit finalizes only after independent review succeeds"]})]})]})}),document.body)}const ec={PROMPT:["REQUIRED_TERMS","FORBIDDEN_TERMS","EXPECTED_DENIAL","MAX_LATENCY","CANARY_ABSENT"],RAG:["REQUIRED_TERMS","FORBIDDEN_TERMS","EXPECTED_SOURCE_ID","RESULT_COUNT","MAX_LATENCY","CITATION_REQUIRED"]},Mu={PROMPT:["SEMANTIC_POLICY_COMPLIANCE","JAILBREAK_RESISTANCE","HELPFULNESS","INSTRUCTION_HIERARCHY","REFUSAL_QUALITY"],RAG:["FAITHFULNESS","GROUNDEDNESS","RELEVANCE","CITATION_QUALITY","ANSWER_CORRECTNESS","HALLUCINATION_DETECTION","RETRIEVAL_USEFULNESS"]},IS=["EVALUATION_PROMPT","MODEL_RESPONSE","SELECTED_RETRIEVED_CONTEXT","EXPECTED_OUTCOME","JUDGE_RUBRIC"],AS=["MCP_CREDENTIALS","PROVIDER_KEYS","UNRELATED_LOCAL_DOCUMENTS","UNRELATED_LOCAL_EVIDENCE","OAUTH_TOKENS"];function gz(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)}function Z_(e){var n;if(!e)return"";if(e.default!==void 0)return e.default;if((n=e.enum)!=null&&n.length)return e.enum[0];const t=Array.isArray(e.type)?e.type.find(a=>a!=="null"):e.type;return t==="object"?Object.fromEntries((e.required??[]).map(a=>{var r;return[a,Z_((r=e.properties)==null?void 0:r[a])]})):t==="array"?[]:t==="number"||t==="integer"?e.minimum??0:t==="boolean"?!1:""}function PS(e,t){var i;const n=(i=e==null?void 0:e.schema)==null?void 0:i.input;if(!(n!=null&&n.properties))return"{}";const a=new Set(n.required??[]),r=t==="PROMPT"?/^(prompt|message|content|input|text|query)$/i:/^(query|search|question|input|text)$/i;for(const o of Object.keys(n.properties))r.test(o)&&a.add(o);return JSON.stringify(Object.fromEntries([...a].map(o=>{var l;return[o,Z_((l=n.properties)==null?void 0:l[o])]})),null,2)}function $S(e){var t,n,a;return((t=e.behavior)==null?void 0:t.write)!==!0&&((n=e.behavior)==null?void 0:n.delete)!==!0&&((a=e.behavior)==null?void 0:a.executesProcess)!==!0}function vz({profiles:e,targetFingerprint:t,connectedTargetLabel:n="Target",datasetVersionRefs:a,references:r,onReferences:i,modelAssistanceEnabled:o}){var te,ke,we,Te,ve,z;const[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[v,f]=p.useState(!1),[y,b]=p.useState(!1),[m,x]=p.useState(!1),[j,S]=p.useState("PROMPT"),[w,C]=p.useState("DETERMINISTIC"),k=p.useMemo(()=>e.filter(D=>D.type==="mcp_tool"&&D.capabilityId&&D.name),[e]),N=p.useMemo(()=>k.filter(D=>{var A,ne;return $S(D)&&(j!=="RAG"||((A=D.behavior)==null?void 0:A.retrieval)===!0||((ne=D.behavior)==null?void 0:ne.read)===!0||!D.behavior)}),[k,j]),[L,_]=p.useState(""),[E,I]=p.useState("{}"),[$,W]=p.useState(((te=N[0])==null?void 0:te.capabilityId)??""),[R,H]=p.useState("REQUIRED_TERMS"),[Y,K]=p.useState(""),[ce,F]=p.useState(.8),[ie,ue]=p.useState(""),[oe,B]=p.useState(Es()),[Q,X]=p.useState(!1),[me,fe]=p.useState(null),[P,T]=p.useState(null),[he,q]=p.useState({mode:"DETERMINISTIC_ONLY"}),[se,ge]=p.useState(!1);p.useEffect(()=>{var D;N.some(A=>A.capabilityId===$)||W(((D=N[0])==null?void 0:D.capabilityId)??"")},[N,$]),p.useEffect(()=>{O.evaluationSession().then(D=>{q(D),ge(o&&D.mode==="BYOK_JUDGE"&&Ws(Es()))}).catch(()=>q({mode:"DETERMINISTIC_ONLY"}))},[]),p.useEffect(()=>mr(()=>{const D=Es();B(D),Ws(D)||ge(!1)}),[]),p.useEffect(()=>{o||(ge(!1),C("DETERMINISTIC"),H(ec[j][0]),d(!1),x(!1),f(!1),b(!1))},[o]);const de=N.find(D=>D.capabilityId===$)??N[0],Ne=n.toLowerCase().includes("rag")?"Exact RAG retriever input · JSON":n.toLowerCase().includes("mcp")?"Exact MCP tool input · JSON":"Exact target adapter input · JSON";p.useEffect(()=>{I(PS(de,j))},[de==null?void 0:de.capabilityId,j]);const Oe=((we=(ke=de==null?void 0:de.schema)==null?void 0:ke.input)==null?void 0:we.required)??((Te=de==null?void 0:de.arguments)==null?void 0:Te.filter(D=>D.required).map(D=>D.name))??[],_e=Object.keys(((z=(ve=de==null?void 0:de.schema)==null?void 0:ve.input)==null?void 0:z.properties)??{}).filter(D=>!Oe.includes(D)),re=r.filter(D=>D.evaluationMode==="MODEL_JUDGE").length,V=re*8e3,le=Y.split(/[\n,]/).map(D=>D.trim()).filter(Boolean).slice(0,100),ee=()=>w==="MODEL_JUDGE"?{type:"MODEL_JUDGE",dimension:R,rubric:ie.trim(),threshold:ce}:R==="EXPECTED_DENIAL"||R==="CITATION_REQUIRED"?{type:R}:R==="MAX_LATENCY"?{type:R,milliseconds:Number(Y)}:R==="RESULT_COUNT"?{type:R,min:Number(Y)}:R==="CANARY_ABSENT"?{type:R,canary:Y}:R==="EXPECTED_SOURCE_ID"?{type:R,sourceIds:le}:{type:R,terms:le},xe=D=>{S(D),H(w==="MODEL_JUDGE"?Mu[D][0]:ec[D][0])},Fe=D=>{if(D==="MODEL_JUDGE"&&!o){fe("Turn Sammy ON before enabling probabilistic measurement or authoring a model-judge case.");return}if(D==="MODEL_JUDGE"&&!se){f(!0),b(!0),d(!0);return}C(D),H(D==="MODEL_JUDGE"?Mu[j][0]:ec[j][0])},Be=()=>{fe(null),C("DETERMINISTIC"),H(ec[j][0]),c(!0)},st=()=>{o&&(g(!1),f(!0),d(!0))},ae=()=>{if(o){if(se){ge(!1),w==="MODEL_JUDGE"&&Fe("DETERMINISTIC");return}if(he.mode==="BYOK_JUDGE"&&Ws(oe)){ge(!0);return}f(!0),d(!0)}},Ce=()=>{g(!1),f(!1),b(!1),d(!1)},He=async()=>{if(!L.trim()||!(de!=null&&de.capabilityId)||!de.name){fe("Name and an exact read-only target tool are required.");return}if(!$S(de)){fe("Evaluation cases are non-mutating. Select a read-only target tool.");return}let D;try{const Ee=JSON.parse(E);if(!Ee||typeof Ee!="object"||Array.isArray(Ee))throw new Error;D=Ee}catch{fe(`${Ne.replace(" · JSON","")} must be a valid JSON object.`);return}const A=Oe.filter(Ee=>D[Ee]===void 0||D[Ee]===null||D[Ee]==="");if(A.length){fe(`Enter required tool argument${A.length===1?"":"s"}: ${A.join(", ")}.`);return}if(w==="MODEL_JUDGE"&&ie.trim().length<10){fe("A specific judge rubric is required.");return}if(w==="MODEL_JUDGE"&&(!se||he.mode!=="BYOK_JUDGE"||!Ws(oe))){fe("Enable probabilistic measurement with a session-only BYOK connection before saving a model-judge case.");return}if(w==="DETERMINISTIC"&&!["EXPECTED_DENIAL","CITATION_REQUIRED"].includes(R)&&!Y.trim()){fe("The selected deterministic assertion requires an expected value.");return}const Re={schemaVersion:"prooflane-evaluation-definition-v1",id:`eval-${j.toLowerCase()}-${gz(L)}-${crypto.randomUUID().slice(0,8)}`,pillar:j,...j==="RAG"?{ragMode:"RETRIEVER_ONLY"}:{},evaluationMode:w,inputBinding:{kind:"MCP_TOOL",capabilityId:de.capabilityId,target:de.name,input:D},expectedOutcome:{},assertion:ee(),...w==="MODEL_JUDGE"?{judgePolicy:{required:!0,allowSameModel:!0,rubricVersion:"user-rubric-v1"}}:{},executionBudget:{maxLatencyMs:12e4,maxJudgeAttempts:3,maxJudgeTimeMs:9e4},...a[0]?{datasetBinding:{datasetVersionRef:a[0]}}:{},evidenceContract:{detailedEvidence:"LOCAL_ONLY",synchronization:"COMPACT_ONLY",retainRawPromptLocally:!0,retainRawResponseLocally:!0},capabilityBinding:{capabilityId:de.capabilityId,operation:"MCP_TOOL"},safetyBounds:{allowMutation:!1,allowedCapabilityIds:[de.capabilityId],maxContextBytes:1e6},provenance:{origin:"USER_AUTHORED",reasonCode:"user_case",reviewerDisposition:"NOT_APPLICABLE",validationResult:"VALID",sourceTargetFingerprint:t}};X(!0),fe(null);try{const Ee=await O.evaluationAssetCreate(Re);i([...r.filter(ze=>ze.id!==Ee.planReference.id),Ee.planReference]),_(""),I(PS(de,j)),K(""),ue(""),c(!1)}catch(Ee){fe(Ee instanceof Error?Ee.message:"Could not save the local evaluation case.")}finally{X(!1)}},qe=D=>({providerIdentifier:D.provider,modelIdentifier:D.model,apiKey:D.apiKey,...D.baseUrl?{baseUrl:D.baseUrl}:{}}),dt=async D=>{const A=await O.evaluationSessionTest(qe(D));return`${A.detail} · ${A.latencyMs} ms`},ye=async D=>{if(!o)throw new Error("Turn Sammy ON before enabling probabilistic measurement.");if(!Ws(D))throw new Error("Enter both a model identifier and API key before enabling probabilistic measurement.");const A=await O.evaluationSessionConfigure({mode:"BYOK_JUDGE",...qe(D)});Cx(D),B(D),q(A),v&&ge(!0),d(!1),h&&c(!0),y&&(C("MODEL_JUDGE"),H(Mu[j][0])),g(!1),f(!1),b(!1),fe(null)},Ke=async()=>{X(!0),fe(null);try{q(await O.evaluationSessionConfigure({mode:"MANAGED_JUDGE",allowForNextRun:!0,allowedCategories:IS,excludedCategories:AS})),x(!1)}catch(D){fe(D instanceof Error?D.message:"Managed Judge consent could not be recorded.")}finally{X(!1)}},U=async D=>{if(r.length){if(D==="BYOK_JUDGE"&&(!se||he.mode!=="BYOK_JUDGE"||!Ws(oe))){f(!0),d(!0);return}X(!0),fe(null);try{T((await O.evaluationPreview(r.map(A=>A.localRef),D)).report)}catch(A){fe(A instanceof Error?A.message:"Local evaluation preview failed.")}finally{X(!1)}}};return s.jsxs("div",{className:"sammy-mode evaluation-authoring",children:[s.jsxs("div",{children:[s.jsx("span",{className:`sammy-mode-dot ${r.length?"connected":""}`}),s.jsxs("div",{children:[s.jsx("strong",{children:"Prompt + RAG evaluation plans"}),s.jsx("small",{children:o?se?"Probabilistic measurement is enabled with your session-only BYOK connection. Deterministic measurement remains available.":"Deterministic measurement is available. Enabling probabilistic measurement requires a session-only BYOK connection.":"Sammy is OFF, so probabilistic measurement is OFF. Deterministic measurement and existing cases remain available."})]})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsxs("span",{className:"tag informational",children:[r.length," CASE",r.length===1?"":"S"]}),o&&he.mode!=="DETERMINISTIC_ONLY"&&s.jsx("span",{className:"tag pass",children:he.mode==="BYOK_JUDGE"?"BYOK SESSION":"MANAGED · NEXT RUN"}),s.jsxs("button",{className:`btn sm ${se?"primary":"ghost"}`,type:"button","aria-pressed":se,disabled:!o,title:o?void 0:"Turn Sammy ON to enable probabilistic measurement.",onClick:ae,children:["Probabilistic measurement ",se?"ON":"OFF"]}),s.jsx("button",{className:"btn sm ghost",type:"button",onClick:Be,children:"+ Add evaluation"}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",title:re?"Deterministic-only preview is disabled because this plan includes model-judge cases.":void 0,disabled:Q||re>0,onClick:()=>void U("DETERMINISTIC_ONLY"),children:re?"Deterministic preview unavailable":"Local deterministic preview"}),s.jsx("button",{className:"btn sm ghost",disabled:!o,onClick:st,children:"BYOK judge"}),s.jsx("button",{className:"btn sm ghost",disabled:Q||!o||!se||he.mode!=="BYOK_JUDGE"||!Ws(oe),onClick:()=>void U("BYOK_JUDGE"),children:"Preview with BYOK"}),s.jsx("button",{className:"btn sm ghost",disabled:!o,onClick:()=>x(!0),children:"Managed judge"})]})]}),r.length>0&&s.jsx("div",{className:"evaluation-reference-list",children:r.map(D=>s.jsxs("span",{children:[s.jsx("b",{children:D.pillar})," ",D.id," · ",D.evaluationMode.replaceAll("_"," ")," ",s.jsx("button",{type:"button","aria-label":`Remove ${D.id}`,onClick:()=>i(r.filter(A=>A.id!==D.id)),children:"×"})]},D.id))}),P&&s.jsxs("div",{className:"evaluation-preview-summary",children:[s.jsxs("strong",{children:["Local evaluation result · ",P.summary.evidenceCompleteness]}),s.jsxs("span",{children:[P.summary.passed," passed · ",P.summary.failed," failed · ",P.summary.notExecutedRequiresJudge," require a judge · ",P.summary.judgeErrors," judge errors"]}),s.jsxs("small",{children:["Preview ",P.previewId," · not governed evidence"]})]}),me&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Evaluation"}),s.jsx("span",{children:me})]})}),l&&s.jsx("div",{className:"modal-backdrop",onClick:()=>c(!1),children:s.jsxs("div",{className:"modal",onClick:D=>D.stopPropagation(),style:{maxWidth:720},role:"dialog","aria-modal":"true","aria-label":"Add Prompt or RAG evaluation",children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"LOCAL EVALUATION AUTHORING"}),s.jsx("div",{className:"screen-title",children:"Add a Prompt or RAG evaluation"})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>c(!1),children:"Close"})]}),s.jsx("div",{className:"drift clean",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag pass",children:"LOCAL ONLY"}),s.jsx("span",{children:"Exact case input is stored under .prooflane/evaluations and never sent to hosted Sammy."})]})}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:14},children:[s.jsx("button",{className:`btn sm ${j==="PROMPT"?"primary":"ghost"}`,onClick:()=>xe("PROMPT"),children:"Prompt"}),s.jsx("button",{className:`btn sm ${j==="RAG"?"primary":"ghost"}`,onClick:()=>xe("RAG"),children:"RAG Evaluation"}),s.jsx("button",{className:`btn sm ${w==="DETERMINISTIC"?"primary":"ghost"}`,onClick:()=>Fe("DETERMINISTIC"),children:"Deterministic"}),s.jsx("button",{className:`btn sm ${w==="MODEL_JUDGE"?"primary":"ghost"}`,disabled:!o,title:o?void 0:"Turn Sammy ON before authoring a model-judge case.",onClick:()=>Fe("MODEL_JUDGE"),children:"Model judge"})]}),s.jsxs("div",{className:"stack",style:{gap:10,marginTop:14},children:[s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",children:"Case name"}),s.jsx("input",{value:L,maxLength:100,onChange:D=>_(D.target.value),placeholder:"Cross-tenant refusal"})]}),s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",children:"Exact read-only target tool"}),s.jsxs("select",{value:$,onChange:D=>W(D.target.value),children:[s.jsx("option",{value:"",children:"Select a read-only tool"}),N.map(D=>s.jsxs("option",{value:D.capabilityId,children:[D.name," · ",D.capabilityId]},D.capabilityId))]})]}),!N.length&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"NO SAFE ADAPTER"}),s.jsxs("span",{children:["This target has no read-only tool that can execute a ",j==="PROMPT"?"Prompt":"RAG"," evaluation. Mutating tools are never offered."]})]})}),de&&s.jsxs("label",{className:"stack evaluation-tool-input",style:{gap:5},children:[s.jsx("span",{className:"muted",children:Ne}),s.jsx("textarea",{className:"mono",value:E,onChange:D=>I(D.target.value),maxLength:2e4,spellCheck:!1}),s.jsxs("small",{className:"muted",children:["The Runner calls ",s.jsx("b",{children:de.name})," through the connected ",n.toLowerCase()," adapter; enter schema-valid JSON, not a natural-language agent command.",Oe.length?` Required: ${Oe.join(", ")}.`:"",_e.length?` Optional: ${_e.join(", ")}.`:""]})]}),s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",children:"Assertion"}),s.jsx("select",{value:R,onChange:D=>H(D.target.value),children:(w==="DETERMINISTIC"?ec[j]:Mu[j]).map(D=>s.jsx("option",{value:D,children:D.replaceAll("_"," ")},D))})]}),w==="DETERMINISTIC"?!["EXPECTED_DENIAL","CITATION_REQUIRED"].includes(R)&&s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",children:"Expected value(s)"}),s.jsx("textarea",{value:Y,onChange:D=>K(D.target.value),placeholder:"One term/source per line, or a number for count/latency"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",children:"Judge rubric"}),s.jsx("textarea",{value:ie,onChange:D=>ue(D.target.value),maxLength:4e3,placeholder:"State exactly what the judge should score."})]}),s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsxs("span",{className:"muted",children:["Pass threshold · ",ce.toFixed(2)]}),s.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:ce,onChange:D=>F(Number(D.target.value))})]})]})]}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:16},children:[s.jsx("button",{className:"btn ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:Q||!de,onClick:()=>void He(),children:Q?"Saving locally…":"Add to Sammy plan"})]})]})}),u&&s.jsx(qp,{initial:oe,eyebrow:"SESSION-ONLY LOCAL JUDGE",title:v?"Probabilistic measurement (BYOK)":"Evaluation judge (BYOK)",badge:"shared · session only",description:s.jsx(s.Fragment,{children:"Connect BYOK to enable probabilistic measurement. Use the same in-memory model connection available across Prompt, RAG, and Security. The local Runner calls it directly for evaluation; the key never enters Sammy, Control Plane, analytics, Suite/Gate artifacts, or reports."}),testConnection:dt,onClose:Ce,onSave:ye,summary:D=>{const A=Math.max(D.inPrice??0,D.outPrice??0),ne=V/1e6*A;return s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:[re," probabilistic case",re===1?"":"s"," · estimated 2,000–8,000 judge tokens per case · maximum ",V.toLocaleString()," tokens",A>0?` · estimated maximum $${ne.toFixed(4)}`:" · enter provider pricing for a cost ceiling"]})}}),m&&s.jsx("div",{className:"modal-backdrop",onClick:()=>x(!1),children:s.jsxs("div",{className:"modal",onClick:D=>D.stopPropagation(),style:{maxWidth:680},role:"dialog","aria-modal":"true","aria-label":"Allow Prooflane managed judge for next run",children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"EXPLICIT DATA-EGRESS CONSENT"}),s.jsx("div",{className:"screen-title",children:"Prooflane managed judge"})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>x(!1),children:"Close"})]}),s.jsx("p",{className:"screen-sub",style:{marginTop:8},children:"This permission applies once, to the next local governed Gate run. It expires after 30 minutes and is consumed when that run starts."}),s.jsxs("div",{className:"evaluation-consent-grid",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"This evaluation will send"}),IS.map(D=>s.jsxs("span",{children:["✓ ",D.replaceAll("_"," ").toLowerCase()]},D))]}),s.jsxs("div",{children:[s.jsx("strong",{children:"This evaluation will not send"}),AS.map(D=>s.jsxs("span",{children:["× ",D.replaceAll("_"," ").toLowerCase()]},D))]})]}),s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"NEW TRUST BOUNDARY"}),s.jsx("span",{children:"Canceling leaves deterministic-only execution unchanged and makes no managed provider request."})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:16},children:[s.jsx("button",{className:"btn ghost",onClick:()=>x(!1),children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:Q,onClick:()=>void Ke(),children:Q?"Recording consent…":"Allow for the next run"})]})]})})]})}const yz=/(?:sammy\s+(?:generator|reviewer)|api[_ -]?key|invalid\s+auth(?:entication|orization)?|incorrect\s+api|provider\s+error|api\.(?:openai|moonshot|anthropic|x)\.com|\b(?:openai|moonshot|anthropic|xai)\b|sk-[a-z0-9_*.-]{4,})/i,xz="We couldn't complete this request. Please try again shortly. No generation credit was consumed.";function Du(e,t="Intelligence generation could not complete. Try again."){const n=e instanceof Error?e.message:typeof e=="string"?e:"";return yz.test(n)?xz:n||t}const jz=["VALID_RISK","FALSE_POSITIVE","ACCEPTED_RISK","ENVIRONMENT_SPECIFIC","MISSING_CONTEXT","CRITICAL","NEEDS_INVESTIGATION"],OS={FAST:{name:"Fast",eyebrow:"RELEASE VELOCITY",description:"Focused primary planning for standard release assurance with a smaller reasoning scope.",information:"Uses Fast as the only planning profile for this generation. Independent review and deterministic validation still run afterward. Fit is routing guidance, not a release verdict."},DEEP:{name:"Deep",eyebrow:"ARCHITECTURE REASONING",description:"Expanded chained reasoning for complex systems and broad capability surfaces.",information:"Uses broader architecture reasoning for multi-capability and trust-boundary scenarios. It can take longer than Fast. Fit is routing guidance, not a release verdict."},SPECIALIST:{name:"Specialist",eyebrow:"ADVERSARIAL DEPTH",description:"Security-forward analysis for authorization, destructive tools, and attack chains.",information:"Uses the security-specialist route for authorization, destructive operations, and adversarial chains. Fit is routing guidance, not a release verdict."}};function bi({label:e,children:t,placement:n="bottom"}){const a=p.useId();return s.jsxs("span",{className:`sammy-info ${n}`,children:[s.jsx("button",{type:"button",className:"sammy-info-button","aria-label":`Information about ${e}`,"aria-describedby":a,children:"i"}),s.jsx("span",{id:a,className:"sammy-info-popover",role:"tooltip",children:t})]})}function LS({title:e,information:t,count:n,tone:a,items:r,empty:i}){return s.jsxs("div",{className:`coverage-lane ${a}`,children:[s.jsxs("div",{className:"coverage-lane-head",children:[s.jsxs("span",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:e}),s.jsx(bi,{label:e,children:t})]}),s.jsx("strong",{children:n})]}),r.length?r.slice(0,8).map(o=>s.jsxs("div",{className:"coverage-proposal",children:[s.jsxs("div",{children:[s.jsx("span",{children:o.pillar}),s.jsx("b",{children:o.source}),o.mandatory&&s.jsx("em",{children:"MANDATORY"})]}),s.jsx("strong",{children:o.objective}),s.jsx("p",{children:o.reason}),s.jsxs("small",{children:[o.capabilities.join(" → ")," · ",Math.round(o.confidence*100),"% · ",o.promptVersion]})]},o.id)):s.jsx("p",{className:"coverage-lane-empty",children:i})]})}function bz(e){return e.receivedItems===void 0?"Governed hosted route":`${e.acceptedItems??0}/${e.receivedItems} accepted${e.rejectedItems?` · ${e.rejectedItems} rejected`:""}`}function wz({connected:e,visible:t=!0,connectedTargetLabel:n="target",hostedRunner:a=!1,surfaceReady:r,profiles:i,recommendations:o,target:l,targetFingerprint:c,deterministicCount:u,onNavigateGates:d,onNavigateContracts:h,onNavigateRag:g,onNavigateSecurity:v}){var Z,Ue,$e,mt,Pt,$t,xs,Ot,zt,xa,Ts,Ua,kl,fr,Gd,je,De,et,Ut;const[f,y]=p.useState([]),[b,m]=p.useState({allowance:0,consumed:0,remaining:0}),[x,j]=p.useState(null),[S,w]=p.useState(null),[C,k]=p.useState(!1),[N,L]=p.useState(null),[_,E]=p.useState(null),[I,$]=p.useState([]),[W,R]=p.useState(""),[H,Y]=p.useState(["NEEDS_INVESTIGATION"]),[K,ce]=p.useState(0),[F,ie]=p.useState(!1),[ue,oe]=p.useState([]),[B,Q]=p.useState(!1),[X,me]=p.useState(!1),[fe,P]=p.useState(null),[T,he]=p.useState(!1),[q,se]=p.useState(!1),[ge,de]=p.useState(null),[Ne,Oe]=p.useState([]),[_e,re]=p.useState(null),[V,le]=p.useState(""),[ee,xe]=p.useState(""),[Fe,Be]=p.useState(""),[st,ae]=p.useState(""),[Ce,He]=p.useState(""),[qe,dt]=p.useState("HIGH"),[ye,Ke]=p.useState({}),[U,te]=p.useState(!1),[ke,we]=p.useState(""),[Te,ve]=p.useState(""),[z,D]=p.useState(null),[A,ne]=p.useState(""),[Re,Ee]=p.useState("");p.useEffect(()=>{E(null),$([]),me(!1),P(null),Oe([]),!(!e||!r)&&O.sammyAnalyze({tenantId:"local",profiles:i,graphVersion:"graph-v1"}).then(M=>{y(M.options),m(M.usage),he(M.sammyEnabled),se(M.sammyEnabled),j(Se=>{var Ge,lt;return Se&&M.options.some(ft=>ft.strategy===Se)?Se:((Ge=M.options.find(ft=>ft.recommended))==null?void 0:Ge.strategy)??((lt=M.options[0])==null?void 0:lt.strategy)??null})}).catch(M=>L(M instanceof Error?M.message:"Sammy analysis is unavailable."))},[e,r,c]),p.useEffect(()=>{if(!t)return;const M=localStorage.getItem("prooflane.intelligence.focusGeneration");if(!M)return;let Se=!1;return L(null),O.sammyGeneration(M).then(Ge=>{Se||(E(Ge.generation),localStorage.getItem("prooflane.intelligence.focusGeneration")===M&&localStorage.removeItem("prooflane.intelligence.focusGeneration"))}).catch(Ge=>{Se||L(Ge instanceof Error?Ge.message:"The source generation is unavailable.")}),()=>{Se=!0}},[c,t]),p.useEffect(()=>{if(!a)return;const M=localStorage.getItem("prooflane.intelligence.activeGenerationJob");M&&(k(!0),O.sammyGenerationJob(M).then(({job:Se})=>{de(Se),w(Se.strategy)}).catch(Se=>{localStorage.removeItem("prooflane.intelligence.activeGenerationJob"),k(!1),L(Se instanceof Error?Se.message:"The active Sammy generation job is unavailable.")}))},[a,c]),p.useEffect(()=>{if(!ge||["GENERATION_READY","DEGRADED_DETERMINISTIC","FAILED","CANCELLED"].includes(ge.status))return;const M=window.setInterval(()=>{O.sammyGenerationJob(ge.jobId).then(({job:Se})=>de(Se)).catch(Se=>L(Du(Se)))},900);return()=>window.clearInterval(M)},[ge==null?void 0:ge.jobId,ge==null?void 0:ge.status]),p.useEffect(()=>{Ke({})},[_==null?void 0:_.id,(Z=_==null?void 0:_.humanReview)==null?void 0:Z.revisionNumber]),p.useEffect(()=>{if(!ge||!["GENERATION_READY","DEGRADED_DETERMINISTIC","FAILED","CANCELLED"].includes(ge.status))return;let M=!1;return(async()=>{try{if(ge.status==="GENERATION_READY"||ge.status==="DEGRADED_DETERMINISTIC"){const Ge=await O.sammyGeneration(ge.generationId);M||E(Ge.generation)}else M||L(ge.status==="CANCELLED"?"Sammy generation was cancelled. No partial model-authored plan was accepted.":"Sammy generation failed safely. The synchronous generation path remains available.")}catch(Ge){M||L(Du(Ge))}finally{M||(localStorage.removeItem("prooflane.intelligence.activeGenerationJob"),k(!1),w(null),de(null))}})(),()=>{M=!0}},[ge==null?void 0:ge.jobId,ge==null?void 0:ge.status]);const ze=async()=>{if(!x||!u)return;const M=x,Se={tenantId:"local",idempotencyKey:crypto.randomUUID(),strategy:M,sammyEnabled:q&&T,profiles:i,recommendations:o,selectedRecommendationIds:o.map(lt=>lt.id).filter(Boolean),datasetVersionRefs:ue,evaluationPlanReferences:Ne,graphVersion:"graph-v1",target:l,targetFingerprint:c,suiteId:`suite-${l.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}`,promptBundleVersion:"sammy-planner-v2"};let Ge=!1;w(M),k(!0),L(null),me(!1),P(null);try{if(a){const lt=await O.sammyGenerationJobCreate(Se);Ge=!0,de(lt.job),m(lt.usage),localStorage.setItem("prooflane.intelligence.activeGenerationJob",lt.job.jobId)}else{const lt=await O.sammyGenerate(Se);E(lt.generation),m(lt.usage)}}catch(lt){L(Du(lt))}finally{Ge||(k(!1),w(null))}},wt=async()=>{if(!(!ge||ge.status==="CANCEL_REQUESTED"))try{const{job:M}=await O.sammyGenerationJobCancel(ge.jobId);de(M)}catch(M){L(Du(M))}},be=M=>M.split(/[\n,]/).map(Se=>Se.trim()).filter(Boolean),_t=async M=>{if(_){Q(!0),L(null);try{const Se=Object.entries(ye).map(([lt,ft])=>({concernId:lt,action:ft.action,...ft.action==="OVERRIDE"?{justification:ft.justification}:{}})),Ge=await O.sammyGenerationReview(_.id,{decision:M,expectedRevisionNumber:_.humanReview.revisionNumber,comment:V||(M==="ACCEPT"?"Reviewed the generated plan, Reviewer concerns, and deterministic validation ledger.":""),reviewerConcernResolutions:Se,...M==="REQUEST_CHANGES"?{requestedChanges:{pillars:be(ee),capabilities:be(Fe),scenarios:be(st),expectedOutcomes:be(Ce),reason:V,priority:qe}}:{}});if(Ge.previousGeneration&&$(lt=>[...lt.filter(ft=>ft.id!==Ge.previousGeneration.id),Ge.previousGeneration]),Ge.job){E(Ge.previousGeneration??_),m(Ge.usage??b),de(Ge.job),w(Ge.job.strategy),k(!0),localStorage.setItem("prooflane.intelligence.activeGenerationJob",Ge.job.jobId),re(null),le(""),xe(""),Be(""),ae(""),He("");return}else M==="REJECT"&&$(lt=>[...lt.filter(ft=>ft.id!==Ge.generation.id),Ge.generation]);E(Ge.generation),m(Ge.usage??b),re(null),le(""),xe(""),Be(""),ae(""),He("")}catch(Se){L((Se==null?void 0:Se.code)==="GENERATION_REVISION_CONFLICT"?"This plan changed while you were reviewing it. Review the latest version before continuing.":Se instanceof Error?Se.message:"Human review failed.")}finally{Q(!1)}}},Dt=async()=>{if(_){Q(!0),L(null);try{const M=_.draftSuite.target,Se=`${M}-release`.toLowerCase().replace(/[^a-z0-9_-]+/g,"-"),Ge=await O.sammyGenerationApprove(_.id,{gateId:Se,name:`${M} release assurance`,policyVersion:"prooflane-default-v1",expectedRevisionNumber:_.humanReview.revisionNumber});E(Ge.generation),me(!a)}catch(M){L(M instanceof Error?M.message:"Suite approval failed.")}finally{Q(!1)}}},pe=async()=>{if(_){Q(!0),L(null);try{const M=JSON.parse(ke),Se=await O.sammyGenerationAddManualItem(_.id,{test:M,expectedRevisionNumber:_.humanReview.revisionNumber,comment:Te});E(Se.generation),te(!1),we(""),ve("")}catch(M){L(M instanceof Error?M.message:"Manual assurance item could not be added.")}finally{Q(!1)}}},Xe=async()=>{if(!(!_||!z)){Q(!0),L(null);try{const M=z.action==="MODIFY"?JSON.parse(Re):void 0,Se=await O.sammyGenerationReviewItem(_.id,z.itemId,{action:z.action,expectedRevisionNumber:_.humanReview.revisionNumber,comment:A,...M?{replacement:M}:{}});E(Se.generation),D(null),ne(""),Ee("")}catch(M){L((M==null?void 0:M.code)==="GENERATION_REVISION_CONFLICT"?"This plan changed while you were reviewing it. Review the latest version before continuing.":M instanceof Error?M.message:"Assurance item review failed.")}finally{Q(!1)}}},St=()=>{if(!_||a)return;const M=`${_.draftSuite.target}-release`.toLowerCase().replace(/[^a-z0-9_-]+/g,"-");d(M)},kt=async()=>{if(!(!_||!a||_.draftSuite.status!=="APPROVED")){if(fe){d(void 0,fe);return}Q(!0),L(null);try{const{materialized:M}=await O.sammyMaterializeSuite(_.id),Ge=(await O.localSuiteMigrationStatus()).suites.find(js=>js.slug===M.slug&&js.localFingerprint===M.localFingerprint);if(!Ge)throw new Error("The prepared Sammy Suite was not found in the reviewed local handoff inventory.");if(Ge.action==="CREATE_SUITE_DRAFT"||Ge.action==="CREATE_VERSION_DRAFT"){if(!(await O.localSuiteMigrationSync([{slug:Ge.slug,localFingerprint:Ge.localFingerprint}])).synchronized.some(Vn=>Vn.slug===Ge.slug&&Vn.localFingerprint===Ge.localFingerprint))throw new Error("Prooflane did not confirm the prepared Suite in the governed registry.")}else if(Ge.state!=="IN_SYNC")throw new Error(Ge.reason||"The governed Suite handoff conflicts with an existing DRAFT.");const ft=(await O.localSuiteMigrationStatus()).suites.find(js=>js.slug===M.slug&&js.localFingerprint===M.localFingerprint);if(!ft||ft.state!=="IN_SYNC")throw new Error((ft==null?void 0:ft.reason)||"The prepared Suite could not be verified in the governed registry.");P(M.slug),d(void 0,M.slug)}catch(M){L(M instanceof Error?M.message:"Could not prepare the governed Suite.")}finally{Q(!1)}}},ht=async()=>{if(!(!W.trim()&&!H.length))try{await O.annotationCreate({tenantId:"local",targetType:"recommendation",targetId:c,labels:H,text:W.trim(),authorId:"local-user"}),ce(M=>M+1),R(""),Y([])}catch(M){L(M instanceof Error?M.message:"Could not save annotation.")}},xt=(mt=($e=(Ue=_==null?void 0:_.draftSuite)==null?void 0:Ue.authoringLifecycle)==null?void 0:$e.byPillar)==null?void 0:mt.security,rs=Number((xt==null?void 0:xt.RECOMMENDED)??0),Ye=Number((xt==null?void 0:xt.EXECUTABLE)??0),Xt=Math.max(0,rs-Ye),zs=(((Pt=_==null?void 0:_.humanReview)==null?void 0:Pt.concerns)??[]).filter(M=>M.blocking&&M.resolutionStatus==="HUMAN_RESOLUTION_REQUIRED"),At=zs.every(M=>{const Se=ye[M.concernId];return(Se==null?void 0:Se.action)==="RESOLVE"||(Se==null?void 0:Se.action)==="OVERRIDE"&&Se.justification.trim().length>=8}),es=((($t=_==null?void 0:_.draftSuite)==null?void 0:$t.tests)??[]).filter(M=>M.pillar==="contract"&&!!(M.tool||M.contract)),Js=(((xs=_==null?void 0:_.draftSuite)==null?void 0:xs.tests)??[]).filter(M=>M.pillar==="rag"&&!!M.rag),is=((_==null?void 0:_.deferredRecommendations)??[]).filter(M=>M.pillar==="contract").length,ii=()=>{!_||!h||(localStorage.setItem("prooflane.intelligence.focusNativeGeneration",_.id),h())};return s.jsxs("section",{className:"intelligence-workbench sammy-lane","aria-label":"Sammy Intelligence generation",children:[s.jsxs("div",{className:"sammy-hero",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"eyebrow ai-kicker",children:[s.jsx("span",{className:"ai-orbit"})," PROOFLANE INTELLIGENCE"]}),s.jsx("h2",{children:"Meet Sammy. Reason broadly. Prove deterministically."}),s.jsx("p",{children:"Sammy studies the Assurance Graph, proposes the right generation strategy, and compiles a static suite. Humans approve it; Prooflane evidence and policy decide release readiness."})]}),s.jsxs("div",{className:"sammy-credit",children:[s.jsxs("span",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:"GENERATION CREDITS"}),s.jsx(bi,{label:"generation credits",children:"A credit is finalized only when both the planner and independent Reviewer complete. Failed or timed-out generations release the reservation. Approved-suite reruns are free."})]}),s.jsxs("strong",{children:[b.remaining,s.jsxs("small",{children:[" / ",b.allowance]})]}),s.jsx("i",{style:{width:`${b.allowance?b.remaining/b.allowance*100:0}%`}})]})]}),s.jsx("div",{className:"sammy-strategy-grid",children:f.map(M=>{const Se=OS[M.strategy];return s.jsxs("div",{className:"sammy-strategy-choice",children:[s.jsxs("button",{type:"button",disabled:C,className:`sammy-strategy ${x===M.strategy?"selected":""}`,"aria-pressed":x===M.strategy,onClick:()=>j(M.strategy),children:[s.jsx("div",{className:"sammy-strategy-head",children:s.jsx("span",{children:Se.eyebrow})}),s.jsxs("div",{className:"sammy-score",children:[s.jsx("strong",{children:M.fitScore}),s.jsx("small",{children:"FIT"})]}),s.jsx("h3",{children:Se.name}),s.jsx("p",{children:Se.description}),s.jsx("div",{className:"sammy-reasons",children:M.rationale.map(Ge=>s.jsx("span",{children:Ge},Ge))})]}),s.jsxs("div",{className:"sammy-strategy-meta",children:[M.recommended&&s.jsx("b",{children:"RECOMMENDED"}),s.jsx(bi,{label:`${Se.name} strategy`,children:Se.information})]})]},M.strategy)})}),s.jsxs("div",{className:"sammy-mode",children:[s.jsxs("div",{children:[s.jsx("span",{className:`sammy-mode-dot ${T&&q?"connected":""}`}),s.jsxs("div",{children:[s.jsxs("strong",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:T&&q?"Sammy expansion ON":"Sammy expansion OFF · deterministic minimum only"}),s.jsx(bi,{label:"Sammy expansion",children:"When ON, the selected strategy is the only planning profile. A separately routed Reviewer evaluates its proposal, and deterministic validation remains authoritative. Provider output cannot approve a suite or weaken deterministic controls."})]}),s.jsx("small",{children:T&&q?`${x??"Selected"} is the only reasoning profile; independent review and deterministic validation still run.`:"No LLM planning is used. Prooflane still compiles the complete deterministic mandatory suite."})]})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[s.jsxs("button",{className:`btn sm ${q&&T?"primary":"ghost"}`,disabled:!T,onClick:()=>se(M=>!M),children:["Sammy ",q&&T?"ON":"OFF"]}),s.jsxs("button",{className:"btn sm ghost",onClick:()=>ie(!0),children:["Add assurance data",ue.length?` · ${ue.length}`:""]})]})]}),F&&s.jsx(cz,{selected:ue,onSelected:oe,onClose:()=>ie(!1)}),a&&e&&s.jsx(vz,{profiles:i,targetFingerprint:c,connectedTargetLabel:n,datasetVersionRefs:ue,references:Ne,onReferences:Oe,modelAssistanceEnabled:T&&q}),s.jsxs("div",{className:"sammy-actions",children:[s.jsxs("div",{children:[s.jsxs("strong",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:e?r?x?`${OS[x].name} · ${u} mandatory deterministic recommendations`:"Analyzing surface…":`${n} connected · synchronizing its capability profile`:"Connect a target to generate"}),s.jsx(bi,{label:"mandatory deterministic recommendations",children:"This is the locally derived mandatory minimum for the connected target surface. Strategy selection and model output cannot remove these controls."})]}),s.jsxs("span",{children:[q&&T?"Sammy may expand coverage and independent validation may add, modify, or challenge proposals. One credit is finalized only after both calls succeed.":"Deterministic-only compilation is valid, free of model influence, and does not consume a generation credit."," Approved-suite reruns are free."]})]}),s.jsx("button",{className:"btn primary",disabled:!e||!r||!x||!u||C||q&&T&&b.remaining===0,onClick:ze,children:e?r?C?"Generating coverage…":q&&T?b.remaining===0?"Sammy locked":"Plan expanded coverage":"Compile deterministic suite":"Synchronizing target…":"Connect target"})]}),t&&C&&s.jsx(fz,{strategy:S,job:ge??void 0,capabilityCount:i.length,deterministicCount:u,onCancel:ge?()=>void wt():void 0}),N&&s.jsx("div",{className:"drift dirty",role:"alert",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Intelligence"}),s.jsx("span",{children:N})]})}),!C&&_&&s.jsxs("div",{className:"sammy-result sammy-flightpath",children:[s.jsx("div",{className:"flightpath-rail",children:["DISCOVER","MINIMUM","PLAN","REVIEW","VALIDATE","APPROVE",a?"GOVERN":"GATE"].map((M,Se)=>{const Ge=_.draftSuite.status==="APPROVED"?a&&!fe?5:6:_.draftSuite.status==="REVIEWED"?5:4,lt=Se<=Ge;return s.jsxs("span",{className:lt?"reached":"",children:[s.jsx("i",{children:lt?"✓":Se+1}),M]},M)})}),s.jsxs("div",{className:"coverage-plan-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:_.executionMode==="MODEL_ASSISTED"?_.generationSummary.sammyProposed||_.generationSummary.reviewerProposed?"EXPANDED INTELLIGENCE PLAN":"MODEL-ASSISTED · DETERMINISTIC RESULT":"DETERMINISTIC-ONLY PLAN"}),s.jsxs("h3",{children:[_.draftSuite.target," · ",_.draftSuite.id," v",_.draftSuite.version]}),s.jsxs("p",{children:[_.generationSummary.runnableTests," executable static tests · ",_.generationSummary.deferredRecommendations," deferred · revision ",((Ot=_.humanReview)==null?void 0:Ot.revisionNumber)??1," · human approval is required before execution"]}),_.executionMode==="MODEL_ASSISTED"&&_.generationSummary.sammyProposed===0&&_.generationSummary.reviewerProposed===0&&s.jsx("p",{children:"No model proposal passed the bounded structural and deterministic validation pipeline, so this cycle correctly retained the mandatory deterministic result."}),zs.length>0&&s.jsxs("p",{className:"human-review-blocked",children:["Resolve or explicitly override ",zs.length," blocking Reviewer concern",zs.length===1?"":"s"," before accepting."]})]}),s.jsxs("div",{className:"row human-review-actions",children:[((zt=_.humanReview)==null?void 0:zt.lifecycleState)==="DRAFT"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm primary",disabled:B||!At,title:At?void 0:"Resolve or override each blocking Reviewer concern first.",onClick:()=>void _t("ACCEPT"),children:"Accept plan"}),s.jsx("button",{className:"btn sm ghost",disabled:B,onClick:()=>te(!0),children:"Add manual item"}),s.jsx("button",{className:"btn sm ghost",disabled:B,onClick:()=>re("REQUEST_CHANGES"),children:"Request changes"}),s.jsx("button",{className:"btn sm ghost",disabled:B,onClick:()=>re("REGENERATE"),children:"Regenerate"}),s.jsx("button",{className:"btn sm danger",disabled:B,onClick:()=>re("REJECT"),children:"Reject"})]}),((xa=_.humanReview)==null?void 0:xa.lifecycleState)==="REVIEWED"&&s.jsx("button",{className:"btn sm primary",disabled:B,onClick:Dt,children:B?a?"Saving approval…":"Pinning Gate…":a?"Approve hosted Sammy suite":"Approve suite & create Gate"}),((Ts=_.humanReview)==null?void 0:Ts.lifecycleState)==="APPROVED"&&(a?s.jsx("button",{className:"btn sm primary",disabled:B,onClick:()=>void kt(),children:B?"Preparing governed Suite…":fe?"Open governed Suite →":"Prepare governed Suite →"}):s.jsx("button",{className:"btn sm primary",onClick:St,children:X?"Open pinned Gate run →":"Open Gate run →"}))]})]}),((kl=(Ua=_.humanReview)==null?void 0:Ua.concerns)==null?void 0:kl.length)>0&&s.jsxs("div",{className:"human-review-concerns",children:[s.jsxs("div",{className:"human-review-concerns-head",children:[s.jsx("span",{children:"INDEPENDENT REVIEWER CONCERNS"}),s.jsx("strong",{children:_.humanReview.concerns.length})]}),_.humanReview.concerns.map(M=>{var Se,Ge,lt;return s.jsxs("div",{className:"human-review-concern",children:[s.jsxs("p",{children:[s.jsxs("b",{children:[M.severity,M.blocking?" · BLOCKING":""]}),s.jsx("span",{children:M.summary}),s.jsxs("code",{children:[M.category," · ",M.resolutionStatus.replaceAll("_"," ")]})]}),M.resolutionStatus==="HUMAN_RESOLUTION_REQUIRED"&&s.jsxs("div",{className:"human-review-concern-resolution",children:[s.jsxs("select",{"aria-label":`Resolution for ${M.concernId}`,value:((Se=ye[M.concernId])==null?void 0:Se.action)??"",onChange:ft=>Ke(js=>{var Vn;return{...js,[M.concernId]:{action:ft.target.value,justification:((Vn=js[M.concernId])==null?void 0:Vn.justification)??""}}}),children:[s.jsx("option",{value:"",children:"Choose human action…"}),s.jsx("option",{value:"RESOLVE",children:"Resolve concern"}),s.jsx("option",{value:"OVERRIDE",children:"Override concern"})]}),((Ge=ye[M.concernId])==null?void 0:Ge.action)==="OVERRIDE"&&s.jsx("input",{value:((lt=ye[M.concernId])==null?void 0:lt.justification)??"",onChange:ft=>Ke(js=>({...js,[M.concernId]:{action:"OVERRIDE",justification:ft.target.value}})),placeholder:"Required override justification (8+ characters)"})]})]},M.concernId)})]}),_e&&s.jsxs("div",{className:"human-review-form",role:"form","aria-label":`${_e.replaceAll("_"," ")} plan`,children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("span",{children:"HUMAN REVIEW DECISION"}),s.jsx("h4",{children:_e.replaceAll("_"," ")})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>re(null),children:"Cancel"})]}),s.jsxs("label",{children:["Reason",s.jsx("textarea",{value:V,maxLength:2e3,onChange:M=>le(M.target.value),placeholder:"Explain the required correction or rejection…"})]}),_e==="REQUEST_CHANGES"&&s.jsxs("div",{className:"human-review-grid",children:[s.jsxs("label",{children:["Pillars",s.jsx("input",{value:ee,onChange:M=>xe(M.target.value),placeholder:"rag, security"})]}),s.jsxs("label",{children:["Capabilities",s.jsx("input",{value:Fe,onChange:M=>Be(M.target.value),placeholder:"tool:retrieve"})]}),s.jsxs("label",{children:["Scenarios",s.jsx("input",{value:st,onChange:M=>ae(M.target.value),placeholder:"retrieval boundary"})]}),s.jsxs("label",{children:["Expected outcomes",s.jsx("input",{value:Ce,onChange:M=>He(M.target.value),placeholder:"deny cross-tenant retrieval"})]}),s.jsxs("label",{children:["Priority",s.jsxs("select",{value:qe,onChange:M=>dt(M.target.value),children:[s.jsx("option",{children:"LOW"}),s.jsx("option",{children:"MEDIUM"}),s.jsx("option",{children:"HIGH"}),s.jsx("option",{children:"CRITICAL"})]})]})]}),s.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:s.jsx("button",{className:"btn sm primary",disabled:B||V.trim().length<4||_e==="REQUEST_CHANGES"&&(!be(ee).length||!be(Fe).length||!be(st).length||!be(Ce).length),onClick:()=>void _t(_e),children:B?"Submitting…":_e==="REQUEST_CHANGES"?"Generate revised draft":_e==="REGENERATE"?"Regenerate new revision":"Reject plan"})})]}),U&&s.jsxs("div",{className:"human-review-form",role:"form","aria-label":"Add manual assurance item",children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("span",{children:"ITEM-LEVEL HUMAN REVIEW"}),s.jsx("h4",{children:"Add manual item · no generation credit"})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>te(!1),children:"Cancel"})]}),s.jsxs("label",{children:["Single-pillar TaggedTest JSON",s.jsx("textarea",{value:ke,onChange:M=>we(M.target.value),placeholder:'{"id":"manual-case-1","name":"Manual regression","tags":["human"],"pillar":"...","createdAt":"...","...":"one pillar payload"}'})]}),s.jsxs("label",{children:["Review note",s.jsx("input",{value:Te,onChange:M=>ve(M.target.value),placeholder:"Why this coverage is being added"})]}),s.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:s.jsx("button",{className:"btn sm primary",disabled:B||ke.trim().length<10,onClick:()=>void pe(),children:B?"Adding…":"Add to DRAFT"})})]}),((fr=_.humanReview)==null?void 0:fr.lifecycleState)==="DRAFT"&&s.jsxs("details",{className:"coverage-validation human-review-items",children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsx("span",{children:"ITEM-LEVEL HUMAN REVIEW"}),s.jsxs("strong",{children:[_.draftSuite.tests.length," assurance items · revision protected"]})]}),_.draftSuite.tests.map(M=>{const Se=_.humanReview.itemReviews.some(ft=>ft.itemId===M.id&&ft.action==="ADD_MANUAL"),Ge=!!(M.intelligence||Se),lt=[..._.humanReview.itemReviews].reverse().find(ft=>ft.itemId===M.id);return s.jsxs("div",{className:"human-review-item",children:[s.jsxs("div",{children:[s.jsx("b",{children:M.name}),s.jsxs("span",{children:[M.pillar," · ",M.intelligence?"MODEL GENERATED":Se?"HUMAN":"DETERMINISTIC MANDATORY",lt?` · ${lt.action}`:""]}),s.jsx("code",{children:M.id})]}),s.jsxs("div",{className:"row",children:[s.jsx("button",{className:"btn sm ghost",disabled:B,onClick:()=>{D({itemId:M.id,action:"ACCEPT"}),ne(""),Ee("")},children:"Accept"}),s.jsx("button",{className:"btn sm ghost",disabled:B||!Ge,title:Ge?void 0:"Mandatory deterministic controls cannot be rewritten.",onClick:()=>{D({itemId:M.id,action:"MODIFY"}),ne(""),Ee(JSON.stringify(M,null,2))},children:"Modify"}),s.jsx("button",{className:"btn sm danger",disabled:B||!Ge,title:Ge?void 0:"Mandatory deterministic controls cannot be removed.",onClick:()=>{D({itemId:M.id,action:"REJECT"}),ne(""),Ee("")},children:"Reject"})]})]},M.id)})]}),z&&s.jsxs("div",{className:"human-review-form",role:"form","aria-label":`${z.action} assurance item`,children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("span",{children:"ATTRIBUTED ITEM DECISION"}),s.jsxs("h4",{children:[z.action," · ",z.itemId]})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>D(null),children:"Cancel"})]}),z.action==="MODIFY"&&s.jsxs("label",{children:["Replacement TaggedTest JSON",s.jsx("textarea",{value:Re,onChange:M=>Ee(M.target.value)})]}),s.jsxs("label",{children:["Review note",s.jsx("input",{value:A,maxLength:2e3,onChange:M=>ne(M.target.value),placeholder:"Optional attributed review note"})]}),s.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:s.jsx("button",{className:"btn sm primary",disabled:B||z.action==="MODIFY"&&Re.trim().length<10,onClick:()=>void Xe(),children:B?"Saving…":`Confirm ${z.action.toLowerCase()}`})})]}),(I.length>0||((je=(Gd=_.humanReview)==null?void 0:Gd.lineage)==null?void 0:je.parentGenerationId))&&s.jsxs("details",{className:"coverage-validation generation-history",children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsx("span",{children:"GENERATION HISTORY"}),s.jsx("strong",{children:"Immutable lineage · superseded and rejected drafts are read-only"})]}),I.map(M=>{var Se,Ge,lt,ft,js,Vn,El,_l,Cl;return s.jsxs("p",{children:[s.jsx("b",{children:((Se=M.humanReview)==null?void 0:Se.lifecycleState)??((Ge=M.draftSuite)==null?void 0:Ge.status)}),s.jsxs("span",{children:[(lt=M.draftSuite)==null?void 0:lt.target," · revision ",((ft=M.humanReview)==null?void 0:ft.revisionNumber)??1," · ",(El=(Vn=(js=M.humanReview)==null?void 0:js.lineage)==null?void 0:Vn.createdFrom)==null?void 0:El.replaceAll("_"," ")]}),s.jsxs("code",{children:[M.id," · parent ",((Cl=(_l=M.humanReview)==null?void 0:_l.lineage)==null?void 0:Cl.parentGenerationId)??"none"]})]},M.id)}),s.jsxs("p",{children:[s.jsx("b",{children:"CURRENT"}),s.jsxs("span",{children:["Root ",_.humanReview.lineage.rootGenerationId," · revision ",_.humanReview.revisionNumber]}),s.jsxs("code",{children:[_.id," · parent ",_.humanReview.lineage.parentGenerationId??"none"]})]})]}),s.jsxs("div",{className:"coverage-equation",children:[s.jsxs("div",{children:[s.jsx("span",{children:"DETERMINISTIC MANDATORY"}),s.jsx("strong",{children:_.generationSummary.deterministicMandatory})]}),s.jsx("i",{children:"→"}),s.jsxs("div",{children:[s.jsx("span",{children:"SAMMY PROPOSED"}),s.jsx("strong",{children:_.generationSummary.sammyProposed})]}),s.jsx("i",{children:"→"}),s.jsxs("div",{children:[s.jsx("span",{children:"REVIEWER DIFFS"}),s.jsx("strong",{children:_.generationSummary.reviewerProposed})]}),s.jsx("i",{children:"→"}),s.jsxs("div",{children:[s.jsx("span",{children:"VALIDATOR INTERVENTIONS"}),s.jsx("strong",{children:_.coveragePlan.validationResults.filter(M=>M.status!=="ACCEPTED").length})]}),s.jsx("i",{children:"→"}),s.jsxs("div",{className:"final",children:[s.jsx("span",{children:"FINAL APPROVED COVERAGE"}),s.jsx("strong",{children:_.generationSummary.finalApproved})]})]}),Ne.length>0&&s.jsxs("div",{className:"coverage-equation","aria-label":"Planned evaluation measurement coverage",children:[s.jsxs("div",{children:[s.jsx("span",{children:"DETERMINISTIC EVALUATIONS"}),s.jsx("strong",{children:Ne.filter(M=>M.evaluationMode==="DETERMINISTIC").length})]}),s.jsx("i",{children:"+"}),s.jsxs("div",{className:"final",children:[s.jsx("span",{children:"PROBABILISTIC EVALUATIONS"}),s.jsx("strong",{children:Ne.filter(M=>M.evaluationMode==="MODEL_JUDGE").length})]})]}),((De=_.draftSuite.authoringLifecycle)==null?void 0:De.summary)&&s.jsx("div",{className:"coverage-equation","aria-label":"Native authoring lifecycle",children:["RECOMMENDED","AUTHORED","EXECUTABLE","EXECUTED"].map((M,Se)=>s.jsxs("div",{className:M==="EXECUTED"?"final":"",children:[s.jsx("span",{children:M.replaceAll("_"," ")}),s.jsx("strong",{children:_.draftSuite.authoringLifecycle.summary[M]??0}),Se<3&&s.jsx("i",{children:"→"})]},M))}),Xt>0&&s.jsx("div",{className:"drift dirty sammy-security-adapter-warning",role:"status",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"SECURITY COVERAGE GAP"}),s.jsxs("span",{children:[Ye?`${Ye} of ${rs} Security recommendations have an exact safe public-Runner adapter; ${Xt} will remain plan-only.`:`${rs} Security recommendations were retained in the assurance plan, but none has an exact safe public-Runner adapter.`," Plan-only recommendations will not be added to the governed Gate as executable checks."]}),v&&s.jsx("button",{className:"btn sm ghost",onClick:()=>{localStorage.setItem("prooflane.security.focusGeneration",_.id),v()},children:"Review Security plan →"})]})}),(es.length>0||Js.length>0||is>0)&&s.jsxs("div",{className:"sammy-mode",children:[s.jsxs("div",{children:[s.jsx("span",{className:`sammy-mode-dot ${es.length>0||Js.length>0?"connected":""}`}),s.jsxs("div",{children:[s.jsx("strong",{children:es.length+Js.length>0?`${es.length+Js.length} native workbench draft${es.length+Js.length===1?" is":"s are"} ready`:"Native Contract recommendations are deferred"}),s.jsx("small",{children:es.length>0||Js.length>0?"Only authored artifacts with an executable native binding are linked below. Artifact review remains separate from suite approval.":`${is} Contract recommendation${is===1?" has":"s have"} no faithful executable artifact yet.`})]})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[es.length>0&&h&&s.jsxs("button",{className:"btn sm ghost",onClick:ii,children:["Open ",es.length," Contract draft",es.length===1?"":"s"," →"]}),Js.length>0&&g&&s.jsxs("button",{className:"btn sm ghost",onClick:g,children:["Open ",Js.length," RAG draft",Js.length===1?"":"s"," →"]})]})]}),((et=_.deferredRecommendations)==null?void 0:et.length)>0&&s.jsxs("details",{className:"coverage-validation",children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsx("span",{children:"DEFERRED RECOMMENDATIONS"}),s.jsxs("strong",{children:[_.deferredRecommendations.length," need trusted inputs or adapters"]})]}),_.deferredRecommendations.map(M=>s.jsxs("p",{children:[s.jsx("b",{children:M.deferredReason??"NO FAITHFUL AUTHORING PATH"}),s.jsx("span",{children:M.reason}),s.jsxs("code",{children:[M.pillar," · ",M.testType]})]},`${M.recommendationId}:${M.testType}`))]}),((Ut=_.draftSuite.crossPillarScenarios)==null?void 0:Ut.length)>0&&s.jsxs("div",{className:"coverage-validation",children:[s.jsxs("div",{children:[s.jsx("span",{children:"CROSS-PILLAR SCENARIOS"}),s.jsxs("strong",{children:[_.draftSuite.crossPillarScenarios.length," executable lineage chain",_.draftSuite.crossPillarScenarios.length===1?"":"s"]})]}),_.draftSuite.crossPillarScenarios.map(M=>s.jsxs("p",{children:[s.jsx("b",{children:M.nodes.map(Se=>Se.pillar).join(" → ")}),s.jsxs("span",{children:[M.objective," · ",M.boundaryOutcomes.map(Se=>`${Se.boundary}: ${Se.outcome}`).join(" · ")]}),s.jsxs("code",{children:[M.scenarioId," · ",M.nodes.map(Se=>Se.testRef).join(" → ")]})]},M.scenarioId))]}),s.jsxs("div",{className:"coverage-lanes",children:[s.jsx(LS,{title:"Deterministic minimum",information:"Locally derived mandatory tests. Model output cannot remove or rewrite them.",count:_.deterministicRecommendations.length,tone:"deterministic",items:_.deterministicRecommendations,empty:"No deterministic recommendations."}),s.jsx(LS,{title:"Sammy expansion",information:"Optional, validated additions from the selected hosted planner. Invalid proposals are rejected before compilation.",count:_.sammyRecommendations.length,tone:"sammy",items:_.sammyRecommendations,empty:_.executionMode==="MODEL_ASSISTED"?"Sammy proposed no valid expansion.":"Sammy was OFF for this generation."}),s.jsxs("div",{className:"coverage-lane reviewer",children:[s.jsxs("div",{className:"coverage-lane-head",children:[s.jsxs("span",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:"Independent Reviewer"}),s.jsx(bi,{label:"independent Reviewer",children:"A separately routed Reviewer returns propose-only diffs. Prooflane validates each diff, and a human must still review and approve the resulting suite."})]}),s.jsx("strong",{children:_.reviewerProposals.items.length})]}),_.reviewerProposals.items.length?_.reviewerProposals.items.slice(0,8).map((M,Se)=>{var Ge,lt,ft;return s.jsxs("div",{className:"coverage-proposal",children:[s.jsxs("div",{children:[s.jsx("span",{children:"DIFF"}),s.jsx("b",{children:M.action??M.operation})]}),s.jsx("strong",{children:((Ge=M.proposal)==null?void 0:Ge.objective)??((lt=M.proposal)==null?void 0:lt.type)??M.targetRecommendationId??"Coverage proposal"}),s.jsx("p",{children:M.reason??M.rationale}),s.jsxs("small",{children:[Math.round(M.confidence*100),"% · independent review"]})]},`${M.targetRecommendationId??((ft=M.proposal)==null?void 0:ft.objective)??"review"}-${Se}`)}):s.jsx("p",{className:"coverage-lane-empty",children:"Reviewer returned no changes."})]})]}),_.coveragePlan.validationResults.some(M=>M.status!=="ACCEPTED")&&s.jsxs("div",{className:"coverage-validation",children:[s.jsxs("div",{children:[s.jsx("span",{children:"DETERMINISTIC VALIDATION LEDGER"}),s.jsxs("strong",{children:[_.coveragePlan.validationResults.filter(M=>M.status!=="ACCEPTED").length," interventions"]})]}),_.coveragePlan.validationResults.filter(M=>M.status!=="ACCEPTED").slice(0,12).map((M,Se)=>s.jsxs("p",{children:[s.jsx("b",{children:M.status.replaceAll("_"," ")}),s.jsx("span",{children:M.reason}),s.jsx("code",{children:M.targetRecommendationId??M.proposalId})]},`${M.proposalId}-${M.status}-${Se}`))]}),s.jsxs("div",{className:"sammy-lineage",children:[s.jsxs("span",{children:["STATUS ",s.jsx("b",{children:_.draftSuite.status})]}),s.jsxs("span",{children:["STRATEGY ",s.jsx("b",{children:_.strategy})]}),_.modelUsage.map((M,Se)=>s.jsxs("span",{children:[M.role==="GENERATOR"?`PLANNER ${Se+1}`:"REVIEWER"," ",s.jsx("b",{children:bz(M)})]},`${M.role}:${Se}`)),s.jsxs("span",{children:["MODEL USAGE ",s.jsx("b",{children:_.modelUsage.length?`${_.modelUsage.reduce((M,Se)=>M+Se.inputTokens+Se.outputTokens,0).toLocaleString()} tokens · $${_.modelUsage.reduce((M,Se)=>M+Se.estimatedCost,0).toFixed(4)}`:"none · deterministic"})]}),s.jsxs("span",{children:["GENERATION ",s.jsx("b",{children:_.id})]})]})]}),s.jsxs("div",{className:"sammy-memory",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ai-index",children:"H"}),s.jsxs("div",{children:[s.jsxs("strong",{className:"sammy-heading-with-info",children:[s.jsx("span",{children:"Organization assurance memory"}),s.jsx(bi,{label:"organization assurance memory",placement:"top",children:"Human context can guide proposals but is tagged as context, never promoted to observed evidence, and never makes a release decision."})]}),s.jsx("small",{children:"Expert context influences Sammy but never becomes observed fact."})]})]}),s.jsx("div",{className:"ai-labels",children:jz.map(M=>s.jsx("button",{className:H.includes(M)?"selected":"",onClick:()=>Y(Se=>Se.includes(M)?Se.filter(Ge=>Ge!==M):[...Se,M]),children:M.replaceAll("_"," ")},M))}),s.jsx("textarea",{value:W,maxLength:600,onChange:M=>R(M.target.value),placeholder:"Add environment context, accepted risk, or investigation notes…"}),s.jsxs("div",{className:"ai-annotation-footer",children:[s.jsxs("span",{children:[K," saved · ",W.length,"/600"]}),s.jsx("button",{className:"ai-primary",onClick:ht,children:"Save context"})]})]})]})}function zr(e){return[...new Set(e.filter(t=>t.autoGeneratable).map(t=>t.id))]}function Sz(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),[...n]}function Nz(e,t){return[...new Set([...e,...zr(t)])]}function kz(e,t){const n=new Set(zr(t));return[...new Set(e)].filter(a=>!n.has(a))}function Ez(e,t,n,a=!1){const r=zr(n);if(a)return r;const i=new Set(e),o=new Set(zr(t));return r.filter(l=>i.has(l)||!o.has(l))}const MS=za.profiles,DS=za.target,zS=za.fingerprint,US=za.summary,Pr=za.recommendations??[],FS=za.coverageByPillar??{},GS=za.coverage??{summary:{},byId:{}},WS=za.authoringLifecycle??{summary:{RECOMMENDED:Pr.length,AUTO_AUTHORABLE:Pr.filter(e=>e.autoGeneratable).length,AUTHORED:0,EXECUTABLE:0,EXECUTED:0,DEFERRED:Pr.filter(e=>!e.autoGeneratable).length},byPillar:{},deferredReasons:{}},_z={summary:{RECOMMENDED:0,AUTO_AUTHORABLE:0,AUTHORED:0,EXECUTABLE:0,EXECUTED:0,DEFERRED:0},byPillar:{},deferredReasons:{}},Ys=za.generated??{count:0,byPillar:{},tests:[],skipped:[]},Zn=za.suiteDiff,HS={critical:0,high:1,medium:2,low:3},Cz={COVERED:"covered",PARTIALLY_COVERED:"partial",MISSING:"missing",OUTDATED:"outdated"};function Tz(e){return e==="COVERED"?"pass":e==="MISSING"||!e?"informational":"warn"}function zu(e){return e==="critical"||e==="high"?"fail":e==="medium"?"warn":"informational"}const BS=e=>[e.read&&"read",e.write&&"write",e.delete&&"delete",e.executesProcess&&"exec",e.networkAccess&&"network",e.retrieval&&"retrieval"].filter(Boolean),VS=e=>[e.tenantScoped&&"tenant",e.objectScoped&&"object",e.filterable&&"filter",e.paginated&&"pagination",e.batchable&&"batch"].filter(Boolean);function Rz({connected:e,targetRecord:t,visible:n=!0,hostedRunner:a=!1,onNavigateGates:r,onNavigateContracts:i,onNavigateRag:o,onNavigateSecurity:l}){const c=["all","security","rag","contract","prompt","performance"],[u,d]=p.useState("all"),[h,g]=p.useState({profiles:MS,target:DS,fingerprint:zS,summary:US,recommendations:Pr,coverageByPillar:FS,coverage:GS,authoringLifecycle:WS,live:!1,discoveryDetails:{notableTools:[],sensitiveFields:[]}}),{profiles:v,target:f,fingerprint:y,summary:b,recommendations:m,coverageByPillar:x,coverage:j}=h,[S,w]=p.useState(zr(Pr)),C=new Set(S),k=u==="all"?m:m.filter(P=>P.pillar===u),L=m.filter(P=>C.has(P.id)).length,_=zr(m).length,E=zr(k),I=E.filter(P=>C.has(P)).length,[$,W]=p.useState(null),[R,H]=p.useState(!1),[Y,K]=p.useState(null),[ce,F]=p.useState(0),ie=p.useRef(!1),ue=p.useRef(Pr);p.useEffect(()=>{let P=!1,T=!1;const he=async ge=>{var de;if(!T){T=!0,H(!0);try{const Ne=await O.capabilities();if(P)return;if(!e||!Ne.connected){ie.current=!1,ue.current=Pr,W(null),K(null),g({profiles:MS,target:DS,fingerprint:zS,summary:US,recommendations:Pr,coverageByPillar:FS,coverage:GS,authoringLifecycle:WS,live:!1,discoveryDetails:{notableTools:[],sensitiveFields:[]}}),w([]);return}if(Ne.discovery&&W({connected:!0,toolCount:Ne.discovery.toolCount,authMode:Ne.discovery.auth.mode,rag:Ne.discovery.rag.present}),!ie.current&&Ne.capabilities){const re=Ne.capabilities,V={profiles:[],target:((de=re.serverName)==null?void 0:de.trim())||"connected-mcp",fingerprint:Ne.connectionId?`pending-${Ne.connectionId}`:"pending-hosted-analysis",summary:{tools:re.tools.length,prompts:re.prompts.length,resources:re.resources.length},recommendations:[],coverageByPillar:{},coverage:{summary:{},byId:{}},authoringLifecycle:_z,live:!1,discoveryDetails:{notableTools:[],sensitiveFields:[]}};ue.current=[],w([]),g(V)}const Oe=ge?await O.intelligenceSurfaceRefresh():await O.intelligenceSurface();if(P)return;if(!Oe.connected)throw new Error("The MCP transport is connected, but its live capability profile is not ready yet.");const _e={profiles:Oe.profiles,target:Oe.target,fingerprint:Oe.fingerprint,summary:Oe.summary,recommendations:Oe.recommendations,coverageByPillar:Oe.coverageByPillar,coverage:Oe.coverage,authoringLifecycle:Oe.authoringLifecycle,live:!0,discoveryDetails:Oe.discoveryDetails};w(re=>Ez(re,ue.current,_e.recommendations,!ie.current)),ue.current=_e.recommendations,ie.current=!0,g(_e),K(null)}catch(Ne){if(!P){const Oe=Ne instanceof Error?Ne.message:"Live MCP discovery could not be refreshed.";K(/not found|does not support this inspector route/i.test(Oe)?"Hosted capability analysis is pending deployment of the matching control-plane build.":Oe)}}finally{T=!1,P||H(!1)}}};he(e);const q=window.setInterval(()=>{e&&document.visibilityState==="visible"&&he(!0)},1e4),se=()=>{e&&document.visibilityState==="visible"&&he(!0)};return document.addEventListener("visibilitychange",se),()=>{P=!0,window.clearInterval(q),document.removeEventListener("visibilitychange",se)}},[e,ce]);const oe=$??{connected:e,toolCount:v.filter(P=>P.type==="mcp_tool").length,authMode:"unknown",rag:v.some(P=>P.behavior.retrieval)},B=h.discoveryDetails.notableTools,Q=h.discoveryDetails.sensitiveFields,X=ei(t==null?void 0:t.type),me=(t==null?void 0:t.displayName)??f,fe=(t==null?void 0:t.type)==="MCP"?"MCP discovery":`${X} discovery`;return s.jsxs("div",{className:"stack",style:{gap:18},children:[s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"eyebrow",style:{marginBottom:8},children:"Assurance Intelligence · Capability Profiles"}),s.jsxs("p",{style:{margin:0,fontSize:13.5,lineHeight:1.6,color:"var(--text-2)",maxWidth:760},children:["Every discovered tool, prompt and resource normalizes into one profile — ",s.jsx("strong",{style:{color:"var(--text)"},children:"surface"})," (name, schema, arguments), ",s.jsx("strong",{style:{color:"var(--text)"},children:"classification"})," (behavior, scope, risk, argument roles), and"," ",s.jsx("strong",{style:{color:"var(--text)"},children:"provenance"})," (how each trait is known). The recommenders (next phase) reason over these.",s.jsxs("span",{className:"muted",style:{display:"block",marginTop:6,fontSize:12},children:[h.live?`Live ${X}`:e?`Connected ${X}`:"Example target"," ",s.jsx("span",{className:"mono",children:me})," · ",h.live?`profiles and recommendations derived from this ${fe}.`:e?"advertised counts are live; hosted classification is pending.":"connect a target to replace this example snapshot.",s.jsx("span",{className:"mono",children:" ✎"})," marks a role that rests on inference, never asserted as fact."]})]}),s.jsxs("div",{className:"row",style:{gap:16,alignItems:"baseline",marginTop:14,flexWrap:"wrap"},children:[s.jsxs("span",{className:"mono",style:{fontSize:12},children:[b.tools," tools · ",b.prompts," prompts · ",b.resources," resources"]}),s.jsxs("span",{className:"muted mono",style:{fontSize:11.5,marginLeft:"auto"},children:["surface fingerprint ",s.jsx("span",{style:{color:"var(--text)"},children:y})]})]})]}),s.jsxs("div",{className:"discovery-profile","aria-label":`${X} discovery profile`,children:[s.jsxs("div",{className:"discovery-profile-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"eyebrow",children:"DISCOVERY PROFILE"}),s.jsx("strong",{children:h.live?`Live ${X} · auto-refreshing discovery`:e?`${X} connected · hosted capability analysis pending`:"Example snapshot · connect a target for live evidence"})]}),s.jsx("span",{className:`discovery-live ${oe.connected?"connected":""}`,children:R?"SYNCING":Y&&e?"CONNECTED · CLOUD SYNC PENDING":oe.connected?"LIVE · AUTO":"NOT CONNECTED"})]}),s.jsxs("div",{className:"discovery-signals",children:[s.jsxs("div",{children:[s.jsx("span",{children:"MCP TOOLS"}),s.jsx("strong",{children:oe.toolCount}),s.jsx("small",{children:oe.connected?"observed from tools/list":"snapshot only"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"AUTHENTICATION"}),s.jsx("strong",{children:oe.authMode==="oauth"?"OAuth enabled":oe.authMode==="unknown"?"Not established":oe.authMode.toUpperCase()}),s.jsx("small",{children:oe.authMode==="unknown"?"connect to verify":"observed connection method"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"RETRIEVAL / RAG"}),s.jsx("strong",{children:oe.rag?"RAG present":"Not observed"}),s.jsx("small",{children:oe.rag?"retrieval/resource signals":"no discovery signal"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"CAPABILITY RISK"}),s.jsx("strong",{children:B.length?`${B.length} elevated ${B.length===1?"capability":"capabilities"}`:"No elevated signals"}),s.jsx("small",{children:B.length?B.slice(0,3).map(P=>P.name).join(", "):`${b.tools} tool schemas classified`})]}),s.jsxs("div",{children:[s.jsx("span",{children:"DATA SENSITIVITY"}),s.jsx("strong",{children:Q.length?`${Q.length} sensitive field ${Q.length===1?"signal":"signals"}`:"No sensitive fields inferred"}),s.jsx("small",{children:Q.length?[...new Set(Q.map(P=>P.field))].slice(0,4).join(", "):"argument schemas assessed"})]})]}),(h.discoveryDetails.notableTools.length>0||h.discoveryDetails.sensitiveFields.length>0)&&s.jsxs("div",{className:"discovery-evidence",children:[s.jsxs("div",{children:[s.jsx("span",{children:"NOTABLE CAPABILITIES"}),h.discoveryDetails.notableTools.slice(0,12).map(P=>s.jsxs("p",{children:[s.jsx("code",{children:P.name}),s.jsx("b",{children:P.traits.join(" · ")}),s.jsxs("small",{children:[P.evidence," evidence"]})]},P.name))]}),s.jsxs("div",{children:[s.jsx("span",{children:"SENSITIVE FIELD SIGNALS"}),h.discoveryDetails.sensitiveFields.slice(0,12).map(P=>s.jsxs("p",{children:[s.jsx("code",{children:P.field}),s.jsx("b",{children:P.capabilityId}),s.jsxs("small",{children:[P.evidence," · ",P.confidence.toFixed(2)]})]},`${P.capabilityId}-${P.field}`))]})]}),Y&&e&&s.jsx("div",{className:"drift dirty",role:"status",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Discovery refresh"}),s.jsxs("span",{children:[Y," Prooflane will retry automatically; your MCP connection remains active."]}),s.jsx("button",{type:"button",className:"btn sm ghost",style:{marginLeft:"auto",flex:"none"},disabled:R,onClick:()=>F(P=>P+1),children:R?"Refreshing…":"Refresh"})]})}),s.jsx("p",{children:"Discovery reports what the target exposes. It does not claim a datastore connection from a tool name alone; explicit metadata or execution evidence is required to upgrade an inference to an observed fact."})]}),s.jsx(wz,{connected:e,visible:n,connectedTargetLabel:X,hostedRunner:a,surfaceReady:h.live,profiles:v,recommendations:m,target:f,targetFingerprint:y,deterministicCount:m.length,onNavigateGates:r,onNavigateContracts:i,onNavigateRag:o,onNavigateSecurity:l}),s.jsxs("div",{className:"card","aria-label":"Native authoring lifecycle",children:[s.jsxs("div",{className:"row spread",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("div",{className:"eyebrow",children:"Native authoring lifecycle"}),s.jsx("span",{className:"muted",style:{fontSize:11.5},children:"Cumulative milestones; deferred is the explicit terminal branch."})]}),s.jsx("div",{className:"tiles",style:{marginTop:10,gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))"},children:["RECOMMENDED","AUTHORED","EXECUTABLE","EXECUTED"].map(P=>s.jsxs("div",{className:"tile",children:[s.jsxs("div",{className:"tile-head",children:[s.jsx("span",{className:`tile-dot ${P==="EXECUTED"?"pass":"info"}`}),s.jsx("span",{className:"tile-name",children:P.replaceAll("_"," ")})]}),s.jsx("div",{className:"tile-value",style:{fontSize:22},children:h.authoringLifecycle.summary[P]??0})]},P))}),Object.keys(h.authoringLifecycle.deferredReasons??{}).length>0&&s.jsxs("details",{style:{marginTop:10},children:[s.jsx("summary",{className:"muted",style:{cursor:"pointer",fontSize:12.5},children:"Deferred reason drill-down"}),s.jsx("div",{className:"stack",style:{gap:5,marginTop:8},children:Object.entries(h.authoringLifecycle.deferredReasons).map(([P,T])=>s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:T}),s.jsx("span",{className:"mono",children:P})]},P))})]})]}),m.length>0&&s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("div",{className:"eyebrow",children:"Recommended coverage"}),s.jsx("span",{className:"mono muted",style:{fontSize:11},children:Object.entries(x).map(([P,T])=>`${P} ${T}`).join(" · ")}),s.jsxs("span",{className:"muted",style:{fontSize:11.5,marginLeft:"auto"},children:[m.length," recommendations · ",m.filter(P=>P.autoGeneratable).length," auto-generatable"]})]}),s.jsxs("p",{className:"muted",style:{fontSize:11.5,margin:"6px 0 12px"},children:["What the surface warrants proving, checked against the tests that already exist so generation fills only gaps."," ",s.jsx("span",{className:"mono",style:{color:"var(--pass)"},children:"✓"})," auto-generatable ·"," ",s.jsx("span",{className:"mono",children:"○"})," declared, executor is a later phase · ",s.jsx("span",{style:{color:"var(--warn)"},children:"✎"})," reasoning rests on inference.",s.jsx("span",{style:{display:"block",marginTop:4},children:"This checklist organizes human review focus. Deterministic recommendations remain mandatory during Sammy planning unless an explicit attributed override is recorded."}),j.summary&&s.jsxs("span",{style:{display:"block",marginTop:4},children:["coverage: ",j.summary.COVERED??0," covered · ",j.summary.PARTIALLY_COVERED??0," partial · ",j.summary.MISSING??0," missing",j.summary.OUTDATED?` · ${j.summary.OUTDATED} outdated`:""]})]}),s.jsxs("div",{className:"recommendation-toolbar",children:[s.jsx("div",{className:"recommendation-filters",role:"group","aria-label":"Filter recommendations by assurance pillar",children:c.map(P=>{const T=P==="all"?m:m.filter(ge=>ge.pillar===P),he=zr(T),q=he.filter(ge=>C.has(ge)).length,se=P==="contract"?"Schema / Contract":P==="all"?"All":P;return s.jsxs("button",{type:"button",title:"selected / auto-generatable",className:u===P?"active":"",onClick:()=>d(P),children:[se," ",s.jsxs("span",{children:[q,"/",he.length]})]},P)})}),s.jsxs("div",{className:"recommendation-selection","aria-live":"polite",children:[s.jsxs("strong",{children:[L,"/",_]})," in review shortlist",u!=="all"&&s.jsxs("span",{children:["· ",I,"/",E.length," in view"]}),s.jsx("button",{type:"button",onClick:()=>w(P=>Nz(P,k)),children:"Select visible"}),s.jsx("button",{type:"button",onClick:()=>w(P=>kz(P,k)),children:"Clear visible"}),s.jsx("button",{type:"button",onClick:()=>w([]),children:"Clear all"})]})]}),s.jsx("div",{className:"recommendation-grid",children:[...k].sort((P,T)=>(HS[P.priority]??9)-(HS[T.priority]??9)).map(P=>s.jsxs("label",{className:`recommendation-check ${C.has(P.id)?"selected":""} ${P.autoGeneratable?"":"disabled"}`,children:[s.jsx("input",{type:"checkbox","aria-label":`${C.has(P.id)?"Remove":"Add"} ${P.testType} for ${P.capabilityId}`,checked:C.has(P.id),disabled:!P.autoGeneratable,onChange:()=>w(T=>Sz(T,P.id))}),s.jsx("span",{className:"mono",title:P.autoGeneratable?"auto-generatable":"declared — executor is a later phase",style:{color:P.autoGeneratable?"var(--pass)":"var(--muted)"},children:P.autoGeneratable?"✓":"○"}),s.jsx("span",{className:`tag ${zu(P.priority)}`,style:{fontSize:9.5,minWidth:54,textAlign:"center"},children:P.priority}),s.jsx("span",{className:"tag informational",style:{fontSize:9,minWidth:66,textAlign:"center"},children:P.pillar}),s.jsx("strong",{className:"mono",children:P.testType}),s.jsx("span",{className:"mono muted capability",children:P.capabilityId}),s.jsx("p",{children:P.reason}),s.jsx("span",{className:`tag ${P.authoringStatus==="EXECUTABLE"?"pass":P.authoringStatus==="DEFERRED"?"warn":"informational"}`,style:{fontSize:9},children:(P.authoringStatus??(P.autoGeneratable?"AUTO_AUTHORABLE":"DEFERRED")).replaceAll("_"," ")}),P.deferredReason&&s.jsx("span",{className:"mono muted",style:{fontSize:9.5},children:P.deferredReason}),P.nativeArtifactRef&&s.jsx("span",{className:"mono muted",style:{fontSize:9.5},children:P.nativeArtifactRef}),j.byId[P.id]&&s.jsx("span",{className:`tag ${Tz(j.byId[P.id])}`,style:{fontSize:9},children:Cz[j.byId[P.id]]??j.byId[P.id]}),s.jsxs("span",{className:"muted evidence",children:[P.observed?P.evidenceSource:s.jsxs("span",{style:{color:"var(--warn)"},children:[P.evidenceSource," ✎"]})," · ",P.confidence.toFixed(2)]})]},P.id))})]}),!h.live&&Ys.count>0&&s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("div",{className:"eyebrow",children:"Generated draft suite"}),Ys.suite&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"mono",style:{fontSize:11.5},children:[Ys.suite.id," v",Ys.suite.version]}),s.jsx("span",{className:"tag warn",style:{fontSize:9},children:Ys.suite.status})]}),s.jsx("span",{className:"mono muted",style:{fontSize:11},children:Object.entries(Ys.byPillar).map(([P,T])=>`${P} ${T}`).join(" · ")}),s.jsxs("span",{className:"muted",style:{fontSize:11.5,marginLeft:"auto"},children:[Ys.count," tests from gaps · ",Ys.skipped.length," skipped"]})]}),Ys.suite&&s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:[Ys.suite.suiteFingerprint," · bound to ",Ys.suite.targetFingerprint," · lifecycle DRAFT → REVIEWED → APPROVED (immutable)"]}),s.jsxs("p",{className:"muted",style:{fontSize:11.5,margin:"6px 0 12px"},children:["Runnable test drafts built from the uncovered gaps, each stamped with the capability fingerprint so coverage re-reads them as covered.",s.jsx("strong",{style:{color:"var(--text)"},children:" Never auto-approved"})," — this is a DRAFT for review."]}),s.jsx("div",{style:{display:"grid",gap:3},children:Ys.tests.map(P=>s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",padding:"3px 0",borderTop:"1px solid var(--border)"},children:[s.jsx("span",{className:"tag pass",style:{fontSize:9},children:"+"}),s.jsx("span",{className:"tag informational",style:{fontSize:9,minWidth:66,textAlign:"center"},children:P.pillar}),s.jsx("span",{style:{fontSize:12},children:P.name}),s.jsx("span",{className:"mono muted",style:{fontSize:10,marginLeft:"auto"},children:P.tags.find(T=>T.startsWith("capfp:"))??""})]},P.id))}),Ys.skipped.length>0&&s.jsxs("p",{className:"muted",style:{fontSize:11,marginTop:12},children:[Ys.skipped.length," gaps not generated (contract/RAG objectives and negative-prompt assertions have no faithful slot in the current suite schema yet)."]}),Zn&&Zn.added+Zn.removed+Zn.changed>0&&s.jsxs("div",{style:{marginTop:16,paddingTop:14,borderTop:"1px solid var(--border)"},children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsxs("span",{className:"mono",style:{fontSize:12},children:["v",Zn.fromVersion," → v",Zn.toVersion]}),s.jsxs("span",{className:"muted",style:{fontSize:11},children:[s.jsxs("span",{style:{color:"var(--pass)"},children:["+",Zn.added]})," ·"," ",s.jsxs("span",{style:{color:"var(--fail)"},children:["−",Zn.removed]})," ·"," ",s.jsxs("span",{style:{color:"var(--warn)"},children:["~",Zn.changed]})," · ",Zn.unchanged," unchanged"]}),s.jsx("span",{className:"muted",style:{fontSize:11,marginLeft:"auto"},children:"surface drift → reviewable delta, not a silent swap"})]}),s.jsx("div",{style:{marginTop:6},children:Zn.addedTests.map((P,T)=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",fontSize:11.5,padding:"1px 0"},children:[s.jsx("span",{style:{color:"var(--pass)"},children:"+"}),s.jsx("span",{className:"mono muted",style:{fontSize:9.5,minWidth:60},children:P.pillar}),s.jsx("span",{children:P.name})]},T))})]})]}),v.map(P=>s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{className:"mono",style:{fontSize:14,color:"var(--text)"},children:P.capabilityId}),s.jsx("span",{className:"tag informational",style:{fontSize:9.5},children:P.type.replace("mcp_","")}),s.jsx("span",{className:"mono muted",style:{fontSize:11,marginLeft:"auto"},children:P.fingerprint})]}),P.description&&s.jsx("div",{className:"muted",style:{fontSize:12.5,marginTop:4},children:P.description}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginTop:14},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",style:{fontSize:10,marginBottom:6},children:"Behavior"}),s.jsx("div",{className:"row",style:{gap:6,flexWrap:"wrap"},children:BS(P.behavior).length?BS(P.behavior).map(T=>s.jsx("span",{className:"pill",style:{fontSize:11},children:T},T)):s.jsx("span",{className:"muted",style:{fontSize:12},children:"—"})})]}),s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",style:{fontSize:10,marginBottom:6},children:"Scope"}),s.jsx("div",{className:"row",style:{gap:6,flexWrap:"wrap"},children:VS(P.scope).length?VS(P.scope).map(T=>s.jsx("span",{className:"pill",style:{fontSize:11},children:T},T)):s.jsx("span",{className:"muted",style:{fontSize:12},children:"—"})})]}),s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",style:{fontSize:10,marginBottom:6},children:"Risk"}),s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap",fontSize:11},children:[s.jsxs("span",{className:`tag ${zu(P.risk.authz)}`,style:{fontSize:9.5},children:["authz ",P.risk.authz]}),s.jsxs("span",{className:`tag ${zu(P.risk.dataExposure)}`,style:{fontSize:9.5},children:["data ",P.risk.dataExposure]}),s.jsxs("span",{className:`tag ${zu(P.risk.destructive)}`,style:{fontSize:9.5},children:["destr ",P.risk.destructive]})]})]})]}),P.arguments.length>0&&s.jsxs("div",{style:{marginTop:14},children:[s.jsx("div",{className:"eyebrow",style:{fontSize:10,marginBottom:6},children:"Arguments"}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:"3px 16px"},children:P.arguments.map(T=>s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",fontSize:12,padding:"2px 0"},children:[s.jsx("span",{className:"mono",children:T.name}),s.jsxs("span",{className:"muted",children:["→ ",T.semanticRole]}),s.jsxs("span",{className:"muted",style:{fontSize:10.5,marginLeft:"auto"},children:[T.confidence.toFixed(2),T.evidenceType==="inferred"?s.jsx("span",{style:{color:"var(--warn)"},children:" ✎"}):""]})]},T.name))})]})]},P.capabilityId))]})}function _f(e,t){const n=URL.createObjectURL(new Blob([`${JSON.stringify(t,null,2)}
|
|
65
|
-
`],{type:"application/json"})),a=document.createElement("a");a.href=n,a.download=e,a.click(),URL.revokeObjectURL(n)}const Ya=(e,t="")=>e==null?"Not measured":`${Math.round(e*10)/10}${t}`,Dv=e=>e==null?"Not measured":`${Math.round(e*10)/10}%`,X_=e=>e?`${e.low.toFixed(1)}–${e.high.toFixed(1)}%`:"Unavailable",qS={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://prooflane.ai/schemas/benchmark-methodology-v3.json",title:"Prooflane Benchmark Methodology v3 Validation Record",type:"object",required:["methodologyVersion","datasetFingerprint","runId","config","candidates","cases","evidenceCoverage"],properties:{methodologyVersion:{const:"prooflane-benchmark-v3"},datasetFingerprint:{type:"string",minLength:16},runId:{type:"string",minLength:1},config:{type:"object",required:["trials","warmup","schedule","seed","bootstrapIterations","minimumPairedSamples","minimumWinnerMargin","requireSignificantWinner"],properties:{schedule:{enum:["paired-interleaved","candidate-parallel"]},bootstrapIterations:{type:"integer",minimum:100},minimumPairedSamples:{type:"integer",minimum:2},minimumWinnerMargin:{type:"number",minimum:0},requireSignificantWinner:{type:"boolean"}}},candidates:{type:"array",minItems:2,maxItems:8},cases:{type:"array",minItems:1},evidenceCoverage:{type:"object"}},inference:{confidenceInterval:"seeded non-parametric bootstrap, 95%",pairedHypothesisTest:"two-sided sign test",standardizedEffectSize:"Cohen's dz",multipleComparisonCorrection:"Holm step-down family-wise correction",significanceRule:"adjusted p < 0.05 AND paired bootstrap confidence interval excludes zero"}};function Iz({kind:e}){return e==="paired"?s.jsxs("div",{className:"benchmark-method-diagram paired","aria-hidden":"true",children:[s.jsx("span",{children:"Case 1"}),s.jsxs("div",{children:[s.jsx("b",{children:"A"}),s.jsx("i",{}),s.jsx("b",{children:"B"}),s.jsx("i",{}),s.jsx("b",{children:"C"})]}),s.jsx("span",{children:"Case 2"}),s.jsxs("div",{children:[s.jsx("b",{children:"A"}),s.jsx("i",{}),s.jsx("b",{children:"B"}),s.jsx("i",{}),s.jsx("b",{children:"C"})]})]}):e==="secure"?s.jsxs("div",{className:"benchmark-method-diagram secure","aria-hidden":"true",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Useful task"}),s.jsx("b",{children:"✓"})]}),s.jsx("em",{children:"+"}),s.jsxs("div",{children:[s.jsx("span",{children:"Boundary held"}),s.jsx("b",{children:"✓"})]}),s.jsx("em",{children:"="}),s.jsxs("div",{children:[s.jsx("span",{children:"Secure success"}),s.jsx("b",{children:"✓"})]})]}):e==="uncertainty"?s.jsxs("div",{className:"benchmark-method-diagram uncertainty","aria-hidden":"true",children:[s.jsx("span",{children:"82"}),s.jsxs("div",{children:[s.jsx("i",{}),s.jsx("b",{children:"●"}),s.jsx("i",{})]}),s.jsx("span",{children:"96"}),s.jsx("small",{children:"95% confidence interval"})]}):e==="missing"?s.jsxs("div",{className:"benchmark-method-diagram missing","aria-hidden":"true",children:[s.jsx("span",{children:"Tool use"}),s.jsx("strong",{children:"— Not measured"})]}):e==="privacy"?s.jsxs("div",{className:"benchmark-method-diagram privacy","aria-hidden":"true",children:[s.jsx("span",{children:"API key"}),s.jsx("i",{children:"→"}),s.jsx("strong",{children:"Local memory"}),s.jsxs("div",{children:[s.jsx("b",{children:"│"}),s.jsx("em",{children:"× Cloud"})]})]}):s.jsxs("div",{className:"benchmark-method-diagram pareto","aria-hidden":"true",children:[s.jsx("span",{children:"Quality ↑"}),s.jsxs("div",{children:[s.jsx("i",{className:"a",children:"● A"}),s.jsx("i",{className:"b",children:"● B"}),s.jsx("i",{className:"c",children:"● C"})]}),s.jsx("small",{children:"──────── Cost →"})]})}const Az=e=>e==="candidate-parallel"?"Candidate parallel":"Paired interleaved",tc=e=>(e??0)>0;function Pz({report:e,configured:t}){var f,y,b;const[n,a]=p.useState("idle"),r=[{title:"Paired & interleaved",body:"Concurrent paired-trial execution gives every candidate the same case and trial in one time window; seeded candidate-order rotation reduces provider throttling and temporal latency bias.",detail:"The scheduler constructs case × trial units, deterministically shuffles candidates from the run seed, rotates that order per unit, then dispatches candidates together. A per-candidate pool enforces the configured concurrency ceiling while preserving paired observations.",badge:"Deterministic",diagram:"paired"},{title:"Security-aware success",body:"A task counts as securely successful only when the useful-task assertion passes and every protected-boundary assertion holds; blocking security failures disqualify a candidate.",detail:"Canary-absence and security assertions are graded per retained trial, with the configured severity and blocking flag carried into candidate gates. Recommendation logic excludes disqualified candidates before any winner is selected.",badge:"Canary gated",diagram:"secure"},{title:"Statistical rigor",body:"95% seeded bootstrap confidence intervals, a two-sided paired sign test, Cohen’s dz, and Holm family-wise correction quantify uncertainty without pretending small samples are decisive.",detail:"For each candidate pair, the engine aligns scores by case and trial, bootstraps the mean paired difference, computes Cohen’s dz, and applies the exact two-sided sign test. A winner requires adjusted p < 0.05, a confidence interval excluding zero, sufficient paired observations, and the configured minimum margin.",badge:"Paired inference",formula:s.jsxs(s.Fragment,{children:["Significance threshold: ",s.jsx("b",{children:"α = 0.05"})," · Holm correction across ",s.jsx("b",{children:"K"})," candidate pairs · CI must exclude zero"]}),diagram:"uncertainty"},{title:"Honest non-measurement",body:"Explicit non-measurement: unexercised dimensions—including cost, RAG, and tool contracts—are marked N/M rather than imputed, padded, or inferred from adjacent metrics.",detail:"Metric aggregation only consumes assertion dimensions that produced evidence. Missing pricing, scorers, tool traces, or retrieval traces remain null throughout the report and cannot silently improve a decision score.",badge:"No imputation",diagram:"missing"},{title:"Zero-retention privacy",body:"Keys exist in volatile local Runner memory only; Prooflane’s external Control Plane receives zero API keys, raw prompts, completions, or raw benchmark traces.",detail:"Provider credentials are held in an in-memory map for the local run and cleared when execution ends. Output and trace retention are forced to redacted in this UI path; the model provider still receives the prompt required to execute the benchmark.",badge:"Local runtime",diagram:"privacy"},{title:"Pareto frontier",body:"Non-dominated quality, security, reliability, latency, and cost trade-offs remain visible instead of collapsing unlike operational priorities into one universal leaderboard.",detail:"A candidate is Pareto-optimal only when no eligible peer is at least as good on every measured objective and strictly better on one. Missing objectives stay outside that dominance claim rather than being assigned synthetic values.",badge:"Multi-objective",diagram:"pareto"}],i=e==null?void 0:e.config,o=(e==null?void 0:e.health.coverage.dimensions)??{},l=Object.entries((e==null?void 0:e.health.coverage.attackLevels)??{}).filter(([,m])=>tc(m)).map(([m])=>m).sort(),c=(e==null?void 0:e.candidates.some(m=>m.costUsd!=null))??!1,u=e?{methodologyVersion:e.methodologyVersion,datasetFingerprint:e.datasetFingerprint,runId:e.runId,config:e.config,candidates:e.candidates.map(({id:m,label:x,vendor:j,model:S})=>({id:m,label:x,vendor:j,model:S})),cases:e.cases,evidenceCoverage:e.health.coverage}:null,d=[["Methodology version",(e==null?void 0:e.methodologyVersion)??"Available after run"],["Dataset fingerprint",e?`${e.datasetFingerprint.slice(0,20)}…`:"Available after run"],["Candidates",String((e==null?void 0:e.candidates.length)??t.candidates)],["Cases",String((e==null?void 0:e.health.coverage.cases)??t.cases)],["Trials per case",String((i==null?void 0:i.trials)??t.trials)],["Warmup",String((i==null?void 0:i.warmup)??t.warmup)],["Schedule",Az(i==null?void 0:i.schedule)],["Concurrency",`${(i==null?void 0:i.concurrencyPerCandidate)??t.concurrency} per candidate`],["Seed",i?String(i.seed):"Available after run"],["Bootstrap iterations",((f=i==null?void 0:i.bootstrapIterations)==null?void 0:f.toLocaleString())??"Available after run"],["Minimum paired samples",String((i==null?void 0:i.minimumPairedSamples)??(e==null?void 0:e.health.power.minimumRequiredPairedSamples)??"Available after run")],["Winner margin",(i==null?void 0:i.minimumWinnerMargin)!=null?`${i.minimumWinnerMargin} point${i.minimumWinnerMargin===1?"":"s"}`:"Available after run"],["Significant winner required",i?i.requireSignificantWinner===!1?"No":"Yes":"Available after run"]],h=[["Quality",e?tc(o.quality)||e.candidates.some(m=>m.quality!=null)?"Tested":"Not measured":"Pending run"],["Security",e?l.length?`${l.join(" + ")} only`:tc(o.security)?"Tested":"Not measured":"Pending run"],["Tool use",e?tc(o.tool)||e.candidates.some(m=>m.toolAccuracy!=null)?"Tested":"Not measured":"Pending run"],["RAG",e?tc(o.rag)||e.candidates.some(m=>m.ragScore!=null)?"Tested":"Not measured":"Pending run"],["Reliability",e?e.candidates.some(m=>m.reliability!=null)?"Tested":"Not measured":"Pending run"],["Latency",e?e.candidates.some(m=>{var x;return((x=m.latency)==null?void 0:x.p95)!=null})?"Tested":"Not measured":"Pending run"],["Cost",e?c?"Tested":"Not measured":"Pending run"],["Judge evaluation",e?(((y=e.health.judges)==null?void 0:y.evaluations)??0)>0?`${(b=e.health.judges)==null?void 0:b.evaluations} evaluations`:"Not used":"Pending run"]],g=["A winner when the margin is below threshold","Security superiority from a single attack case","Tool-use quality when no tools were exercised","Lower cost when pricing is unavailable","Statistical significance without sufficient evidence","100% certainty from a small sample"];async function v(){if(u)try{await navigator.clipboard.writeText(`${JSON.stringify(u,null,2)}
|
|
66
|
-
`),a("copied")}catch{a("failed")}}return s.jsxs("div",{className:"benchmark-methodology-stack",children:[s.jsxs("section",{className:"benchmark-panel benchmark-methodology",children:[s.jsxs("div",{className:"benchmark-section-head benchmark-method-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"Audit & proof guarantees"}),s.jsx("h2",{children:"Audit-Ready Benchmarking Standards"}),s.jsx("p",{children:"How Prooflane produces reproducible, auditable, and statistically defensible benchmark decisions."}),s.jsxs("div",{className:"benchmark-method-badges",children:[s.jsx("span",{children:"Local runtime"}),s.jsx("span",{children:"Deterministic"}),s.jsx("span",{children:"Zero-payload persistence"})]})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>_f("prooflane-benchmark-validation-schema-v3.json",qS),children:"↓ Validation schema"})]}),s.jsx("div",{className:"benchmark-method-grid",children:r.map((m,x)=>s.jsxs("details",{className:"benchmark-method-card",children:[s.jsxs("summary",{children:[s.jsx("span",{className:"benchmark-method-number",children:String(x+1).padStart(2,"0")}),s.jsxs("div",{children:[s.jsxs("div",{className:"benchmark-method-title",children:[s.jsx("strong",{children:m.title}),s.jsx("small",{children:m.badge})]}),s.jsx(Iz,{kind:m.diagram}),s.jsx("p",{children:m.body}),m.formula&&s.jsx("div",{className:"benchmark-method-formula",children:m.formula})]}),s.jsx("span",{className:"benchmark-method-expand",children:"+"})]}),s.jsxs("div",{className:"benchmark-method-detail",children:[s.jsx("span",{children:"Enforcement mechanics"}),s.jsx("p",{children:m.detail})]})]},m.title))}),s.jsxs("aside",{className:"benchmark-compliance-note",children:[s.jsx("span",{children:"🛡"}),s.jsxs("div",{children:[s.jsx("strong",{children:"Compliance note"}),s.jsx("p",{children:"Prooflane never transmits API keys, raw prompts, completions, or raw traces to its external Control Plane. Evaluation executes inside the local Runner; only the configured model provider receives the request payload required for inference."})]})]})]}),s.jsxs("section",{className:"benchmark-panel benchmark-audit-panel",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsx("span",{children:"This run"}),s.jsx("h2",{children:e?"Benchmark audit record":"Audit record pending"}),s.jsx("p",{children:e?`Generated ${new Date(e.generatedAt).toLocaleString()} · ${e.runId}`:"Run the configured benchmark to bind the methodology to a dataset and produce its reproducibility record."})]}),s.jsx("dl",{className:"benchmark-run-facts",children:d.map(([m,x])=>s.jsxs("div",{children:[s.jsx("dt",{children:m}),s.jsx("dd",{className:x.includes("Available")?"pending":"",children:x})]},m))})]}),s.jsxs("section",{className:"benchmark-method-lower",children:[s.jsxs("div",{className:"benchmark-panel benchmark-evidence-coverage",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsx("span",{children:"Evidence coverage"}),s.jsx("h2",{children:"Measured in this run"})]}),s.jsx("dl",{children:h.map(([m,x])=>s.jsxs("div",{children:[s.jsx("dt",{children:m}),s.jsx("dd",{className:x==="Not measured"||x==="Not used"||x==="Pending run"?"missing":"tested",children:x})]},m))})]}),s.jsxs("div",{className:"benchmark-panel benchmark-nonclaims",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsx("span",{children:"What Prooflane will not claim"}),s.jsx("h2",{children:"Guardrails against overclaiming"})]}),s.jsx("ul",{children:g.map(m=>s.jsxs("li",{children:[s.jsx("span",{children:"×"}),m]},m))})]})]}),s.jsxs("section",{className:"benchmark-panel benchmark-reproduction",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsx("span",{children:"Reproducibility"}),s.jsx("h2",{children:"Recreate this benchmark decision"})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Dataset SHA256"}),s.jsx("dd",{children:e?e.datasetFingerprint:"Available after run"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Methodology"}),s.jsx("dd",{children:(e==null?void 0:e.methodologyVersion)??"Available after run"})]})]})]}),s.jsxs("div",{className:"benchmark-reproduction-actions",children:[s.jsx("button",{className:"btn ghost",disabled:!u,onClick:()=>void v(),children:n==="copied"?"✓ Copied":n==="failed"?"Copy failed":"Copy reproduction config"}),s.jsx("button",{className:"btn ghost",onClick:()=>_f("prooflane-benchmark-validation-schema-v3.json",qS),children:"↓ Download validation schema"}),s.jsx("button",{className:"btn primary",disabled:!u,onClick:()=>u&&_f(`prooflane-methodology-${e.runId}.json`,u),children:"Download methodology JSON"})]})]})]})}function $z({report:e,onDownload:t,onConfigurePricing:n,onStrengthenEvidence:a,showEvaluatorProvenance:r=!1}){var v,f,y,b,m,x;const i=new Map(e.candidates.map(j=>[j.id,j.label])),[o,l]=p.useState(null),c=(v=e.samples)==null?void 0:v[0],[u,d]=p.useState(c?{caseId:c.caseId,trial:c.trial}:null),h=u?(e.samples??[]).filter(j=>j.caseId===u.caseId&&j.trial===u.trial):[],g=(f=e.cases)==null?void 0:f.find(j=>j.id===(u==null?void 0:u.caseId));return s.jsxs("div",{className:"benchmark-results",children:[s.jsxs("section",{className:`benchmark-recommendation ${e.recommendation.winner?"winner":"no-winner"}`,children:[s.jsxs("div",{children:[s.jsx("span",{children:"Benchmark conclusion"}),s.jsx("h2",{children:e.recommendation.winner?i.get(e.recommendation.winner)??e.recommendation.winner:"No defensible winner yet"}),s.jsx("p",{children:e.recommendation.reason})]}),s.jsx("button",{className:"btn ghost",onClick:t,children:"Download full JSON"}),s.jsxs("div",{className:"benchmark-recommendation-meta",children:[s.jsxs("span",{className:e.health.status,children:[e.health.status," evidence"]}),s.jsxs("span",{children:[e.health.coverage.cases," cases"]}),s.jsxs("span",{children:[((y=e.config)==null?void 0:y.trials)??"—"," trials / case"]}),s.jsx("span",{children:e.methodologyVersion})]})]}),s.jsxs("div",{className:"benchmark-proof-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Proof behind the benchmark"}),s.jsx("h2",{children:"Observed scores with their evidence"})]}),s.jsx("p",{children:"A score is an observation, not a claim of universal performance. Open any candidate to see what was and was not measured."})]}),s.jsx("div",{className:"benchmark-proof-grid",children:e.candidates.map(j=>{const S=j.attempted>=20&&e.health.status==="healthy"?"Strong":j.attempted>=6?"Moderate":"Limited",w=o===j.id;return s.jsxs("article",{className:`benchmark-proof-card ${j.disqualified?"disqualified":""}`,children:[s.jsxs("div",{className:"benchmark-proof-card-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:j.vendor}),s.jsx("h3",{children:j.label}),s.jsx("code",{children:j.model})]}),s.jsx("span",{title:j.paretoOptimal?"No other candidate was better across all measured objectives used by this benchmark.":void 0,className:`benchmark-gate ${j.disqualified?"fail":j.paretoOptimal?"pass":"neutral"}`,children:j.disqualified?"Disqualified":j.paretoOptimal?"Pareto optimal":"Eligible"})]}),s.jsxs("div",{className:"benchmark-score-row",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Decision score"}),s.jsx("strong",{children:Ya(j.decisionScore)})]}),s.jsxs("div",{className:"benchmark-evidence-grade",children:[s.jsx("span",{children:"Evidence strength"}),s.jsx("strong",{className:S.toLowerCase(),children:S})]})]}),s.jsxs("div",{className:"benchmark-proof-stats",children:[s.jsxs("div",{children:[s.jsxs("strong",{children:[j.succeeded," / ",j.attempted]}),s.jsx("span",{children:"successful trials"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:Dv(j.verdictConsistency)}),s.jsx("span",{children:"verdict consistency"})]}),s.jsxs("div",{children:[s.jsx("strong",{children:Ya(j.latency.p95," ms")}),s.jsx("span",{children:"p95 latency"})]})]}),j.secureTaskSuccess&&s.jsxs("div",{className:"benchmark-confidence",children:[s.jsx("span",{children:"Observed secure-task success"}),s.jsxs("strong",{children:[j.secureTaskSuccess.value,"%"]}),s.jsxs("small",{children:[j.secureTaskSuccess.successes," / ",j.secureTaskSuccess.total," · 95% CI ",X_(j.secureTaskSuccess.ci95)]})]}),s.jsxs("div",{className:"benchmark-coverage-strip","aria-label":`${j.label} evidence coverage`,children:[s.jsxs("span",{className:j.toolAccuracy==null?"missing":"measured",children:["Tool accuracy · ",Ya(j.toolAccuracy)]}),s.jsxs("span",{className:j.ragScore==null?"missing":"measured",children:["RAG · ",Ya(j.ragScore)]}),s.jsxs("span",{className:j.costUsd==null?"missing":"measured",children:["Cost · ",j.costUsd==null?"Not measured":`$${j.costUsd.toFixed(4)}`]})]}),s.jsxs("button",{className:"benchmark-proof-button","aria-expanded":w,onClick:()=>l(w?null:j.id),children:[w?"Hide score proof":"Why this score?",s.jsx("span",{children:"→"})]}),w&&s.jsx(Oz,{candidate:j})]},j.id)})}),(((b=e.samples)==null?void 0:b.length)??0)>0&&s.jsxs("section",{className:"benchmark-panel benchmark-matrix-section",children:[s.jsx("div",{className:"benchmark-section-head",children:s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"Evidence"}),s.jsx("h2",{children:"Proof by case and trial"}),s.jsx("p",{children:"Open a trial to compare retained outputs, assertions, latency, tokens, and retries side by side."})]})}),s.jsx(Lz,{report:e,labels:i,selection:u,onSelect:d}),u&&s.jsx(Mz,{caseName:(g==null?void 0:g.name)??u.caseId,purpose:g==null?void 0:g.purpose,samples:h,showEvaluatorProvenance:r})]}),e.pairwise.length>0&&s.jsxs("section",{className:"benchmark-panel",children:[s.jsx("div",{className:"benchmark-section-head",children:s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"Statistics"}),s.jsx("h2",{children:"Paired comparisons"}),s.jsx("p",{children:"Differences are shown with sample size, significance, and statistical power."})]})}),s.jsx("div",{className:"benchmark-comparison-list",children:e.pairwise.map(j=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("strong",{children:i.get(j.a)??j.a}),s.jsx("span",{children:"versus"}),s.jsx("strong",{children:i.get(j.b)??j.b})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Quality Δ"}),s.jsx("strong",{children:Ya(j.qualityDelta)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Paired n"}),s.jsx("strong",{children:j.pairedObservations})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Inference"}),s.jsx("strong",{children:j.significant==null?"Unavailable":j.significant?"Significant":"Not significant"})]}),s.jsx("span",{className:"benchmark-comparison-result",children:j.winner?`Winner · ${i.get(j.winner)??j.winner}`:"No defensible winner"})]},`${j.a}-${j.b}`))})]}),e.notes.length>0&&s.jsxs("section",{className:"benchmark-health-notes",children:[s.jsx("strong",{children:"Benchmark health notes"}),s.jsx("ul",{children:e.notes.map(j=>{const S=j.startsWith("Cost not measured")||j.startsWith("No pricing resolver")||j.startsWith("Cost remains unknown"),w=j.includes("quality confidence interval");return s.jsxs("li",{children:[s.jsx("span",{children:j}),S&&n&&s.jsx("button",{type:"button",onClick:n,children:"Configure pricing"}),w&&a&&s.jsx("button",{type:"button",onClick:a,children:"Set 5 trials & review cases"})]},j)})})]}),s.jsxs("footer",{className:"benchmark-method-footer",children:[s.jsxs("span",{children:["Methodology ",e.methodologyVersion]}),s.jsxs("span",{children:["Dataset ",e.datasetFingerprint.slice(0,16),"…"]}),s.jsx("span",{children:((m=e.config)==null?void 0:m.schedule)??"paired-interleaved"}),s.jsxs("span",{children:["Seed ",((x=e.config)==null?void 0:x.seed)??"—"]})]})]})}function Oz({candidate:e}){var n,a;const t=[{label:"Quality",value:Ya(e.quality),detail:e.qualityCi95?`95% CI ${e.qualityCi95.low.toFixed(1)}–${e.qualityCi95.high.toFixed(1)}`:"No interval available"},{label:"Security resistance",value:Dv((n=e.securityResistance)==null?void 0:n.value),detail:e.securityResistance?`${e.securityResistance.successes} / ${e.securityResistance.total} resisted · 95% CI ${X_(e.securityResistance.ci95)}`:"Not exercised"},{label:"RAG assurance",value:Ya(e.ragScore),detail:e.ragScore==null?"Not exercised":"Retrieval assertions graded"},{label:"Tool accuracy",value:Ya(e.toolAccuracy),detail:e.toolAccuracy==null?"Not exercised":"Tool assertions graded"},{label:"Reliability",value:Dv((a=e.reliability)==null?void 0:a.successRate.value),detail:e.reliability?`${e.reliability.successRate.successes} / ${e.reliability.successRate.total} requests succeeded`:"Unavailable"},{label:"Cost",value:e.costUsd==null?"Not measured":`$${e.costUsd.toFixed(4)}`,detail:e.costUsd==null?"No versioned pricing supplied":"Measured provider cost"}];return s.jsxs("div",{className:"benchmark-score-proof",children:[s.jsxs("div",{className:"benchmark-score-proof-title",children:["Why ",e.label," scored ",Ya(e.decisionScore)]}),t.map(r=>s.jsxs("div",{className:r.value==="Not measured"?"missing":"",children:[s.jsx("span",{children:r.label}),s.jsx("strong",{children:r.value}),s.jsx("small",{children:r.detail})]},r.label)),e.gateReasons.map(r=>s.jsx("p",{className:"benchmark-gate-reason",children:r},r))]})}function Lz({report:e,labels:t,selection:n,onSelect:a}){const r=p.useMemo(()=>{const o=new Map;for(const l of e.samples??[])o.set(`${l.caseId}:${l.trial}`,{caseId:l.caseId,caseName:l.caseName,purpose:l.purpose,trial:l.trial});return[...o.values()]},[e.samples]),i=new Map((e.samples??[]).map(o=>[`${o.caseId}:${o.trial}:${o.candidateId}`,o]));return s.jsx("div",{className:"benchmark-matrix-wrap",children:s.jsxs("table",{className:"benchmark-matrix",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Case / trial"}),e.candidates.map(o=>s.jsx("th",{children:t.get(o.id)??o.id},o.id)),s.jsx("th",{children:"Evidence"})]})}),s.jsx("tbody",{children:r.map(o=>s.jsxs("tr",{className:(n==null?void 0:n.caseId)===o.caseId&&(n==null?void 0:n.trial)===o.trial?"selected":"",children:[s.jsxs("td",{children:[s.jsx("strong",{children:o.caseName}),s.jsxs("span",{children:[o.purpose," · Trial ",o.trial+1]})]}),e.candidates.map(l=>{const c=i.get(`${o.caseId}:${o.trial}:${l.id}`);return s.jsx("td",{children:s.jsx(Q_,{sample:c})},l.id)}),s.jsx("td",{children:s.jsx("button",{onClick:()=>a({caseId:o.caseId,trial:o.trial}),children:"View proof →"})})]},`${o.caseId}:${o.trial}`))})]})})}function Q_({sample:e}){if(!e)return s.jsx("span",{className:"benchmark-verdict missing",children:"Missing"});const t=e.verdict==="pass"&&e.purpose==="security"?"Resisted":e.verdict==="pass"?"Pass":e.verdict==="drift"?"Drift":e.verdict==="ungraded"?"Ungraded":"Fail";return s.jsx("span",{className:`benchmark-verdict ${e.verdict}`,children:t})}function Mz({caseName:e,purpose:t,samples:n,showEvaluatorProvenance:a}){return s.jsxs("div",{className:"benchmark-trial-proof",children:[s.jsxs("div",{className:"benchmark-trial-proof-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:t==="security"?"Protected boundary":"Trial evidence"}),s.jsx("h3",{children:e})]}),t==="security"&&s.jsx("strong",{children:"Boundary crossing observed only when an assertion proves it."})]}),s.jsx("div",{className:"benchmark-response-grid",children:n.map(r=>{var i,o;return s.jsxs("article",{children:[s.jsxs("div",{className:"benchmark-response-head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:r.candidateLabel}),s.jsxs("span",{children:["Trial ",r.trial+1]})]}),s.jsx(Q_,{sample:r})]}),s.jsx("pre",{children:r.output||"Output not retained under this run's privacy policy."}),s.jsx("div",{className:"benchmark-assertions",children:r.assertionResults.map(l=>s.jsxs("div",{children:[s.jsx("span",{children:l.passed===!0?"✓":l.passed===!1?"×":"?"}),s.jsxs("div",{children:[s.jsx("strong",{children:l.kind}),s.jsx("p",{children:l.evidence||l.rationale||"No assertion explanation retained."}),l.hint&&s.jsxs("p",{className:"benchmark-assertion-hint",children:[s.jsx("strong",{children:"Assertion mismatch —"})," ",l.hint]})]})]},l.assertionId))}),a&&s.jsxs("div",{className:"benchmark-trial-provenance",children:[s.jsx("span",{children:"Evaluation provenance"}),r.evaluationPath?s.jsxs(s.Fragment,{children:[s.jsxs("strong",{children:[r.evaluationPath.evaluationMethod.replaceAll("-"," ")," · ",((i=r.evaluationPath.finalVerdictSource)==null?void 0:i.replaceAll("_"," "))??"NOT MEASURED"]}),(o=r.evaluatorProvenance)!=null&&o.length?s.jsx("ul",{children:r.evaluatorProvenance.map((l,c)=>{var u;return s.jsxs("li",{children:[s.jsx("b",{children:l.evaluatorId}),s.jsx("small",{children:[l.provider,l.model,l.evaluatorVersion??l.ruleVersion].filter(Boolean).join(" · ")||"Version not available"}),s.jsx("em",{children:((u=l.independence)==null?void 0:u.status.replaceAll("_"," "))??"Independence unknown"})]},`${l.evaluatorId}-${c}`)})}):s.jsx("p",{children:"Evaluator details were not captured for this historical run."})]}):s.jsx("p",{children:"Not available for this historical run."})]}),s.jsxs("footer",{children:[s.jsxs("span",{children:[r.latencyMs," ms"]}),s.jsxs("span",{children:[r.usage.inputTokens," in / ",r.usage.outputTokens," out"]}),s.jsxs("span",{children:[r.retriesUsed," retries"]}),s.jsx("span",{children:r.outputHash?`hash ${r.outputHash.slice(0,10)}…`:"no output hash"})]})]},r.candidateId)})})]})}const zv=[{id:"openai",label:"OpenAI",vendor:"OpenAI",transport:"openai",baseUrl:"https://api.openai.com/v1",modelHint:"Enter an OpenAI model ID",keyHint:"OpenAI API key"},{id:"anthropic",label:"Anthropic",vendor:"Anthropic",transport:"anthropic",baseUrl:"https://api.anthropic.com",modelHint:"Enter a Claude model ID",keyHint:"Anthropic API key"},{id:"google",label:"Google Gemini",vendor:"Google",transport:"openai",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai",modelHint:"Enter a Gemini model ID",keyHint:"Gemini API key"},{id:"openrouter",label:"OpenRouter",vendor:"OpenRouter",transport:"openai",baseUrl:"https://openrouter.ai/api/v1",modelHint:"provider/model",keyHint:"OpenRouter API key"},{id:"groq",label:"Groq",vendor:"Groq",transport:"openai",baseUrl:"https://api.groq.com/openai/v1",modelHint:"Enter a Groq model ID",keyHint:"Groq API key"},{id:"mistral",label:"Mistral",vendor:"Mistral AI",transport:"openai",baseUrl:"https://api.mistral.ai/v1",modelHint:"Enter a Mistral model ID",keyHint:"Mistral API key"},{id:"together",label:"Together AI",vendor:"Together AI",transport:"openai",baseUrl:"https://api.together.ai/v1",modelHint:"provider/model",keyHint:"Together API key"},{id:"ollama",label:"Ollama · local",vendor:"Ollama",transport:"openai",baseUrl:"http://127.0.0.1:11434/v1",modelHint:"Installed Ollama model",keyHint:"No key required",local:!0},{id:"custom",label:"Custom OpenAI-compatible",vendor:"Custom",transport:"openai",modelHint:"Endpoint model ID",keyHint:"Endpoint API key"}],Ux={GENERAL_AI:"General AI",PROMPT:"Prompt",RAG:"RAG",AGENT:"Agent",MCP_TOOL:"MCP / Tool",CODE:"Code",CUSTOM:"Custom"},Cf={FAST:{label:"Fast",eyebrow:"RELEASE VELOCITY",detail:"Bounded planning · two targets · Prooflane orchestration is free"},DEEP:{label:"Deep",eyebrow:"ARCHITECTURE REASONING",detail:"Broader adversarial coverage · stronger evidence expectations"},CUSTOM:{label:"Custom",eyebrow:"GOVERNED CONFIGURATION",detail:"Approved policy · privacy · budget · local/private configuration"}},Uu=()=>`bench-ui-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`,Cr=e=>zv.find(t=>t.id===e)??zv[0],Tf=e=>({id:`candidate-${e+1}`,label:`Candidate ${String.fromCharCode(65+e)}`,providerId:e===1?"anthropic":"openai",model:"",apiKey:""}),qc=e=>{var t,n,a,r,i,o;return Number.isFinite((t=e.pricing)==null?void 0:t.input)&&Number((n=e.pricing)==null?void 0:n.input)>=0&&Number.isFinite((a=e.pricing)==null?void 0:a.output)&&Number((r=e.pricing)==null?void 0:r.output)>=0&&!!((o=(i=e.pricing)==null?void 0:i.source)!=null&&o.trim())},Dz=e=>e.pricing!=null&&Object.values(e.pricing).some(t=>t!==void 0&&t!==""),zz=e=>/\r|\n/.test(e)||/,\s*(?:session|memory)[ -]?only\s*$/i.test(e),KS="A separately routed reviewer challenges Sammy’s proposed plan for coverage, bias, redundancy, fairness and executability. It cannot override deterministic facts.",JS={decisionExplanation:!1,evaluatorProvenance:!1,reproducibility:!1,evidenceStrengthExplanation:!1,judgingStrategy:!1};function eC(e){return e.evaluatorType==="DETERMINISTIC"?"Deterministic":e.evaluatorType==="INDEPENDENT_LLM_JUDGE"?"Independent Semantic Judge":e.evaluatorType==="DOMAIN_EVALUATOR"?"Domain Evaluator":e.pillar==="rag"?"RAG Assurance":e.pillar==="security"?"Security Evidence":e.pillar==="agent_tool"?"Agent / Tool Evidence":e.pillar==="contract"?"Contract Evidence":"Pillar Evaluator"}function Uz(e){const t=["Deterministic","RAG Assurance","Security Evidence","Agent / Tool Evidence","Contract Evidence","Domain Evaluator","Pillar Evaluator","Independent Semantic Judge"],n=new Map;for(const i of e.cases){const o=eC(i);n.set(o,(n.get(o)??0)+1)}const a=[...n.entries()].map(([i,o])=>({label:i,count:o})).sort((i,o)=>t.indexOf(i.label)-t.indexOf(o.label)),r=e.cases.filter(i=>i.evaluatorType==="INDEPENDENT_LLM_JUDGE").reduce((i,o)=>i+o.repetitionPolicy.measured*e.capabilityMatrix.targets.length,0);return{mix:a,semanticJudgeCalls:r}}function Va({text:e}){return s.jsx("i",{className:"benchmark-info-tip",tabIndex:0,role:"img","aria-label":e,"data-tooltip":e,children:"i"})}function sc(e,t){const n=URL.createObjectURL(new Blob([`${JSON.stringify(t,null,2)}
|
|
67
|
-
`],{type:"application/json"})),a=document.createElement("a");a.href=n,a.download=e,a.click(),URL.revokeObjectURL(n)}function Fz(){const[e,t]=p.useState([Tf(0),Tf(1)]),[n,a]=p.useState("Choose the stronger model for a production support assistant that must answer from approved knowledge, resist retrieved prompt injection, and keep latency predictable."),[r,i]=p.useState("RAG"),[o,l]=p.useState("FAST"),[c,u]=p.useState("SANITIZED_HOSTED_ALLOWED"),[d,h]=p.useState("SUMMARY_ONLY"),[g,v]=p.useState(2),[f,y]=p.useState(1),[b,m]=p.useState("setup"),[x,j]=p.useState(!1),[S,w]=p.useState(null),[C,k]=p.useState(null),[N,L]=p.useState(null),[_,E]=p.useState(null),[I,$]=p.useState([]),[W,R]=p.useState(null),[H,Y]=p.useState(!1),[K,ce]=p.useState("APPLE_APP_STORE"),[F,ie]=p.useState(""),[ue,oe]=p.useState([]),[B,Q]=p.useState(null),[X,me]=p.useState(null),[fe,P]=p.useState([]),[T,he]=p.useState("all"),[q,se]=p.useState(JS),[ge,de]=p.useState([]),[Ne,Oe]=p.useState(null),_e=p.useRef(Uu()),re=p.useRef(null),V=p.useRef(Uu()),le=p.useRef(2);p.useEffect(()=>{ee()},[]);async function ee(){try{const z=await O.benchmarkEntitlements();$(z.entitlements),R(z.pricingPolicy.products.PAID_SINGLE_RUN.priceUsd),se(z.featureFlags??JS)}catch{}}const xe=I.find(z=>z.state==="AVAILABLE"&&(o==="FAST"||z.type!=="FREE_FAST")),Fe=I.some(z=>z.type==="FREE_FAST"&&z.state==="AVAILABLE"),Be=I.some(z=>z.productId==="prooflane-benchmark-development"&&z.state==="AVAILABLE"),st=(z,D)=>t(A=>A.map(ne=>ne.id===z?D(ne):ne));function ae(z,D){return{...z,providerId:D,apiKey:Cr(D).local?"ollama":z.apiKey==="ollama"?"":z.apiKey,baseUrl:D==="custom"?z.baseUrl:void 0,pricing:void 0}}function Ce(z){l(z),v(z==="FAST"?2:3),L(null),k(null),z==="FAST"&&t(D=>D.slice(0,2))}function He(z=!1){if(!n.trim())return"Describe what this benchmark should decide.";if(o==="FAST"&&e.length!==2)return"Fast benchmarks compare exactly two targets.";if(e.some(D=>!D.label.trim()||!D.model.trim()))return"Every target needs a label and model ID.";if(e.some(D=>{var A;return D.providerId==="custom"&&!((A=D.baseUrl)!=null&&A.trim())}))return"Custom OpenAI-compatible targets need a base URL.";if(e.some(D=>Dz(D)&&!qc(D)))return"Cost measurement needs non-negative input/output prices and an auditable source.";if(z&&e.some(D=>!Cr(D.providerId).local&&!D.apiKey.trim()))return"Enter each provider credential for this local execution. Credentials stay in volatile memory only.";if(z){const D=e.find(A=>!Cr(A.providerId).local&&zz(A.apiKey));if(D)return`${D.label} credential includes copied display text. Paste only the provider key; Prooflane keeps it memory-only automatically.`}return null}function qe(z){const D=Cr(z.providerId),A=qc(z)?{input:Number(z.pricing.input),output:Number(z.pricing.output),currency:"USD",source:z.pricing.source.trim(),...z.pricing.effectiveAt?{effectiveAt:z.pricing.effectiveAt}:{}}:void 0;return{id:z.id,label:z.label.trim(),provider:D.transport,adapter:D.local?"prooflane-local-openai-compatible":`prooflane-${D.transport}`,adapterVersion:"1",requestedModelId:z.model.trim(),capabilities:{structuredOutput:!0,jsonSchema:D.transport==="openai",toolCalling:D.transport==="openai",streaming:!0,multimodal:!1,ragIntegration:!1,agentTool:D.transport==="openai",temperatureConfigurable:!0,seed:D.transport==="openai",maxOutputControls:!0,knownProviderConstraints:D.local?["Runtime capability is adapter-reported at execution."]:[],pricingAvailable:!!A},pricing:A}}async function dt(){const z=He();if(z){w(z);return}j(!0),w(null),k(null),oe([]),Q(null),me(null);try{const D=await O.benchmarkPlan({requestId:_e.current,objective:n.trim(),targetType:r,mode:o,privacyClass:c,storageMode:d,measuredRepetitions:g,warmups:f,targets:e.map(qe),sourceRefs:r==="RAG"?["rag-assurance:trusted-goldens","learning:governed-failures"]:["prompt-studio:saved-tests","learning:governed-failures"]});L(D.plan),E(D.planningMode),de(D.judgeRegistry??[]),Oe(D.judgingValidation??null),m("plan")}catch(D){w(D instanceof Error?D.message:"Sammy could not complete the BenchmarkPlan.")}finally{j(!1)}}async function ye(){if(!N){const A="Review and approve a BenchmarkPlan before starting execution.";w(A),k(A);return}const z=He(!0);if(z){w(z),k(z),requestAnimationFrame(()=>{var Ee;const A=e.find(ze=>!Cr(ze.providerId).local&&!ze.apiKey.trim()),ne=A?document.getElementById(`benchmark-credential-${A.id}`):null,Re=document.getElementById("benchmark-run-validation");(Ee=ne??Re)==null||Ee.scrollIntoView({behavior:"smooth",block:"center"}),ne instanceof HTMLInputElement&&ne.focus()});return}if(!xe){w(W==null?"This workspace needs a server-verified single-run entitlement.":`This workspace needs one server-verified $${W.toFixed(2)} single-run entitlement.`);return}if(N.review.status==="LIMITED"){w("Execution is blocked because independent model-assisted review was unavailable. Connect an approved Sammy route and regenerate the plan.");return}const D=new AbortController;re.current=D,j(!0),w(null),k(null),oe([{status:"CONNECTION_PREFLIGHT",detail:xe.type==="FREE_FAST"||xe.productId==="prooflane-benchmark-development"?"Testing each configured LLM route before Prooflane reserves the run.":"Validating the reviewed plan before Prooflane reserves the run."}]),m("run");try{const A=e.map(Re=>{const Ee=Cr(Re.providerId);return{id:Re.id,label:Re.label,apiKey:Ee.local?"ollama":Re.apiKey,route:{label:Re.label,provider:Ee.transport,vendor:Ee.vendor,model:Re.model,baseUrl:Re.providerId==="custom"?Re.baseUrl:Ee.baseUrl,parameters:{temperature:0,maxTokens:1024}},...qc(Re)?{pricing:{input:Number(Re.pricing.input),output:Number(Re.pricing.output),currency:"USD",source:Re.pricing.source.trim(),...Re.pricing.effectiveAt?{effectiveAt:Re.pricing.effectiveAt}:{}}}:{}}}),ne=await O.benchmarkRunStream({requestId:_e.current,entitlementId:xe.id,plan:N,candidates:A,options:{concurrencyPerCandidate:1,schedule:"paired-interleaved"}},Re=>oe(Ee=>[...Ee.slice(-39),Re]),D.signal);if(!ne.ok||!ne.report||!ne.workflow){const Re=ne.error??"The benchmark ended without a governed result.";w(Re),k(Re),oe([]),m("plan"),requestAnimationFrame(()=>{var Ee;return(Ee=document.getElementById("benchmark-run-validation"))==null?void 0:Ee.scrollIntoView({behavior:"smooth",block:"center"})});return}Q(ne.report),me(ne.workflow),m("results"),await ee(),await Ds()}catch(A){w(D.signal.aborted?"Benchmark cancelled. Any unconsumed entitlement reservation was released safely.":A instanceof Error?A.message:"The benchmark could not complete.")}finally{re.current=null,j(!1)}}async function Ke(){if(!F.trim()){w("Paste the receipt returned by the approved in-app purchase provider.");return}j(!0),w(null);try{await O.benchmarkVerifyPurchase({provider:K,productId:"prooflane-benchmark-single-run",receipt:F.trim(),idempotencyKey:V.current}),ie(""),Y(!1),V.current=Uu(),await ee()}catch(z){w(z instanceof Error?z.message:"Prooflane could not verify this purchase receipt.")}finally{j(!1)}}async function U(z){if(N){j(!0),w(null);try{const D=await O.benchmarkReviseJudgingStrategy(N,z);L(D.plan),de(D.judgeRegistry),Oe(D.judgingValidation)}catch(D){throw w(D instanceof Error?D.message:"The judging strategy could not be saved."),D}finally{j(!1)}}}async function te(){j(!0),w(null);try{const z=await O.benchmarkHistory();P(z.runs),m("history")}catch(z){w(z instanceof Error?z.message:"Benchmark history is unavailable.")}finally{j(!1)}}async function ke(z){var D;j(!0),w(null);try{const A=await O.benchmarkStoredRun(z);L(A.run.plan),Q(A.run.report??null);const ne=(D=A.run.summary)==null?void 0:D.result;me(ne?{runId:A.run.runId,status:A.run.status,comparison:ne,summary:A.run.summary??{},pricingSnapshots:[],reportFilename:`benchmark-report-${A.run.runId}.html`,storage:{localDetailedReport:!0,cloudMode:A.run.plan.privacyPolicy.storageMode,rawEvidenceSynced:!1}}:null),m(A.run.report?"results":"history")}catch(A){w(A instanceof Error?A.message:"Benchmark Run could not be opened.")}finally{j(!1)}}const we=(N==null?void 0:N.cases.filter(z=>T==="all"||z.pillar===T))??[],Te=ue.at(-1),ve=Te!=null&&Te.totalMeasured?Math.round((Te.measuredDone??0)/Te.totalMeasured*100):0;return s.jsxs("div",{className:"benchmark-workspace benchmark-v2",children:[s.jsxs("header",{className:"benchmark-hero benchmark-sammy-hero",children:[s.jsxs("div",{children:[s.jsx("div",{className:"benchmark-kicker",children:"Sammy-orchestrated · evidence-proven"}),s.jsx("h1",{children:"AI Benchmarking"}),s.jsx("p",{children:"Choose what you want to compare. Sammy designs the experiment, a separately routed Reviewer challenges the plan, and Prooflane’s governed evidence decides what can actually be claimed."})]}),s.jsxs("div",{className:"benchmark-hero-actions",children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>void te(),children:"Run history"}),s.jsxs("span",{className:`benchmark-entitlement-pill ${Fe||Be?"free":"paid"}`,children:[s.jsx("b",{children:Be?"DEV":Fe?"FREE":W==null?"VERIFY":`$${W.toFixed(2)}`}),s.jsx("small",{children:Be?"Governed development runs":Fe?"Prooflane orchestration · Fast":"per verified run"})]})]})]}),s.jsxs("nav",{className:"benchmark-journey","aria-label":"Benchmark workflow",children:[["setup","plan","run","results"].map((z,D)=>s.jsxs("button",{disabled:z==="plan"&&!N||z==="run"&&b!=="run"||z==="results"&&!B,className:b===z?"active":"",onClick:()=>m(z),children:[s.jsx("span",{children:b===z?"●":D+1}),z==="setup"?"Choose":z==="plan"?"Review plan":z==="run"?"Run":"Decision"]},z)),s.jsxs("button",{className:b==="methodology"?"active":"",onClick:()=>m("methodology"),children:[s.jsx("span",{children:"◎"}),"Methodology"]})]}),S&&s.jsxs("div",{className:"benchmark-error benchmark-global-error",role:"alert",children:[s.jsx("span",{children:"!"}),s.jsx("p",{children:S}),s.jsx("button",{"aria-label":"Dismiss error",onClick:()=>w(null),children:"×"})]}),b==="setup"&&s.jsx(Gz,{objective:n,setObjective:a,targetType:r,setTargetType:z=>{i(z),L(null)},mode:o,setMode:Ce,privacyClass:c,setPrivacyClass:u,storageMode:d,setStorageMode:h,targets:e,setTargets:t,updateTarget:st,changeProvider:ae,addTarget:()=>{if(o!=="FAST"&&e.length<8){const z=le.current++;t(D=>[...D,Tf(z)])}},busy:x,onDesign:()=>void dt()}),b==="plan"&&N&&s.jsxs(s.Fragment,{children:[s.jsx(Hz,{plan:N,planningMode:_,targets:e,credentialError:C,onCredentialChange:(z,D)=>{st(z,A=>({...A,apiKey:D})),k(null),w(null)},entitlement:xe,paidPrice:W,busy:x,filter:T,setFilter:he,visibleCases:we,judgingEnabled:q.judgingStrategy,judgeRegistry:ge,judgingValidation:Ne,onSaveJudgingStrategy:z=>U(z),onBack:()=>m("setup"),onMethodology:()=>m("methodology"),onRun:()=>void ye(),onPurchase:()=>Y(!0)}),H&&s.jsx(Vz,{provider:K,setProvider:ce,receipt:F,setReceipt:ie,price:W,busy:x,onCancel:()=>{ie(""),Y(!1)},onVerify:()=>void Ke()})]}),b==="run"&&s.jsx(Kz,{latest:Te,progress:ue,progressPct:ve,plan:N,busy:x,onStop:()=>{var z;return(z=re.current)==null?void 0:z.abort()}}),b==="results"&&B&&s.jsx(Jz,{plan:N,report:B,workflow:X,showEvaluatorProvenance:q.evaluatorProvenance,onSetup:()=>m("setup"),onNew:()=>{_e.current=Uu(),L(null),Q(null),me(null),m("setup")}}),b==="history"&&s.jsx(Zz,{history:fe,onNew:()=>m("setup"),onOpen:z=>void ke(z)}),b==="methodology"&&s.jsx(Pz,{report:B,configured:{candidates:e.length,cases:(N==null?void 0:N.cases.length)??0,trials:(N==null?void 0:N.trialPolicy.measured)??g,warmup:(N==null?void 0:N.trialPolicy.warmups)??f,concurrency:1}})]})}function Gz(e){return s.jsxs("div",{className:"benchmark-setup benchmark-sammy-setup",children:[s.jsxs("section",{className:"benchmark-panel benchmark-objective-panel",children:[s.jsx("div",{className:"benchmark-section-head",children:s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"01 · Decision"}),s.jsx("h2",{children:"What should this benchmark decide?"}),s.jsx("p",{children:"A short objective lets Sammy choose relevant Prompt, RAG, Security, Agent/Tool, performance, and cost coverage."})]})}),s.jsxs("label",{className:"benchmark-field benchmark-objective",children:[s.jsx("span",{children:"Benchmark objective"}),s.jsx("textarea",{rows:3,value:e.objective,onChange:t=>e.setObjective(t.target.value),maxLength:2e3})]}),s.jsxs("div",{className:"benchmark-setup-options",children:[s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Benchmark target"}),s.jsx("select",{value:e.targetType,onChange:t=>e.setTargetType(t.target.value),children:Object.entries(Ux).map(([t,n])=>s.jsx("option",{value:t,children:n},t))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Privacy boundary"}),s.jsxs("select",{value:e.privacyClass,onChange:t=>e.setPrivacyClass(t.target.value),children:[s.jsx("option",{value:"SANITIZED_HOSTED_ALLOWED",children:"Sanitized planning allowed"}),s.jsx("option",{value:"LOCAL_ONLY",children:"Local only · fail closed"}),s.jsx("option",{value:"HOSTED_ALLOWED",children:"Hosted allowed"})]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Cloud record"}),s.jsxs("select",{value:e.storageMode,onChange:t=>e.setStorageMode(t.target.value),children:[s.jsx("option",{value:"SUMMARY_ONLY",children:"Summary only · default"}),s.jsx("option",{value:"FULL_ENCRYPTED_REPORT",disabled:e.privacyClass==="LOCAL_ONLY",children:"Encrypted detailed report · opt-in"})]})]})]}),s.jsx("div",{className:"benchmark-mode-grid",children:["FAST","DEEP","CUSTOM"].map(t=>s.jsxs("button",{type:"button",className:e.mode===t?"active":"","aria-pressed":e.mode===t,onClick:()=>e.setMode(t),children:[s.jsxs("span",{className:"benchmark-mode-head",children:[s.jsx("span",{children:Cf[t].eyebrow}),t==="FAST"&&s.jsx("em",{children:"Recommended"})]}),s.jsx("strong",{children:Cf[t].label}),s.jsx("span",{className:"benchmark-mode-reasons",children:Cf[t].detail.split(" · ").map(n=>s.jsx("small",{children:n},n))})]},t))})]}),s.jsxs("section",{className:"benchmark-panel",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"02 · Compare"}),s.jsx("h2",{children:"Models and deployment targets"}),s.jsx("p",{children:"Model IDs are free-form. Sammy inspects an explicit capability matrix before declaring any case comparable."})]}),e.mode!=="FAST"&&s.jsx("button",{className:"btn ghost",disabled:e.targets.length>=8,onClick:e.addTarget,children:"+ Add target"})]}),s.jsx("div",{className:"benchmark-target-list",children:e.targets.map((t,n)=>{const a=Cr(t.providerId);return s.jsxs("article",{className:"benchmark-target-row",children:[s.jsx("span",{className:"benchmark-target-letter",children:String.fromCharCode(65+n)}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Label"}),s.jsx("input",{value:t.label,onChange:r=>e.updateTarget(t.id,i=>({...i,label:r.target.value}))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Provider / adapter"}),s.jsx("select",{value:t.providerId,onChange:r=>e.updateTarget(t.id,i=>e.changeProvider(i,r.target.value)),children:zv.map(r=>s.jsx("option",{value:r.id,children:r.label},r.id))})]}),s.jsxs("label",{className:"benchmark-field benchmark-model-field",children:[s.jsxs("span",{children:["Model ID ",s.jsx("em",{children:"Any model supported by this endpoint"})]}),s.jsx("input",{value:t.model,placeholder:a.modelHint,onChange:r=>e.updateTarget(t.id,i=>({...i,model:r.target.value}))})]}),e.mode!=="FAST"&&e.targets.length>2&&s.jsx("button",{className:"benchmark-icon-button danger","aria-label":`Remove ${t.label}`,onClick:()=>e.setTargets(r=>r.filter(i=>i.id!==t.id)),children:"×"}),t.providerId==="custom"&&s.jsxs("label",{className:"benchmark-field benchmark-custom-url",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{value:t.baseUrl??"",placeholder:"https://…/v1",onChange:r=>e.updateTarget(t.id,i=>({...i,baseUrl:r.target.value}))})]}),s.jsx(Wz,{target:t,update:r=>e.updateTarget(t.id,r)})]},t.id)})})]}),s.jsxs("section",{className:"benchmark-panel benchmark-plan-launch",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"03 · Plan"}),s.jsx("h2",{children:"Sammy will author the evidence plan"}),s.jsx("p",{children:"Canonical Sammy Intelligence, independent Reviewer, deterministic validation, and pillar-native specialty delegation. No target API credential is sent during planning."}),s.jsxs("div",{className:"benchmark-source-chips",children:[s.jsx("span",{children:"Prompt Studio"}),s.jsx("span",{children:"RAG Assurance"}),s.jsx("span",{children:"Security evidence"}),s.jsx("span",{children:"Governed failures"})]})]}),s.jsxs("div",{className:"benchmark-plan-launch-action",children:[s.jsx("button",{className:"btn primary",disabled:e.busy,onClick:e.onDesign,children:e.busy?"Sammy designs · Reviewer challenges…":"Design benchmark with Sammy →"}),s.jsx("small",{children:"Plan and cost estimate appear before any entitlement is reserved."})]})]})]})}function Wz({target:e,update:t}){var n,a,r,i;return s.jsxs("details",{className:`benchmark-pricing-config${qc(e)?" configured":""}`,children:[s.jsxs("summary",{children:[s.jsxs("span",{children:["Execution-time pricing snapshot ",s.jsx("em",{children:"Optional"})]}),s.jsx("strong",{children:qc(e)?"Ready":"Cost not measured"})]}),s.jsxs("div",{className:"benchmark-pricing-body",children:[s.jsx("p",{children:"Historical cost is bound to this versioned snapshot and never recalculated from today’s prices."}),s.jsxs("div",{className:"benchmark-pricing-grid",children:[s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Input USD / 1M"}),s.jsx("input",{type:"number",min:"0",step:"0.0001",value:((n=e.pricing)==null?void 0:n.input)??"",onChange:o=>t(l=>({...l,pricing:{...l.pricing,input:o.target.value===""?void 0:Number(o.target.value),currency:"USD"}}))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Output USD / 1M"}),s.jsx("input",{type:"number",min:"0",step:"0.0001",value:((a=e.pricing)==null?void 0:a.output)??"",onChange:o=>t(l=>({...l,pricing:{...l.pricing,output:o.target.value===""?void 0:Number(o.target.value),currency:"USD"}}))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Source / version"}),s.jsx("input",{value:((r=e.pricing)==null?void 0:r.source)??"",placeholder:"Provider price card · 2026-08-18",onChange:o=>t(l=>({...l,pricing:{...l.pricing,source:o.target.value,currency:"USD"}}))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Effective date"}),s.jsx("input",{type:"date",value:((i=e.pricing)==null?void 0:i.effectiveAt)??"",onChange:o=>t(l=>({...l,pricing:{...l.pricing,effectiveAt:o.target.value||void 0,currency:"USD"}}))})]})]})]})]})}function Hz({plan:e,planningMode:t,targets:n,credentialError:a,onCredentialChange:r,entitlement:i,paidPrice:o,busy:l,filter:c,setFilter:u,visibleCases:d,judgingEnabled:h,judgeRegistry:g,judgingValidation:v,onSaveJudgingStrategy:f,onBack:y,onMethodology:b,onRun:m,onPurchase:x}){const j=Uz(e),S=h&&!!(v!=null&&v.errors.length);return s.jsxs("div",{className:"benchmark-plan-review",children:[s.jsxs("section",{className:"benchmark-panel benchmark-plan-banner",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"benchmark-kicker",children:["BenchmarkPlan v",e.version," · ",e.hash.slice(0,12)]}),s.jsx("h2",{children:e.objective}),s.jsxs("p",{children:[Ux[e.targetType]," · ",e.mode," reasoning · ",e.lineage.specialties.join(" / ")," specialty delegation"]})]}),s.jsxs("div",{className:`benchmark-review-stamp ${e.review.status.toLowerCase()}`,children:[s.jsx("span",{children:e.review.independent?"✓":"!"}),s.jsxs("strong",{children:[e.review.status==="COMPLETED"?"Sammy + separate Reviewer":"Review limitation",e.review.status==="COMPLETED"&&s.jsx(Va,{text:KS})]}),s.jsx("small",{children:t==="MODEL_ASSISTED"?"Independently routed plan review":"Deterministic preview"})]})]}),s.jsxs("section",{className:"benchmark-estimate-grid",children:[s.jsxs("article",{children:[s.jsx("span",{children:"Benchmark cases"}),s.jsx("strong",{children:e.estimate.generatedCaseCount}),s.jsx("small",{children:"Designed by Sammy"})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Measured calls"}),s.jsx("strong",{children:e.estimate.estimatedMeasuredCalls}),s.jsxs("small",{children:["+ ",e.estimate.estimatedWarmupCalls," warmups"]})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Semantic judge calls"}),s.jsx("strong",{children:j.semanticJudgeCalls}),s.jsx("small",{children:j.semanticJudgeCalls?"Separate inference estimate":"Not required by this plan"})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Target tokens"}),s.jsxs("strong",{children:[Math.round(e.estimate.estimatedTargetTokens/1e3),"k"]}),s.jsxs("small",{children:[Math.round(e.estimate.targetTokenCeiling/1e3),"k ceiling"]})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Sammy tokens"}),s.jsxs("strong",{children:[Math.round(e.estimate.estimatedSammyTokens/1e3),"k"]}),s.jsxs("small",{children:[Math.round(e.estimate.sammyTokenCeiling/1e3),"k ceiling"]})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Duration"}),s.jsxs("strong",{children:["~",Math.max(1,Math.round(e.estimate.expectedDurationSeconds/60)),"m"]}),s.jsx("small",{children:"Paired / interleaved"})]}),s.jsxs("article",{title:e.estimate.estimatedExternalProviderCostUsd==null?"No versioned input/output pricing was supplied for every compared provider. Add pricing before execution to see an estimate; model usage runs on your credentials.":"Estimated from the versioned provider prices supplied for this plan.",children:[s.jsx("span",{children:"Estimated provider cost"}),s.jsx("strong",{children:e.estimate.estimatedExternalProviderCostUsd==null?"Unavailable":`$${e.estimate.estimatedExternalProviderCostUsd.toFixed(3)}`}),s.jsx("small",{children:e.estimate.estimatedExternalProviderCostUsd==null?"Versioned provider pricing not supplied":"Before-execution estimate"})]})]}),s.jsxs("section",{className:"benchmark-plan-grid",children:[s.jsxs("div",{className:"benchmark-panel",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"benchmark-step benchmark-panel-label",children:["Plan coverage ",s.jsx(Va,{text:"Sammy designs these cases, but the saved BenchmarkPlan, deterministic validation, and named evaluators govern what can execute and what can be claimed."})]}),s.jsxs("h2",{children:["Benchmark cases ",s.jsx("small",{children:"Designed by Sammy"})]}),s.jsx("p",{children:"Every governed case identifies who judges it and the capability evidence it requires."})]}),s.jsxs("select",{className:"benchmark-filter",value:c,onChange:w=>u(w.target.value),children:[s.jsx("option",{value:"all",children:"All pillars"}),[...new Set(e.cases.map(w=>w.pillar))].map(w=>s.jsx("option",{value:w,children:w},w))]})]}),s.jsx("div",{className:"benchmark-authored-cases",children:d.map((w,C)=>s.jsxs("details",{open:C<3,children:[s.jsxs("summary",{children:[s.jsx("span",{className:`benchmark-pillar-dot ${w.pillar}`}),s.jsxs("div",{children:[s.jsx("strong",{children:w.name}),s.jsxs("small",{children:[w.pillar.replaceAll("_"," ")," · ",w.evaluationContract.assertionKind]})]}),s.jsxs("span",{className:"benchmark-case-judge",children:[s.jsx("em",{children:"Judged by:"}),s.jsx("b",{children:eC(w)}),s.jsxs("code",{children:["· ",w.evaluatorRef]})]}),s.jsx("b",{children:"⌄"})]}),s.jsxs("div",{children:[s.jsx("p",{children:w.prompt}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Evaluator reference"}),s.jsx("dd",{children:w.evaluatorRef})]}),w.rubricRef&&s.jsxs("div",{children:[s.jsx("dt",{children:"Rubric"}),s.jsxs("dd",{children:[w.rubricRef.id," v",w.rubricRef.version," · ",w.rubricRef.hash.slice(0,10),"…"]})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Capabilities"}),s.jsx("dd",{children:w.requiredCapabilities.join(", ")||"Base text inference"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Retries / timeout"}),s.jsxs("dd",{children:[w.timeoutRetryPolicy.retryLimit," / ",Math.round(w.timeoutRetryPolicy.timeoutMs/1e3),"s"]})]})]})]})]},w.caseId))})]}),s.jsxs("aside",{className:"benchmark-plan-side",children:[s.jsxs("section",{className:"benchmark-panel",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsxs("span",{className:"benchmark-panel-label",children:["Independent review ",s.jsx(Va,{text:KS})]}),s.jsx("h2",{children:"Reviewer verdict"}),s.jsx("p",{children:e.review.summary})]}),e.review.diffs.length?s.jsx("ul",{className:"benchmark-review-diffs",children:e.review.diffs.map((w,C)=>s.jsxs("li",{children:[s.jsx("b",{children:w.action}),s.jsx("span",{children:w.reason})]},`${w.action}-${C}`))}):s.jsx("div",{className:"benchmark-no-diff",children:"No material ADD / REMOVE / MODIFY diff survived deterministic validation."}),s.jsx("footer",{children:"Reviewer cannot approve, execute, or override deterministic facts."})]}),s.jsxs("section",{className:"benchmark-panel benchmark-evaluation-mix",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsxs("span",{className:"benchmark-panel-label",children:["Governed evidence ",s.jsx(Va,{text:"The mix counts benchmark cases by their assigned evidence mechanism. It shows where deterministic, pillar-native, security, and independent semantic evaluation will be used."})]}),s.jsx("h2",{children:"Evaluation mix"}),s.jsx("p",{children:"Prooflane assigns each case to the strongest applicable evidence mechanism."})]}),s.jsx("ul",{children:j.mix.map(w=>s.jsxs("li",{children:[s.jsx("strong",{children:w.count}),s.jsx("span",{children:w.label})]},w.label))}),s.jsxs("footer",{className:"benchmark-evidence-target",children:[s.jsx("span",{children:"Evidence target"}),s.jsx("strong",{children:"HIGH"}),s.jsx("small",{children:"Achieved strength is calculated after execution and may be lower."})]})]}),s.jsxs("section",{className:"benchmark-panel benchmark-methodology-summary",children:[s.jsxs("div",{className:"benchmark-audit-heading",children:[s.jsxs("span",{className:"benchmark-panel-label",children:["Evaluation methodology ",s.jsx(Va,{text:"Deterministic facts have precedence. Pillar evaluators handle specialized evidence, a separately routed semantic judge is used only when required, and the comparator makes the final benchmark decision."})]}),s.jsx("h2",{children:"Who decides what"})]}),s.jsxs("ol",{children:[s.jsx("li",{children:"Deterministic facts"}),s.jsx("li",{children:"Pillar evaluators"}),s.jsxs("li",{children:["Independent semantic judge ",s.jsx("small",{children:"when required"})]}),s.jsx("li",{children:"Comparator"})]}),s.jsx("p",{children:"Sammy designs → Reviewer challenges → Prooflane validates → Evaluators prove → Comparator decides."}),s.jsx("button",{className:"btn ghost sm",onClick:b,children:"Open full methodology →"})]}),s.jsxs("section",{className:"benchmark-panel benchmark-boundary-card",children:[s.jsxs("span",{className:"benchmark-panel-label",children:["Storage boundary ",s.jsx(Va,{text:"Raw prompts, responses, and credentials remain local by default. Only policy-approved sanitized semantic evidence may be routed to an approved judge."})]}),s.jsx("h3",{children:e.privacyPolicy.storageMode==="SUMMARY_ONLY"?"Summary only · default":"Encrypted detailed report · opted in"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Raw prompts and responses stay local by default"}),s.jsx("li",{children:"Only sanitized semantic evidence may reach an approved judge"}),s.jsx("li",{children:"Credentials are never persisted"})]})]})]})]}),h&&e.judgingStrategy&&s.jsx(Bz,{plan:e,registry:g,validation:v,busy:l,onSave:f}),s.jsx(qz,{plan:e}),s.jsxs("section",{className:"benchmark-panel benchmark-execution-ready",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"benchmark-step benchmark-panel-label",children:["Execution ",s.jsx(Va,{text:"For free and development runs, Prooflane first sends a minimal request to each configured LLM. Failed connections leave the entitlement available; successful preflight is not benchmark evidence."})]}),s.jsx("h2",{children:"Review the plan, then supply local credentials"}),s.jsx("p",{children:"The entitlement is reserved only after the configured LLM routes answer a minimal connection test. It is consumed at the first measured target call—not for planning, connection preflight, or warmups."})]}),s.jsx("div",{className:"benchmark-credential-grid",children:n.map(w=>{const C=Cr(w.providerId),k=!!(a&&!C.local&&!w.apiKey.trim());return s.jsxs("label",{className:"benchmark-field",children:[s.jsxs("span",{children:[w.label," · ",C.local?"Local route":"API key"," ",s.jsx("em",{children:"Memory only"})]}),s.jsx("input",{id:`benchmark-credential-${w.id}`,type:"password",autoComplete:"off",disabled:C.local,value:C.local?"":w.apiKey,placeholder:C.keyHint,"aria-invalid":k,"aria-describedby":k?"benchmark-run-validation":void 0,onChange:N=>r(w.id,N.target.value)})]},w.id)})}),s.jsxs("p",{id:"benchmark-model-usage-note",className:"benchmark-usage-note",children:[s.jsx("strong",{children:"Prooflane orchestration is free."})," Model usage—including the small connection test—runs on your supplied credentials. A failed test does not reserve or consume the benchmark entitlement."]}),a&&s.jsx("div",{id:"benchmark-run-validation",className:"benchmark-error benchmark-run-validation",role:"alert",children:a}),s.jsxs("div",{className:"benchmark-run-action",children:[s.jsx("button",{className:"btn ghost",onClick:y,children:"← Edit choices"}),s.jsx("button",{className:"btn primary","aria-describedby":"benchmark-model-usage-note",disabled:l||e.review.status==="LIMITED"||S,onClick:i?m:x,children:i?i.productId==="prooflane-benchmark-development"?"Test connections & Run Development Benchmark":i.type==="FREE_FAST"?"Test connections & Run Free Benchmark":"Start governed benchmark":o==null?"Verify purchase entitlement":`Purchase / verify run · $${o.toFixed(2)}`})]}),S&&s.jsx("div",{className:"benchmark-limit-note",children:"Execution is blocked until the judging strategy passes deterministic topology and independence validation."}),e.review.status==="LIMITED"&&s.jsx("div",{className:"benchmark-limit-note",children:"Execution is fail-closed: reconnect an approved Sammy planning/Reviewer route and regenerate this plan."})]})]})}const Pn=e=>`${e.providerId}\0${e.modelId}`;function Bz({plan:e,registry:t,validation:n,busy:a,onSave:r}){const i=e.judgingStrategy,[o,l]=p.useState(i),[c,u]=p.useState(!1);p.useEffect(()=>{l(i),u(!1)},[e.hash]);const d=t.filter(f=>f.available&&f.judgeEligible),h=(f,y)=>{const b=d.find(m=>Pn(m)===f);return b?{providerId:b.providerId,modelId:b.modelId,...b.modelFamily?{modelFamily:b.modelFamily}:{},role:y}:void 0},g=f=>{var y;return f?((y=d.find(b=>Pn(b)===Pn(f)))==null?void 0:y.displayName)??`${f.providerId} / ${f.modelId}`:"None"},v=o.maxJudgeCallsPerCase??1+(o.reviewer?1:0)+(o.adjudicator?1:0);return s.jsxs("section",{className:"benchmark-panel benchmark-judging-strategy",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"benchmark-step benchmark-panel-label",children:["Step 2 · Judging strategy ",s.jsx(Va,{text:"This topology applies only to semantic assertions. Deterministic assertions make zero judge calls and retain precedence."})]}),s.jsx("h2",{children:"Semantic evaluation topology"}),s.jsx("p",{children:"Sammy recommended a bounded judge configuration from Prooflane’s canonical model registry. Review it before execution."})]}),s.jsxs("span",{className:`benchmark-independence ${(n==null?void 0:n.independence.toLowerCase())??"unknown"}`,children:[(n==null?void 0:n.independence.replaceAll("_"," "))??"UNKNOWN"," independence"]})]}),s.jsxs("div",{className:"benchmark-judge-summary",children:[s.jsxs("article",{children:[s.jsx("span",{children:"Primary"}),s.jsx("strong",{children:g(i.primary)})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Reviewer"}),s.jsx("strong",{children:g(i.reviewer)})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Adjudicator"}),s.jsx("strong",{children:g(i.adjudicator)})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Maximum calls / semantic case"}),s.jsx("strong",{children:i.maxJudgeCallsPerCase??1+(i.reviewer?1:0)+(i.adjudicator?1:0)})]})]}),s.jsxs("div",{className:"benchmark-strategy-policies",children:[s.jsx("span",{children:i.independencePolicy.replaceAll("_"," ")}),s.jsx("span",{children:i.agreementPolicy.replaceAll("_"," ")}),s.jsx("span",{children:i.disagreementPolicy.replaceAll("_"," ")}),s.jsxs("code",{children:["plan v",e.version," · ",e.hash.slice(0,12)]})]}),n!=null&&n.warnings.length||n!=null&&n.errors.length?s.jsxs("div",{className:`benchmark-judging-validation ${n.errors.length?"invalid":"warning"}`,children:[s.jsx("strong",{children:n.errors.length?"Configuration blocked":"Review note"}),[...n.errors,...n.warnings].map(f=>s.jsx("p",{children:f},f))]}):null,c?s.jsxs("div",{className:"benchmark-judge-editor",children:[s.jsxs("div",{className:"benchmark-judge-editor-grid",children:[s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Primary judge"}),s.jsx("select",{value:Pn(o.primary),onChange:f=>{const y=h(f.target.value,"PRIMARY");y&&l(b=>({...b,primary:y}))},children:d.map(f=>s.jsx("option",{value:Pn(f),children:f.displayName},Pn(f)))})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Reviewer judge"}),s.jsxs("select",{value:o.reviewer?Pn(o.reviewer):"",onChange:f=>{const y=h(f.target.value,"REVIEWER");l(b=>y?{...b,reviewer:y,agreementPolicy:b.agreementPolicy==="PRIMARY_ONLY"?"UNANIMOUS":b.agreementPolicy,disagreementPolicy:b.disagreementPolicy==="PRIMARY_WINS"?"MARK_REVIEW":b.disagreementPolicy,maxJudgeCallsPerCase:Math.max(2,b.maxJudgeCallsPerCase??2)}:{...b,reviewer:void 0,adjudicator:void 0,agreementPolicy:"PRIMARY_ONLY",disagreementPolicy:"PRIMARY_WINS",maxJudgeCallsPerCase:1})},children:[s.jsx("option",{value:"",children:"None · primary only"}),d.map(f=>s.jsx("option",{value:Pn(f),children:f.displayName},Pn(f)))]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Independence policy"}),s.jsxs("select",{value:o.independencePolicy,onChange:f=>l(y=>({...y,independencePolicy:f.target.value})),children:[s.jsx("option",{value:"REQUIRE_DIFFERENT_MODEL_FAMILY",children:"Require different model family"}),s.jsx("option",{value:"PREFER_DIFFERENT_MODEL_FAMILY",children:"Prefer different model family"}),s.jsx("option",{value:"NOT_REQUIRED",children:"Not required"})]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Agreement policy"}),s.jsxs("select",{value:o.agreementPolicy,onChange:f=>l(y=>({...y,agreementPolicy:f.target.value})),children:[s.jsx("option",{value:"PRIMARY_ONLY",children:"Primary only"}),s.jsx("option",{value:"UNANIMOUS",children:"Unanimous"}),s.jsx("option",{value:"MAJORITY",children:"Majority"})]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Disagreement policy"}),s.jsxs("select",{value:o.disagreementPolicy,onChange:f=>l(y=>({...y,disagreementPolicy:f.target.value})),children:[s.jsx("option",{value:"MARK_REVIEW",children:"Mark for review"}),s.jsx("option",{value:"ADJUDICATE",children:"Adjudicate once"}),s.jsx("option",{value:"PRIMARY_WINS",children:"Primary wins"})]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Adjudicator"}),s.jsxs("select",{value:o.adjudicator?Pn(o.adjudicator):"",onChange:f=>{const y=h(f.target.value,"ADJUDICATOR");l(b=>({...b,adjudicator:y,maxJudgeCallsPerCase:y?3:Math.min(2,b.maxJudgeCallsPerCase??2)}))},children:[s.jsx("option",{value:"",children:"None"}),d.map(f=>s.jsx("option",{value:Pn(f),children:f.displayName},Pn(f)))]})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Maximum judge calls / semantic case"}),s.jsxs("select",{value:v,onChange:f=>l(y=>({...y,maxJudgeCallsPerCase:Number(f.target.value)})),children:[s.jsx("option",{value:1,children:"1"}),s.jsx("option",{value:2,children:"2"}),s.jsx("option",{value:3,children:"3"})]})]})]}),s.jsx("p",{className:"benchmark-judge-boundary",children:"Judge choices apply only to semantic cases. No compared model can silently become its own sole judge, and adjudication never recurses."}),s.jsxs("div",{className:"benchmark-judge-editor-actions",children:[s.jsx("button",{className:"btn ghost",type:"button",disabled:a,onClick:()=>{l(i),u(!1)},children:"Cancel"}),s.jsx("button",{className:"btn primary",type:"button",disabled:a||d.length===0,onClick:()=>void r({...o,source:"USER_EDITED"}).then(()=>u(!1)).catch(()=>{}),children:a?"Saving…":"Save as new plan version"})]})]}):s.jsx("button",{className:"btn ghost sm",type:"button",onClick:()=>u(!0),children:"Edit judging strategy"})]})}function Vz({provider:e,setProvider:t,receipt:n,setReceipt:a,price:r,busy:i,onCancel:o,onVerify:l}){return s.jsxs("section",{className:"benchmark-panel benchmark-purchase-panel",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"Server-verified purchase"}),s.jsx("h2",{children:"Unlock one governed Benchmark Run"}),s.jsx("p",{children:"The receipt is sent directly to Prooflane for provider verification. The browser cannot set paid state, and raw receipt material is discarded after verification."})]}),s.jsxs("div",{className:"benchmark-purchase-price",children:[s.jsx("strong",{children:r==null?"Current price":`$${r.toFixed(2)}`}),s.jsx("small",{children:"One single-run entitlement · compared-model usage remains separate"})]}),s.jsxs("label",{className:"benchmark-field",children:[s.jsx("span",{children:"Receipt provider"}),s.jsxs("select",{value:e,onChange:c=>t(c.target.value),children:[s.jsx("option",{value:"APPLE_APP_STORE",children:"Apple App Store"}),s.jsx("option",{value:"GOOGLE_PLAY",children:"Google Play"}),s.jsx("option",{value:"STRIPE",children:"Stripe / web checkout"}),s.jsx("option",{value:"OTHER",children:"Approved store provider"})]})]}),s.jsxs("label",{className:"benchmark-field benchmark-purchase-receipt",children:[s.jsxs("span",{children:["Purchase receipt ",s.jsx("em",{children:"Volatile memory only"})]}),s.jsx("textarea",{rows:4,value:n,autoComplete:"off",maxLength:65536,onChange:c=>a(c.target.value),placeholder:"Paste the receipt returned by the purchase flow"})]}),s.jsxs("div",{className:"benchmark-purchase-actions",children:[s.jsx("button",{className:"btn ghost",disabled:i,onClick:o,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:i||!n.trim(),onClick:l,children:i?"Verifying with Prooflane…":"Verify receipt"})]})]})}function qz({plan:e}){return s.jsxs("section",{className:"benchmark-panel",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"benchmark-step benchmark-panel-label",children:["Fairness preflight ",s.jsx(Va,{text:"This matrix verifies that every target can execute the same case under equivalent conditions. Unsupported capability is reported as coverage and is never converted into an ordinary model failure."})]}),s.jsx("h2",{children:"Capability matrix"}),s.jsx("p",{children:"Unsupported capability is coverage—not a model failure. Adaptation is explicit and fingerprinted."})]}),s.jsxs("code",{children:[e.capabilityMatrix.fingerprint.slice(0,16),"…"]})]}),s.jsx("div",{className:"benchmark-capability-table-wrap",children:s.jsxs("table",{className:"benchmark-capability-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Case"}),e.capabilityMatrix.targets.map(t=>s.jsx("th",{children:t.label},t.id))]})}),s.jsx("tbody",{children:e.cases.map(t=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:t.name}),s.jsx("small",{children:t.requiredCapabilities.join(", ")||"Base"})]}),e.capabilityMatrix.targets.map(n=>{const a=e.capabilityMatrix.cells.find(r=>r.targetId===n.id&&r.caseId===t.caseId);return s.jsxs("td",{children:[s.jsx("span",{className:`benchmark-capability-status ${((a==null?void 0:a.classification)??"ADAPTER_MISSING").toLowerCase()}`,children:a==null?void 0:a.classification.replaceAll("_"," ")}),s.jsx("small",{children:(a==null?void 0:a.adapterRef)??(a==null?void 0:a.reason)})]},n.id)})]},t.caseId))})]})})]})}function Kz({latest:e,progress:t,progressPct:n,plan:a,busy:r,onStop:i}){var o,l;return s.jsxs("section",{className:"benchmark-live-run",children:[s.jsx("div",{className:"benchmark-live-orbit",children:s.jsxs("div",{children:[s.jsx("span",{children:"Prooflane"}),s.jsxs("b",{children:[n,"%"]})]})}),s.jsxs("div",{className:"benchmark-live-main",children:[s.jsx("span",{className:"benchmark-kicker",children:(e==null?void 0:e.runId)??"Creating immutable run id"}),s.jsx("h2",{children:((o=e==null?void 0:e.status)==null?void 0:o.replaceAll("_"," "))??"Preparing benchmark"}),s.jsx("p",{children:(e==null?void 0:e.detail)??"Validating the reviewed plan and entitlement."}),s.jsx("div",{className:"benchmark-progress-track",children:s.jsx("i",{style:{width:`${Math.max(3,n)}%`}})}),s.jsxs("div",{className:"benchmark-live-facts",children:[s.jsxs("span",{children:[s.jsx("b",{children:(e==null?void 0:e.measuredDone)??0})," / ",(e==null?void 0:e.totalMeasured)??(a==null?void 0:a.estimate.estimatedMeasuredCalls)??0," trials"]}),s.jsxs("span",{children:[s.jsx("b",{children:(e==null?void 0:e.targetTokens)??0})," target tokens"]}),s.jsxs("span",{children:[s.jsx("b",{children:(e==null?void 0:e.targetTokensRemaining)??(a==null?void 0:a.budgetPolicy.targetTokenCeiling)??0})," remaining"]}),s.jsxs("span",{children:[s.jsx("b",{children:((l=e==null?void 0:e.pillar)==null?void 0:l.replaceAll("_"," "))??"Preflight"})," pillar"]}),s.jsxs("span",{children:[s.jsxs("b",{children:[Math.round(((e==null?void 0:e.elapsedMs)??0)/1e3),"s"]})," elapsed"]}),s.jsxs("span",{children:[s.jsx("b",{children:(e==null?void 0:e.estimatedRemainingSeconds)==null?"—":`${e.estimatedRemainingSeconds}s`})," ETA"]})]}),s.jsx("button",{className:"btn ghost",disabled:!r,onClick:i,children:"Stop safely"})]}),s.jsx("ol",{className:"benchmark-event-log",children:t.slice(-8).map((c,u)=>s.jsxs("li",{children:[s.jsx("span",{children:u===t.slice(-8).length-1?"●":"✓"}),s.jsxs("div",{children:[s.jsx("strong",{children:c.status.replaceAll("_"," ")}),s.jsx("small",{children:c.detail})]})]},`${c.status}-${u}`))})]})}function Jz({plan:e,report:t,workflow:n,showEvaluatorProvenance:a,onSetup:r,onNew:i}){var g,v;const o=(n==null?void 0:n.comparison.outcome)==="MODEL_A_BETTER"?`${(g=t.candidates[0])==null?void 0:g.label} is better for this objective`:(n==null?void 0:n.comparison.outcome)==="MODEL_B_BETTER"?`${(v=t.candidates[1])==null?void 0:v.label} is better for this objective`:(n==null?void 0:n.comparison.outcome)==="STATISTICALLY_SIMILAR"?"Statistically similar":"Cannot conclude",l=t.judgingComposition,c=t.health.judges,u=(l==null?void 0:l.semanticJudgments)??(c==null?void 0:c.evaluations)??0,d=(l==null?void 0:l.independence.status)??(c==null?void 0:c.independence)??"NOT_MEASURED",h=l?l.agreement.measured?`${l.agreement.rate??0}%`:"NOT_MEASURED":(c==null?void 0:c.agreementStatus)??"NOT_MEASURED";return s.jsxs("div",{className:"benchmark-v2-results",children:[n&&s.jsxs("section",{className:`benchmark-v2-conclusion ${n.comparison.outcome.toLowerCase()}`,children:[s.jsxs("div",{children:[s.jsxs("span",{children:[n.runId," · ",n.comparison.evidenceStrength," evidence"]}),s.jsx("h2",{children:o}),s.jsx("p",{children:n.comparison.reason})]}),s.jsxs("div",{className:"benchmark-result-actions",children:[s.jsx("a",{className:"btn primary",href:`/api/benchmark/runs/${encodeURIComponent(n.runId)}/report.html`,download:n.reportFilename,children:"Download HTML"}),s.jsx("button",{className:"btn ghost",onClick:()=>sc(`benchmark-${n.runId}.json`,{plan:e,report:t,workflow:n}),children:"Download JSON"})]}),s.jsxs("div",{className:"benchmark-driver-grid",children:[s.jsx(YS,{title:"Primary decision drivers",items:n.comparison.primaryDrivers,report:t,empty:"No driver clears the evidence threshold."}),s.jsx(YS,{title:"Trade-offs",items:n.comparison.tradeoffs,report:t,empty:"No measured trade-off changed the recommendation."}),s.jsxs("article",{children:[s.jsx("span",{children:"Judging composition"}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx("b",{children:u}),"semantic judgments"]}),s.jsxs("li",{children:[s.jsx("b",{children:d.replaceAll("_"," ")}),"independence"]}),s.jsxs("li",{children:[s.jsx("b",{children:h.replaceAll("_"," ")}),"agreement"]}),l&&s.jsxs(s.Fragment,{children:[s.jsxs("li",{children:[s.jsx("b",{children:l.primaryCalls}),"primary calls"]}),s.jsxs("li",{children:[s.jsx("b",{children:l.reviewerCalls}),"reviewer calls"]}),s.jsxs("li",{children:[s.jsx("b",{children:l.adjudicatorCalls}),"adjudicator calls"]})]})]}),!u&&s.jsx("p",{children:"Semantic evidence was inconclusive or no approved judge route was configured."})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Governance"}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx("b",{children:n.storage.cloudSummaryStored?"Stored":"Local only"}),"compact cloud record"]}),s.jsxs("li",{children:[s.jsx("b",{children:n.storage.cloudDetailedReportStored?"Encrypted Cloud + local":"Local"}),"detailed report"]}),s.jsxs("li",{children:[s.jsx("b",{children:"Draft only"}),"Gate recommendation"]})]}),n.storage.cloudStorageError&&s.jsx("p",{children:n.storage.cloudStorageError})]})]})]}),(t.decisionExplanation||t.evidenceStrengthExplanation||t.confidence||t.reproducibility||t.governanceImpact||t.baselineComparison)&&s.jsx(Yz,{report:t}),s.jsx($z,{report:t,showEvaluatorProvenance:a,onDownload:()=>sc(`prooflane-benchmark-${t.runId}.json`,t),onConfigurePricing:r,onStrengthenEvidence:r}),s.jsxs("section",{className:"benchmark-result-footer-actions",children:[s.jsx("button",{className:"btn ghost",onClick:()=>sc(`benchmark-evidence-${t.runId}.json`,{runId:t.runId,samples:t.samples,datasetFingerprint:t.datasetFingerprint}),children:"Export evidence"}),s.jsx("button",{className:"btn ghost",onClick:()=>sc(`benchmark-baseline-${t.runId}.json`,{version:"prooflane-benchmark-baseline-v1",sourceRunId:t.runId,planHash:e==null?void 0:e.hash,datasetFingerprint:t.datasetFingerprint,candidates:t.candidates.map(f=>{var y;return{id:f.id,model:f.model,decisionScore:f.decisionScore,quality:f.quality,secureTaskSuccess:(y=f.secureTaskSuccess)==null?void 0:y.value,p95LatencyMs:f.latency.p95,costPerSuccessfulTask:f.costPerSuccessfulTask}})}),children:"Save as baseline"}),s.jsx("button",{className:"btn ghost",onClick:()=>sc(`benchmark-gate-draft-${t.runId}.json`,{version:"prooflane-gate-draft-v1",status:"DRAFT",source:"AI_BENCHMARK",sourceRunId:t.runId,planId:e==null?void 0:e.planId,planHash:e==null?void 0:e.hash,recommendation:(n==null?void 0:n.comparison)??{outcome:"CANNOT_CONCLUDE",evidenceStrength:"INSUFFICIENT"},notice:"Draft only. Human review and the normal approval workflow are required before any release gate changes."}),children:"Create Gate Draft"}),s.jsx("button",{className:"btn primary",onClick:i,children:"New benchmark"})]})]})}function Yz({report:e}){var n,a;const t=e.decisionExplanation;return s.jsxs("section",{className:"benchmark-panel benchmark-decision-details",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step benchmark-panel-label",children:"Decision details"}),s.jsx("h2",{children:"Why Prooflane reached this result"}),s.jsx("p",{children:"Read-only facts frozen when this run was finalized. Rendering this view makes no model call."})]}),e.reproducibility&&s.jsxs("code",{children:[e.reproducibility.runFingerprint.slice(0,16),"…"]})]}),t&&s.jsxs("div",{className:"benchmark-decision-explanation",children:[s.jsx("p",{children:t.summary}),s.jsxs("div",{children:[s.jsxs("article",{children:[s.jsx("span",{children:"Observed drivers"}),t.observedDrivers.length?s.jsx("ul",{children:t.observedDrivers.map((r,i)=>s.jsxs("li",{children:[s.jsx("b",{children:r.metric.replaceAll("_"," ")}),r.candidateId&&s.jsx("small",{children:r.candidateId}),r.value!=null&&s.jsx("strong",{children:String(r.value)}),r.delta!=null&&s.jsxs("em",{children:["Δ ",String(r.delta)]})]},`${r.metric}-${i}`))}):s.jsx("p",{children:"None cleared the existing decision threshold."})]}),s.jsxs("article",{children:[s.jsx("span",{children:"Limiting evidence"}),t.limitingEvidence.length?s.jsx("ul",{children:t.limitingEvidence.map(r=>s.jsxs("li",{children:[s.jsx("b",{children:r.label}),s.jsx("strong",{children:r.status.replaceAll("_"," ")})]},r.code))}):s.jsx("p",{children:"No additional limitation was recorded."})]})]})]}),s.jsxs("div",{className:"benchmark-evidence-detail-grid",children:[e.evidenceStrengthExplanation&&s.jsxs("article",{children:[s.jsxs("span",{children:["Evidence strength · ",e.evidenceStrengthExplanation.level]}),s.jsx("h3",{children:"Existing evidence engine"}),s.jsxs("ul",{children:[e.evidenceStrengthExplanation.positiveFactors.map(r=>s.jsxs("li",{children:["+ ",r.label,r.value!=null?` · ${r.value}`:""]},r.code)),e.evidenceStrengthExplanation.limitingFactors.map(r=>s.jsxs("li",{children:["− ",r.label,r.value!=null?` · ${r.value}`:""]},r.code))]})]}),e.confidence&&s.jsxs("article",{children:[s.jsx("span",{children:"Confidence"}),s.jsxs("h3",{children:[e.confidence.overallEvidence," overall evidence"]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Statistical"}),s.jsx("dd",{children:e.confidence.statistical})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Evaluator"}),s.jsx("dd",{children:e.confidence.evaluator})]})]})]}),e.governanceImpact&&s.jsxs("article",{children:[s.jsx("span",{children:"Governance impact"}),s.jsx("h3",{children:e.governanceImpact.status.replaceAll("_"," ")}),s.jsx("p",{children:e.governanceImpact.message}),s.jsxs("small",{children:["Gate modified: ",e.governanceImpact.gateModified?"yes":"no"]})]}),e.reproducibility&&s.jsxs("article",{children:[s.jsx("span",{children:"Reproducibility"}),s.jsx("h3",{children:new Date(e.reproducibility.executedAt).toLocaleString()}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Dataset"}),s.jsx("dd",{children:((n=e.reproducibility.datasetFingerprint)==null?void 0:n.slice(0,16))??"Not recorded"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Evaluators"}),s.jsx("dd",{children:e.reproducibility.evaluatorVersions.length})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Pricing snapshots"}),s.jsx("dd",{children:e.reproducibility.pricingSnapshotRefs.length})]})]})]}),e.baselineComparison&&s.jsxs("article",{children:[s.jsx("span",{children:"Baseline comparison · supplementary"}),s.jsx("h3",{children:e.baselineComparison.label}),s.jsxs("p",{children:["Immutable run ",e.baselineComparison.baselineRunId]}),s.jsx("dl",{children:e.baselineComparison.metrics.slice(0,6).map(r=>s.jsxs("div",{children:[s.jsxs("dt",{children:[r.candidateId?`${r.candidateId} · `:"",r.metric]}),s.jsxs("dd",{children:[r.delta>0?"+":"",r.delta]})]},`${r.candidateId}-${r.metric}`))})]})]}),(a=e.candidateScoreExplanations)!=null&&a.length?s.jsxs("details",{className:"benchmark-score-details",children:[s.jsxs("summary",{children:["Candidate score inputs ",s.jsxs("span",{children:[e.candidateScoreExplanations.length," candidates"]})]}),s.jsx("div",{children:e.candidateScoreExplanations.map(r=>s.jsxs("article",{children:[s.jsxs("h3",{children:[r.candidateId," · ",r.decisionScore??"NOT MEASURED"]}),s.jsx("ul",{children:r.measuredDimensions.map(i=>s.jsxs("li",{children:[s.jsx("span",{children:i.metric.replaceAll("_"," ")}),s.jsx("strong",{children:String(i.value)})]},i.metric))}),r.unmeasuredDimensions.length?s.jsxs("p",{children:["Unmeasured: ",r.unmeasuredDimensions.join(", "),". ",r.unmeasuredImpact]}):null]},r.candidateId))})]}):null]})}function YS({title:e,items:t,report:n,empty:a}){return s.jsxs("article",{children:[s.jsx("span",{children:e}),t.length?s.jsx("ul",{children:t.map(r=>{var i,o;return s.jsxs("li",{children:[s.jsx("b",{children:r.direction==="MODEL_A"?(i=n.candidates[0])==null?void 0:i.label:r.direction==="MODEL_B"?(o=n.candidates[1])==null?void 0:o.label:"Neutral"}),r.dimension.replaceAll("_"," ")," · Δ ",r.magnitude.toFixed(2)]},r.dimension)})}):s.jsx("p",{children:a})]})}function Zz({history:e,onNew:t,onOpen:n}){return s.jsxs("section",{className:"benchmark-panel benchmark-history",children:[s.jsxs("div",{className:"benchmark-section-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"benchmark-step",children:"Governed history"}),s.jsx("h2",{children:"Benchmark Runs"}),s.jsx("p",{children:"Compact history is cloud-safe; detailed evidence stays on this Runner by default."})]}),s.jsx("button",{className:"btn primary",onClick:t,children:"New benchmark"})]}),e.length?s.jsx("div",{className:"benchmark-history-list",children:e.map(a=>s.jsxs("button",{onClick:()=>n(a.runId),children:[s.jsx("span",{className:`benchmark-history-status ${a.status.toLowerCase()}`,children:a.status.replaceAll("_"," ")}),s.jsxs("div",{children:[s.jsx("strong",{children:a.objective}),s.jsxs("small",{children:[a.runId," · ",Ux[a.targetType]," · ",a.mode]})]}),s.jsx("time",{children:new Date(a.createdAt).toLocaleString()}),s.jsx("b",{children:"→"})]},a.runId))}):s.jsxs("div",{className:"benchmark-empty",children:[s.jsx("div",{children:"◎"}),s.jsx("h2",{children:"No governed runs yet"}),s.jsx("p",{children:"Your first eligible Fast benchmark is free."})]})]})}function Xz(e,t,n){if(t===0)return{label:"NOT APPLICABLE",tone:"",completed:0,countLabel:"0 tests",progressPercent:0};const a=n.filter(f=>f.type==="TEST_COMPLETED"&&f.pillar===e),r=a.length,i=a.some(f=>f.status==="FAIL"),o=a.some(f=>f.status==="ERROR"),l=a.some(f=>f.status==="REVIEW"),c=a.some(f=>f.status==="INCONCLUSIVE"),u=n.some(f=>f.type==="PILLAR_STARTED"&&f.pillar===e),d=n.some(f=>f.type==="PILLAR_COMPLETED"&&f.pillar===e),h=t&&t>0?t:r,g=h>0?Math.min(100,Math.round(r/h*100)):u?8:0,v=t&&t>0?`${r}/${t} complete`:`${r} complete`;return i?{label:"FAIL",tone:"fail",completed:r,countLabel:v,progressPercent:g}:o?{label:"ERROR",tone:"warn",completed:r,countLabel:v,progressPercent:g}:l?{label:"REVIEW",tone:"warn",completed:r,countLabel:v,progressPercent:g}:c?{label:"INCONCLUSIVE",tone:"warn",completed:r,countLabel:v,progressPercent:g}:d||r>0?{label:"PASS",tone:"pass",completed:r,countLabel:v,progressPercent:g}:u?{label:"RUNNING",tone:"",completed:r,countLabel:v,progressPercent:g}:{label:"WAITING",tone:"",completed:r,countLabel:v,progressPercent:g}}const Qz=["prompt","rag","contract","security","performance","tool"];function Sc(e){return`/api/governance/gate-run-reports/${encodeURIComponent(e)}/report.html`}function tC(e){const t=e.gate.slug.replace(/[^a-z0-9_-]+/g,"-"),n=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}
|
|
68
|
-
`],{type:"application/json"})),a=document.createElement("a");a.href=n,a.download=`prooflane-${t}-${e.run.id}.json`,a.click(),URL.revokeObjectURL(n)}function Kc(e){return e.latestVersion.state==="APPROVED"&&!!e.latestVersion.manifestHash&&!!e.latestVersion.signature}function Zo(e,t){const n=e.latestVersion.manifest.policyRef;if(n)return t.find(a=>{var r;return a.policy.id===n.policyId&&((r=a.approvedVersion)==null?void 0:r.state)==="APPROVED"&&a.approvedVersion.version===n.version&&a.approvedVersion.manifestHash===n.manifestHash&&!!a.approvedVersion.signature})}function Jc(e){return Qz.filter(t=>e.latestVersion.manifest.controls.some(n=>n.pillar===t))}function sC(e){const t="-gate";return`${e.suite.slug.slice(0,64-t.length).replace(/[-_]+$/,"")}${t}`}function e5(e,t,n){return e.flatMap(a=>{const r=t.filter(o=>[o.latestVersion,o.approvedVersion].some(l=>(l==null?void 0:l.manifest.suiteRef.suiteId)===a.suite.id)),i=r.find(o=>!o.gate.archivedAt)??(n?r[0]:void 0);return!i&&r.length>0?[]:[{suite:a,entry:i}]})}function t5(e,t,n,a){var o;const r=(o=Zo(e,t))==null?void 0:o.approvedVersion,i=e.latestVersion.manifestHash;return!(r!=null&&r.manifestHash)||!i||!Kc(e)?null:{schemaVersion:"prooflane-gate-manifest-v1",suiteRef:{suiteId:e.suite.id,slug:e.suite.slug,suiteVersionId:e.latestVersion.id,version:e.latestVersion.version,manifestHash:i},policyRef:{policyId:r.policyId,policyVersionId:r.id,version:r.version,manifestHash:r.manifestHash},targetScope:{projectId:e.suite.projectId},environment:n,requiredPillars:a,settings:{executionMode:"ALL_CONTROLS",evidenceSync:"COMPACT_ONLY"},approvalRules:{minimumApprovals:1,requireDistinctReviewer:!1}}}function s5({entry:e,initialSuiteVersionId:t,suites:n,policies:a,onSaved:r,onClose:i}){const o=p.useMemo(()=>n.filter(E=>Kc(E)&&Zo(E,a)),[n,a]),l=o.find(E=>E.latestVersion.id===t)??o[0],c=t&&o.some(E=>E.latestVersion.id===t)?t:(e==null?void 0:e.latestVersion.manifest.suiteRef.suiteVersionId)??(l==null?void 0:l.latestVersion.id)??"",[u,d]=p.useState((e==null?void 0:e.gate.displayName)??(l?`${l.suite.displayName} Gate`:"")),[h,g]=p.useState(c),[v,f]=p.useState((e==null?void 0:e.latestVersion.manifest.environment)??"production"),[y,b]=p.useState(e&&(!t||e.latestVersion.manifest.suiteRef.suiteVersionId===t)?e.latestVersion.manifest.requiredPillars:l?Jc(l):[]),[m,x]=p.useState(!1),[j,S]=p.useState(null),w=(e==null?void 0:e.gate.slug)??u.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),C=o.find(E=>E.latestVersion.id===h),k=C?Zo(C,a):void 0,N=C?Jc(C):[],L=E=>{g(E);const I=o.find($=>$.latestVersion.id===E);b(I?Jc(I):[])},_=async()=>{const E=C==null?void 0:C.latestVersion.manifestHash,I=k==null?void 0:k.approvedVersion,$=v.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);if(w.length<2||!u.trim()||!C||!E||!(I!=null&&I.manifestHash)||!y.length||$.length<2){S("Give the Gate a name and environment, choose an APPROVED signed Suite with its exact APPROVED signed Policy, and require at least one represented pillar.");return}if(y.some(R=>!N.includes(R))){S("Every required pillar must be represented by the selected signed Suite.");return}const W={schemaVersion:"prooflane-gate-manifest-v1",suiteRef:{suiteId:C.suite.id,slug:C.suite.slug,suiteVersionId:C.latestVersion.id,version:C.latestVersion.version,manifestHash:E},policyRef:{policyId:k.policy.id,policyVersionId:I.id,version:I.version,manifestHash:I.manifestHash},targetScope:{projectId:C.suite.projectId},environment:$,requiredPillars:y,settings:{executionMode:"ALL_CONTROLS",evidenceSync:"COMPACT_ONLY"},approvalRules:{minimumApprovals:1,requireDistinctReviewer:!1}};x(!0),S(null);try{e?e.latestVersion.state==="DRAFT"?await O.governedGateUpdateDraft(e.gate.slug,e.latestVersion.version,W):await O.governedGateCreateVersion(e.gate.slug,{manifest:W,supersedesVersionId:e.latestVersion.id}):await O.governedGateCreate({slug:w,displayName:u.trim(),manifest:W}),await r(),i()}catch(R){S(R instanceof Error?R.message:"Could not save the governed Gate DRAFT.")}finally{x(!1)}};return s.jsxs("div",{className:"card stack",style:{padding:18,gap:13,borderColor:"var(--accent)"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:(e==null?void 0:e.latestVersion.state)==="DRAFT"?"EDIT GATE DRAFT":e?"CREATE REPLACEMENT VERSION":"CREATE FIRST-CLASS CLOUD GATE"}),s.jsx("strong",{children:e?`${e.gate.slug}@${e.latestVersion.version}`:"New Gate DRAFT"})]}),o.length===0&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Prerequisite"}),s.jsx("span",{children:"An APPROVED signed Suite that pins an exact APPROVED signed Policy is required."})]})}),s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Gate name"}),s.jsx("input",{className:"field",value:u,onChange:E=>d(E.target.value),disabled:!!e,placeholder:"RAG nightly release"})]}),!e&&s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:["Immutable slug: ",w||"—"]}),s.jsxs("label",{className:"stack",style:{gap:5},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"APPROVED signed Suite and exact Policy"}),s.jsxs("select",{className:"field",value:h,onChange:E=>L(E.target.value),children:[s.jsx("option",{value:"",children:"Select a Suite"}),o.map(E=>{const I=Zo(E,a);return s.jsxs("option",{value:E.latestVersion.id,children:[E.suite.slug,"@",E.latestVersion.version," · Policy ",I.policy.slug,"@",I.approvedVersion.version]},E.latestVersion.id)})]})]}),s.jsxs("div",{className:"row",style:{gap:10,flexWrap:"wrap"},children:[s.jsxs("label",{className:"stack",style:{gap:5,flex:"1 1 190px"},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Environment"}),s.jsx("input",{className:"field",value:v,onChange:E=>f(E.target.value),placeholder:"production"})]}),s.jsxs("div",{className:"card",style:{padding:10,flex:"1 1 250px"},children:[s.jsx("div",{className:"muted",style:{fontSize:11},children:"Fixed execution boundary"}),s.jsx("div",{className:"mono",style:{fontSize:11,marginTop:5},children:"ALL_CONTROLS · COMPACT_ONLY evidence"})]})]}),s.jsxs("div",{children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Required pillars (only Suite-represented pillars are selectable)"}),s.jsx("div",{className:"row",style:{gap:10,flexWrap:"wrap",marginTop:7},children:N.map(E=>s.jsxs("label",{className:"row",style:{gap:5},children:[s.jsx("input",{type:"checkbox",checked:y.includes(E),onChange:I=>b($=>I.target.checked?[...$,E]:$.filter(W=>W!==E))})," ",s.jsx("span",{style:{fontSize:12},children:E})]},E))})]}),s.jsx("div",{className:"card",style:{padding:11},children:s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,lineHeight:1.6},children:["targetScope: project ",(C==null?void 0:C.suite.projectId)??"—",s.jsx("br",{}),"approvalRules: recorded review required · current reviewer may approve and sign"]})}),j&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"Gate"}),s.jsx("span",{children:j})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:i,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void _(),disabled:m||o.length===0,children:m?"Saving…":(e==null?void 0:e.latestVersion.state)==="DRAFT"?"Save DRAFT":"Create DRAFT"})]})]})}function n5({entry:e,onSaved:t,onClose:n}){const[a,r]=p.useState(e.gate.displayName),[i,o]=p.useState(!1),[l,c]=p.useState(null),u=async()=>{const d=a.trim();if(d.length<2||d.length>100){c("Gate name must be 2–100 characters.");return}o(!0),c(null);try{await O.governedGateRename(e.gate.slug,d),await t(),n()}catch(h){c(h instanceof Error?h.message:"Could not rename the Gate.")}finally{o(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"modal",onClick:d=>d.stopPropagation(),style:{maxWidth:560},children:[s.jsx("div",{className:"screen-title",children:"Rename Gate"}),s.jsxs("div",{className:"screen-sub",style:{marginTop:5},children:["GitHub Actions continues to use the immutable slug ",s.jsx("span",{className:"mono",children:e.gate.slug}),". Renaming changes only this display label."]}),s.jsxs("label",{className:"stack",style:{gap:5,marginTop:16},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Display name"}),s.jsx("input",{className:"field",value:a,onChange:d=>r(d.target.value),maxLength:100,autoFocus:!0})]}),l&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"Gate"}),s.jsx("span",{children:l})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:16},children:[s.jsx("button",{className:"btn ghost",onClick:n,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:i||a.trim()===e.gate.displayName,onClick:()=>void u(),children:i?"Saving…":"Save name"})]})]})})}function a5({suite:e,entry:t,policies:n,onConfirm:a,onClose:r}){const i=Jc(e),[o,l]=p.useState((t==null?void 0:t.latestVersion.manifest.environment)??"production"),[c,u]=p.useState((t==null?void 0:t.latestVersion.manifest.requiredPillars.filter(b=>i.includes(b)))??i),[d,h]=p.useState(!1),[g,v]=p.useState(null),f=e.latestVersion.manifest.policyRef,y=async()=>{const b=o.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);if(b.length<2||!c.length){v("Choose an environment and at least one Suite-represented pillar.");return}h(!0),v(null);try{await a(b,c),r()}catch(m){v(m instanceof Error?m.message:"The Gate workflow could not reach a signed runnable state.")}finally{h(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:()=>{d||r()},children:s.jsxs("div",{className:"modal gate-review-modal",role:"dialog","aria-modal":"true","aria-labelledby":"gate-review-title",onClick:b=>b.stopPropagation(),style:{maxWidth:720},children:[s.jsx("div",{className:"eyebrow",children:"REVIEW & SIGN"}),s.jsx("div",{className:"screen-title",id:"gate-review-title",children:"Review exact release Gate setup"}),s.jsx("div",{className:"screen-sub",style:{marginTop:6},children:"Prooflane will record each existing Suite and Gate review/approval transition separately. No Policy, manifest, signature, or execution rule is bypassed."}),s.jsxs("div",{className:"gate-review-grid",style:{marginTop:16},children:[s.jsxs("div",{children:[s.jsx("span",{children:"Suite"}),s.jsxs("strong",{children:[e.suite.slug,"@",e.latestVersion.version]}),s.jsxs("small",{children:[e.latestVersion.state," · ",e.latestVersion.manifestHash??"hash pending approval"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Policy"}),s.jsx("strong",{children:f?`${f.policyId}@${f.version}`:"Not pinned"}),s.jsx("small",{children:(f==null?void 0:f.manifestHash)??"Exact approved Policy required"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Gate"}),s.jsx("strong",{children:t?`${t.gate.slug}@${t.latestVersion.version}`:`${sC(e)}@1`}),s.jsx("small",{children:(t==null?void 0:t.latestVersion.state)??"Will create DRAFT"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:e.latestVersion.manifest.targetFingerprint?"Pinned":"Missing"}),s.jsx("small",{children:e.latestVersion.manifest.targetFingerprint??"Connected target must be saved in the Suite"})]})]}),s.jsxs("label",{className:"stack",style:{gap:5,marginTop:15},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Environment"}),s.jsx("input",{className:"field",value:o,onChange:b=>l(b.target.value),disabled:d})]}),s.jsxs("div",{style:{marginTop:14},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Required pillars"}),s.jsx("div",{className:"row",style:{gap:10,flexWrap:"wrap",marginTop:7},children:i.map(b=>s.jsxs("label",{className:"row",style:{gap:5},children:[s.jsx("input",{type:"checkbox",checked:c.includes(b),disabled:d,onChange:m=>u(x=>m.target.checked?[...x,b]:x.filter(j=>j!==b))}),s.jsx("span",{style:{fontSize:12},children:b})]},b))})]}),s.jsx("div",{className:"card",style:{padding:11,marginTop:15},children:s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,lineHeight:1.7},children:["1 · review Suite DRAFT if required",s.jsx("br",{}),"2 · approve and sign reviewed Suite if required",s.jsx("br",{}),"3 · create/update exact Gate DRAFT",s.jsx("br",{}),"4 · review Gate DRAFT",s.jsx("br",{}),"5 · approve and sign reviewed Gate"]})}),g&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"Stopped safely"}),s.jsx("span",{children:g})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:18},children:[s.jsx("button",{className:"btn ghost",disabled:d,onClick:r,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:d||!f||!e.latestVersion.manifest.targetFingerprint||!i.length,onClick:()=>void y(),children:d?"Validating and signing…":"Confirm · review & make runnable"})]})]})})}function r5({entry:e,events:t,onClose:n}){return s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"modal",onClick:a=>a.stopPropagation(),style:{maxWidth:760},children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{children:[s.jsx("div",{className:"screen-title",children:"Gate audit"}),s.jsxs("div",{className:"screen-sub",children:[e.gate.slug,"@",e.latestVersion.version]})]}),s.jsx("button",{className:"btn ghost",onClick:n,children:"Close"})]}),s.jsx("div",{className:"stack",style:{gap:8,marginTop:16},children:t.length===0?s.jsx("span",{className:"muted",children:"No audit events returned."}):t.map(a=>s.jsxs("div",{className:"card",style:{padding:11},children:[s.jsxs("div",{className:"row spread",style:{gap:8},children:[s.jsx("strong",{style:{fontSize:12},children:a.action.replaceAll("_"," ")}),s.jsx("span",{className:"mono muted",style:{fontSize:10.5},children:new Date(a.occurredAt).toLocaleString()})]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:5},children:["actor ",a.actorId," · version ",a.gateVersionId??"gate record"," · request ",a.requestId]})]},a.id))})]})})}function i5({result:e}){var i,o;const t=(i=e.evaluationEvidence)==null?void 0:i.judgeRelationship,n=e.evaluationStatus==="NOT_EXECUTED_REQUIRES_JUDGE",a=n?"NOT RUN · BYOK REQUIRED":e.evaluationStatus??e.outcome,r=n?"No evaluation judge was attached to this run. Connect BYOK before authoring or rerunning model-judge evaluations.":e.detail;return s.jsxs("div",{className:"card",style:{padding:11},children:[s.jsxs("div",{className:"row spread",style:{gap:8,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("strong",{style:{fontSize:12},children:e.name}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:[e.id," · ",e.pillar," · ",e.latencyMs," ms",e.evaluationEvidence?` · ${e.evaluationEvidence.executionMode.replaceAll("_"," ")}`:""]})]}),s.jsx("span",{className:`tag ${e.outcome==="PASS"?"pass":e.outcome==="ERROR"||e.evaluationStatus==="JUDGE_ERROR"||n?"warn":"fail"}`,children:a})]}),s.jsx("div",{className:"muted",style:{fontSize:11.5,marginTop:7},children:r}),t&&s.jsxs("div",{className:"mono muted",style:{fontSize:10,marginTop:5},children:["judge relationship ",t.replaceAll("_"," ").toLowerCase(),((o=e.evaluationEvidence)==null?void 0:o.score)!==void 0?` · score ${e.evaluationEvidence.score.toFixed(3)}`:""]}),t==="SAME_MODEL"&&s.jsx("div",{className:"drift dirty",style:{marginTop:8},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"LOWER CONFIDENCE"}),s.jsx("span",{children:"This evaluation was judged by the same model or model family under evaluation."})]})}),t==="JUDGE_RELATIONSHIP_UNKNOWN"&&s.jsx("div",{className:"drift dirty",style:{marginTop:8},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"UNRESOLVED"}),s.jsx("span",{children:"The runtime target model could not be established, so Prooflane does not claim judge independence."})]})})]})}function o5({report:e,onClose:t,onRerun:n,rerunning:a}){var i;const r=((i=e.localReport)==null?void 0:i.stored)!==!1;return s.jsx("div",{className:"modal-backdrop",onClick:t,children:s.jsxs("div",{className:"modal governed-run-report",onClick:o=>o.stopPropagation(),children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"GOVERNED RUN REPORT"}),s.jsxs("div",{className:"screen-title",children:[e.gate.slug,"@",e.gate.version]}),s.jsxs("div",{className:"screen-sub mono",children:["Run ",e.run.id," · ",e.execution.decision]})]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn ghost",onClick:()=>tC(e),children:"Download JSON"}),r?s.jsx("a",{className:"btn ghost",href:Sc(e.run.id),download:!0,children:"Download HTML"}):s.jsx("button",{className:"btn ghost",disabled:!0,title:"The detailed report could not be saved on this machine.",children:"HTML unavailable"}),s.jsx("button",{className:"btn ghost",disabled:a,onClick:n,children:a?"Rerunning…":"Rerun Gate"}),s.jsx("button",{className:"btn primary",onClick:t,children:"Close report"})]})]}),!r&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Local report"}),s.jsx("span",{children:"The run completed and compact evidence synchronized, but its detailed report could not be saved locally. JSON remains available from this open report."})]})}),s.jsxs("div",{className:"card mono governed-run-report-identifiers",children:["Gate ",e.gate.manifestHash,s.jsx("br",{}),"Suite ",e.suite.slug,"@",e.suite.version," · ",e.suite.manifestHash,s.jsx("br",{}),"Policy ",e.policy.id,"@",e.policy.version," · ",e.policy.manifestHash,s.jsx("br",{}),"Target ",e.run.targetFingerprint," · evidence ",e.run.evidenceFingerprint]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",marginTop:12},children:[s.jsx("span",{className:`tag ${e.execution.decision==="READY"?"pass":e.execution.decision==="BLOCK"?"fail":"warn"}`,children:e.execution.decision}),s.jsxs("span",{className:"tag informational",children:[e.execution.passed," passed"]}),s.jsxs("span",{className:"tag informational",children:[e.execution.failed," failed"]}),s.jsxs("span",{className:"tag informational",children:[e.execution.errors," errors"]})]}),e.execution.evaluationEvidenceSummary&&s.jsxs("div",{className:"card",style:{padding:11,marginTop:12},children:[s.jsxs("div",{className:"row spread",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("strong",{style:{fontSize:12},children:"Prompt + RAG evaluation evidence"}),s.jsx("span",{className:`tag ${e.execution.evaluationEvidenceSummary.evidenceCompleteness==="COMPLETE"?"pass":"warn"}`,children:e.execution.evaluationEvidenceSummary.evidenceCompleteness})]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:6},children:[e.execution.evaluationEvidenceSummary.deterministicPassed,"/",e.execution.evaluationEvidenceSummary.deterministicTotal," deterministic passed · ",e.execution.evaluationEvidenceSummary.probabilisticExecuted,"/",e.execution.evaluationEvidenceSummary.probabilisticTotal," judged · ",e.execution.evaluationEvidenceSummary.probabilisticNotExecuted," require a judge · ",e.execution.evaluationEvidenceSummary.probabilisticJudgeError," judge errors"]})]}),s.jsx("div",{className:"stack",style:{gap:8,marginTop:14,maxHeight:"48vh",overflow:"auto"},children:e.execution.results.map(o=>s.jsx(i5,{result:o},o.id))})]})})}function l5({suites:e,policies:t,governedRuns:n,currentTargetFingerprint:a,focusedSuiteSlug:r,onOpenCi:i,onRunCompleted:o,onGovernedRunsChanged:l,onApproveSuite:c,onEditSuite:u,onArchiveSuite:d,onDeprecateSuite:h,onReviewSuiteDrift:g}){var ye,Ke;const[v,f]=p.useState([]),[y,b]=p.useState(null),[m,x]=p.useState(null),[j,S]=p.useState(null),[w,C]=p.useState(null),[k,N]=p.useState(null),[L,_]=p.useState(null),[E,I]=p.useState(null),[$,W]=p.useState(null),[R,H]=p.useState([]),[Y,K]=p.useState([]),[ce,F]=p.useState(null),[ie,ue]=p.useState([]),[oe,B]=p.useState(""),[Q,X]=p.useState(null),[me,fe]=p.useState(!1),[P,T]=p.useState(()=>new Set),he=p.useRef(new Set),q=U=>T(te=>{const ke=new Set(te);return ke.has(U)?ke.delete(U):ke.add(U),ke}),se=async()=>{try{const[U,te]=await Promise.all([O.governedGatesList(!0),O.remoteRunners()]);f(U.gates),ue(te.runners),B(ke=>{var we;return ke&&te.runners.some(Te=>Te.id===ke&&Te.status==="ACTIVE")?ke:((we=te.runners.find(Te=>Te.status==="ACTIVE"&&Te.targetFingerprint))==null?void 0:we.id)??""}),_(null)}catch(U){_(U instanceof Error?U.message:"Cloud Gate registry is unavailable.")}},ge=async()=>{try{H((await O.governedGateReportsLocal()).reports)}catch{H([])}},de=async()=>{try{const U=await O.governedGateJobsLocal();K(U.jobs);const te=U.jobs.filter(ke=>ke.status==="COMPLETED"&&ke.runId&&!he.current.has(ke.runId));for(const ke of te){he.current.add(ke.runId);try{o(await O.governedGateReportLocal(ke.runId))}catch{}}te.length&&ge()}catch{K([])}};p.useEffect(()=>{se(),ge(),de()},[]),p.useEffect(()=>{r&&window.requestAnimationFrame(()=>{var U;return(U=document.getElementById(`release-gate-${r}`))==null?void 0:U.scrollIntoView({behavior:"smooth",block:"center"})})},[r,e,v]);const Ne=Y.filter(U=>U.status==="QUEUED"||U.status==="RUNNING").map(U=>`${U.id}:${U.status}`).join("|");p.useEffect(()=>{if(!Ne)return;const U=window.setInterval(()=>{de()},800);return()=>window.clearInterval(U)},[Ne]),p.useEffect(()=>{if(!Q||["COMPLETED","EXECUTION_ERROR","CANCELLED","EXPIRED"].includes(Q.status))return;const U=window.setInterval(()=>{O.remoteRunnerJob(Q.id).then(async te=>{if(X(te.job),["COMPLETED","EXECUTION_ERROR"].includes(te.job.status))try{const ke=await O.governedRuns(20);l==null||l(ke.runs)}catch{}}).catch(te=>{_(te instanceof Error?te.message:"Could not refresh the Remote Runner job.")})},1200);return()=>window.clearInterval(U)},[Q==null?void 0:Q.id,Q==null?void 0:Q.status]);const Oe=async(U,te)=>{N(`${U.gate.id}:${te}`),_(null);try{te==="review"?await O.governedGateReview(U.gate.slug,U.latestVersion.version):te==="approve"?await O.governedGateApprove(U.gate.slug,U.latestVersion.version):await O.governedGateDeprecate(U.gate.slug,U.latestVersion.version),await se()}catch(ke){_(ke instanceof Error?ke.message:`Could not ${te} the Gate version.`)}finally{N(null)}},_e=async U=>{N(`${U.gate.id}:audit`),_(null);try{const te=await O.governedGateAudit(U.gate.slug);C({entry:U,events:te.events})}catch(te){_(te instanceof Error?te.message:"Could not load Gate audit events.")}finally{N(null)}},re=async U=>{N(`${U.gate.id}:run`),_(null);try{const te=await O.governedGateStartLocalJob(U.gate.slug);K(ke=>[te.job,...ke.filter(we=>we.id!==te.job.id)])}catch(te){_(te instanceof Error?te.message:"Could not start the governed Gate job against the connected local target.")}finally{N(null)}},V=async(U,te=!1)=>{F(U.runId),_(null);try{const ke=await O.governedGateReportLocal(U.runId);te?tC(ke):I(ke)}catch(ke){_(ke instanceof Error?ke.message:"Could not open the saved local governed Run report.")}finally{F(null)}},le=async U=>{F(U.runId),_(null);try{const te=await O.governedGateSpineReportLocal(U.runId);W({summary:U,html:te})}catch(te){_(te instanceof Error?te.message:"Could not open the Prooflane Spine report.")}finally{F(null)}},ee=async U=>{if(!oe){_("Select an active private Runner before dispatching this Gate.");return}N(`${U.gate.id}:remote`),_(null),X(null);try{const te=await O.governedGateRunRemote(U.gate.slug,oe,`ui_${crypto.randomUUID().replaceAll("-","")}`);X(te.job)}catch(te){_(te instanceof Error?te.message:"Could not dispatch the governed Gate to the private Runner.")}finally{N(null)}},xe=async(U,te,ke,we)=>{N(`workflow:${U.suite.id}`),_(null);try{if(te!=null&&te.gate.archivedAt)throw new Error("Restore the archived Gate before making this release runnable.");const Te=Kc(U)?U:await c(U);if(!Kc(Te))throw new Error("Suite approval did not return an exact signed APPROVED version.");const ve=t5(Te,t,ke,we);if(!ve)throw new Error("The exact approved signed Suite and Policy pins are not available for Gate creation.");let z=te,D=te==null?void 0:te.latestVersion;const A=D&&D.manifest.suiteRef.suiteVersionId===ve.suiteRef.suiteVersionId&&D.manifest.policyRef.policyVersionId===ve.policyRef.policyVersionId&&D.manifest.environment===ve.environment&&D.manifest.requiredPillars.length===ve.requiredPillars.length&&D.manifest.requiredPillars.every(ne=>ve.requiredPillars.includes(ne));if(z?(D==null?void 0:D.state)==="DRAFT"?D=(await O.governedGateUpdateDraft(z.gate.slug,D.version,ve)).version:(!A||(D==null?void 0:D.state)==="DEPRECATED")&&(D=(await O.governedGateCreateVersion(z.gate.slug,{manifest:ve,supersedesVersionId:D==null?void 0:D.id})).version):(z=await O.governedGateCreate({slug:sC(Te),displayName:`${Te.suite.displayName} Gate`,manifest:ve}),D=z.latestVersion),!D)throw new Error("The Gate DRAFT was not returned by the registry.");if(D.state==="DRAFT"&&(D=(await O.governedGateReview(z.gate.slug,D.version)).version),D.state==="REVIEWED"&&(D=(await O.governedGateApprove(z.gate.slug,D.version)).version),D.state!=="APPROVED"||!D.signature||!D.manifestHash)throw new Error("Gate approval did not return an exact signed APPROVED version.")}finally{await se(),N(null)}},Fe=async U=>{const te=U.approvedVersion?"Archive Gate":"Discard DRAFT";if(window.confirm(`${te} “${U.gate.displayName}”? The Gate will leave the active list, but versions, signatures, runs, reports, and audit history will be retained.`)){N(`${U.gate.id}:archive`),_(null);try{await O.governedGateArchive(U.gate.slug),await se()}catch(ke){_(ke instanceof Error?ke.message:"Could not archive the Gate.")}finally{N(null)}}},Be=async U=>{var te;if(window.confirm(`Remove “${U.gate.displayName}” from active Gates? Its immutable versions, signatures, runs, reports, and audit history will be retained, and it can be restored from Show archived.`)){N(`${U.gate.id}:remove`),_(null);try{((te=U.approvedVersion)==null?void 0:te.state)==="APPROVED"&&await O.governedGateDeprecate(U.gate.slug,U.approvedVersion.version);const ke=await O.governedGateArchive(U.gate.slug);f(we=>we.map(Te=>Te.gate.id===ke.gate.id?{...Te,gate:ke.gate}:Te)),await se()}catch(ke){_(ke instanceof Error?ke.message:"Could not remove the Gate from the active list.")}finally{N(null)}}},st=async U=>{N(`${U.gate.id}:restore`),_(null);try{await O.governedGateRestore(U.gate.slug),await se()}catch(te){_(te instanceof Error?te.message:"Could not restore the Gate.")}finally{N(null)}},ae=U=>{var A;const te=U.approvedVersion,ke=te?e.find(ne=>ne.suite.id===te.manifest.suiteRef.suiteId&&ne.latestVersion.id===te.manifest.suiteRef.suiteVersionId):void 0,we=ke?(A=Zo(ke,t))==null?void 0:A.approvedVersion:void 0,Te=!!(te&&we&&te.manifest.policyRef.policyVersionId===we.id&&te.manifest.policyRef.version===we.version&&te.manifest.policyRef.manifestHash===we.manifestHash),ve=ke==null?void 0:ke.latestVersion.manifest.targetFingerprint,z=te&&Te&&ve?n.find(ne=>{var Re,Ee;return((Re=ne.gate)==null?void 0:Re.gateVersionId)===te.id&&ne.suite.suiteVersionId===te.manifest.suiteRef.suiteVersionId&&ne.policy.policyVersionId===te.manifest.policyRef.policyVersionId&&ne.targetFingerprint===ve&&ne.status==="COMPLETED"&&!!((Ee=ne.counts)!=null&&Ee.total)}):void 0,D=!U.gate.archivedAt&&(te==null?void 0:te.state)==="APPROVED"&&!!te.manifestHash&&!!te.signature&&Te;return{approved:te,runtimeProof:z,signed:D,ciReady:D&&!!z}},Ce=v.some(U=>!U.gate.archivedAt&&ae(U).ciReady),He=e5(e,v,me),qe=new Set(He.flatMap(({entry:U})=>U?[U.gate.id]:[])),dt=v.filter(U=>!qe.has(U.gate.id)&&(me||!U.gate.archivedAt));return s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Release Gates"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:5},children:"One stable workflow from reviewed tests to an exact signed Gate and its first governed run."})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[s.jsx("button",{className:`btn sm ${me?"primary":"ghost"}`,onClick:()=>fe(U=>!U),children:me?"Hide archived":"Show archived"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{se(),ge(),de()},children:"↻ Refresh"})]})]}),s.jsxs("div",{className:"row gate-workflow-steps",style:{gap:6,flexWrap:"wrap"},children:[s.jsx("span",{className:"tag informational",children:"1 · CONFIGURE"}),s.jsx("span",{className:"tag informational",children:"2 · REVIEW & SIGN"}),s.jsx("span",{className:"tag informational",children:"3 · RUN"})]}),Ce&&s.jsxs("details",{className:"card",style:{padding:12},children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsx("strong",{style:{fontSize:12},children:"Private Runner configuration"}),s.jsx("span",{className:"muted",style:{fontSize:11.5,marginLeft:8},children:"Optional after readiness proof"})]}),s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap",marginTop:12},children:[s.jsx("div",{className:"muted",style:{fontSize:11.5},children:"Hosted execution dispatches the exact signed Gate and returns structured compact evidence only."}),s.jsxs("label",{className:"row",style:{gap:7},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:"Runner"}),s.jsxs("select",{className:"field",value:oe,onChange:U=>B(U.target.value),children:[s.jsx("option",{value:"",children:"No active Runner"}),ie.filter(U=>U.status==="ACTIVE").map(U=>s.jsxs("option",{value:U.id,children:[U.name," · ",U.lastSeenAt&&Date.now()-Date.parse(U.lastSeenAt)<12e4?"online":"offline"," · ",U.targetFingerprint??"target pending"]},U.id))]})]})]}),s.jsx("div",{className:"mono muted",style:{fontSize:10.5,marginTop:8},children:"Register/start locally: prooflane runner register <config> --project <id> --name <name> · prooflane runner start <config>"})]}),y&&s.jsx(s5,{entry:y.entry,initialSuiteVersionId:y.suiteVersionId,suites:e,policies:t,onSaved:se,onClose:()=>b(null)},`${((ye=y.entry)==null?void 0:ye.gate.id)??"new"}:${y.suiteVersionId??"any"}`),m&&s.jsx(a5,{suite:m.suite,entry:m.entry,policies:t,onConfirm:(U,te)=>xe(m.suite,m.entry,U,te),onClose:()=>x(null)},`${m.suite.latestVersion.id}:${((Ke=m.entry)==null?void 0:Ke.latestVersion.id)??"new"}`),j&&s.jsx(n5,{entry:j,onSaved:se,onClose:()=>S(null)}),L&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Cloud Gate"}),s.jsx("span",{children:L})]})}),!L&&He.length===0&&dt.length===0&&s.jsx("div",{className:"card",style:{padding:18},children:s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"No release Gate setup exists yet. Configure one from reviewed test groups; the exact approved signed Policy remains mandatory."})}),He.map(({suite:U,entry:te})=>{var kt;const ke=Zo(U,t),we=te==null?void 0:te.latestVersion,Te=te?ae(te):{signed:!1,ciReady:!1},ve=!!(te&&[te.latestVersion,te.approvedVersion].some(ht=>(ht==null?void 0:ht.manifest.suiteRef.suiteVersionId)===U.latestVersion.id)),z=!!(a&&U.latestVersion.manifest.targetFingerprint&&a!==U.latestVersion.manifest.targetFingerprint),D=!ke||!U.latestVersion.manifest.targetFingerprint||z||!Jc(U).length,A=te?Y.find(ht=>ht.gateSlug===te.gate.slug):void 0,ne=(A==null?void 0:A.status)==="QUEUED"||(A==null?void 0:A.status)==="RUNNING",Re=te?R.find(ht=>ht.gate.slug===te.gate.slug):void 0,Ee=(A==null?void 0:A.runId)??(Re==null?void 0:Re.runId)??null,ze=Ee?R.find(ht=>ht.runId===Ee):void 0,wt=!!(te!=null&&te.gate.archivedAt),be=wt?"ARCHIVED":z?"TARGET CHANGED":Te.ciReady&&ve?"READY":Te.signed&&ve?"SIGNED · FIRST RUN REQUIRED":D?"SETUP BLOCKED":"REVIEW REQUIRED",_t=be==="READY"?"pass":be==="ARCHIVED"||be==="TARGET CHANGED"||be==="SETUP BLOCKED"?"fail":"warn",Dt=(A==null?void 0:A.status)==="COMPLETED"?100:A!=null&&A.progress.total?Math.round(A.progress.completed/A.progress.total*100):0,pe=r===U.suite.slug,Xe=(te==null?void 0:te.gate.slug)??U.suite.slug,St=P.has(Xe);return s.jsxs("div",{id:`release-gate-${U.suite.slug}`,className:`card release-gate-card${pe?" focused":""}`,style:{padding:"17px 18px"},children:[s.jsxs("div",{className:"row spread",style:{gap:14,flexWrap:"wrap",alignItems:"flex-start"},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"eyebrow",children:["RELEASE GATE · ",U.latestVersion.state]}),s.jsx("div",{className:"release-gate-title",children:(te==null?void 0:te.gate.displayName)??U.suite.displayName}),s.jsxs("div",{className:"mono muted",style:{fontSize:11,marginTop:5},children:["project ",U.suite.projectId," · ",te?`${te.gate.slug}@${te.latestVersion.version}`:"Gate not signed yet"]})]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsx("span",{className:`tag ${_t}`,children:be}),wt&&te?s.jsx("button",{className:"btn sm primary",disabled:!!k,onClick:()=>void st(te),children:k===`${te.gate.id}:restore`?"Restoring…":"Restore Gate"}):D?s.jsx("button",{className:"btn sm primary",onClick:()=>z?void g(U):u(U),children:z?"Review changed setup":"Fix setup"}):Te.signed&&ve&&te?s.jsx("button",{className:"btn sm primary",disabled:!!k||ne,onClick:()=>void re(te),children:ne?"Run in progress…":k===`${te.gate.id}:run`?"Starting…":"Run Gate"}):s.jsx("button",{className:"btn sm primary",disabled:!!k,onClick:()=>x({suite:U,entry:te}),children:k===`workflow:${U.suite.id}`?"Validating…":"Review & make runnable"}),!wt&&te&&s.jsx("button",{className:"btn sm ghost",disabled:!!k||ne,onClick:()=>void Be(te),children:k===`${te.gate.id}:remove`?"Removing…":"Remove"}),s.jsx("button",{className:"btn sm ghost",type:"button","aria-expanded":!St,onClick:()=>q(Xe),children:St?"Expand":"Collapse"})]})]}),!St&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:9},children:["Planned coverage v",U.latestVersion.version," · ",new Date(U.latestVersion.createdAt).toLocaleString()]}),s.jsxs("div",{className:"release-gate-facts",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Suite"}),s.jsxs("strong",{children:[U.suite.slug,"@",U.latestVersion.version]}),s.jsx("small",{children:Kc(U)?"Approved · signed":U.latestVersion.state.replaceAll("_"," ")})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Policy"}),s.jsx("strong",{children:U.latestVersion.manifest.policyRef?`${U.latestVersion.manifest.policyRef.policyId}@${U.latestVersion.manifest.policyRef.version}`:"Not pinned"}),s.jsx("small",{children:ke?"Approved · exact pin":"Approval prerequisite"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Gate"}),s.jsx("strong",{children:te?`${te.gate.slug}@${te.latestVersion.version}`:"Will be created"}),s.jsx("small",{children:wt?"Archived":Te.signed?"Approved · signed":(we==null?void 0:we.state)??"Configuration ready"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:U.latestVersion.manifest.targetFingerprint?z?"Changed":"Pinned":"Missing"}),s.jsx("small",{children:U.latestVersion.manifest.targetFingerprint??"Save connected target"})]})]}),s.jsxs("div",{className:"row release-gate-progress",style:{gap:7,flexWrap:"wrap",marginTop:12},children:[s.jsx("span",{className:`tag ${U.latestVersion.manifest.controls.length?"pass":"warn"}`,children:"1 · CONFIGURE"}),s.jsx("span",{className:`tag ${Te.signed&&ve?"pass":"warn"}`,children:"2 · REVIEW & SIGN"}),s.jsx("span",{className:`tag ${Te.ciReady&&ve?"pass":"informational"}`,children:"3 · RUN"})]}),te&&!wt&&s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:10,lineHeight:1.7},children:["Suite ",we.manifest.suiteRef.manifestHash,s.jsx("br",{}),"Policy ",we.manifest.policyRef.manifestHash,s.jsx("br",{}),"Gate ",we.manifestHash??"pending signature"," · key ",((kt=we.signature)==null?void 0:kt.keyId)??"pending signature"]}),A&&s.jsxs("div",{className:"card gate-run-inline",style:{padding:12,marginTop:11},children:[s.jsxs("div",{className:"row spread",style:{gap:8},children:[s.jsxs("div",{children:[s.jsx("strong",{style:{fontSize:12},children:A.progress.current||"Governed Gate run"}),s.jsx("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:A.runId?`Run ${A.runId}`:`Job ${A.id}`})]}),s.jsx("span",{className:`tag ${A.status==="FAILED"?"fail":ne?"warn":(ze==null?void 0:ze.decision)==="READY"?"pass":"warn"}`,children:A.status==="COMPLETED"?(ze==null?void 0:ze.decision)??"COMPLETED":A.status})]}),ne&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{marginTop:9},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:A.progress.current}),s.jsx("span",{className:"mono muted",style:{fontSize:10.5},children:A.progress.total?`${A.progress.completed}/${A.progress.total}`:"queued"})]}),s.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Dt,className:"gate-run-progress",children:s.jsx("div",{style:{width:`${Math.max(4,Dt)}%`}})})]}),ze&&s.jsxs("div",{className:"row spread",style:{gap:8,marginTop:9},children:[s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:[ze.counts.passed,"/",ze.counts.total," passed · ",ze.counts.failed," failed · ",ze.counts.errors," errors"]}),s.jsx("button",{className:"btn sm ghost",disabled:ce===ze.runId,onClick:()=>void le(ze),children:ce===ze.runId?"Opening…":"Open Spine report"})]})]}),s.jsxs("details",{className:"release-gate-advanced",style:{marginTop:11},children:[s.jsx("summary",{className:"muted",style:{cursor:"pointer",fontSize:11.5},children:"Advanced actions"}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap",marginTop:9},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>u(U),children:U.latestVersion.state==="DRAFT"?"Edit Suite DRAFT":"Edit as new Suite DRAFT"}),U.latestVersion.state==="APPROVED"&&s.jsx("button",{className:"btn sm ghost",onClick:()=>void h(U),children:"Deprecate Suite"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void d(U),children:"Archive Suite"}),te&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>b({entry:te,suiteVersionId:U.latestVersion.id}),children:"Edit Gate setup"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>S(te),children:"Rename Gate"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void _e(te),children:"Audit"}),te.latestVersion.state==="APPROVED"&&s.jsx("button",{className:"btn sm ghost",onClick:()=>void Oe(te,"deprecate"),children:"Deprecate Gate"}),!te.gate.archivedAt&&s.jsx("button",{className:"btn sm ghost",disabled:!!te.approvedVersion||ne||!!k,title:te.approvedVersion?"Deprecate the approved Gate before archiving.":ne?"Wait for the active Gate job to finish.":void 0,onClick:()=>void Fe(te),children:te.latestVersion.state==="DRAFT"?"Discard DRAFT":"Archive Gate"})]}),te&&Te.signed&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",disabled:!oe||!!k,onClick:()=>void ee(te),children:"Run on private Runner"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i(te.gate.slug),children:"GitHub CI"})]})]})]})]})]},U.suite.id)}),dt.map(U=>{var wt;const te=U.latestVersion,{approved:ke,signed:we,ciReady:Te}=ae(U),ve=Y.find(be=>be.gateSlug===U.gate.slug),z=(ve==null?void 0:ve.status)==="QUEUED"||(ve==null?void 0:ve.status)==="RUNNING",D=R.find(be=>be.gate.slug===U.gate.slug),A=ve?ve.runId:(D==null?void 0:D.runId)??null,ne=A?R.find(be=>be.runId===A):void 0,Re=R.filter(be=>be.gate.slug===U.gate.slug&&be.runId!==A),Ee=(ve==null?void 0:ve.status)==="COMPLETED"?100:ve!=null&&ve.progress.total?Math.round(ve.progress.completed/ve.progress.total*100):0,ze=P.has(U.gate.slug);return s.jsxs("div",{className:"card",style:{padding:"16px 18px"},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"eyebrow",children:[te.state," · ",U.gate.slug,"@",te.version]}),s.jsx("div",{style:{fontWeight:700},children:U.gate.displayName}),s.jsxs("div",{className:"mono muted",style:{fontSize:11.5,marginTop:5},children:["environment ",te.manifest.environment," · project ",te.manifest.targetScope.projectId," · ALL_CONTROLS · COMPACT_ONLY"]})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[U.gate.archivedAt?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag fail",children:"ARCHIVED"}),s.jsx("button",{className:"btn sm primary",disabled:!!k,onClick:()=>void st(U),children:k===`${U.gate.id}:restore`?"Restoring…":"Restore Gate"})]}):Te?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"tag pass",children:["READY · SIGNED · v",ke.version]}),s.jsx("button",{className:"btn sm primary",disabled:!!k||z,onClick:()=>void re(U),children:z?"Run in progress…":k===`${U.gate.id}:run`?"Starting…":"Run Gate"}),s.jsx("button",{className:"btn sm ghost",disabled:!!k||!oe,onClick:()=>void ee(U),children:k===`${U.gate.id}:remote`?"Dispatching…":"Run on private Runner"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i(U.gate.slug),children:"GitHub CI"})]}):we?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag warn",children:"SIGNED · FIRST RUN REQUIRED"}),s.jsx("button",{className:"btn sm primary",disabled:!!k||z,onClick:()=>void re(U),children:z?"Run in progress…":k===`${U.gate.id}:run`?"Starting…":"Run Gate"})]}):s.jsxs("span",{className:"tag warn",children:["NOT READY · ",te.state]}),!U.gate.archivedAt&&!we&&te.state==="DRAFT"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm primary",disabled:!!k,onClick:()=>void Oe(U,"review"),children:k===`${U.gate.id}:review`?"Submitting…":"Review Gate"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>b({entry:U}),children:"Edit setup"})]}),!U.gate.archivedAt&&!we&&te.state==="REVIEWED"&&s.jsx("button",{className:"btn sm primary",disabled:!!k,onClick:()=>void Oe(U,"approve"),children:k===`${U.gate.id}:approve`?"Signing…":"Approve & sign"}),!U.gate.archivedAt&&!we&&te.state==="APPROVED"&&s.jsx("button",{className:"btn sm primary",onClick:()=>b({entry:U}),children:"Update Gate setup"}),!U.gate.archivedAt&&!we&&te.state==="DEPRECATED"&&s.jsx("button",{className:"btn sm primary",onClick:()=>b({entry:U}),children:"Create replacement Gate"}),s.jsx("button",{className:"btn sm ghost",type:"button","aria-expanded":!ze,onClick:()=>q(U.gate.slug),children:ze?"Expand":"Collapse"})]})]}),!ze&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"row",style:{gap:7,flexWrap:"wrap",marginTop:10},children:te.manifest.requiredPillars.map(be=>s.jsx("span",{className:"tag informational",children:be},be))}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:9,lineHeight:1.65},children:["Suite ",te.manifest.suiteRef.slug,"@",te.manifest.suiteRef.version," · ",te.manifest.suiteRef.manifestHash,s.jsx("br",{}),"Policy ",te.manifest.policyRef.policyId,"@",te.manifest.policyRef.version," · ",te.manifest.policyRef.manifestHash,s.jsx("br",{}),"Gate hash ",te.manifestHash??"pending until approval"," · key ",((wt=te.signature)==null?void 0:wt.keyId)??"pending until approval"]}),s.jsxs("details",{style:{marginTop:10},children:[s.jsx("summary",{className:"muted",style:{cursor:"pointer",fontSize:11.5},children:"Advanced Gate governance"}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap",marginTop:8},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>S(U),children:"Rename display name"}),!U.gate.archivedAt&&te.state!=="DRAFT"&&s.jsx("button",{className:"btn sm ghost",onClick:()=>b({entry:U}),children:"Create replacement DRAFT"}),!U.gate.archivedAt&&te.state==="APPROVED"&&s.jsx("button",{className:"btn sm ghost",disabled:!!k,onClick:()=>void Oe(U,"deprecate"),children:"Deprecate"}),s.jsx("button",{className:"btn sm ghost",disabled:!!k,onClick:()=>void _e(U),children:"Audit"}),!U.gate.archivedAt&&s.jsx("button",{className:"btn sm ghost",disabled:!!U.approvedVersion||z||!!k,onClick:()=>void Fe(U),children:te.state==="DRAFT"?"Discard DRAFT":"Archive Gate"}),ne&&s.jsx("button",{className:"btn sm ghost",disabled:ce===ne.runId,onClick:()=>void V(ne),children:ce===ne.runId?"Opening…":"Inspect raw results"})]})]}),Te&&ke.id!==te.id&&s.jsxs("div",{className:"card mono",style:{padding:10,fontSize:10.5,marginTop:9,lineHeight:1.65},children:["CI approved alias → ",U.gate.slug,"@",ke.version,s.jsx("br",{}),"Suite ",ke.manifest.suiteRef.slug,"@",ke.manifest.suiteRef.version," · Policy ",ke.manifest.policyRef.policyId,"@",ke.manifest.policyRef.version,s.jsx("br",{}),"Gate hash ",ke.manifestHash," · key ",ke.signature.keyId]}),(ve||D)&&s.jsxs("div",{className:"card",style:{padding:13,marginTop:9},children:[s.jsxs("div",{className:"row spread",style:{gap:8,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("strong",{children:ve?`Local governed job ${ve.id}`:`Local governed Run ${D.runId}`}),s.jsx("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:ve!=null&&ve.runId?`Run ${ve.runId}`:ve?ve.progress.current:`Completed ${new Date(D.completedAt).toLocaleString()}`})]}),s.jsx("span",{className:`tag ${(ve==null?void 0:ve.status)==="FAILED"||(ne==null?void 0:ne.decision)==="BLOCK"?"fail":z||(ne==null?void 0:ne.decision)==="REVIEW"?"warn":"pass"}`,children:(ve==null?void 0:ve.status)??(ne==null?void 0:ne.decision)??"COMPLETED"})]}),ve&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row spread",style:{gap:8,marginTop:10},children:[s.jsx("span",{className:"muted",style:{fontSize:11.5},children:ve.progress.current}),s.jsx("span",{className:"mono muted",style:{fontSize:10.5},children:ve.progress.total?`${ve.progress.completed}/${ve.progress.total}`:ve.status==="QUEUED"?"queued":`${Ee}%`})]}),s.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ee,style:{height:7,borderRadius:99,background:"var(--line)",marginTop:8,overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:`${Math.max(z?4:0,Ee)}%`,background:ve.status==="FAILED"?"var(--fail)":"var(--accent)",transition:"width .25s ease"}})})]}),ne&&s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:9},children:[ne.counts.passed," passed · ",ne.counts.failed," failed · ",ne.counts.errors," errors · compact evidence synchronized"]}),(ve==null?void 0:ve.error)&&s.jsx("div",{className:"muted",style:{color:"var(--fail)",fontSize:11.5,marginTop:9},children:ve.error}),s.jsxs("div",{className:"row",style:{gap:7,justifyContent:"flex-end",marginTop:10,flexWrap:"wrap"},children:[A&&(ve==null?void 0:ve.reportStored)!==!1&&s.jsx("a",{className:"btn sm primary",href:Sc(A),target:"_blank",rel:"noreferrer",children:"Open assurance report"}),!z&&s.jsx("button",{className:"btn sm ghost",disabled:!!k,onClick:()=>void re(U),children:k===`${U.gate.id}:run`?"Starting…":"Rerun Gate"})]})]}),Re.length>0&&s.jsxs("details",{className:"card",style:{padding:11,marginTop:9},children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsxs("strong",{style:{fontSize:12},children:["Saved local reports · ",Re.length]}),s.jsx("span",{className:"muted",style:{fontSize:11.5,marginLeft:8},children:"Detailed results remain on this machine"})]}),s.jsx("div",{className:"stack",style:{gap:8,marginTop:10},children:Re.map(be=>s.jsxs("div",{className:"card",style:{padding:10},children:[s.jsxs("div",{className:"row spread",style:{gap:8,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("strong",{style:{fontSize:12},children:["Run ",be.runId]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:[new Date(be.completedAt).toLocaleString()," · Gate v",be.gate.version," · Suite ",be.suite.slug,"@",be.suite.version," · Policy v",be.policy.version]})]}),s.jsx("span",{className:`tag ${be.decision==="READY"?"pass":be.decision==="BLOCK"?"fail":"warn"}`,children:be.decision})]}),s.jsxs("div",{className:"muted",style:{fontSize:11.5,marginTop:6},children:[be.counts.passed,"/",be.counts.total," passed · ",be.counts.failed," failed · ",be.counts.errors," errors · ",(be.durationMs/1e3).toFixed(1),"s"]}),s.jsxs("div",{className:"row",style:{gap:7,justifyContent:"flex-end",marginTop:8},children:[s.jsx("button",{className:"btn sm ghost",disabled:ce===be.runId,onClick:()=>void V(be),children:ce===be.runId?"Opening…":"Inspect raw results"}),s.jsx("button",{className:"btn sm ghost",disabled:ce===be.runId,onClick:()=>void V(be,!0),children:"Download JSON"}),s.jsx("a",{className:"btn sm ghost",href:Sc(be.runId),download:!0,children:"Download HTML"}),s.jsx("button",{className:"btn sm ghost",disabled:!!k,onClick:()=>void re(U),children:k===`${U.gate.id}:run`?"Rerunning…":"Rerun Gate"})]})]},be.runId))})]}),(Q==null?void 0:Q.gateSlug)===U.gate.slug&&s.jsxs("div",{className:"card",style:{padding:11,marginTop:9},children:[s.jsxs("div",{className:"row spread",style:{gap:8,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("strong",{children:["Private Runner job ",Q.id]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:4},children:["Gate ",Q.gateSlug,"@",Q.gateVersion," · Run ",Q.runId," · target ",Q.targetFingerprint]})]}),s.jsx("span",{className:`tag ${Q.status==="COMPLETED"?"pass":["EXECUTION_ERROR","CANCELLED","EXPIRED"].includes(Q.status)?"fail":"warn"}`,children:Q.status})]}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:7},children:Q.events.length?Q.events.map(be=>be.type==="SUITE_PROGRESS"&&be.progress?`${be.progress.completed}/${be.progress.total}`:be.type.replaceAll("_"," ")).join(" · "):"Waiting for the private Runner to claim this signed job."}),["QUEUED","CLAIMED"].includes(Q.status)&&s.jsx("div",{className:"row",style:{justifyContent:"flex-end",marginTop:8},children:s.jsx("button",{className:"btn sm ghost",onClick:()=>void O.remoteRunnerJobCancel(Q.id).then(be=>X(be.job)).catch(be=>_(be instanceof Error?be.message:"Could not cancel the Remote Runner job.")),children:"Cancel job"})})]})]})]},U.gate.id)}),s.jsxs("details",{className:"card",style:{padding:12},children:[s.jsxs("summary",{style:{cursor:"pointer"},children:[s.jsx("strong",{style:{fontSize:12},children:"Advanced Gate registry"}),s.jsx("span",{className:"muted",style:{fontSize:11.5,marginLeft:8},children:"Manual creation and registry refresh"})]}),s.jsxs("div",{className:"row",style:{gap:7,justifyContent:"flex-end",marginTop:10},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>b({}),children:"+ Create Gate manually"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{se(),ge(),de()},children:"↻ Refresh Gates"})]})]}),w&&s.jsx(r5,{entry:w.entry,events:w.events,onClose:()=>C(null)}),$&&s.jsx("div",{className:"modal-backdrop gate-report-preview-backdrop",onClick:()=>W(null),children:s.jsxs("div",{className:"modal gate-report-preview",onClick:U=>U.stopPropagation(),children:[s.jsxs("div",{className:"gate-report-preview-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"POST-RUN ASSURANCE ARTIFACT"}),s.jsx("strong",{children:"Prooflane Spine report"}),s.jsxs("span",{children:[$.summary.gate.slug,"@",$.summary.gate.version," · ",$.summary.runId]})]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("a",{className:"btn ghost",href:Sc($.summary.runId),target:"_blank",rel:"noreferrer",children:"Open in new tab"}),s.jsx("a",{className:"btn ghost",href:Sc($.summary.runId),download:!0,children:"Download HTML"}),s.jsx("button",{className:"btn primary",onClick:()=>W(null),children:"Close report"})]})]}),s.jsx("iframe",{title:`Prooflane Spine report for ${$.summary.gate.slug}`,srcDoc:$.html,sandbox:""})]})}),E&&s.jsx(o5,{report:E,onClose:()=>I(null),rerunning:Y.some(U=>U.gateSlug===E.gate.slug&&(U.status==="QUEUED"||U.status==="RUNNING"))||v.some(U=>k===`${U.gate.id}:run`&&U.gate.slug===E.gate.slug),onRerun:()=>{const U=v.find(te=>te.gate.slug===E.gate.slug);U&&re(U)}})]})}function c5({runs:e,onRunDisposition:t}){var _;const[n,a]=p.useState([]),[r,i]=p.useState([]),[o,l]=p.useState(null),[c,u]=p.useState([]),[d,h]=p.useState(null),[g,v]=p.useState({}),[f,y]=p.useState("REVIEW"),[b,m]=p.useState(null),[x,j]=p.useState(null),S=p.useMemo(()=>e.filter(E=>E.status==="COMPLETED"&&E.gate&&E.pillarSummary.some(I=>I.decision!=="PASS"&&I.total>0)),[e]),w=async()=>{try{const[E,I]=await Promise.all([O.learningGenerations(20),O.learnedTests(50)]);a(E.generations),i(I.tests),j(null)}catch(E){j(E instanceof Error?E.message:"Governed learning is unavailable.")}};p.useEffect(()=>{w()},[]);const C=async E=>{var I;m(`run:${E.id}`),j(null);try{const[$,W]=await Promise.all([O.learningFindings(E.id),O.learningDisposition(E.id)]);l(E.id),u($.findings),h(W.disposition),y(((I=W.disposition)==null?void 0:I.finalDecision)??(E.finalDecision==="READY"||E.finalDecision==="BLOCK"?E.finalDecision:"REVIEW")),v(Object.fromEntries($.findings.map(R=>{var H,Y;return[R.findingId,((Y=(H=W.disposition)==null?void 0:H.findings.find(K=>K.findingId===R.findingId))==null?void 0:Y.disposition)??"CONFIRMED"]})))}catch($){j($ instanceof Error?$.message:"Could not load compact learning findings.")}finally{m(null)}},k=async()=>{if(!(!o||!c.length)){m("disposition"),j(null);try{const E=await O.learningDispositionApprove(o,{schemaVersion:"prooflane-learning-disposition-request-v1",finalDecision:f,findings:c.map(I=>({findingId:I.findingId,disposition:g[I.findingId]??"CONFIRMED"}))});h(E.disposition),t(o,E.disposition.finalDecision)}catch(E){j(E instanceof Error?E.message:"Could not approve the learning disposition.")}finally{m(null)}}},N=async()=>{m("generation"),j(null);try{await O.learningGenerate(`learning-ui:${crypto.randomUUID()}`),await w()}catch(E){j(E instanceof Error?E.message:"Could not create the next learning generation.")}finally{m(null)}},L=async(E,I)=>{m(`${I}:${E.id}`),j(null);try{const $=I==="review"?await O.learnedTestReview(E.id):await O.learnedTestApprove(E.id);i(W=>W.map(R=>R.id===$.test.id?$.test:R))}catch($){j($ instanceof Error?$.message:`Could not ${I} the learned test.`)}finally{m(null)}};return s.jsxs("div",{className:"card stack",style:{gap:13,padding:"16px 18px"},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"GOVERNED LEARNING · COMPACT ONLY"}),s.jsx("div",{style:{fontWeight:700},children:"Learning registry"}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:4},children:"Approved Run dispositions can produce DRAFT regression, evolution, or suppression-validation proposals. Raw prompts, responses, documents, tool traffic, and credentials stay local."})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsxs("span",{className:"tag",children:["Generation ",((_=n[0])==null?void 0:_.generation)??"—"]}),s.jsx("button",{className:"btn sm ghost",disabled:b!==null,onClick:()=>void w(),children:"Refresh"}),s.jsx("button",{className:"btn sm primary",disabled:b!==null,onClick:()=>void N(),children:b==="generation"?"Generating…":"Generate next cycle"})]})]}),x&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Learning"}),s.jsx("span",{children:x})]})}),s.jsxs("div",{className:"stack",style:{gap:8},children:[s.jsx("div",{className:"section-label",children:"Compact findings awaiting disposition"}),S.length===0&&s.jsx("span",{className:"muted",style:{fontSize:12},children:"No completed Gate-bound Run currently has REVIEW or BLOCK pillar findings."}),S.map(E=>s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap",border:"1px solid var(--border)",borderRadius:9,padding:"9px 11px"},children:[s.jsxs("div",{children:[s.jsxs("strong",{style:{fontSize:12.5},children:[E.gate.slug,"@",E.gate.version," · ",E.finalDecision]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:[E.id," · Suite ",E.suite.slug,"@",E.suite.version," · Policy v",E.policy.version]})]}),s.jsx("button",{className:"btn sm ghost",disabled:b!==null,onClick:()=>void C(E),children:o===E.id?"Selected":"Review compact findings"})]},E.id))]}),o&&s.jsxs("div",{className:"stack",style:{gap:9,borderTop:"1px solid var(--border)",paddingTop:12},children:[s.jsxs("div",{className:"row spread",children:[s.jsxs("div",{className:"section-label",children:["Human disposition · ",o]}),d&&s.jsx("span",{className:"tag pass",children:"APPROVED · IMMUTABLE"})]}),c.map(E=>s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("strong",{style:{fontSize:12},children:[E.pillar," · ",E.decision]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:[E.counts.failed," failed · ",E.counts.errors," errors · ",E.findingFingerprint]})]}),s.jsx("select",{disabled:!!d,value:g[E.findingId]??"CONFIRMED",onChange:I=>v($=>({...$,[E.findingId]:I.target.value})),children:["CONFIRMED","FALSE_POSITIVE","ACCEPTED_RISK","REMEDIATED"].map(I=>s.jsx("option",{value:I,children:I.replaceAll("_"," ")},I))})]},E.findingId)),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end",flexWrap:"wrap"},children:[s.jsxs("label",{className:"row",style:{gap:6,fontSize:12},children:["Final decision ",s.jsx("select",{disabled:!!d,value:f,onChange:E=>y(E.target.value),children:["READY","REVIEW","BLOCK"].map(E=>s.jsx("option",{children:E},E))})]}),!d&&s.jsx("button",{className:"btn sm primary",disabled:b!==null||c.length===0,onClick:()=>void k(),children:"Approve disposition"})]})]}),s.jsxs("div",{className:"stack",style:{gap:8,borderTop:"1px solid var(--border)",paddingTop:12},children:[s.jsxs("div",{className:"row spread",children:[s.jsx("div",{className:"section-label",children:"Learned proposals"}),s.jsx("span",{className:"muted",style:{fontSize:11},children:"Creator, reviewer, and approver must be distinct identities."})]}),r.length===0&&s.jsx("span",{className:"muted",style:{fontSize:12},children:"No governed learned-test proposals exist yet."}),r.map(E=>s.jsx("div",{style:{border:"1px solid var(--border)",borderRadius:9,padding:"10px 11px"},children:s.jsxs("div",{className:"row spread",style:{gap:10,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("strong",{style:{fontSize:12.5},children:["Generation ",E.generation," · ",E.kind.replaceAll("_"," ")," · ",E.pillar]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:[E.sourceControlId," · utility ",E.utilityScore,"/100 · Gate ",E.lineage.gate.slug,"@",E.lineage.gate.version," · Run ",E.lineage.runId]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5},children:["finding ",E.lineage.findingId," → disposition ",E.lineage.dispositionId," · ",E.proposalHash]})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[s.jsx("span",{className:`tag ${E.state==="APPROVED"?"pass":E.state==="SUPPRESSED"||E.state==="SUPERSEDED"?"":"warn"}`,children:E.state}),E.state==="DRAFT"&&s.jsx("button",{className:"btn sm ghost",disabled:b!==null,onClick:()=>void L(E,"review"),children:"Review"}),E.state==="REVIEWED"&&s.jsx("button",{className:"btn sm primary",disabled:b!==null,onClick:()=>void L(E,"approve"),children:"Approve"})]})]})},E.id))]})]})}function d5({onClose:e,gateSlug:t}){const[n,a]=p.useState(null),[r,i]=p.useState(null),[o,l]=p.useState(null),[c,u]=p.useState([]),[d,h]=p.useState(!1),[g,v]=p.useState(null),[f,y]=p.useState(!1),[b,m]=p.useState(!1),x=async()=>{h(!0),v(null),y(!1);try{const w=await O.ciToken();a(w.token),i(w.expiresAt),l(w.projectIds[0]??null),u(w.scopes)}catch(w){const C=w;y(!!C.upgrade),v(C.message||"Could not generate a CI token.")}finally{h(!1)}},j=async()=>{if(n)try{await navigator.clipboard.writeText(n),m(!0),setTimeout(()=>m(!1),1500)}catch{}},S=`# GitHub Actions secrets
|
|
69
|
-
PROOFLANE_TOKEN=<the token shown above>
|
|
70
|
-
PROOFLANE_PROJECT=${o??"<project-id>"}
|
|
71
|
-
|
|
72
|
-
npx --yes @prooflane/cli@latest gate "$MCP_CONFIG" \\
|
|
73
|
-
--gate ${t} \\
|
|
74
|
-
--github`;return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"modal",onClick:w=>w.stopPropagation(),style:{maxWidth:640},children:[s.jsx("div",{className:"screen-title",style:{marginBottom:4},children:"Scoped GitHub CI token"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:14},children:"This project-bound service credential resolves the approved signed Gate, its exact Suite and Policy pins, and creates compact Run records. It cannot write governance state or administer Prooflane."}),s.jsxs("div",{className:"card mono",style:{padding:10,fontSize:11,marginBottom:14},children:["GitHub selector: --gate ",t,s.jsx("br",{}),s.jsx("span",{className:"muted",children:"The immutable slug is used in CI; changing the Gate display name does not change this command."})]}),n?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"card mono",style:{padding:12,fontSize:12,wordBreak:"break-all",background:"var(--panel-2, rgba(128,128,128,0.06))"},children:n}),s.jsxs("div",{className:"row spread",style:{marginTop:8,alignItems:"center"},children:[s.jsxs("span",{className:"muted",style:{fontSize:11.5},children:["Expires ",r?new Date(r*1e3).toLocaleDateString():"in 90 days"," · shown once — copy it now."]}),s.jsx("button",{className:"btn sm ghost",onClick:j,children:b?"Copied ✓":"Copy token"})]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:8},children:["Project ",o," · scopes ",c.join(", ")]}),s.jsx("div",{className:"section-label",style:{marginTop:16},children:"GitHub Actions command"}),s.jsx("pre",{className:"card mono",style:{padding:12,fontSize:11.5,whiteSpace:"pre-wrap",lineHeight:1.5,margin:0,overflowX:"auto"},children:S}),s.jsx("div",{className:"row",style:{justifyContent:"flex-end",marginTop:16},children:s.jsx("button",{className:"btn primary",onClick:e,children:"Done"})})]}):s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{className:"drift dirty",style:{marginBottom:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:`tag ${f?"warn":"fail"}`,children:f?"upgrade":"error"}),s.jsx("span",{style:{fontSize:12.5},children:g})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:e,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:x,disabled:d,children:d?"Generating…":"Generate CI token"})]})]})]})})}const u5={tool:"Tool",security:"Security",rag:"RAG",prompt:"Prompt",contract:"Contract",performance:"Performance"},h5=["mcp-protocol","tool-abuse","resource"];function nC(e){var t,n,a;if(e.determinism)return e.determinism;if(e.pillar==="tool"||e.pillar==="contract")return"deterministic";if(e.pillar==="security"){const r=e.security,i=!!((t=r==null?void 0:r.packs)!=null&&t.length||(n=r==null?void 0:r.categories)!=null&&n.length||(a=r==null?void 0:r.attackIds)!=null&&a.length),o=(r==null?void 0:r.layers)??[];return!i&&o.length&&o.every(l=>h5.includes(l))?"deterministic":"non-deterministic"}return"non-deterministic"}function Uv(e){return`tag-${e}`.replace(/[^A-Za-z0-9_.:/-]+/g,"-").slice(0,128)}function p5(e){var t,n;return e.pillar==="tool"||e.pillar==="contract"?nC(e)==="deterministic":e.pillar!=="rag"||e.determinism==="non-deterministic"||!((t=e.rag)!=null&&t.tool)||(n=e.rag.expectedAnswer)!=null&&n.length?!1:e.rag.judgeStrategy===void 0||e.rag.judgeStrategy==="deterministic"}function aC(e,t){const n=t.filter(o=>o.tags.includes(e)),a=[...new Set(n.map(o=>o.pillar))],r=a.length===1&&["prompt","rag","contract","security","performance","tool","model"].includes(a[0])?a[0]:"tool",i=Uv(e);return n.length>0&&n.every(p5)?{id:i,label:`Reviewed test group #${e}`,pillar:r,executionType:"LOCAL_DETERMINISTIC",executor:"TAG_REFERENCE",operation:"tag.execute",localRef:{kind:"TAG",name:e}}:{id:i,label:`Reviewed test group #${e}`,pillar:r,executionType:"LEASED_INTELLIGENCE",intelligenceRef:{controlId:i,leaseRequired:!0}}}function rC(e){return e.some(t=>t.executionType==="LEASED_INTELLIGENCE")?"HYBRID":"LOCAL_ONLY"}function m5({tags:e,tests:t,policies:n,targetFingerprint:a,requiredCapabilities:r,onSave:i,onClose:o}){var C;const[l,c]=p.useState(""),[u,d]=p.useState(""),[h,g]=p.useState([]),v=n.filter(k=>{var N;return(N=k.approvedVersion)==null?void 0:N.manifestHash}),[f,y]=p.useState(((C=v[0])==null?void 0:C.policy.id)??""),[b,m]=p.useState(!1),[x,j]=p.useState(null),S=l.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),w=async()=>{var L;const k=v.find(_=>_.policy.id===f);if(S.length<2||!h.length||!((L=k==null?void 0:k.approvedVersion)!=null&&L.manifestHash)){j("Give the Suite a name, select a reviewed test group, and choose an APPROVED signed Policy.");return}const N=h.map(_=>aC(_,t));m(!0),j(null);try{await i({slug:S,displayName:l.trim(),...u.trim()?{description:u.trim()}:{},manifest:{schemaVersion:"prooflane-suite-manifest-v1",executionClass:rC(N),controls:N,...a?{targetFingerprint:a}:{},...r!=null&&r.length?{requiredCapabilities:r}:{},policyRef:{policyId:k.policy.id,version:k.approvedVersion.version,manifestHash:k.approvedVersion.manifestHash},privacy:{rawEvidence:"LOCAL_ONLY",synchronization:"COMPACT_ONLY"}}}),o()}catch(_){j(_ instanceof Error?_.message:"Could not create the Cloud Suite.")}finally{m(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:o,children:s.jsxs("div",{className:"modal",onClick:k=>k.stopPropagation(),style:{maxWidth:680},children:[s.jsx("div",{className:"screen-title",children:"Configure a Release Gate"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:16},children:"Choose the reviewed test groups and exact approved Policy for this release check. Prooflane saves the underlying Suite as a DRAFT; review and signing happen together from the stable Gate card."}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Release Gate name"}),s.jsx("input",{value:l,onChange:k=>c(k.target.value),placeholder:"RAG nightly"})]}),s.jsxs("div",{className:"mono muted",style:{fontSize:11.5,marginTop:5},children:["Suite identity: ",S||"rag-nightly"]}),s.jsxs("label",{className:"field",style:{marginTop:14},children:[s.jsx("span",{children:"Description"}),s.jsx("textarea",{value:u,maxLength:600,onChange:k=>d(k.target.value),placeholder:"Nightly governed RAG regression Suite"})]}),s.jsxs("label",{className:"field",style:{marginTop:14},children:[s.jsx("span",{children:"Approved Policy"}),s.jsxs("select",{value:f,onChange:k=>y(k.target.value),children:[s.jsx("option",{value:"",children:"Choose a signed Policy"}),v.map(k=>s.jsxs("option",{value:k.policy.id,children:[k.policy.displayName," · v",k.approvedVersion.version]},k.policy.id))]})]}),!v.length&&s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:7},children:"Create, review, and approve a Policy before this Suite can become executable."}),s.jsx("div",{className:"section-label",style:{marginTop:16},children:"Reviewed test groups"}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:e.map(k=>s.jsxs("button",{className:`btn sm ${h.includes(k)?"primary":"ghost"}`,onClick:()=>g(N=>N.includes(k)?N.filter(L=>L!==k):[...N,k]),children:["#",k]},k))}),!e.length&&s.jsx("div",{className:"muted",style:{fontSize:12},children:"Capture and tag a test before creating a Suite."}),x&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:x})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:18},children:[s.jsx("button",{className:"btn ghost",onClick:o,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:b||!e.length,onClick:w,children:b?"Saving setup…":"Save Gate setup"})]})]})})}function f5({entry:e,tags:t,tests:n,policies:a,currentTargetFingerprint:r,currentRequiredCapabilities:i,onSave:o,onClose:l}){var S,w;const c=t.filter(C=>e.latestVersion.manifest.controls.some(k=>k.id===Uv(C))),[u,d]=p.useState(c),h=a.filter(C=>{var k;return(k=C.approvedVersion)==null?void 0:k.manifestHash}),[g,v]=p.useState(((S=e.latestVersion.manifest.policyRef)==null?void 0:S.policyId)??((w=h[0])==null?void 0:w.policy.id)??""),[f,y]=p.useState(!1),[b,m]=p.useState(null),x=e.latestVersion.state!=="DRAFT",j=async()=>{var _;const C=new Set(t.map(Uv)),k=e.latestVersion.manifest.controls.filter(E=>!C.has(E.id)),N=u.map(E=>aC(E,n)),L=h.find(E=>E.policy.id===g);if(!k.length&&!N.length){m("Select at least one reviewed test group.");return}if(!((_=L==null?void 0:L.approvedVersion)!=null&&_.manifestHash)){m("Choose an APPROVED signed Policy.");return}y(!0),m(null);try{const E=[...k,...N];await o({...e.latestVersion.manifest,executionClass:rC(E),controls:E,...r?{targetFingerprint:r}:{},...i!=null&&i.length?{requiredCapabilities:i}:{},policyRef:{policyId:L.policy.id,version:L.approvedVersion.version,manifestHash:L.approvedVersion.manifestHash}}),l()}catch(E){m(E instanceof Error?E.message:"Could not save the Suite version.")}finally{y(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:l,children:s.jsxs("div",{className:"modal",onClick:C=>C.stopPropagation(),style:{maxWidth:680},children:[s.jsx("div",{className:"screen-title",children:x?`Create v${e.latestVersion.version+1} DRAFT`:`Edit ${e.suite.slug}@${e.latestVersion.version}`}),s.jsx("div",{className:"screen-sub",style:{marginBottom:16},children:x?`Version ${e.latestVersion.version} is immutable. Saving creates a new DRAFT that supersedes it; the approved alias does not move.`:"Only a DRAFT can be changed. Review freezes its manifest before signing."}),s.jsx("div",{className:"section-label",children:"Reviewed test groups"}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:t.map(C=>s.jsxs("button",{className:`btn sm ${u.includes(C)?"primary":"ghost"}`,onClick:()=>d(k=>k.includes(C)?k.filter(N=>N!==C):[...k,C]),children:["#",C]},C))}),s.jsxs("label",{className:"field",style:{marginTop:14},children:[s.jsx("span",{children:"Exact approved Policy pin"}),s.jsxs("select",{value:g,onChange:C=>v(C.target.value),children:[s.jsx("option",{value:"",children:"Choose a signed Policy"}),h.map(C=>s.jsxs("option",{value:C.policy.id,children:[C.policy.displayName," · v",C.approvedVersion.version]},C.policy.id))]})]}),b&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:b})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:18},children:[s.jsx("button",{className:"btn ghost",onClick:l,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:f,onClick:j,children:f?"Saving…":x?"Create new DRAFT":"Save DRAFT"})]})]})})}function g5({onSynchronized:e}){const[t,n]=p.useState(null),[a,r]=p.useState(!1),[i,o]=p.useState([]),[l,c]=p.useState(!1),[u,d]=p.useState(null),h=async()=>{try{const f=await O.localSuiteMigrationStatus();n(f),o(f.suites.filter(y=>y.action==="CREATE_SUITE_DRAFT"||y.action==="CREATE_VERSION_DRAFT").map(y=>y.slug)),d(null)}catch(f){d(f instanceof Error?f.message:"Could not inspect local Suite migration status.")}};if(p.useEffect(()=>{h()},[]),!t&&!u||t&&!t.suites.length&&!t.issues.length)return null;const g=(t==null?void 0:t.suites.filter(f=>f.action==="CREATE_SUITE_DRAFT"||f.action==="CREATE_VERSION_DRAFT"))??[],v=async()=>{const f=g.filter(y=>i.includes(y.slug)).map(y=>({slug:y.slug,localFingerprint:y.localFingerprint}));if(!f.length){d("Select at least one reviewed local Suite migration.");return}c(!0),d(null);try{await O.localSuiteMigrationSync(f),await h(),await e()}catch(y){d(y instanceof Error?y.message:"Local Suite migration failed safely.")}finally{c(!1)}};return s.jsxs("div",{className:"card",style:{padding:"14px 16px",borderStyle:"dashed"},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"EXISTING LOCAL SUITES"}),s.jsxs("div",{style:{fontWeight:700},children:[(t==null?void 0:t.pending)??0," local Suite",(t==null?void 0:t.pending)===1?"":"s"," not synchronized"]}),s.jsx("div",{className:"muted",style:{fontSize:12,marginTop:5},children:"Migration creates Cloud DRAFT versions only. Local files are never changed or deleted, and approval remains a separate explicit action."})]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>r(f=>!f),children:a?"Close review":"Review & Sync"})]}),u&&s.jsx("div",{className:"drift dirty",style:{marginTop:10},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"migration"}),s.jsx("span",{children:u})]})}),a&&t&&s.jsxs("div",{className:"stack",style:{gap:8,marginTop:13},children:[t.suites.map(f=>{const y=f.action==="CREATE_SUITE_DRAFT"||f.action==="CREATE_VERSION_DRAFT";return s.jsxs("label",{className:"card",style:{padding:"10px 12px",display:"flex",gap:10,alignItems:"flex-start"},children:[y?s.jsx("input",{type:"checkbox",checked:i.includes(f.slug),onChange:()=>o(b=>b.includes(f.slug)?b.filter(m=>m!==f.slug):[...b,f.slug])}):s.jsx("span",{className:`tag ${f.state==="IN_SYNC"?"pass":"warn"}`,children:f.state}),s.jsxs("span",{style:{flex:1},children:[s.jsxs("span",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsx("strong",{children:f.slug}),s.jsxs("span",{className:"tag informational",children:["local v",f.localVersion," ",f.localStatus]}),y&&s.jsx("span",{className:"tag warn",children:f.action.replaceAll("_"," ")})]}),s.jsxs("span",{className:"mono muted",style:{display:"block",fontSize:10.5,marginTop:4},children:[f.localFingerprint," · ",f.testCount," tests"]}),s.jsxs("span",{className:"muted",style:{display:"block",fontSize:11.5,marginTop:4},children:[f.reason,f.genericCompatibility.unsupported?` ${f.genericCompatibility.unsupported} test(s) require a compatible local/private runner before execution.`:""]})]})]},`${f.slug}:${f.localFingerprint}`)}),t.issues.map(f=>s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"invalid"}),s.jsxs("span",{children:[f.fileName,": ",f.error]})]})},f.fileName)),s.jsx("div",{className:"row",style:{justifyContent:"flex-end",gap:8},children:s.jsx("button",{className:"btn sm primary",disabled:l||!g.some(f=>i.includes(f.slug)),onClick:()=>void v(),children:l?"Creating DRAFTs…":"Create selected Cloud DRAFTs"})})]})]})}function v5({tags:e,initial:t,onSave:n,onClose:a}){const[r,i]=p.useState((t==null?void 0:t.name)??""),[o,l]=p.useState((t==null?void 0:t.tags)??[]),[c,u]=p.useState((t==null?void 0:t.minScore)??80),[d,h]=p.useState((t==null?void 0:t.repeat)??1),[g,v]=p.useState((t==null?void 0:t.deterministicOnly)??!1),[f,y]=p.useState(!1),[b,m]=p.useState(null),x=((t==null?void 0:t.id)??r.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")).slice(0,64),j=async()=>{if(x.length<2||o.length===0){m("Give the legacy group a name and select at least one test group.");return}y(!0),m(null);const S=new Date().toISOString();try{await n({id:x,name:r.trim(),tags:o,minScore:c,repeat:d,deterministicOnly:g,createdAt:(t==null?void 0:t.createdAt)??S,updatedAt:S}),a()}catch(w){m(w instanceof Error?w.message:"Could not save the legacy local regression group.")}finally{y(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:a,children:s.jsxs("div",{className:"modal",onClick:S=>S.stopPropagation(),style:{maxWidth:680},children:[s.jsx("div",{className:"screen-title",children:t?"Edit legacy local group":"Create a legacy local regression group"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:16},children:"P8 compatibility artifact only. This local tag group is not a governed Cloud Gate and cannot be resolved by the public Runner with --gate."}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Legacy group name"}),s.jsx("input",{value:r,disabled:!!t,onChange:S=>i(S.target.value),placeholder:"Smoke test"})]}),s.jsx("div",{className:"section-label",style:{marginTop:16},children:"Scans and test groups"}),s.jsx("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:e.map(S=>s.jsxs("button",{className:`btn sm ${o.includes(S)?"primary":"ghost"}`,onClick:()=>l(w=>w.includes(S)?w.filter(C=>C!==S):[...w,S]),children:["#",S]},S))}),!e.length&&s.jsx("div",{className:"muted",style:{fontSize:12},children:"Capture and tag a test from Security, RAG, Prompts, Contracts, or MCP Inspector first."}),s.jsxs("div",{className:"row",style:{gap:12,marginTop:16,flexWrap:"wrap"},children:[s.jsxs("label",{className:"field",style:{minWidth:150},children:[s.jsx("span",{children:"Minimum score"}),s.jsx("input",{type:"number",min:0,max:100,value:c,onChange:S=>u(Math.max(0,Math.min(100,Number(S.target.value))))})]}),s.jsxs("label",{className:"field",style:{minWidth:150},children:[s.jsx("span",{children:"Variable-test repetitions"}),s.jsx("input",{type:"number",min:1,max:10,value:d,onChange:S=>h(Math.max(1,Math.min(10,Number(S.target.value))))})]})]}),s.jsxs("label",{className:"row",style:{gap:8,marginTop:12,fontSize:12.5},children:[s.jsx("input",{type:"checkbox",checked:g,onChange:S=>v(S.target.checked)})," Run deterministic tests only"]}),b&&s.jsx("div",{className:"drift dirty",style:{marginTop:12},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:b})]})}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:8,marginTop:18},children:[s.jsx("button",{className:"btn ghost",onClick:a,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:f||!e.length,onClick:j,children:f?"Saving…":"Save legacy group"})]})]})})}function y5({gate:e,open:t,onClose:n}){var _;const[a,r]=p.useState(null),[i,o]=p.useState([]),[l,c]=p.useState(),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[v,f]=p.useState(null),[y,b]=p.useState(null),m=a?["READY","REVIEW","BLOCK","FAILED","CANCELLED"].includes(a.lifecycleState):!1,x=async E=>{const I=await O.assuranceRun(E);r(I.run),c(I.evidence),I.error&&b(I.error)},j=async()=>{d(!0),b(null),o([]),c(void 0);try{const E=await O.assuranceGateRun(e.gateId);r(E.run);const I=O.assuranceRunEvents(E.run.id,$=>{o(W=>W.some(R=>R.sequence===$.sequence)?W:[...W,$].sort((R,H)=>R.sequence-H.sequence)),$.type==="GATE_DECIDED"&&r(W=>W&&{...W,lifecycleState:$.decision??"REVIEW",decision:$.decision}),["RUN_COMPLETED","RUN_CANCELLED","RUN_FAILED"].includes($.type)&&(I(),x(E.run.id))},()=>{x(E.run.id).catch(()=>b("Live stream disconnected. Reconnect will resume from the last event."))})}catch(E){b(E instanceof Error?E.message:"Could not start the legacy assurance binding run.")}finally{d(!1)}};p.useEffect(()=>{j()},[e.gateId]);const S=i.filter(E=>E.type==="TEST_COMPLETED"),w=["prompt","rag","contract","security","performance"],C=i.filter(E=>E.type==="FINDING_CREATED"),k=async()=>{if(a)try{await O.assuranceRunCancel(a.id),r({...a,lifecycleState:"CANCELLED"})}catch(E){b(E instanceof Error?E.message:"Could not cancel run.")}},N=E=>{if(!a)return;const I=URL.createObjectURL(new Blob([E],{type:"text/html;charset=utf-8"})),$=document.createElement("a"),W=e.gateId.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"gate";$.href=I,$.download=`prooflane-${W}-${a.id}.html`,$.click(),window.setTimeout(()=>URL.revokeObjectURL(I),6e4)},L=async E=>{if(!(!a||!l)){g(!0),b(null);try{const I=await O.assuranceRunReport(a.id);E?N(I):f(I)}catch(I){b(I instanceof Error?I.message:"Could not create the Gate report.")}finally{g(!1)}}};return t?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"modal-backdrop gate-run-backdrop",onClick:n,children:s.jsxs("div",{className:"modal gate-run-console",onClick:E=>E.stopPropagation(),children:[s.jsxs("div",{className:"gate-run-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"LEGACY LOCAL ASSURANCE BINDING · LIVE RUN"}),s.jsx("h2",{children:e.name??e.gateId}),s.jsxs("div",{className:"mono muted",children:["Compatibility binding, not a governed Cloud Gate · ",e.target?`${e.target} · `:"","Suite ",e.suiteId," v",e.suiteVersion," · ",e.testCount??"—"," runnable tests · Policy ",e.policyVersion,a?` · ${a.id}`:""]})]}),s.jsx("div",{className:`gate-decision ${((_=a==null?void 0:a.decision)==null?void 0:_.toLowerCase())??(a==null?void 0:a.lifecycleState.toLowerCase())??"queued"}`,children:(a==null?void 0:a.decision)??(a==null?void 0:a.lifecycleState)??"QUEUED"})]}),s.jsxs("div",{className:"gate-run-body",children:[s.jsxs("div",{className:"gate-progress-grid",children:[s.jsxs("div",{className:"gate-progress-total",children:[s.jsxs("strong",{children:[S.length," / ",e.testCount??S.length]}),s.jsx("span",{children:"suite tests completed"})]}),w.map(E=>{var $;const I=Xz(E,($=e.coverage)==null?void 0:$[E],i);return s.jsxs("div",{className:"gate-progress-row",children:[s.jsx("span",{children:E}),s.jsx("div",{children:s.jsx("i",{style:{width:`${I.progressPercent}%`}})}),s.jsx("b",{className:I.tone,children:I.label}),s.jsx("small",{children:I.countLabel})]},E)})]}),(l==null?void 0:l.policyEvaluation)&&s.jsxs("div",{className:"gate-policy-evaluation",children:[s.jsxs("div",{className:"gate-policy-evaluation-head",children:[s.jsxs("div",{children:[s.jsxs("strong",{children:["Policy decision · ",l.policyEvaluation.policyName]}),s.jsx("span",{children:l.policyEvaluation.summary}),s.jsx("code",{children:l.policyEvaluation.aggregateRuleId})]}),s.jsx("span",{className:`tag ${l.policyEvaluation.gateDecision==="READY"?"pass":l.policyEvaluation.gateDecision==="BLOCK"?"fail":"warn"}`,children:l.policyEvaluation.gateDecision==="REVIEW"&&l.policyEvaluation.reviewRequired?"HUMAN REVIEW REQUIRED":l.policyEvaluation.gateDecision})]}),s.jsx("div",{className:"gate-policy-pillars",children:l.policyEvaluation.pillars.map(E=>s.jsxs("div",{className:"gate-policy-pillar",children:[s.jsxs("span",{children:[E.pillar,s.jsx("b",{className:E.disposition.toLowerCase(),children:E.disposition})]}),s.jsx("code",{title:E.ruleIds.join(" · "),children:E.ruleIds.join(" · ")})]},E.pillar))})]}),s.jsxs("div",{className:"gate-console-grid",children:[s.jsxs("div",{className:"gate-terminal",children:[s.jsxs("div",{className:"gate-terminal-title",children:[s.jsx("span",{children:"Execution stream"}),s.jsx("span",{className:"live-dot",children:"LIVE"})]}),s.jsx("div",{className:"gate-terminal-lines",children:i.length?i.map(E=>{var I;return s.jsxs("div",{children:[s.jsx("time",{children:new Date(E.timestamp).toLocaleTimeString()}),s.jsx("span",{className:`event-mark ${((I=E.status)==null?void 0:I.toLowerCase())??""}`,children:E.type==="TEST_COMPLETED"?E.status==="PASS"?"✓":E.status==="FAIL"?"×":"!":"›"}),s.jsx("code",{children:E.type.replaceAll("_"," ").toLowerCase()}),s.jsx("p",{children:E.message??[E.pillar,E.testId].filter(Boolean).join(" · ")})]},E.sequence)}):s.jsx("div",{className:"gate-terminal-empty",children:"Dispatching the pinned suite to the shared runner…"})})]}),s.jsxs("div",{className:"gate-findings",children:[s.jsxs("div",{className:"gate-terminal-title",children:[s.jsx("span",{children:"Findings"}),s.jsx("span",{children:C.length})]}),C.length?C.map(E=>{var I;return s.jsxs("div",{className:`gate-finding ${(I=E.status)==null?void 0:I.toLowerCase()}`,children:[s.jsx("strong",{children:E.status}),s.jsxs("span",{children:[E.pillar," · ",E.testId]}),s.jsx("p",{children:E.message})]},E.sequence)}):s.jsx("div",{className:"gate-terminal-empty",children:"Findings appear here as evidence is produced."})]})]}),l&&s.jsxs("div",{className:"gate-evidence",children:[s.jsxs("div",{children:[s.jsx("span",{children:"EVIDENCE FINGERPRINT"}),s.jsx("code",{children:l.fingerprint})]}),s.jsxs("div",{children:[s.jsx("span",{children:"VERIFIED"}),s.jsx("strong",{children:l.counts.PASS??0})]}),s.jsxs("div",{children:[s.jsx("span",{children:"REVIEW"}),s.jsx("strong",{children:(l.counts.REVIEW??0)+(l.counts.INCONCLUSIVE??0)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"FAILED"}),s.jsx("strong",{children:(l.counts.FAIL??0)+(l.counts.ERROR??0)})]})]}),y&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:y})]})})]}),s.jsxs("div",{className:"gate-run-actions",children:[s.jsx("button",{className:"btn ghost",onClick:n,children:"Close"}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap",justifyContent:"flex-end"},children:[a&&!m&&s.jsx("button",{className:"btn ghost",onClick:k,children:"Cancel run"}),m&&s.jsx("button",{className:"btn ghost",onClick:()=>void j(),disabled:u,children:"Rerun Gate"}),m&&s.jsx("button",{className:"btn ghost",disabled:!l||h,onClick:()=>void L(!0),children:"Download HTML"}),s.jsx("button",{className:"btn ghost",disabled:!l,onClick:()=>l&&navigator.clipboard.writeText(JSON.stringify({run:a,evidence:l},null,2)),children:"Copy evidence"}),m&&s.jsx("button",{className:"btn primary",disabled:!l||h,onClick:()=>void L(!1),children:h?"Preparing…":"Open Spine report"})]})]})]})}),v&&s.jsx("div",{className:"modal-backdrop gate-report-preview-backdrop",onClick:()=>f(null),children:s.jsxs("div",{className:"modal gate-report-preview",onClick:E=>E.stopPropagation(),children:[s.jsxs("div",{className:"gate-report-preview-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"POST-RUN ASSURANCE ARTIFACT"}),s.jsx("strong",{children:"Prooflane Spine report"}),s.jsxs("span",{children:[e.name??e.gateId," · ",a==null?void 0:a.id]})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:()=>N(v),children:"Download HTML"}),s.jsx("button",{className:"btn primary",onClick:()=>f(null),children:"Close report"})]})]}),s.jsx("iframe",{title:`Prooflane Spine report for ${e.name??e.gateId}`,srcDoc:v,sandbox:""})]})})]}):null}function x5({hostedRunner:e=!1,focusedLegacyGateId:t=null,onFocusedLegacyGateConsumed:n,focusedSuiteSlug:a=null,onFocusedSuiteConsumed:r}){const[i,o]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState(null),[h,g]=p.useState([]),[v,f]=p.useState([]),[y,b]=p.useState([]),[m,x]=p.useState([]),[j,S]=p.useState(null),[w,C]=p.useState([]),[k,N]=p.useState(null),[L,_]=p.useState(!1),[E,I]=p.useState(null),[$,W]=p.useState(!1),[R,H]=p.useState(null),[Y,K]=p.useState(null),[ce,F]=p.useState(null),[ie,ue]=p.useState(),[oe,B]=p.useState(),Q=()=>{O.suitesList().then(le=>{f(le.suites),S(null)}).catch(le=>S(le instanceof Error?le.message:"Cloud Suite registry is unavailable.")),O.policiesList().then(le=>b(le.policies)).catch(le=>S(le instanceof Error?le.message:"Cloud Policy registry is unavailable.")),O.governedRuns(20).then(le=>{x(le.runs),Eu(le.runs)}).catch(()=>x([])),O.intelligenceSurface().then(le=>{ue(le!=null&&le.connected&&typeof le.governedTargetFingerprint=="string"?le.governedTargetFingerprint:void 0),B(le!=null&&le.connected&&Array.isArray(le.governedCapabilities)?le.governedCapabilities:void 0)}).catch(()=>{ue(void 0),B(void 0)});const V=e?Promise.resolve({version:"prooflane-assurance-gates-v1",gates:[]}):O.legacyAssuranceBindings().catch(()=>({version:"prooflane-assurance-gates-v1",gates:[]}));return Promise.all([O.tagsList(),O.legacyRegressionGroupsList().catch(()=>({version:"prooflane-regression-gates-v1",gates:[]})),V]).then(([le,ee,xe])=>{o(le.config.tests),g(ee.gates),C(xe.gates),d(null);const Fe=t?xe.gates.find(Be=>Be.gateId===t):void 0;Fe&&(n==null||n(),N(Fe),_(!0))}).catch(le=>d(le instanceof Error?le.message:"Could not load tagged tests.")).finally(()=>c(!1))};p.useEffect(()=>{Q()},[e,t]),p.useEffect(()=>{if(!a)return;let V=!1;return O.suitesList().then(le=>{if(V)return;f(le.suites);const ee=le.suites.find(xe=>xe.suite.slug===a);if(!ee){S(`Prepared Suite ${a} is not available in the governed registry yet.`);return}S(null),K(ee.suite.slug),r==null||r()}).catch(le=>{V||S(le instanceof Error?le.message:"Cloud Suite registry is unavailable.")}),()=>{V=!0}},[a,r]);const X=async V=>{try{const le=await O.tagRemove(V);o(le.config.tests)}catch(le){d(le instanceof Error?le.message:"Could not remove the test.")}},me=new Map;for(const V of i)for(const le of V.tags){const ee=me.get(le)??[];ee.push(V),me.set(le,ee)}const fe=[...me.keys()].sort((V,le)=>V.localeCompare(le)),P=async V=>{const le=await O.legacyRegressionGroupSave(V);g(le.gates)},T=async V=>{const le=await O.legacyRegressionGroupRemove(V);g(le.gates)},he=async V=>{const le=await O.suiteCreate(V);f(ee=>[le,...ee.filter(xe=>xe.suite.slug!==le.suite.slug)])},q=async V=>{window.confirm(`Archive Suite ${V.suite.slug}? Its Gate remains separately governed and must be deprecated before it can be archived.`)&&(await O.suiteArchive(V.suite.slug),f(le=>le.filter(ee=>ee.suite.slug!==V.suite.slug)))},se=(V,le)=>f(ee=>ee.map(xe=>xe.suite.slug===V?{...xe,latestVersion:le}:xe)),ge=async(V,le)=>{const ee=V.latestVersion.state==="DRAFT"?await O.suiteUpdateDraft(V.suite.slug,V.latestVersion.version,le):await O.suiteCreateVersion(V.suite.slug,{manifest:le,supersedesVersionId:V.latestVersion.id});se(V.suite.slug,ee.version)},de=async(V,le)=>{S(null);try{const ee=le==="review"?await O.suiteReview(V.suite.slug,V.latestVersion.version):le==="approve"?await O.suiteApprove(V.suite.slug,V.latestVersion.version):await O.suiteDeprecate(V.suite.slug,V.latestVersion.version);se(V.suite.slug,ee.version)}catch(ee){S(ee instanceof Error?ee.message:`Could not ${le} the Suite version.`)}},Ne=async V=>{S(null);try{let le=V.latestVersion;if(le.state==="DRAFT"&&(le=(await O.suiteReview(V.suite.slug,le.version)).version,se(V.suite.slug,le)),le.state==="REVIEWED"&&(le=(await O.suiteApprove(V.suite.slug,le.version)).version,se(V.suite.slug,le)),le.state!=="APPROVED"||!le.manifestHash||!le.signature)throw new Error(`Suite ${V.suite.slug}@${le.version} did not reach an APPROVED signed state.`);return{...V,latestVersion:le}}catch(le){const ee=le instanceof Error?le.message:"Could not review and approve the Suite version.";throw S(ee),le instanceof Error?le:new Error(ee)}},Oe=async V=>{S(null);try{const le=await O.suiteAssessDrift(V.suite.slug);le.draft?se(V.suite.slug,le.draft):await Q()}catch(le){S(le instanceof Error?le.message:"Could not govern target drift.")}},_e=w.filter(V=>V.currentTargetMatch!==!1),re=w.filter(V=>V.currentTargetMatch===!1);return s.jsxs("div",{className:"stack",style:{gap:20},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"center",flexWrap:"wrap",gap:10},children:[s.jsx("span",{className:"muted",style:{fontSize:12.5,maxWidth:"60ch"},children:"Govern first-class Cloud Gates that pin one exact approved signed Suite and Policy. The same Gate slug resolves to the same signed release identity in the UI, CLI, and GitHub Actions."}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn sm primary",onClick:()=>W(!0),children:"+ Configure Release Gate"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>I("new"),children:"+ Legacy local group"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>{c(!0),Q()},title:"Reload captured tests",children:"↻ Refresh"})]})]}),s.jsx("div",{className:"card",style:{padding:"11px 14px",borderStyle:"dashed"},children:s.jsx("span",{className:"muted",style:{fontSize:12},children:"Capture runnable tests locally and group them with tags. Governed Suites synchronize only bounded control references and compact metadata; raw prompts, documents, answers, credentials, and evidence stay local."})}),$&&s.jsx(m5,{tags:fe,tests:i,policies:y,targetFingerprint:ie,requiredCapabilities:oe,onSave:he,onClose:()=>W(!1)}),R&&s.jsx(f5,{entry:R,tags:fe,tests:i,policies:y,currentTargetFingerprint:ie,currentRequiredCapabilities:oe,onSave:V=>ge(R,V),onClose:()=>H(null)}),E&&s.jsx(v5,{tags:fe,initial:E==="new"?void 0:E,onSave:P,onClose:()=>I(null)}),k&&s.jsx(y5,{gate:k,open:L,onClose:()=>_(!1)},k.gateId),ce&&s.jsx(d5,{gateSlug:ce,onClose:()=>F(null)}),s.jsx(g5,{onSynchronized:Q}),j&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag warn",children:"Gate setup"}),s.jsx("span",{children:j})]})}),s.jsx(l5,{suites:v,policies:y,governedRuns:m,currentTargetFingerprint:ie,focusedSuiteSlug:Y,onApproveSuite:Ne,onEditSuite:H,onArchiveSuite:q,onDeprecateSuite:V=>de(V,"deprecate"),onReviewSuiteDrift:Oe,onOpenCi:F,onGovernedRunsChanged:V=>{x(V),Eu(V)},onRunCompleted:V=>{Eu([V.run]),x(le=>[V.run,...le.filter(ee=>ee.id!==V.run.id)])}}),s.jsx(c5,{runs:m,onRunDisposition:(V,le)=>{const ee=m.find(xe=>xe.id===V);ee&&Eu([{...ee,finalDecision:le}]),x(xe=>xe.map(Fe=>Fe.id===V?{...Fe,finalDecision:le}:Fe))}}),s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsx("div",{className:"section-label",children:"Governed CI Runs"}),m.length===0&&s.jsx("div",{className:"card",style:{padding:18},children:s.jsx("span",{className:"muted",style:{fontSize:12.5},children:"No GitHub CI Runs have been recorded for this project. Compact decisions appear here after the scoped Runner completes."})}),m.map(V=>s.jsxs("div",{className:"card",style:{padding:"14px 18px"},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"eyebrow",children:[V.gate?"GOVERNED GATE RUN":"SUITE COMPATIBILITY RUN"," · ",V.status]}),s.jsx("div",{style:{fontWeight:700},children:V.gate?`Gate ${V.gate.slug}@${V.gate.version} · ${V.gate.manifestHash}`:"Suite compatibility run · no Gate pin"}),s.jsxs("div",{className:"mono muted",style:{fontSize:11,marginTop:5},children:["Suite ",V.suite.slug,"@",V.suite.version," · Policy v",V.policy.version," · Run ",V.id]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:3},children:[V.runner.type.replaceAll("_"," ")," · runner ",V.runner.runnerId]})]}),s.jsx("span",{className:`tag ${V.finalDecision==="READY"?"pass":V.finalDecision==="BLOCK"||V.status==="EXECUTION_ERROR"?"fail":"warn"}`,children:V.finalDecision??V.automatedDecision??V.status})]}),s.jsxs("div",{className:"mono muted",style:{fontSize:10.5,marginTop:8},children:["Suite ",V.suite.manifestHash," · Policy ",V.policy.manifestHash," · evidence ",V.evidenceFingerprint??"pending"]}),V.counts&&s.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:7},children:[V.counts.passed,"/",V.counts.total," passed · ",V.counts.failed," failed · ",V.counts.errors," errors · ",V.durationMs===null?"duration pending":`${(V.durationMs/1e3).toFixed(1)}s`]})]},V.id))]}),_e.length>0&&s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsx("div",{className:"section-label",children:"Legacy local assurance bindings"}),s.jsx("div",{className:"muted",style:{fontSize:12},children:"P8 compatibility bindings from the local assurance file. These can run the old local executor, but they are not first-class Cloud Gates and are not resolvable with --gate."}),_e.map(V=>{var ee,xe;const le=(k==null?void 0:k.gateId)===V.gateId;return s.jsxs("div",{className:`card approved-gate-card ${(ee=V.staleness)!=null&&ee.stale?"stale":""}`,children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"LEGACY LOCAL BINDING · PINNED RELEASE DECISION"}),s.jsx("h3",{children:V.name??V.gateId}),s.jsxs("div",{className:"mono muted",children:[V.target?`${V.target} · `:"",V.suiteId," v",V.suiteVersion," · ",V.testCount??"—"," runnable tests · ",V.policyVersion," · ",V.runnerId??"auto runner"]}),((xe=V.staleness)==null?void 0:xe.stale)&&s.jsxs("div",{className:"gate-stale-warning",children:[s.jsx("span",{children:"△ SURFACE DRIFT"}),s.jsx("p",{children:V.staleness.warning}),s.jsxs("code",{children:[V.staleness.suiteTargetFingerprint," → ",V.staleness.currentTargetFingerprint]})]}),V.staleness&&!V.staleness.stale&&s.jsx("div",{className:"gate-surface-current",children:"✓ Suite matches the current target surface"})]}),s.jsxs("button",{className:"btn primary run-gate-button",onClick:()=>{N(V),_(!0)},children:[s.jsx("span",{children:"▶"})," ",le?"Open latest readiness proof":"Run readiness proof"]})]},V.gateId)})]}),re.length>0&&s.jsxs("div",{className:"card gate-stale-warning",children:[s.jsx("span",{children:"LEGACY BINDINGS FOR OTHER TARGETS"}),s.jsxs("p",{children:[re.length," local compatibility binding",re.length===1?" belongs":"s belong"," to a different MCP target and will not run against ",re[0].currentTarget??"the current connection","."]}),re.map(V=>s.jsxs("code",{children:[V.target??V.suiteId," · ",V.testCount??"—"," tests · ",V.name??V.gateId]},V.gateId))]}),h.length>0&&s.jsxs("div",{className:"stack",style:{gap:10},children:[s.jsx("div",{className:"section-label",children:"Legacy local regression groups"}),h.map(V=>s.jsxs("div",{className:"card",style:{padding:"16px 18px"},children:[s.jsxs("div",{className:"row spread",style:{gap:12,flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:700},children:V.name}),s.jsx("div",{className:"mono muted",style:{fontSize:11.5,marginTop:5},children:"Project-local compatibility artifact · not resolvable by the public CI Runner"})]}),s.jsxs("div",{className:"row",style:{gap:7},children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>I(V),children:"Edit"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>void T(V.id),children:"Delete"})]})]}),s.jsxs("div",{className:"row",style:{gap:7,marginTop:11,flexWrap:"wrap"},children:[V.tags.map(le=>s.jsxs("span",{className:"tag pass",children:["#",le]},le)),s.jsxs("span",{className:"tag informational",children:["score ≥ ",V.minScore]}),V.repeat>1&&s.jsxs("span",{className:"tag warn",children:["variable ×",V.repeat]}),V.deterministicOnly&&s.jsx("span",{className:"tag pass",children:"deterministic only"})]})]},V.id))]}),l?s.jsx(Bc,{label:"Loading tagged tests…"}):u?s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{style:{fontSize:13},children:u})]})}):i.length===0?s.jsx("div",{className:"card",style:{padding:22},children:s.jsxs("span",{className:"muted",style:{fontSize:13},children:["No tagged tests yet. Run a test on any pillar (Security, RAG, Prompts, Contracts, Performance, or a tool test) and click"," ",s.jsx("b",{children:"Tag"})," to capture it for CI. It will appear here, grouped by the tags you gave it."]})}):s.jsx("div",{className:"stack",style:{gap:16},children:fe.map(V=>{const le=me.get(V);return s.jsxs("div",{className:"card",style:{padding:"14px 16px"},children:[s.jsxs("div",{className:"row spread",style:{alignItems:"baseline",flexWrap:"wrap",gap:8},children:[s.jsxs("div",{className:"row",style:{gap:10,alignItems:"baseline"},children:[s.jsx("span",{className:"tag pass",style:{fontSize:12},children:V}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[le.length," test",le.length===1?"":"s"]})]}),s.jsxs("span",{className:"mono muted",style:{fontSize:11},children:["legacy gate --tag ",V]})]}),s.jsx("div",{className:"stack",style:{gap:6,marginTop:10},children:le.map(ee=>s.jsxs("div",{className:"row spread",style:{padding:"7px 10px",border:"1px solid var(--border)",borderRadius:8,gap:8},children:[s.jsxs("span",{className:"row",style:{gap:8,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{className:"pill",style:{fontSize:11},children:u5[ee.pillar]??ee.pillar}),nC(ee)==="deterministic"?s.jsx("span",{className:"tag pass",style:{fontSize:10},title:"Repeatable — the gate holds it to an exact pass.",children:"deterministic"}):s.jsx("span",{className:"tag warn",style:{fontSize:10},title:"Variable or LLM-driven — the gate scores it on a threshold and can repeat it (--repeat).",children:"non-deterministic"}),s.jsx("span",{style:{fontSize:13},children:ee.name}),ee.tags.filter(xe=>xe!==V).map(xe=>s.jsxs("span",{className:"mono muted",style:{fontSize:10.5},children:["#",xe]},xe))]}),s.jsx("button",{className:"btn sm ghost",onClick:()=>X(ee.id),title:"Remove this captured test",children:"Delete"})]},ee.id))})]},V)})})]})}const j5=()=>`policy_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,b5=["off","critical","high","medium","low"],Fv=["prompt","rag","contract","security","performance","tool"],Gv=["PASS","REVIEW","FAIL","INCONCLUSIVE","ERROR"],w5=["PASS","REVIEW","BLOCK"];function S5(){return s.jsxs("div",{className:"stack policy-control-center",children:[s.jsx(N5,{}),s.jsx(E5,{})]})}function N5(){const[e,t]=p.useState([]),[n,a]=p.useState(""),[r,i]=p.useState(null),[o,l]=p.useState(!1),[c,u]=p.useState(null),d=async()=>{try{const y=await O.policiesList();t(y.policies),a(b=>{var m;return b&&y.policies.some(x=>x.policy.id===b)?b:((m=y.policies[0])==null?void 0:m.policy.id)??""}),u(null)}catch(y){u(y instanceof Error?y.message:"Could not load governed Policies.")}};p.useEffect(()=>{d()},[]);const h=e.find(y=>y.policy.id===n)??e[0],g=()=>({schemaVersion:"prooflane-policy-manifest-v1",name:"Production assurance",description:"Verified failures block. Unresolved evidence requires review. Only passing evidence is ready.",scope:"production",pillarMappings:Object.fromEntries(Fv.map(y=>[y,{PASS:"PASS",REVIEW:"REVIEW",FAIL:"BLOCK",INCONCLUSIVE:"REVIEW",ERROR:"REVIEW"}])),aggregation:{blockWhenAnyPillarBlocks:!0,reviewWhenAnyPillarReviews:!0,emptySuiteDecision:"REVIEW"},humanReview:{requiredForReview:!0,allowBlockException:!1,exceptionRequiresReason:!0}}),v=async(y,b)=>{l(!0),u(null);try{if(b){const m=b.latestVersion.state==="DRAFT"?await O.policyUpdateDraft(b.policy.id,b.latestVersion.version,y):await O.policyCreateVersion(b.policy.id,{manifest:y,supersedesVersionId:b.latestVersion.id});t(x=>x.map(j=>j.policy.id===b.policy.id?{...j,latestVersion:m.version}:j))}else{const m=y.name.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);if(m.length<2)throw new Error("Policy name must produce a valid 2-character slug.");const x=await O.policyCreate({slug:m,displayName:y.name,description:y.description,manifest:y});t(j=>[x,...j]),a(x.policy.id)}i(null)}catch(m){u(m instanceof Error?m.message:"Could not save the governed Policy version.")}finally{l(!1)}},f=async(y,b)=>{l(!0),u(null);try{const m=b==="review"?await O.policyReview(y.policy.id,y.latestVersion.version):b==="approve"?await O.policyApprove(y.policy.id,y.latestVersion.version):await O.policyDeprecate(y.policy.id,y.latestVersion.version);t(x=>x.map(j=>j.policy.id===y.policy.id?{...j,latestVersion:m.version,approvedVersion:m.version.state==="APPROVED"?m.version:m.version.state==="DEPRECATED"?null:j.approvedVersion}:j))}catch(m){u(m instanceof Error?m.message:`Could not ${b} the Policy version.`)}finally{l(!1)}};return s.jsxs("section",{className:"stack policy-section",style:{gap:14},children:[s.jsxs("div",{className:"policy-section-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"ASSURANCE POLICY · CLOUD AUTHORITATIVE"}),s.jsx("h2",{children:"Evidence-to-decision control"}),s.jsx("p",{children:"Approved versions are canonicalized, hashed, and signed by the Control Plane. Suites pin one exact Policy version and hash."})]}),s.jsx("button",{className:"btn primary",onClick:()=>i({manifest:g()}),children:"+ New Policy"})]}),s.jsxs("div",{className:"policy-flow","aria-label":"Policy evaluation flow",children:[s.jsx("span",{children:"Immutable test facts"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"Pillar mapping"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"Gate aggregation"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"Human review"})]}),c&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"error"}),s.jsx("span",{children:c})]})}),s.jsxs("div",{className:"policy-version-layout",children:[s.jsx("div",{className:"policy-version-list",children:e.map(y=>s.jsxs("button",{className:`policy-version-card ${y.policy.id===(h==null?void 0:h.policy.id)?"selected":""}`,onClick:()=>a(y.policy.id),children:[s.jsxs("span",{children:[s.jsx("strong",{children:y.policy.displayName}),s.jsxs("code",{children:[y.policy.slug," · v",y.latestVersion.version]})]}),s.jsx("em",{children:y.latestVersion.state})]},y.policy.id))}),h&&s.jsxs("div",{className:"card policy-version-detail",children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start"},children:[s.jsxs("div",{children:[s.jsxs("div",{className:"eyebrow",children:["VERSION ",h.latestVersion.version," · ",h.latestVersion.state]}),s.jsx("h3",{children:h.latestVersion.manifest.name}),s.jsx("p",{children:h.latestVersion.manifest.description})]}),s.jsx("span",{className:`tag ${h.latestVersion.state==="APPROVED"?"pass":"warn"}`,children:h.latestVersion.signature?"signed":h.latestVersion.state.toLowerCase()})]}),s.jsxs("div",{className:"policy-meta",children:[s.jsxs("span",{children:[s.jsx("b",{children:"Policy ID"}),s.jsx("code",{children:h.policy.id})]}),s.jsxs("span",{children:[s.jsx("b",{children:"Scope"}),s.jsx("strong",{children:h.latestVersion.manifest.scope})]}),s.jsxs("span",{children:[s.jsx("b",{children:"Author"}),s.jsx("strong",{children:h.latestVersion.createdBy})]}),s.jsxs("span",{children:[s.jsx("b",{children:"Created"}),s.jsx("strong",{children:new Date(h.latestVersion.createdAt).toLocaleString()})]})]}),s.jsx("div",{className:"policy-mapping-preview",children:Fv.map(y=>s.jsxs("div",{children:[s.jsx("strong",{children:y}),Gv.map(b=>s.jsxs("span",{className:h.latestVersion.manifest.pillarMappings[y][b].toLowerCase(),children:[b," → ",h.latestVersion.manifest.pillarMappings[y][b]]},b))]},y))}),s.jsxs("div",{className:"policy-rule-summary",children:[s.jsxs("span",{children:[s.jsx("b",{children:"BLOCK"})," if any pillar maps to BLOCK"]}),s.jsxs("span",{children:[s.jsx("b",{children:"REVIEW"})," if none block and any pillar maps to REVIEW"]}),s.jsxs("span",{children:[s.jsx("b",{children:"READY"})," only when every evaluated fact maps to PASS"]})]}),s.jsxs("div",{className:"row",style:{gap:7,flexWrap:"wrap"},children:[s.jsxs("span",{className:`tag ${h.latestVersion.manifest.humanReview.requiredForReview?"warn":"pass"}`,children:["Review ",h.latestVersion.manifest.humanReview.requiredForReview?"requires human":"automatic"]}),h.latestVersion.manifestHash&&s.jsxs("code",{children:[h.latestVersion.manifestHash.slice(0,28),"…"]})]}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:12,flexWrap:"wrap"},children:[h.latestVersion.state==="DRAFT"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>i({manifest:structuredClone(h.latestVersion.manifest),policy:h}),children:"Edit DRAFT"}),s.jsx("button",{className:"btn sm primary",disabled:o,onClick:()=>void f(h,"review"),children:"Submit review"})]}),h.latestVersion.state==="REVIEWED"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>i({manifest:structuredClone(h.latestVersion.manifest),policy:h}),children:"Create replacement DRAFT"}),s.jsx("button",{className:"btn sm primary",disabled:o,onClick:()=>void f(h,"approve"),children:"Approve + sign"})]}),h.latestVersion.state==="APPROVED"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",onClick:()=>i({manifest:structuredClone(h.latestVersion.manifest),policy:h}),children:"Create new version"}),s.jsx("button",{className:"btn sm ghost",disabled:o,onClick:()=>void f(h,"deprecate"),children:"Deprecate"})]}),h.latestVersion.state==="DEPRECATED"&&s.jsx("button",{className:"btn sm ghost",onClick:()=>i({manifest:structuredClone(h.latestVersion.manifest),policy:h}),children:"Create replacement DRAFT"})]})]})]}),s.jsx("div",{className:"card policy-bindings",children:s.jsxs("div",{children:[s.jsx("div",{className:"section-label",children:"Exact Suite pinning"}),s.jsx("p",{children:"Only APPROVED signed versions appear in Suite authoring. The Suite stores the Policy ID, version, and manifest hash; approval fails if any value differs."})]})}),r&&s.jsx(k5,{manifest:r.manifest,busy:o,onClose:()=>i(null),onSave:y=>void v(y,r.policy)})]})}function k5({manifest:e,busy:t,onClose:n,onSave:a}){const[r,i]=p.useState(e),o=(c,u,d)=>i(h=>({...h,pillarMappings:{...h.pillarMappings,[c]:{...h.pillarMappings[c],[u]:d}}})),l=!!(r.name.trim()&&r.description.trim()&&r.scope.trim());return s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"modal assurance-policy-editor",onClick:c=>c.stopPropagation(),children:[s.jsx("div",{className:"screen-title",children:"Create immutable Policy version"}),s.jsx("p",{className:"muted",children:"Save a DRAFT, submit it for review, then approve and sign it before a Suite can pin it."}),s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Policy name"}),s.jsx("input",{className:"field",value:r.name,onChange:c=>i({...r,name:c.target.value})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Scope"}),s.jsx("input",{className:"field",value:r.scope,onChange:c=>i({...r,scope:c.target.value})})]})]}),s.jsxs("div",{style:{marginTop:10},children:[s.jsx("label",{className:"label",children:"Description"}),s.jsx("input",{className:"field",value:r.description,onChange:c=>i({...r,description:c.target.value})})]}),s.jsxs("div",{className:"policy-mapping-table",children:[s.jsxs("div",{className:"policy-mapping-header",children:[s.jsx("b",{children:"Pillar"}),Gv.map(c=>s.jsx("b",{children:c},c))]}),Fv.map(c=>s.jsxs("div",{className:"policy-mapping-row",children:[s.jsx("strong",{children:c}),Gv.map(u=>s.jsx("select",{value:r.pillarMappings[c][u],onChange:d=>o(c,u,d.target.value),children:w5.map(d=>s.jsx("option",{children:d},d))},u))]},c))]}),s.jsxs("div",{className:"policy-human-rules",children:[s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:r.humanReview.requiredForReview,onChange:c=>i({...r,humanReview:{...r.humanReview,requiredForReview:c.target.checked}})})," Require human disposition for REVIEW"]}),s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:r.humanReview.allowBlockException,onChange:c=>i({...r,humanReview:{...r.humanReview,allowBlockException:c.target.checked}})})," Allow a reasoned human exception to BLOCK"]})]}),s.jsxs("div",{className:"row spread",style:{marginTop:16},children:[s.jsx("span",{className:"muted",style:{fontSize:11},children:l?"Approval makes the version immutable and signed.":"Complete the name, description, and scope."}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:n,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:!l||t,onClick:()=>a(r),children:t?"Saving…":"Save DRAFT"})]})]})]})})}function E5(){const[e,t]=p.useState(rp()),[n,a]=p.useState(xx()),[r,i]=p.useState(null),o=d=>{const g=e.some(v=>v.id===d.id)?e.map(v=>v.id===d.id?d:v):[...e,d];t(g),Tw(g),i(null)},l=d=>{a(d),TE(d)},c=()=>i({...structuredClone(xd[1]),id:j5(),name:"New release policy",description:""}),u=d=>{if(e.length<=1)return;const h=e.filter(g=>g.id!==d);t(h),Tw(h),n===d&&l(h[0].id)};return s.jsxs("section",{className:"stack policy-section release-policy-section",style:{gap:20},children:[s.jsx("div",{className:"policy-section-head",children:s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"DEPLOYMENT SCORE POLICY · LOCAL"}),s.jsx("h2",{children:"Weighted release scoring"}),s.jsx("p",{children:"These browser-local profiles score Deployment Assurance. They do not change the pinned, server-side Assurance Gate policy above."})]})}),s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("span",{className:"muted",style:{fontSize:12.5},children:["Policies turn assurance evidence into a weighted ",s.jsx("b",{children:"Pass / Review / Block"})," release decision. Hard gates always win over the score."]}),s.jsx("button",{className:"btn sm primary",onClick:c,children:"+ New score policy"})]}),s.jsx("div",{className:"stack",style:{gap:10},children:e.map(d=>{const h=d.id===n;return s.jsxs("div",{className:"card",style:{padding:"14px 16px",borderColor:h?"var(--accent)":void 0},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsxs("div",{className:"stack",style:{gap:4},children:[s.jsxs("div",{className:"row",style:{gap:8,alignItems:"baseline",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:15,fontWeight:700},children:d.name}),h&&s.jsx("span",{className:"tag pass",children:"active"}),s.jsxs("span",{className:"muted mono",style:{fontSize:11},children:["PASS ≥",d.passAt," · REVIEW ≥",d.reviewAt]})]}),s.jsx("span",{className:"muted",style:{fontSize:12.5},children:d.description||"No description"})]}),s.jsxs("div",{className:"row",style:{gap:6},children:[!h&&s.jsx("button",{className:"btn sm",onClick:()=>l(d.id),children:"Use for releases"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>i(structuredClone(d)),children:"Edit"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>u(d.id),disabled:e.length<=1,children:"Delete"})]})]}),s.jsxs("div",{className:"row",style:{gap:6,marginTop:10,flexWrap:"wrap"},children:[dl.map(g=>s.jsxs("span",{className:"pill",children:[Sl[g]," ",Math.round(d.weights[g]*100),"%"]},g)),d.hardGates.contracts&&s.jsx("span",{className:"tag fail",children:"Contracts block"}),d.hardGates.securityMaxSeverity!=="off"&&s.jsxs("span",{className:"tag fail",children:["Security ≥",d.hardGates.securityMaxSeverity]}),d.hardGates.ragMinScore!=null&&s.jsxs("span",{className:"tag warn",children:["RAG ≥",d.hardGates.ragMinScore]}),d.hardGates.promptMinScore!=null&&s.jsxs("span",{className:"tag warn",children:["Prompts ≥",d.hardGates.promptMinScore]}),d.hardGates.perfMinScore!=null&&s.jsxs("span",{className:"tag warn",children:["Perf ≥",d.hardGates.perfMinScore]})]})]},d.id)})}),r&&s.jsx(_5,{policy:r,onClose:()=>i(null),onSave:o})]})}function _5({policy:e,onClose:t,onSave:n}){const[a,r]=p.useState(e),i=p.useMemo(()=>dl.reduce((u,d)=>u+a.weights[d],0),[a.weights]),o=(u,d)=>{const h=Math.max(0,Number(d)||0);r(g=>({...g,weights:{...g.weights,[u]:h/100}}))},l=(u,d)=>r(h=>({...h,hardGates:{...h.hardGates,[u]:d===""?void 0:d}})),c=a.name.trim()&&i>0&&a.reviewAt<=a.passAt;return s.jsx("div",{className:"modal-backdrop",onClick:t,children:s.jsxs("div",{className:"modal",style:{maxWidth:670,maxHeight:"86vh",overflowY:"auto"},onClick:u=>u.stopPropagation(),children:[s.jsx("div",{className:"screen-title",style:{marginBottom:12},children:e.name==="New release policy"?"New policy":"Edit policy"}),s.jsxs("div",{className:"stack",style:{gap:14},children:[s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Policy name"}),s.jsx("input",{className:"field",value:a.name,onChange:u=>r({...a,name:u.target.value})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Description"}),s.jsx("input",{className:"field",value:a.description,onChange:u=>r({...a,description:u.target.value}),placeholder:"When to use this release policy"})]})]}),s.jsxs("fieldset",{style:{border:"1px solid var(--border)",borderRadius:9,padding:"10px 12px",margin:0},children:[s.jsx("legend",{className:"muted",style:{fontSize:11,padding:"0 6px"},children:"Weighted decision"}),s.jsxs("div",{className:"grid-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Pass score"}),s.jsx("input",{className:"field mono",type:"number",min:"0",max:"100",value:a.passAt,onChange:u=>r({...a,passAt:Number(u.target.value)})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Review score"}),s.jsx("input",{className:"field mono",type:"number",min:"0",max:"100",value:a.reviewAt,onChange:u=>r({...a,reviewAt:Number(u.target.value)})})]})]}),s.jsx("div",{className:"grid-2",style:{marginTop:10},children:dl.map(u=>s.jsxs("div",{children:[s.jsxs("label",{className:"label",children:[Sl[u]," weight (%)"]}),s.jsx("input",{className:"field mono",type:"number",min:"0",max:"100",value:Math.round(a.weights[u]*100),onChange:d=>o(u,d.target.value)})]},u))}),s.jsxs("span",{className:"muted",style:{display:"block",marginTop:8,fontSize:11.5},children:["Weights total ",Math.round(i*100),"%. Prooflane normalizes the entered weights when calculating the score."]})]}),s.jsxs("fieldset",{style:{border:"1px solid var(--border)",borderRadius:9,padding:"10px 12px",margin:0},children:[s.jsx("legend",{className:"muted",style:{fontSize:11,padding:"0 6px"},children:"Hard gates — always block a release"}),s.jsxs("div",{className:"grid-2",children:[s.jsxs("label",{className:"row",style:{gap:7,alignItems:"center",fontSize:12.5,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:a.hardGates.contracts,onChange:u=>l("contracts",u.target.checked)})," Breaking contract failure"]}),s.jsxs("div",{children:[s.jsx("label",{className:"label",children:"Security breach severity"}),s.jsx("select",{className:"field",value:a.hardGates.securityMaxSeverity,onChange:u=>l("securityMaxSeverity",u.target.value),children:b5.map(u=>s.jsx("option",{value:u,children:u==="off"?"Do not hard-block":`${u} or above`},u))})]}),s.jsx(Rf,{label:"RAG minimum score",value:a.hardGates.ragMinScore,onChange:u=>l("ragMinScore",u)}),s.jsx(Rf,{label:"Prompt minimum score",value:a.hardGates.promptMinScore,onChange:u=>l("promptMinScore",u)}),s.jsx(Rf,{label:"Performance minimum score",value:a.hardGates.perfMinScore,onChange:u=>l("perfMinScore",u)})]})]})]}),s.jsxs("div",{className:"row spread",style:{marginTop:18,alignItems:"center"},children:[s.jsx("span",{className:"muted",style:{fontSize:11.5},children:c?"Hard gates override the weighted score.":"Use a name, positive weights, and a Review score no higher than Pass."}),s.jsxs("div",{className:"row",style:{gap:8},children:[s.jsx("button",{className:"btn ghost",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:!c,onClick:()=>n(a),children:"Save policy"})]})]})]})})}function Rf({label:e,value:t,onChange:n}){return s.jsxs("div",{children:[s.jsx("label",{className:"label",children:e}),s.jsx("input",{className:"field mono",type:"number",min:"0",max:"100",value:t??"",placeholder:"Optional",onChange:a=>n(a.target.value)})]})}const C5="prooflane-github-oidc-trust-v1",iC={repository:"",repositoryId:"",repositoryOwnerId:"",workflowPath:".github/workflows/prooflane-assurance-gate.yml",refPatterns:`refs/heads/main
|
|
75
|
-
refs/pull/*/merge`,environment:"",jobWorkflowRef:"",eventNames:"pull_request, push, workflow_dispatch",runnerEnvironment:"any"};function ZS(e){return[...new Set(e.split(/[\n,]+/).map(t=>t.trim()).filter(Boolean))]}function XS(e){return!e||e.revokedAt?iC:{repository:e.manifest.repository,repositoryId:e.manifest.repositoryId,repositoryOwnerId:e.manifest.repositoryOwnerId,workflowPath:e.manifest.workflowPath,refPatterns:e.manifest.refPatterns.join(`
|
|
76
|
-
`),environment:e.manifest.environment??"",jobWorkflowRef:e.manifest.jobWorkflowRef??"",eventNames:e.manifest.eventNames.join(", "),runnerEnvironment:e.manifest.runnerEnvironment??"any"}}function T5(e){return{schemaVersion:C5,repository:e.repository.trim(),repositoryId:e.repositoryId.trim(),repositoryOwnerId:e.repositoryOwnerId.trim(),workflowPath:e.workflowPath.trim(),refPatterns:ZS(e.refPatterns),environment:e.environment.trim()||null,jobWorkflowRef:e.jobWorkflowRef.trim()||null,eventNames:ZS(e.eventNames),runnerEnvironment:e.runnerEnvironment==="any"?null:e.runnerEnvironment}}function R5({enabled:e}){const[t,n]=p.useState(iC),[a,r]=p.useState(null),[i,o]=p.useState("load"),[l,c]=p.useState(null),[u,d]=p.useState(null);p.useEffect(()=>{if(!e){o(null);return}O.githubOidcTrust().then(({trust:y})=>{r(y),n(XS(y))}).catch(y=>d(y instanceof Error?y.message:"GitHub OIDC trust could not be loaded.")).finally(()=>o(null))},[e]);const h=(y,b)=>n(m=>({...m,[y]:b}));async function g(){o("save"),d(null),c(null);try{const y=await O.githubOidcTrustSave(T5(t));r(y.trust),n(XS(y.trust)),c("OIDC trust saved. Matching GitHub jobs can now obtain a short-lived Prooflane identity without a stored Prooflane token.")}catch(y){d(y instanceof Error?y.message:"GitHub OIDC trust could not be saved.")}finally{o(null)}}async function v(){o("revoke"),d(null),c(null);try{const y=await O.githubOidcTrustRevoke();r(y.trust),c("OIDC trust revoked. New GitHub identity exchanges are blocked.")}catch(y){d(y instanceof Error?y.message:"GitHub OIDC trust could not be revoked.")}finally{o(null)}}const f=!!(a&&!a.revokedAt);return s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"GitHub Actions identity"}),s.jsx("div",{className:"muted",style:{marginTop:7,fontSize:13,maxWidth:720},children:"Bind this Prooflane project to one repository, workflow, and allowed refs. Matching jobs exchange GitHub's signed OIDC assertion for a ten-minute Prooflane identity; no long-lived Prooflane secret is required."})]}),s.jsx("span",{className:`tag ${f?"pass":"warn"}`,children:i==="load"?"loading":f?"OIDC active":"not configured"})]}),s.jsxs("div",{className:"card inset",style:{padding:14,marginTop:16,fontSize:12.5,lineHeight:1.55},children:["The workflow must grant ",s.jsx("span",{className:"mono",children:"contents: read"}),", ",s.jsx("span",{className:"mono",children:"id-token: write"}),", and ",s.jsx("span",{className:"mono",children:"checks: write"}),". Prooflane verifies GitHub's signature and every binding below before execution. OIDC assertions and GitHub tokens are never stored."]}),s.jsxs("details",{className:"card inset",style:{padding:14,marginTop:10,fontSize:12.5,lineHeight:1.55},children:[s.jsx("summary",{style:{cursor:"pointer",fontWeight:700},children:"Where to get the OIDC binding details"}),s.jsxs("div",{className:"muted",style:{marginTop:10},children:["Run this with GitHub CLI after replacing ",s.jsx("span",{className:"mono",children:"OWNER/REPO"}),". It returns the immutable repository and owner IDs used by GitHub's signed OIDC claims."]}),s.jsx("div",{className:"mono",style:{marginTop:8,padding:10,border:"1px solid var(--border)",borderRadius:8,overflowX:"auto"},children:"gh api repos/OWNER/REPO --jq '{repository: .full_name, repositoryId: (.id|tostring), ownerId: (.owner.id|tostring)}'"}),s.jsxs("div",{className:"muted",style:{marginTop:9},children:["Workflow path is the exact repository-relative file under ",s.jsx("span",{className:"mono",children:".github/workflows/"}),". Allowed refs and events must match that workflow's triggers. Set Environment only when the job declares one; set Reusable workflow ref only for an exact reusable-workflow binding."]})]}),s.jsxs("div",{className:"grid-2",style:{marginTop:16,gap:13},children:[s.jsx(jr,{label:"Repository (owner/name)",value:t.repository,onChange:y=>h("repository",y),placeholder:"acme/payments"}),s.jsx(jr,{label:"GitHub repository ID",value:t.repositoryId,onChange:y=>h("repositoryId",y),placeholder:"123456789",help:"The repository's immutable numeric id from the GitHub API command above."}),s.jsx(jr,{label:"GitHub owner ID",value:t.repositoryOwnerId,onChange:y=>h("repositoryOwnerId",y),placeholder:"987654321",help:"The organization or user owner's immutable numeric id from the same command."}),s.jsx(jr,{label:"Workflow path",value:t.workflowPath,onChange:y=>h("workflowPath",y),placeholder:".github/workflows/prooflane-assurance-gate.yml"}),s.jsx(jr,{label:"Allowed refs (comma or newline)",value:t.refPatterns,onChange:y=>h("refPatterns",y),multiline:!0,placeholder:"refs/heads/main"}),s.jsx(jr,{label:"Allowed events",value:t.eventNames,onChange:y=>h("eventNames",y),placeholder:"pull_request, push"}),s.jsx(jr,{label:"Environment (optional exact match)",value:t.environment,onChange:y=>h("environment",y),placeholder:"production"}),s.jsx(jr,{label:"Reusable workflow ref (optional exact match)",value:t.jobWorkflowRef,onChange:y=>h("jobWorkflowRef",y),placeholder:"acme/ci/.github/workflows/prooflane.yml@refs/heads/main"}),s.jsxs("label",{children:[s.jsx("span",{className:"label",children:"Runner environment"}),s.jsxs("select",{className:"field",value:t.runnerEnvironment,onChange:y=>h("runnerEnvironment",y.target.value),children:[s.jsx("option",{value:"any",children:"Any GitHub runner"}),s.jsx("option",{value:"github-hosted",children:"GitHub-hosted only"}),s.jsx("option",{value:"self-hosted",children:"Self-hosted only"})]})]})]}),f&&a&&s.jsxs("div",{className:"muted mono",style:{marginTop:13,fontSize:11},children:["Last updated ",new Date(a.updatedAt).toLocaleString()," · repository #",a.manifest.repositoryId]}),l&&s.jsx("div",{style:{color:"var(--pass)",marginTop:13,fontSize:12.5},children:l}),u&&s.jsx("div",{style:{color:"var(--fail)",marginTop:13,fontSize:12.5},children:u}),s.jsxs("div",{className:"row",style:{gap:8,marginTop:16,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn primary",onClick:g,disabled:!e||i!==null,children:i==="save"?"Saving…":f?"Update OIDC trust":"Enable OIDC trust"}),f&&s.jsx("button",{className:"btn ghost",onClick:v,disabled:i!==null,children:i==="revoke"?"Revoking…":"Revoke trust"})]})]})}function jr({label:e,value:t,onChange:n,placeholder:a,multiline:r=!1,help:i}){return s.jsxs("label",{children:[s.jsx("span",{className:"label",children:e}),r?s.jsx("textarea",{className:"field",rows:3,value:t,onChange:o=>n(o.target.value),placeholder:a}):s.jsx("input",{className:"field",value:t,onChange:o=>n(o.target.value),placeholder:a}),i&&s.jsx("small",{className:"muted",style:{display:"block",marginTop:5},children:i})]})}const I5="cloud-workspace-v1",oC="local-workspace-v1",lC="prooflane.localWorkspaceAgreement";function A5(e){try{const t=localStorage.getItem(lC);if(!t)return!1;const n=JSON.parse(t);return n.account===e&&n.version===oC}catch{return!1}}function P5(e){try{localStorage.setItem(lC,JSON.stringify({account:e,version:oC}))}catch{}}function $5({onEnabled:e,onClose:t}){const[n,a]=p.useState(!1),[r,i]=p.useState(!1),[o,l]=p.useState(null),c=async()=>{if(n){i(!0),l(null);try{await e()}catch(u){l(u instanceof Error?u.message:"Prooflane could not enable Cloud History & Recovery.")}finally{i(!1)}}};return s.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:t,children:s.jsxs("div",{className:"modal cloud-history-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cloud-history-title",onMouseDown:u=>u.stopPropagation(),children:[s.jsxs("div",{className:"row spread",style:{alignItems:"flex-start",gap:18},children:[s.jsxs("div",{children:[s.jsx("div",{id:"cloud-history-title",className:"screen-title",style:{fontSize:20},children:"Cloud History & Recovery"}),s.jsx("div",{className:"screen-sub",style:{marginTop:7},children:"Keep assurance history securely so Prooflane can identify drift, compare regressions, and restore your workspace if this device is lost."})]}),s.jsx("button",{className:"btn sm ghost",onClick:t,"aria-label":"Close Cloud History and Recovery",children:"×"})]}),s.jsxs("div",{className:"card inset",style:{padding:14,marginTop:18,fontSize:13,lineHeight:1.55},children:[s.jsx("b",{children:"What is backed up:"})," selected assurance runs, contracts, prompts, and recorded sessions. Prooflane creates an encrypted snapshot at most once every 24 hours while Inspector is open and you are signed in."]}),s.jsxs("div",{className:"card inset",style:{padding:14,marginTop:10,fontSize:13,lineHeight:1.55},children:[s.jsx("b",{children:"What always stays on this device:"})," your MCP server URL and connection settings, OAuth tokens, LLM/API keys, authorization headers, passwords, and private keys. Prooflane never uploads these values, and Cloud Workspace rejects them again if they are ever included in a backup."]}),s.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start",cursor:"pointer",marginTop:18},children:[s.jsx("input",{type:"checkbox",checked:n,onChange:u=>a(u.target.checked),style:{marginTop:3}}),s.jsx("span",{style:{fontSize:13,lineHeight:1.5},children:"I consent to encrypted Cloud History & Recovery backups of the approved assurance artifacts described above. I understand that my connection settings and credentials always stay on this device."})]}),o&&s.jsx("div",{style:{color:"var(--fail)",fontSize:12.5,marginTop:14},children:o}),s.jsxs("div",{className:"row",style:{justifyContent:"flex-end",gap:10,marginTop:20},children:[s.jsx("button",{className:"btn ghost",onClick:t,disabled:r,children:"Not now"}),s.jsx("button",{className:"btn primary",onClick:c,disabled:!n||r,children:r?"Enabling secure backup…":"Enable Cloud History"})]})]})})}function O5({account:e,enabled:t,configured:n,eligible:a,planLabel:r,onAccepted:i}){const o=t,[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[v,f]=p.useState(!1),[y,b]=p.useState(null),m=o&&!n,x=l&&u&&!m,j=async()=>{if(x){g(!0),b(null);try{o?(await O.workspaceConsent(I5,!0,!0),f(!0),window.setTimeout(i,5e3)):(P5(e),i())}catch(S){b(S instanceof Error?S.message:"Could not save the workspace agreement."),g(!1)}}};return v?s.jsx("div",{className:"auth-gate workspace-splash","aria-live":"polite",children:s.jsxs("div",{className:"workspace-splash-brand",children:[s.jsx(ur,{}),s.jsx("div",{className:"workspace-splash-name",children:"prooflane"}),s.jsx("div",{className:"workspace-splash-welcome",children:"Welcome to your Cloud Workspace"}),s.jsx("div",{className:"workspace-splash-tag",children:"CLOUD WORKSPACE READY"})]})}):s.jsx("div",{className:"auth-gate",children:s.jsxs("div",{className:"auth-card",style:{maxWidth:640},children:[s.jsx("div",{className:"screen-title",style:{fontSize:21,marginBottom:7},children:o?"Set up Cloud Workspace":"Your Prooflane workspace"}),s.jsx("div",{className:"screen-sub",style:{marginBottom:20},children:o?s.jsxs(s.Fragment,{children:["Before using Prooflane Inspector, ",s.jsx("b",{children:e})," must accept the Cloud Workspace agreement. This creates your encrypted hosted workspace for assurance results, history and recovery."]}):s.jsxs(s.Fragment,{children:["Before using Prooflane Inspector, ",s.jsx("b",{children:e})," — here's how your ",s.jsx("b",{children:r??"Free"})," workspace works."]})}),s.jsx("div",{className:"drift dirty",style:{marginBottom:16},children:s.jsxs("div",{className:"drift-row",style:{alignItems:"flex-start"},children:[s.jsx("span",{className:"tag warn",children:"important"}),s.jsxs("span",{style:{fontSize:12.5,lineHeight:1.55},children:[o?s.jsxs(s.Fragment,{children:[s.jsx("b",{children:"Back up to keep your assurance history."})," Without a completed Cloud Workspace backup, Prooflane removes local runs, prompts, sessions, and snapshots when you sign in again or your login session expires. This prevents orphaned customer data from remaining on the device. After an encrypted backup has completed, approved assurance history remains available for recovery, drift analysis, and regressions."]}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:"Your workspace lives on this device."})," On ",r??"Free",", your runs, prompts, sessions, and snapshots are stored locally only — there is no cloud copy. ",s.jsx("b",{children:"Signing out or a session/token expiry clears them, and they cannot be recovered."})," To keep assurance history for recovery, drift analysis, and regressions, upgrade to a Cloud Workspace (Scale and above)."]}),s.jsx("br",{}),s.jsx("b",{children:"Prooflane never keeps your credentials."})," Your MCP URL and connection settings, OAuth tokens, LLM/API keys, PATs, authorization headers, passwords, and private keys are never sent to Prooflane — they stay on this device",o?" and are never backed up":"","."]})]})}),m&&s.jsx("div",{className:"drift dirty",style:{marginBottom:14},children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"setup"}),s.jsxs("span",{style:{fontSize:12.5},children:["Cloud Workspace is not configured for this Inspector. Set ",s.jsx("span",{className:"mono",children:"KAWACH_CONTROL_PLANE_URL"})," and restart."]})]})}),s.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start",cursor:"pointer",marginTop:10},children:[s.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),style:{marginTop:3}}),s.jsx("span",{style:{fontSize:13},children:o?"I agree to the Prooflane Cloud Workspace Terms, including authorized-testing requirements, responsibility for my use of connected AI systems, and the local workspace lifecycle described above.":"I understand my workspace is stored locally on this device, and that signing out or a session expiry clears my local runs, prompts, sessions, and snapshots — they cannot be recovered without a Cloud Workspace."})]}),s.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start",cursor:"pointer",marginTop:14},children:[s.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked),style:{marginTop:3}}),s.jsx("span",{style:{fontSize:13},children:o?"I consent to Prooflane processing and retaining selected run output in my encrypted Cloud Workspace for assurance analysis and release decisions.":"I agree to the Prooflane Terms and Data Processing Agreement, and understand Prooflane never stores my passwords, API/LLM keys, OAuth tokens, PATs, MCP configuration, or other credentials."})]}),y&&s.jsx("div",{style:{color:"var(--fail)",fontSize:12.5,marginTop:14},children:y}),s.jsx("button",{className:"btn primary",style:{width:"100%",justifyContent:"center",marginTop:20},onClick:j,disabled:h||!x,children:h?"Saving agreement…":o?"Accept agreement & continue":"Acknowledge & continue"})]})})}function L5({account:e,enabled:t,emailVerified:n,caps:a,connected:r,planStatus:i,automaticBackupAccepted:o,backupCadenceHours:l}){var ue;const[c,u]=p.useState("security"),[d,h]=p.useState(""),[g,v]=p.useState(null),[f,y]=p.useState(null),[b,m]=p.useState(null),[x,j]=p.useState(null),[S,w]=p.useState(!1),[C,k]=p.useState(null),[N,L]=p.useState(!1),[_,E]=p.useState(null),[I,$]=p.useState(null),[W,R]=p.useState(!1),H=(a==null?void 0:a.tools)??[],Y=p.useMemo(()=>H.filter(oe=>/search|retriev|query|lookup|find|fetch|get|read|list/i.test(oe.name)),[H]);p.useEffect(()=>{!d&&Y.length&&h(Y[0].name)},[Y,d]),p.useEffect(()=>{!t||!n||O.workspaceLatestBackup(!0).then(({backup:oe})=>{oe&&j({createdAt:oe.createdAt,counts:{runs:oe.value.runs.length,sessions:oe.value.sessions.length,snapshots:oe.value.snapshots.length,prompts:oe.value.prompts.length}})}).catch(()=>{})},[t,n]);async function K(){w(!0),k(null);try{if(!t||!n)throw new Error("Verify your email and finish Cloud Workspace setup before backing up data.");const oe=await O.workspaceBackup();j({createdAt:oe.capturedAt,counts:oe.counts}),localStorage.setItem(`kawach.cloud-history.last-backup:${e}`,oe.capturedAt)}catch(oe){k(oe instanceof Error?oe.message:"Prooflane could not back up this workspace.")}finally{w(!1)}}async function ce(){L(!0),k(null),E(null);try{if(!t||!n)throw new Error("Verify your email and finish Cloud Workspace setup before restoring.");const oe=await O.workspaceRestore();if(!oe.ok)throw new Error(oe.error??"No cloud backup was found to restore.");const B=oe.restored;E(`Restored ${B.runs} runs · ${B.sessions} sessions · ${B.snapshots} contracts · ${B.prompts} prompts. Reloading…`),setTimeout(()=>window.location.reload(),1400)}catch(oe){k(oe instanceof Error?oe.message:"Prooflane could not restore this workspace.")}finally{L(!1)}}async function F(){R(!0),k(null);try{if(!t||!n)throw new Error("Verify your email and finish Cloud Workspace setup first.");const{versions:oe}=await O.workspaceBackupVersions(50);$(oe.map(({id:B,capturedAt:Q,counts:X})=>({id:B,capturedAt:Q,counts:X})))}catch(oe){k(oe instanceof Error?oe.message:"Prooflane could not load the backup history.")}finally{R(!1)}}async function ie(){v("run"),y(null),m(null);try{if(!t)throw new Error("Cloud Workspace is not configured for this Inspector. Set KAWACH_CONTROL_PLANE_URL and restart it.");if(!n)throw new Error("Verify your email with Prooflane first, then sign in again to use hosted Intelligence.");if(c==="security"&&!Ws())throw new Error("Connect an LLM locally before running the Security task.");if(c==="rag"&&(!r||!d))throw new Error("Connect a local MCP server and select its retriever tool before running the RAG task.");const B=(await O.intelligenceLease(c)).leases[0];if(!B)throw new Error("Prooflane did not return an Intelligence task. Try again.");const Q=await O.intelligenceExecute({lease:B.lease,llm:c==="security"?Es()??void 0:void 0,toolName:c==="rag"?d:void 0,dataHandling:"cloud-consented"});if(!Q.ok)throw new Error(Q.error??"The local Runner could not execute this task.");if(Q.execution){const X=await O.intelligenceEvaluation(B.lease,Q.execution);m({pillar:c,label:B.task.label,...X.evidence,stored:X.stored})}else if(Q.evidence){const X=await O.intelligenceEvidence(B.lease,Q.evidence);m({pillar:c,label:B.task.label,...Q.evidence,stored:X.stored})}else throw new Error("The local Runner did not return evidence.")}catch(oe){y(oe instanceof Error?oe.message:"Hosted Intelligence could not complete this task.")}finally{v(null)}}return(i==null?void 0:i.tier)==="free"?s.jsx("div",{className:"stack",style:{gap:20,maxWidth:1e3},children:s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Local Inspector workspace"}),s.jsx("div",{className:"muted",style:{marginTop:7,fontSize:13,maxWidth:710},children:"Your Free plan keeps assurance data on this device only. Cloud History, recovery, and hosted Intelligence are available on Scale and above."})]}),s.jsx("span",{className:"tag",children:"free plan"})]}),s.jsxs("div",{className:"card inset",style:{padding:14,marginTop:16,fontSize:13,lineHeight:1.55},children:[s.jsx("b",{children:"Local workspace lifecycle."})," To protect data left on a shared or lost device, Prooflane removes local runs, prompts, sessions, and snapshots when you sign in again or your login session expires. Your MCP connection settings and credentials always stay local and are cleared as well."]})]})}):s.jsxs("div",{className:"stack",style:{gap:20,maxWidth:1e3},children:[s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Prooflane Cloud Workspace"}),s.jsx("div",{className:"muted",style:{marginTop:7,fontSize:13},children:"Hosted attack selection, grading and release policy. Your MCP connection and provider credentials remain on this machine."})]}),s.jsx("span",{className:`tag ${t?"pass":"warn"}`,children:t?"ready":"setup needed"})]}),s.jsxs("div",{className:"grid-2",style:{marginTop:20,gap:14},children:[s.jsxs("div",{className:"card inset",style:{padding:14},children:[s.jsx("div",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:".08em"},children:"Signed-in account"}),s.jsx("div",{style:{marginTop:7,fontWeight:650},children:e})]}),s.jsxs("div",{className:"card inset",style:{padding:14},children:[s.jsx("div",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:".08em"},children:"Email verification"}),s.jsx("div",{style:{marginTop:7,fontWeight:650,color:"var(--pass)"},children:"Verified"})]}),s.jsxs("div",{className:"card inset",style:{padding:14},children:[s.jsx("div",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:".08em"},children:"Active plan"}),s.jsx("div",{style:{marginTop:7,fontWeight:650},children:(i==null?void 0:i.label)??"Checking…"}),(i==null?void 0:i.source)==="control-plane"&&s.jsx("div",{className:"muted",style:{marginTop:5,fontSize:12},children:"Confirmed by Prooflane Cloud Workspace"}),(i==null?void 0:i.source)==="local-dev"&&s.jsx("div",{className:"muted",style:{marginTop:5,fontSize:12},children:"Local development override"}),(i==null?void 0:i.source)==="fallback-free"&&s.jsxs("div",{style:{marginTop:5,fontSize:12,color:"var(--fail)"},children:["Free protections are active: ",((ue=i.reason)==null?void 0:ue.replaceAll("-"," "))??"plan could not be confirmed","."]}),(i==null?void 0:i.subject)&&s.jsxs("div",{className:"muted mono",style:{marginTop:8,fontSize:11},children:["Account key: ",i.subject]})]})]})]}),s.jsx(R5,{enabled:t&&n}),s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Cloud history & recovery"}),s.jsx("div",{className:"muted",style:{marginTop:7,fontSize:13,maxWidth:710},children:o?`Encrypted backup is enabled every ${l??24} hours while Inspector is open and signed in.`:"Back up selected assurance runs, contracts, prompts and recorded sessions to identify drift, compare regressions, and recover your workspace if this device is lost."})]}),s.jsxs("div",{className:"row",style:{gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn ghost",onClick:ce,disabled:N||S||!t||!n,title:"Recover runs, contracts, prompts, and sessions from your latest encrypted cloud backup into this device.",children:N?"Restoring…":"Restore from Cloud"}),s.jsx("button",{className:"btn primary",onClick:K,disabled:S||N||!t||!n,children:S?"Backing up…":"Back up local workspace"})]})]}),s.jsxs("div",{className:"card inset",style:{padding:14,marginTop:16,fontSize:13},children:[s.jsx("b",{children:"Private by design."})," Your MCP connection details and credentials always stay on this device; Prooflane refuses them at the Cloud Workspace boundary. Without a completed backup, local assurance history is removed at your next sign-in or session expiry. After an encrypted backup, approved history can be recovered, but connection details and credentials are still cleared locally."]}),x&&s.jsxs("div",{className:"muted",style:{marginTop:13,fontSize:12.5},children:["Latest encrypted backup: ",new Date(x.createdAt).toLocaleString()," · ",x.counts.runs," runs · ",x.counts.sessions," sessions · ",x.counts.snapshots," contracts · ",x.counts.prompts," prompts. If your local workspace is blank, choose ",s.jsx("b",{children:"Restore from Cloud"})," to recover it."]}),_&&s.jsx("div",{style:{marginTop:13,color:"var(--pass)",fontSize:12.5},children:_}),C&&s.jsx("div",{style:{marginTop:13,color:"var(--fail)",fontSize:12.5},children:C}),s.jsx("div",{style:{marginTop:14},children:s.jsx("button",{className:"btn ghost sm",onClick:F,disabled:W||!t||!n,children:W?"Loading…":"Show backup history"})}),I&&s.jsx("div",{className:"card inset",style:{padding:14,marginTop:12,fontSize:12.5},children:I.length===0?s.jsx("div",{className:"muted",children:"No cloud backups exist for this account yet."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"muted",style:{marginBottom:8},children:[I.length," cloud version",I.length===1?"":"s",", newest first. A version with non-zero counts is recoverable — ",s.jsx("b",{children:"Restore from Cloud"})," recovers the newest non-empty one."]}),s.jsx("div",{style:{display:"grid",gap:4},children:I.map(oe=>{const B=oe.counts.runs+oe.counts.sessions+oe.counts.snapshots+oe.counts.prompts;return s.jsxs("div",{className:"mono",style:{display:"flex",justifyContent:"space-between",gap:12,color:B>0?"var(--pass)":"var(--muted)"},children:[s.jsx("span",{children:new Date(oe.capturedAt).toLocaleString()}),s.jsxs("span",{children:[oe.counts.runs," runs · ",oe.counts.snapshots," contracts · ",oe.counts.prompts," prompts · ",oe.counts.sessions," sessions",B===0?" · (empty)":""]})]},oe.id)})})]})})]}),s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"section-title",children:"Run hosted Intelligence"}),s.jsx("div",{className:"muted",style:{marginTop:7,fontSize:13},children:"Prooflane issues one signed, four-hour task. The local Runner executes it with your local connection."})]}),s.jsx(Qr,{})]}),s.jsxs("div",{className:"row",style:{marginTop:18,gap:8},children:[s.jsx("button",{className:`btn sm ${c==="security"?"primary":"ghost"}`,onClick:()=>u("security"),children:"Security red-team"}),s.jsx("button",{className:`btn sm ${c==="rag"?"primary":"ghost"}`,onClick:()=>u("rag"),children:"RAG Assurance"})]}),c==="rag"&&s.jsxs("div",{style:{marginTop:15},children:[s.jsx("label",{className:"label",children:"Local retriever tool"}),s.jsxs("select",{className:"field",value:d,onChange:oe=>h(oe.target.value),disabled:!r,children:[!Y.length&&s.jsx("option",{value:"",children:r?"No likely retriever tool found":"Connect an MCP server first"}),Y.map(oe=>s.jsx("option",{value:oe.name,children:oe.name},oe.name))]})]}),s.jsx("button",{className:"btn primary",style:{marginTop:18},onClick:ie,disabled:g!==null,children:g==="run"?"Running locally…":"Request task & run"})]}),f&&s.jsx("div",{className:"drift dirty",children:s.jsxs("div",{className:"drift-row",children:[s.jsx("span",{className:"tag fail",children:"setup"}),s.jsx("span",{style:{fontSize:13},children:f})]})}),b&&s.jsxs("section",{className:"card",style:{padding:22},children:[s.jsxs("div",{className:"row spread",style:{gap:12},children:[s.jsx("div",{className:"section-title",children:"Latest hosted result"}),s.jsx("span",{className:`tag ${b.outcome==="pass"?"pass":b.outcome==="fail"?"fail":"warn"}`,children:b.outcome})]}),s.jsxs("div",{className:"grid-3",style:{marginTop:16,gap:12},children:[s.jsx(If,{label:"Task",value:b.label}),s.jsx(If,{label:"Score",value:`${b.score}/100`}),s.jsx(If,{label:"Latency",value:`${b.latencyMs} ms`})]}),s.jsxs("div",{className:"muted",style:{marginTop:14,fontSize:13},children:[b.summary," ",b.stored?"Raw output was encrypted and saved to your cloud workspace.":"Only compact evidence was accepted; raw output stayed local."]})]})]})}function If({label:e,value:t}){return s.jsxs("div",{className:"card inset",style:{padding:13},children:[s.jsx("div",{className:"muted",style:{fontSize:11,textTransform:"uppercase",letterSpacing:".08em"},children:e}),s.jsx("div",{style:{marginTop:7,fontSize:15,fontWeight:650},children:t})]})}const Af="prooflane.mcp-tool-selector.collapsed";function M5({featureType:e,resourceId:t,value:n,activeConnectionId:a,onChange:r,onConnectionSelect:i,onConnect:o,onManageConnections:l,required:c=!1,compact:u=!1}){const[d,h]=p.useState([]),[g,v]=p.useState([]),[f,y]=p.useState(null),[b,m]=p.useState(null),[x,j]=p.useState(!0),[S,w]=p.useState(!1),[C,k]=p.useState(null),[N,L]=p.useState(""),[_,E]=p.useState(""),[I,$]=p.useState(null),[W,R]=p.useState(()=>{try{return localStorage.getItem(Af)==="true"}catch{return!1}}),H=n===void 0?f:n,Y=P=>{R(P);try{localStorage.setItem(Af,String(P))}catch{}},K=(P,T)=>{n===void 0&&y(P),r==null||r(P,T)},ce=async()=>{var P,T,he;j(!0),$(null);try{const[q,se,ge]=await Promise.all([O.mcpConnections(),O.mcpTools(),O.mcpBinding(e,t)]);h(q.connections),m(q.entitlement),v(se.tools);const de=a&&q.connections.some(Ne=>Ne.id===a)?a:((P=ge.binding)==null?void 0:P.connectionId)??((T=q.connections.find(Ne=>Ne.status==="CONNECTED"))==null?void 0:T.id)??((he=q.connections[0])==null?void 0:he.id)??"";E(de),K(ge.binding);try{ge.binding&&localStorage.getItem(Af)===null&&R(!0)}catch{}}catch(q){$(q instanceof Error?q.message:"MCP tools could not be loaded.")}finally{j(!1)}};p.useEffect(()=>{ce()},[e,t]),p.useEffect(()=>{a&&d.some(P=>P.id===a)&&E(a)},[a,d]),p.useEffect(()=>{!a&&(H!=null&&H.connectionId)&&d.some(P=>P.id===H.connectionId)&&E(H.connectionId)},[a,H==null?void 0:H.connectionId,d]);const F=p.useMemo(()=>{const P=N.trim().toLowerCase();return P?g.filter(T=>`${T.serverName} ${T.toolName} ${T.description??""}`.toLowerCase().includes(P)):g},[N,g]),ie=d.find(P=>P.id===_),ue=F.filter(P=>P.connectionId===_),oe=(b==null?void 0:b.maxConnections)!==-1&&d.length>=((b==null?void 0:b.maxConnections)??0),B=P=>{E(P),L("");const T=d.find(he=>he.id===P);(T==null?void 0:T.status)==="CONNECTED"&&(i==null||i(P))},Q=async P=>{if(!S){w(!0),$(null);try{const T=await O.mcpPutBinding(e,t,{connectionId:P.connectionId,toolName:P.toolName,schemaDigest:P.schemaDigest});h(he=>he.map(q=>q.id===T.connection.id?T.connection:q)),E(T.connection.id),K(T.binding,{connection:T.connection,capabilities:T.capabilities}),Y(!0)}catch(T){$(T instanceof Error?T.message:"The MCP tool binding could not be saved.")}finally{w(!1)}}},X=async P=>{k(P),$(null);try{const T=await O.mcpRefreshTools(P);h(q=>q.map(se=>se.id===P?T.connection:se)),v(q=>[...q.filter(se=>se.connectionId!==P),...T.tools]);const he=await O.mcpBinding(e,t);K(he.binding)}catch(T){$(T instanceof Error?T.message:"Tool discovery refresh failed.")}finally{k(null)}};if(x)return s.jsx("div",{className:`mcp-selector ${u?"compact":""}`,children:s.jsx("span",{className:"muted",children:"Loading MCP connections and tools…"})});if(b&&!b.mcpEnabled)return s.jsxs("div",{className:`mcp-selector invalid ${u?"compact":""}`,children:[s.jsx("strong",{children:"MCP is not enabled for this workspace."}),s.jsx("span",{className:"muted",children:"Ask a workspace admin to enable the MCP entitlement."})]});if(!d.length)return s.jsxs("div",{className:`mcp-selector empty ${u?"compact":""}`,children:[s.jsxs("div",{children:[s.jsxs("strong",{children:["Select MCP tool",c?" · required":""]}),s.jsx("div",{className:"muted",children:"Connect and manage multiple MCP servers in Settings, then choose one server and one tool here."})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[l&&s.jsx("button",{className:"btn sm ghost",onClick:l,children:"Open Settings"}),o&&s.jsx("button",{className:"btn sm primary",onClick:o,children:"Connect MCP server"})]})]});const me=H?d.find(P=>P.id===H.connectionId):void 0,fe=H&&H.status!=="VALID";return s.jsxs("section",{className:`mcp-selector ${u?"compact":""}`,"aria-label":"MCP tool selector",children:[s.jsxs("div",{className:"mcp-selector-head",children:[s.jsxs("div",{children:[s.jsxs("strong",{children:["Select MCP tool",c?" · required":""]}),s.jsx("div",{className:"muted",children:"One server + one tool is captured for this feature and every run."})]}),s.jsxs("div",{className:"row",style:{gap:8},children:[H&&s.jsx("span",{className:`tag ${H.status==="VALID"?"pass":"warn"}`,children:H.status.replaceAll("_"," ").toLowerCase()}),o&&s.jsx("button",{type:"button",className:"btn sm ghost",disabled:!!oe,onClick:o,children:"+ Add server"}),s.jsxs("button",{type:"button",className:"btn sm ghost mcp-selector-toggle",onClick:()=>Y(!W),"aria-expanded":!W,"aria-controls":`${e}:${t}:mcp-selector-body`,children:[W?"Expand":"Collapse"," ",s.jsx("span",{"aria-hidden":"true",children:W?"+":"−"})]})]})]}),W&&s.jsxs("div",{className:"mcp-selector-summary",role:"status",children:[s.jsxs("div",{children:[s.jsx("strong",{children:(me==null?void 0:me.displayName)??(ie==null?void 0:ie.displayName)??"MCP target"}),s.jsx("span",{className:"muted",children:H?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:H.toolName})," · selected for this feature"]}):"Choose a tool before running this feature"})]}),(H==null?void 0:H.schemaDigest)&&s.jsxs("span",{className:"mono mcp-schema-digest",title:H.schemaDigest,children:[H.schemaDigest.slice(0,17),"…"]})]}),s.jsxs("div",{id:`${e}:${t}:mcp-selector-body`,className:"mcp-selector-body",hidden:W,children:[fe&&s.jsxs("div",{className:"mcp-selector-warning",children:[s.jsx("strong",{children:"Saved MCP target needs attention."}),s.jsxs("span",{children:[(me==null?void 0:me.displayName)??H.connectionId," / ",H.toolName," · ",H.status.replaceAll("_"," ").toLowerCase()]}),s.jsx("span",{className:"mono",children:H.schemaDigest})]}),s.jsxs("div",{className:"mcp-server-choice",children:[s.jsx("label",{className:"label",htmlFor:`${e}:${t}:mcp-server`,children:"MCP server"}),s.jsx("select",{id:`${e}:${t}:mcp-server`,className:"field",value:_,onChange:P=>B(P.target.value),children:d.map(P=>s.jsxs("option",{value:P.id,children:[P.displayName," · ",P.status.toLowerCase().replaceAll("_"," ")," · ",P.toolCount," tools"]},P.id))}),s.jsxs("div",{className:"mcp-settings-hint",children:[s.jsx("span",{children:"Only tools from this server are shown below. Connect and manage multiple MCP servers in Settings."}),l&&s.jsx("button",{type:"button",className:"btn sm ghost",onClick:l,children:"Open Settings"})]})]}),s.jsx("input",{className:"field mcp-selector-search",value:N,onChange:P=>L(P.target.value),placeholder:"Search tools or MCP servers…","aria-label":"Search MCP tools"}),s.jsx("div",{className:"mcp-selector-groups",children:ie?(()=>{const P=ie.status!=="CONNECTED";return s.jsxs("fieldset",{className:"mcp-selector-group",disabled:P||S,children:[s.jsxs("legend",{children:[s.jsxs("span",{children:[s.jsx("strong",{children:ie.displayName}),s.jsx("span",{className:`mcp-health ${ie.healthStatus.toLowerCase()}`,children:ie.status.replaceAll("_"," ").toLowerCase()})]}),s.jsx("button",{type:"button",className:"btn sm ghost",disabled:P||C===ie.id,onClick:()=>void X(ie.id),children:C===ie.id?"Refreshing…":"Refresh tools"})]}),ue.length?ue.map(T=>{const he=(H==null?void 0:H.connectionId)===T.connectionId&&H.toolName===T.toolName&&H.schemaDigest===T.schemaDigest;return s.jsxs("label",{className:`mcp-tool-option ${he?"selected":""}`,children:[s.jsx("input",{type:"radio",name:`${e}:${t}:mcp-tool`,checked:he,disabled:!T.enabled||P||S,onChange:()=>void Q(T)}),s.jsxs("span",{children:[s.jsx("strong",{className:"mono",children:T.toolName}),T.description&&s.jsx("small",{children:T.description})]}),s.jsxs("span",{className:"mono mcp-schema-digest",title:T.schemaDigest,children:[T.schemaDigest.slice(0,17),"…"]})]},T.canonicalToolKey)}):s.jsx("div",{className:"muted mcp-selector-none",children:N?"No matching tools on this server.":ie.toolCount===0?"This server advertises zero tools.":"Tools are unavailable; refresh discovery."})]},ie.id)})():s.jsx("div",{className:"muted mcp-selector-none",children:"Select an MCP server to see its tools."})}),I&&s.jsx("div",{className:"mcp-selector-error",children:I})]})]})}function D5({onConnect:e,onReconnect:t,onChanged:n}){const[a,r]=p.useState([]),[i,o]=p.useState(null),[l,c]=p.useState(null),u=()=>O.targets().then(h=>r(h.targets)).catch(h=>c(h instanceof Error?h.message:"Targets could not be loaded."));p.useEffect(()=>{u()},[]);const d=async(h,g)=>{if(!(g==="remove"&&!window.confirm("Remove this target connection? Governed Suites, Policies, Gates, Runs, reports, and audit history remain intact."))){o(`${h.id}:${g}`),c(null);try{g==="test"?await O.targetTest(h.id):g==="refresh"?await O.targetRefresh(h.id):g==="disconnect"?await O.targetDisconnect(h.id):await O.targetRemove(h.id),await u(),n==null||n()}catch(v){c(v instanceof Error?v.message:`Target ${g} failed.`)}finally{o(null)}}};return s.jsxs("section",{className:"card mcp-connections-view",children:[s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"flex-start"},children:[s.jsxs("div",{children:[s.jsx("div",{className:"eyebrow",children:"Local target registry"}),s.jsx("h3",{children:"Target Connections"}),s.jsx("p",{className:"muted",children:"Manage MCP, API, RAG, target-model, and agent connections. Only safe normalized surface metadata and fingerprints are registered; credentials remain in the local session."})]}),s.jsx("button",{className:"btn sm primary",onClick:()=>e(),children:"+ Connect a target"})]}),s.jsxs("div",{className:"mcp-connection-list",children:[!a.length&&s.jsx("div",{className:"muted",children:"No target connections are registered yet."}),a.map(h=>s.jsxs("article",{className:"mcp-connection-row",children:[s.jsx("span",{className:`conn-dot ${h.connectionStatus==="READY"?"on":""}`}),s.jsxs("div",{className:"mcp-connection-main",children:[s.jsx("strong",{children:h.displayName}),s.jsxs("span",{className:"muted",children:[h.type.replaceAll("_"," / ")," · ",h.connectionStatus.replaceAll("_"," ").toLowerCase()," · ",h.discoveryMetadata.capabilityCount," capabilities"]}),s.jsxs("small",{className:"muted",children:["Target ",QS(h.targetFingerprint)," · Surface ",QS(h.surfaceFingerprint)," · Auth ",h.authProfile.mode.toLowerCase().replaceAll("_"," ")]}),h.lastError&&s.jsx("small",{className:"mcp-selector-error",children:h.lastError})]}),s.jsxs("div",{className:"row",style:{gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:[h.connectionStatus==="READY"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn sm ghost",disabled:i!==null,onClick:()=>void d(h,"test"),children:"Test"}),s.jsx("button",{className:"btn sm ghost",disabled:i!==null,onClick:()=>void d(h,"refresh"),children:"Refresh"}),s.jsx("button",{className:"btn sm ghost",disabled:i!==null,onClick:()=>void d(h,"disconnect"),children:"Disconnect"})]}):s.jsx("button",{className:"btn sm primary",disabled:i!==null,onClick:()=>t(h),children:"Reconnect"}),s.jsx("button",{className:"btn sm ghost danger",disabled:i!==null,onClick:()=>void d(h,"remove"),children:"Remove"})]})]},h.id))]}),l&&s.jsx("div",{className:"mcp-selector-error",children:l})]})}function QS(e){return e?`${e.slice(0,19)}…`:"pending"}const z5=[{type:"MCP",label:"MCP Server",description:"Tools, prompts, resources"},{type:"HTTP_API",label:"HTTP / API",description:"OpenAPI, REST, chat, inference APIs"},{type:"RAG",label:"RAG System",description:"Full-chain or retriever-only"},{type:"MODEL",label:"Model Endpoint",description:"Provider or compatible API"},{type:"AGENT",label:"AI Agent",description:"Agent invoke and trace adapter"}];function U5({availableTypes:e,workspaceId:t,projectId:n,targets:a,onChoose:r,onImport:i,onReconnect:o,onRemove:l,onSignOut:c}){return s.jsxs("div",{className:"target-onboarding",children:[s.jsxs("header",{children:[s.jsxs("div",{className:"brand",children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"agent assurance spine"})]})]}),s.jsxs("div",{className:"row",children:[s.jsxs("span",{className:"tag informational",children:["Workspace · ",t]}),s.jsxs("span",{className:"tag informational",children:["Project · ",n]}),s.jsx("button",{className:"btn sm ghost",onClick:c,children:"Sign out"})]})]}),s.jsxs("main",{className:"target-onboarding-card",children:[s.jsx("div",{className:"eyebrow",children:"Required setup"}),s.jsx("h1",{children:"Connect your first target"}),s.jsx("p",{children:"Connect the AI system you want Prooflane to evaluate. Credentials and raw execution evidence remain local unless a feature explicitly tells you otherwise."}),s.jsx("div",{className:"target-type-grid onboarding-grid",children:z5.map(u=>{const d=e.includes(u.type);return s.jsxs("button",{className:"target-type-card",disabled:!d,onClick:()=>r(u.type),children:[s.jsx("span",{children:u.label}),s.jsx("small",{children:u.description}),d&&u.type==="MCP"&&s.jsx("b",{children:"AVAILABLE"}),d&&u.type!=="MCP"&&s.jsx("b",{children:"BETA"}),!d&&s.jsx("b",{children:"COMING SOON"})]},u.type)})}),s.jsxs("div",{className:"row",style:{marginTop:16,gap:8,flexWrap:"wrap"},children:[s.jsx("button",{className:"btn sm ghost",onClick:i,children:"Import connection config"}),s.jsx("button",{className:"btn sm ghost",onClick:()=>F5(),children:"Download sample config"})]}),a.length>0&&s.jsxs("div",{className:"target-onboarding-existing",children:[s.jsx("div",{className:"eyebrow",children:"Needs attention"}),a.map(u=>s.jsxs("div",{className:"row spread",children:[s.jsxs("span",{children:[s.jsx("strong",{children:u.displayName}),s.jsxs("small",{children:[u.type.replaceAll("_"," / ")," · ",u.connectionStatus.replaceAll("_"," ").toLowerCase()]})]}),s.jsxs("div",{className:"row",children:[s.jsx("button",{className:"btn sm primary",onClick:()=>o(u),children:"Reconnect"}),s.jsx("button",{className:"btn sm ghost danger",onClick:()=>l(u),children:"Remove"})]})]},u.id))]}),s.jsxs("details",{className:"target-help",children:[s.jsx("summary",{children:"Connection help"}),s.jsx("p",{children:"Choose MCP for stdio or remote MCP transports. API, RAG, model, and agent adapters test their configured endpoint locally before the product unlocks. A test connection is never governed evidence."})]})]})]})}function F5(){const e=URL.createObjectURL(new Blob([`${JSON.stringify(Tv,null,2)}
|
|
77
|
-
`],{type:"application/json"})),t=document.createElement("a");t.href=e,t.download=Cv,t.click(),URL.revokeObjectURL(e)}function G5(e,t=Date.now()){if(!e)return null;const n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,Math.ceil((n-t)/864e5))}function W5({plan:e,onStarted:t}){const[n,a]=p.useState(!1),[r,i]=p.useState(null);if(!e||e.source==="local-dev")return null;const o=e.trialDaysRemaining??G5(e.expiresAt);if(e.tier==="trial"&&o!==null){const l=o<=7;return s.jsx("div",{className:"card",style:{padding:"10px 14px",borderColor:l?"var(--warn)":void 0},children:s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("span",{style:{fontSize:12.5},children:[s.jsx("span",{className:`tag ${l?"warn":"pass"}`,style:{marginRight:8},children:"TRIAL"}),o===0?"Your free trial ends today.":`${o} day${o===1?"":"s"} left on your free trial.`," ",s.jsx("span",{className:"muted",children:"Everything stays — runs, contracts and history are yours. Security, RAG and Gates lock when it ends."})]}),s.jsx("span",{className:"tag informational",children:"FULL ACCESS"})]})})}if(e.tier==="free"&&(e.trialStatus==="expired"||e.configuredTier==="trial"&&e.trialUsed))return s.jsx("div",{className:"card",style:{padding:"10px 14px",borderColor:"var(--warn)"},children:s.jsxs("span",{style:{fontSize:12.5},children:[s.jsx("span",{className:"tag warn",style:{marginRight:8},children:"READ-ONLY"}),"Your trial is complete. Existing projects, runs, evidence, Gates, benchmarks, reports, and settings remain available; upgrade options appear only when you start a locked operation."]})});if(e.tier==="free"&&!e.trialUsed){const l=async()=>{a(!0),i(null);try{await O.startTrial(),t()}catch(c){i(c instanceof Error?c.message:"The trial could not be started.")}finally{a(!1)}};return s.jsx("div",{className:"card",style:{padding:"10px 14px"},children:s.jsxs("div",{className:"row spread",style:{gap:12,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("span",{style:{fontSize:12.5},children:["Try every Prooflane feature free for ",e.trialDays??30," days — including Security, RAG, Gates and hosted runs.",s.jsx("span",{className:"muted",children:" No card. One trial per account."})]}),s.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[r&&s.jsx("span",{className:"muted",style:{fontSize:12},children:r}),s.jsx("button",{className:"btn sm primary",disabled:n,onClick:l,children:n?"Starting…":"Start 30-day full-access trial"})]})]})})}return null}const cC="2026-08-20",dC="1",Xn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","referrer","landing_page"],uC={marketing_page_view:["page_path","page_title",...Xn],trial_cta_viewed:["page_path","cta_location","cta_text","cta_variant",...Xn],start_free_clicked:["page_path","cta_location","cta_variant","destination","requested_plan",...Xn],trial_modal_shown:["trigger","page_path","scroll_depth",...Xn],trial_modal_dismissed:["trigger","page_path","scroll_depth",...Xn],trial_modal_clicked:["trigger","page_path","scroll_depth","cta_location","cta_variant","destination",...Xn],register_page_view:["page_path","requested_plan",...Xn],registration_started:["page_path","requested_plan","auth_method",...Xn],registration_validation_failed:["page_path","field","reason","stage"],registration_submitted:["page_path","requested_plan","auth_method",...Xn],registration_completed:["page_path","requested_plan","auth_method",...Xn],registration_abandoned:["page_path","stage","requested_plan",...Xn],trial_started:["trial_id","days_remaining","entitlement_version","requested_plan"],trial_day_7:["trial_id","days_remaining","entitlement_version"],trial_day_14:["trial_id","days_remaining","entitlement_version"],trial_day_21:["trial_id","days_remaining","entitlement_version"],trial_expiring:["trial_id","days_remaining","entitlement_version"],trial_expired:["trial_id","days_remaining","entitlement_version"],upgrade_started:["requested_plan","current_plan","trial_id"],subscription_activated:["requested_plan","current_plan","entitlement_version"],inspector_download_page_viewed:["os","architecture","release_channel","version","page_path"],inspector_download_clicked:["os","architecture","release_channel","version","page_path"],inspector_launch_authorized:["os","architecture","release_channel","version"],inspector_first_launch:["os","architecture","release_channel","version"],inspector_login_completed:["os","architecture","release_channel","version"],cli_install_command_viewed:["os","architecture","release_channel","version","page_path"],cli_install_command_copied:["os","architecture","release_channel","version","page_path"],cli_authenticated:["os","architecture","release_channel","version"],cli_first_command_completed:["os","architecture","release_channel","version","feature","result"],first_login_completed:["auth_method","release_channel","version"],target_connection_started:["target_type","feature"],target_connection_failed:["target_type","feature","failure_category","duration_bucket"],target_connected:["target_type","feature","duration_bucket"],first_run_started:["target_type","feature","run_type"],first_run_failed:["target_type","feature","run_type","failure_category","duration_bucket"],first_run_completed:["target_type","feature","run_type","result","duration_bucket"],gate_decision_generated:["target_type","feature","result","duration_bucket"],gate_decision_viewed:["target_type","feature","result"],first_assurance_value_reached:["target_type","feature","result","run_type"],use_case_selected:["use_case"]};class Mn extends Error{constructor(n,a){super(a);vt(this,"code");this.name="AnalyticsPrivacyError",this.code=n}}const H5=new Set(["marketing","webapp","inspector","cli","backend"]),B5=new Set(Object.keys(uC));function nc(e,t){if(e===void 0)return;const n=e.trim();if(!n||n.length>160||/[\r\n]/.test(n))throw new Mn("invalid_event",`${t} is invalid.`);return n}function V5(e){if(!B5.has(e.name))throw new Mn("invalid_event",`Unknown analytics event: ${String(e.name)}`);if(!H5.has(e.source))throw new Mn("invalid_event",`Unknown analytics source: ${String(e.source)}`);if(nc(e.eventId,"eventId"),nc(e.sessionId,"sessionId"),nc(e.anonymousId,"anonymousId"),nc(e.userId,"userId"),nc(e.organizationId,"organizationId"),!Number.isFinite(Date.parse(e.timestamp)))throw new Mn("invalid_event","timestamp is invalid.");if(e.page!==void 0&&(!e.page.startsWith("/")||e.page.length>256||/[?#\r\n]/.test(e.page)))throw new Mn("invalid_event","page must be a query-free application path.");if(e.properties&&(Array.isArray(e.properties)||Object.getPrototypeOf(e.properties)!==Object.prototype))throw new Mn("invalid_event","properties must be a plain object.")}const q5=["password","passwd","secret","token","authorization","apikey","prompt","response","document","toolinput","tooloutput","mcpconfig","retrievedcontent","retrieveddocument","evidenceraw","rawoutput","rawinput"],K5=[/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/i,/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp|xoxa|xoxr)-[A-Za-z0-9_-]{12,}\b/i,/-----BEGIN [A-Z ]*PRIVATE KEY-----/,/\beyJ[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{12,}\b/,/(?:https?|postgres(?:ql)?|mysql|mongodb(?:\+srv)?):\/\/[^\s/:]+:[^\s/@]+@/i,/["']?(?:password|secret|api[_-]?key|authorization)["']?\s*[:=]\s*["'][^"']{4,}["']/i];function J5(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function Y5(e){const t=J5(e);return q5.some(n=>t.includes(n))}function Z5(e){return K5.some(t=>t.test(e))}class X5{inspect(t){V5(t);const n=t.properties??{},a=new Set(uC[t.name]),r={};for(const[i,o]of Object.entries(n)){if(Y5(i))throw new Mn("prohibited_property",`Analytics property '${i}' is prohibited.`);if(!a.has(i))throw new Mn("prohibited_property",`Analytics property '${i}' is not allowlisted for ${t.name}.`);if(o!==null&&typeof o!="string"&&typeof o!="number"&&typeof o!="boolean")throw new Mn("invalid_event",`Analytics property '${i}' must be a primitive.`);if(typeof o=="number"&&!Number.isFinite(o))throw new Mn("invalid_event",`Analytics property '${i}' must be finite.`);if(typeof o=="string"){if(o.length>512||/[\r\n]/.test(o))throw new Mn("invalid_event",`Analytics property '${i}' exceeds its safe bound.`);if(Z5(o))throw new Mn("suspected_secret",`Analytics property '${i}' resembles secret material.`)}r[i]=o}return{...t,properties:Object.keys(r).length?r:void 0}}}const eN="prooflane-analytics-consent",Fu="prooflane-analytics-anonymous-id",Pf="prooflane-analytics-session-id",tN="prooflane-analytics-attribution",Q5=()=>{const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}};function sN(e){var t;try{const n=(t=globalThis.window)==null?void 0:t[e];if(n)return n}catch{}return Q5()}function eU(){if(typeof navigator>"u")return{globalPrivacyControl:!1,doNotTrack:!1};const e=navigator;return{globalPrivacyControl:e.globalPrivacyControl===!0,doNotTrack:navigator.doNotTrack==="1"||e.msDoNotTrack==="1"}}function tU(e,t,n){if(!e)return null;try{const a=JSON.parse(e);return a.essential!==!0||typeof a.analytics!="boolean"||a.policyVersion!==t||a.consentVersion!==n||typeof a.updatedAt!="string"||!["banner","privacy_settings","jurisdiction_default"].includes(a.source??"")?null:a}catch{return null}}class sU{constructor(t={}){vt(this,"policyVersion");vt(this,"consentVersion");vt(this,"signals");vt(this,"local");vt(this,"session");vt(this,"now");vt(this,"listeners",new Set);vt(this,"state");vt(this,"decided");this.policyVersion=t.policyVersion??cC,this.consentVersion=t.consentVersion??dC,this.local=t.localStorage??sN("localStorage"),this.session=t.sessionStorage??sN("sessionStorage"),this.now=t.now??(()=>new Date);const n=eU();this.signals={...n,...t.signals};const a=tU(this.local.getItem(eN),this.policyVersion,this.consentVersion);this.decided=a!==null,this.state=a??this.newState(!1,"jurisdiction_default"),this.isAnalyticsAllowed()||this.clearAnalyticsStorage()}newState(t,n){return{essential:!0,analytics:t,functional:!1,marketing:!1,policyVersion:this.policyVersion,consentVersion:this.consentVersion,updatedAt:this.now().toISOString(),source:n}}getState(){return{...this.state}}hasDecision(){return this.decided}isPrivacySignalActive(){return this.signals.globalPrivacyControl||this.signals.doNotTrack}isAnalyticsAllowed(){return this.state.analytics&&!this.isPrivacySignalActive()}updateAnalytics(t,n="privacy_settings"){this.state=this.newState(t&&!this.isPrivacySignalActive(),n),this.decided=!0,this.local.setItem(eN,JSON.stringify(this.state)),this.isAnalyticsAllowed()||this.clearAnalyticsStorage();for(const a of this.listeners)a(this.getState());return this.getState()}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}getAnonymousId(t=!0){if(!this.isAnalyticsAllowed())return;const n=this.local.getItem(Fu);if(n)return n;if(!t)return;const a=Wv();return this.local.setItem(Fu,a),a}adoptAnonymousId(t){if(!this.isAnalyticsAllowed())return!1;const n=t.trim();return/^[A-Za-z0-9_-]{8,160}$/.test(n)?(this.local.setItem(Fu,n),!0):!1}getSessionId(t=!0){if(!this.isAnalyticsAllowed())return;const n=this.session.getItem(Pf);if(n)return n;if(!t)return;const a=Wv();return this.session.setItem(Pf,a),a}clearAnalyticsStorage(){this.local.removeItem(Fu),this.local.removeItem(tN),this.session.removeItem(Pf),this.session.removeItem(tN)}}function Wv(){var t;if((t=globalThis.crypto)!=null&&t.randomUUID)return globalThis.crypto.randomUUID();const e=()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(36);return`${e()}-${e()}`}class nU{constructor(t){vt(this,"source");vt(this,"consent");vt(this,"adapters");vt(this,"enabled");vt(this,"debug");vt(this,"pageProvider");vt(this,"now");vt(this,"createId");vt(this,"guard");vt(this,"initialized",!1);vt(this,"userId");vt(this,"organizationId");this.source=t.source,this.consent=t.consent,this.adapters=t.adapters??[],this.enabled=t.enabled??!0,this.debug=t.debug??!1,this.pageProvider=t.page??(()=>{}),this.now=t.now??(()=>new Date),this.createId=t.createId??Wv,this.guard=t.guard??new X5,this.consent.subscribe(()=>{this.isEnabled()?this.ensureInitialized():this.disableAdapters()}),this.isEnabled()&&this.ensureInitialized()}isEnabled(){return this.enabled&&this.consent.isAnalyticsAllowed()&&this.adapters.length>0}ensureInitialized(){var t;if(!(this.initialized||!this.isEnabled())){this.initialized=!0;for(const n of this.adapters)try{Promise.resolve((t=n.initialize)==null?void 0:t.call(n)).catch(()=>{})}catch{}}}disableAdapters(){var t,n;if(this.initialized){this.initialized=!1;for(const a of this.adapters){try{Promise.resolve((t=a.reset)==null?void 0:t.call(a)).catch(()=>{})}catch{}try{Promise.resolve((n=a.shutdown)==null?void 0:n.call(a)).catch(()=>{})}catch{}}}}track(t,n={},a=this.pageProvider()){if(!this.isEnabled())return{accepted:!1,reason:"disabled"};this.ensureInitialized();try{const r=this.guard.inspect({name:t,eventId:this.createId(),timestamp:this.now().toISOString(),sessionId:this.consent.getSessionId(),anonymousId:this.consent.getAnonymousId(),userId:this.userId,organizationId:this.organizationId,source:this.source,page:a,properties:n});if(this.debug){const i=Object.entries(r.properties??{}).map(([o,l])=>`${o}=${String(l)}`).join(" ");console.info(`[Analytics] event=${r.name} source=${r.source}${r.page?` page=${r.page}`:""}${i?` ${i}`:""}`)}for(const i of this.adapters)try{Promise.resolve(i.track(r)).catch(()=>{})}catch{}return{accepted:!0,event:r}}catch(r){const i=r instanceof Error?r:new Error(String(r));return this.debug&&console.warn(`[Analytics] event=${t} rejected=${i.name}`),{accepted:!1,reason:"rejected",error:i}}}page(t,n={}){return this.track(t,n,this.pageProvider())}identify(t,n){var r;if(!this.isEnabled()||!t.trim())return!1;this.userId=t.trim().slice(0,160),this.organizationId=(n==null?void 0:n.trim().slice(0,160))||void 0;const a=this.consent.getAnonymousId();for(const i of this.adapters)try{Promise.resolve((r=i.identify)==null?void 0:r.call(i,this.userId,this.organizationId,a)).catch(()=>{})}catch{}return!0}reset(){var t;this.userId=void 0,this.organizationId=void 0;for(const n of this.adapters)try{Promise.resolve((t=n.reset)==null?void 0:t.call(n)).catch(()=>{})}catch{}this.consent.clearAnalyticsStorage()}getAnonymousId(){return this.consent.getAnonymousId()}}var Me=typeof window<"u"?window:void 0,$s=typeof globalThis<"u"?globalThis:Me,wn=$s==null?void 0:$s.navigator,Ze=$s==null?void 0:$s.document,Kt=$s==null?void 0:$s.location,Fx=$s==null?void 0:$s.fetch,Hv=$s!=null&&$s.XMLHttpRequest&&"withCredentials"in new $s.XMLHttpRequest?$s.XMLHttpRequest:void 0,nN=$s==null?void 0:$s.AbortController,aU=$s==null?void 0:$s.CompressionStream,Xs=wn==null?void 0:wn.userAgent,ac=typeof globalThis<"u"?globalThis:Me;ac&&typeof self>"u"&&(ac.self=ac),ac&&typeof File>"u"&&(ac.File=function(){});var xn=Me??{},ls={DEBUG:!1,LIB_VERSION:"0.5.0",LIB_NAME:"browser-common"};function aN(e,t,n,a,r,i,o){try{var l=e[i](o),c=l.value}catch(u){return void n(u)}l.done?t(c):Promise.resolve(c).then(a,r)}function hr(e){return function(){var t=this,n=arguments;return new Promise(function(a,r){var i=e.apply(t,n);function o(c){aN(i,a,r,o,l,"next",c)}function l(c){aN(i,a,r,o,l,"throw",c)}o(void 0)})}}function Qe(){return Qe=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Qe.apply(null,arguments)}var rc,rU=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],rN=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),iU=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],oU=["token"],hC="NativeGzipValidationError",Bv=e=>e.length>=2&&e[0]===31&&e[1]===139,iN=(e,t)=>e===rN.GZipJS||t===rN.GZipJS||t==="gzip",oN=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError",Gu=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=hC,t},lU=function(){var e=hr(function*(t,n){18>t.size&&Gu("too-short");var a=new Uint8Array(yield t.slice(0,10).arrayBuffer());Bv(a)&&a[2]===8||Gu("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(o=>{for(var l=(()=>{if(rc)return rc;rc=[];for(var d=0;256>d;d++){for(var h=d,g=0;8>g;g++)h=1&h?3988292384^h>>>1:h>>>1;rc[d]=h>>>0}return rc})(),c=4294967295,u=0;o.length>u;u++)c=l[255&(c^o[u])]^c>>>8;return(4294967295^c)>>>0})(n)&&Gu("invalid-crc");var i=n.length>>>0;r.getUint32(4,!0)!==i&&Gu("invalid-size")});return function(t,n){return e.apply(this,arguments)}}();function Vv(){return Vv=hr(function*(e,t,n){t===void 0&&(t=!0);try{var a=new TextEncoder().encode(e),r=new globalThis.CompressionStream("gzip"),i=r.writable.getWriter(),o=i.write(a).then(()=>i.close()).catch(function(){var u=hr(function*(d){try{yield i.abort(d)}catch{}throw d});return function(d){return u.apply(this,arguments)}}()),l=new Response(r.readable).blob(),c=(yield Promise.all([l,o]))[0];return yield lU(c,a),c}catch(u){if(n!=null&&n.rethrow)throw u;return t&&console.error("Failed to gzip compress data",u),null}}),Vv.apply(this,arguments)}var cU=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],lN=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return cU.concat(t).some(a=>{var r=a.toLowerCase();return n.indexOf(r)!==-1})};function rt(e,t){return e.indexOf(t)!==-1}var qv=function(e){return e.replace(/^\$/,"")},pC=Object.prototype,mC=pC.hasOwnProperty,Zp=pC.toString,It=Array.isArray||function(e){return Zp.call(e)==="[object Array]"},Ea=e=>typeof e=="function",da=e=>e===Object(e)&&!It(e),Za=e=>{if(da(e)){for(var t in e)if(mC.call(e,t))return!1;return!0}return!1},Ve=e=>e===void 0,As=e=>Zp.call(e)=="[object String]",cN=e=>As(e)&&e.trim().length===0,Sn=e=>e===null,wi=e=>Ve(e)||Sn(e),Aa=e=>Zp.call(e)=="[object Number]"&&e==e,Ha=e=>Aa(e)&&e>0,bo=e=>Zp.call(e)==="[object Boolean]",dU=e=>e instanceof FormData,uU=e=>rt(iU,e),hU=e=>rt(oU,e),pU=[!0,"true",1,"1","yes"],$f=e=>rt(pU,e),mU=[!1,"false",0,"0","no"];function $i(e,t,n,a,r){return t>n&&(a.warn("min cannot be greater than max."),t=n),Aa(e)?e>n?(a.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(a.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(a.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+r),$i(r||n,t,n,a))}var En="Mobile",cp="iOS",sr="Android",fl="Tablet",fC=sr+" "+fl,gC="iPad",vC="Apple",yC=vC+" Watch",Yc="Safari",gl="BlackBerry",xC="Samsung",jC=xC+"Browser",bC=xC+" Internet",Fi="Chrome",fU=Fi+" OS",wC=Fi+" "+cp,Gx="Internet Explorer",SC=Gx+" "+En,Wx="Opera",gU=Wx+" Mini",Hx="Edge",NC="Microsoft "+Hx,Xo="Firefox",kC=Xo+" "+cp,Sd="Nintendo",Nd="PlayStation",Qo="Xbox",EC=sr+" "+En,_C=En+" "+Yc,Nc="Windows",Kv=Nc+" Phone",dN="Nokia",Jv="Ouya",CC="Generic",vU=CC+" "+En.toLowerCase(),TC=CC+" "+fl.toLowerCase(),Yv="Konqueror",RC="Oculus Browser",dp="Vivaldi",IC="Yandex",up="Whale",Zv="DuckDuckGo",AC="Pale Moon",hp="Waterfox",Zc="Brave",PC="Google Search App",Ht="(\\d+(\\.\\d+)?)",Of=new RegExp("Version/"+Ht),yU=new RegExp(Qo,"i"),xU=new RegExp(Nd+" \\w+","i"),jU=new RegExp(Sd+" \\w+","i"),Bx=new RegExp(gl+"|PlayBook|BB10","i"),bU={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},$C=function(e,t,n,a){t=t||"";var r=function(i){return i!=null&&i.brave?Zc:null}(n);return r||(a!=null&&a.detectGoogleSearchApp&&rt(e,"GSA/")?PC:rt(e," OPR/")&&rt(e,"Mini")?gU:rt(e," OPR/")?Wx:Bx.test(e)?gl:rt(e,"IE"+En)||rt(e,"WPDesktop")?SC:rt(e,"OculusBrowser")?RC:rt(e,jC)?bC:rt(e,Hx)||rt(e,"Edg/")?NC:rt(e,dp+"/")?dp:rt(e,"YaBrowser/")?IC:rt(e,up+"/")?up:rt(e,Zv+"/")||rt(e,"Ddg/")?Zv:rt(e,"FBIOS")?"Facebook "+En:rt(e,"UCWEB")||rt(e,"UCBrowser")?"UC Browser":rt(e,"CriOS")?wC:rt(e,"CrMo")||rt(e,Fi)?Fi:rt(e,sr)&&rt(e,Yc)?EC:rt(e,"FxiOS")?kC:rt(e.toLowerCase(),Yv.toLowerCase())?Yv:rt(e,Zc+"/")?Zc:((i,o)=>o&&rt(o,vC)||function(l){return rt(l,Yc)&&!rt(l,Fi)&&!rt(l,sr)}(i))(e,t)?rt(e,En)?_C:Yc:rt(e,"PaleMoon/")?AC:rt(e,hp+"/")?hp:rt(e,Xo)?Xo:rt(e,"MSIE")||rt(e,"Trident/")?Gx:rt(e,"Gecko")?Xo:"")},wU={[SC]:[new RegExp("rv:"+Ht)],[NC]:[new RegExp(Hx+"?\\/"+Ht)],[Fi]:[new RegExp("("+Fi+"|CrMo)\\/"+Ht)],[wC]:[new RegExp("CriOS\\/"+Ht)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ht)],[Yc]:[Of],[_C]:[Of],[Wx]:[new RegExp("(Opera|OPR)\\/"+Ht)],[Xo]:[new RegExp(Xo+"\\/"+Ht)],[kC]:[new RegExp("FxiOS\\/"+Ht)],[Yv]:[new RegExp("Konqueror[:/]?"+Ht,"i")],[gl]:[new RegExp(gl+" "+Ht),Of],[EC]:[new RegExp("android\\s"+Ht,"i")],[bC]:[new RegExp(jC+"\\/"+Ht)],[RC]:[new RegExp("OculusBrowser\\/"+Ht)],[dp]:[new RegExp(dp+"\\/"+Ht)],[IC]:[new RegExp("YaBrowser\\/"+Ht)],[up]:[new RegExp(up+"\\/"+Ht)],[Zc]:[new RegExp(Zc+"\\/"+Ht)],[Zv]:[new RegExp("(DuckDuckGo|Ddg)\\/"+Ht)],[AC]:[new RegExp("PaleMoon\\/"+Ht)],[hp]:[new RegExp(hp+"\\/"+Ht)],[PC]:[new RegExp("GSA\\/"+Ht)],[Gx]:[new RegExp("(rv:|MSIE )"+Ht)],Mozilla:[new RegExp("rv:"+Ht)]},SU=function(e,t,n,a){var r=$C(e,t,n,a),i=wU[r];if(Ve(i))return null;for(var o=0;i.length>o;o++){var l=e.match(i[o]);if(l)return parseFloat(l[l.length-2])}return null},uN=[[new RegExp(Qo+"; "+Qo+" (.*?)[);]","i"),e=>[Qo,e&&e[1]||""]],[new RegExp(Sd,"i"),[Sd,""]],[new RegExp(Nd,"i"),[Nd,""]],[Bx,[gl,""]],[new RegExp(Nc,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Kv,""];if(new RegExp(En).test(t)&&!/IEMobile\b/.test(t))return[Nc+" "+En,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var a=bU[n[1]]||"";return/arm/i.test(t)&&(a="RT"),[Nc,a]}return[Nc,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[cp,[e[3],e[4],e[5]||"0"].join(".")]:[cp,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ve(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+sr+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+sr+")","i"),e=>e&&e[2]?[sr,[e[2],e[3],e[4]||"0"].join(".")]:[sr,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[fU,""]],[/Linux|debian/i,["Linux",""]]],hN=function(e){return jU.test(e)?Sd:xU.test(e)?Nd:yU.test(e)?Qo:new RegExp(Jv,"i").test(e)?Jv:new RegExp("("+Kv+"|WPDesktop)","i").test(e)?Kv:/iPad/.test(e)?gC:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?yC:Bx.test(e)?gl:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(dN,"i").test(e)?dN:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(En).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?sr:fC:new RegExp("(pda|"+En+")","i").test(e)?vU:new RegExp(fl,"i").test(e)&&!new RegExp(fl+" pc","i").test(e)?TC:""},NU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pN(e,t){return typeof(n=e)=="string"&&NU.test(n)?e:t();var n}function Vx(e){return e&&e.split("#")[0]}var OC=function(e,t){var n=(t===void 0?{}:t).debugEnabled,a={F(r){if(Me&&(ls.DEBUG||Me.POSTHOG_DEBUG||n)&&!Ve(Me.console)&&Me.console){for(var i=("__rrweb_original__"in Me.console[r])?Me.console[r].__rrweb_original__:Me.console[r],o=arguments.length,l=new Array(o>1?o-1:0),c=1;o>c;c++)l[c-1]=arguments[c];i(e,...l)}},debug(){for(var r=arguments.length,i=new Array(r),o=0;r>o;o++)i[o]=arguments[o];a.F("debug",...i)},info(){for(var r=arguments.length,i=new Array(r),o=0;r>o;o++)i[o]=arguments[o];a.F("log",...i)},warn(){for(var r=arguments.length,i=new Array(r),o=0;r>o;o++)i[o]=arguments[o];a.F("warn",...i)},error(){for(var r=arguments.length,i=new Array(r),o=0;r>o;o++)i[o]=arguments[o];a.F("error",...i)},critical(){for(var r=arguments.length,i=new Array(r),o=0;r>o;o++)i[o]=arguments[o];console.error(e,...i)},uninitializedWarning(r){a.error("You must initialize PostHog before calling "+r)},createLogger:(r,i)=>OC(e+" "+r,i)};return a},Ae=OC("[PostHog.js]"),ri=Ae.createLogger,kU=ri("[ExternalScriptsLoader]"),pp=e=>{var t=Ze==null?void 0:Ze.querySelectorAll("script");if(t){for(var n=0;t.length>n;n++)if(t[n].src===e)return t[n]}},Si=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return kU.warn(t+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var a=pp(t);if(a){if(a.__posthog_loading_callback_fired)return n();var r=a.__posthog_loading_error;return r?n(r):(a.addEventListener("load",o=>{a.__posthog_loading_callback_fired=!0,n(void 0,o)}),void a.addEventListener("error",o=>{a.__posthog_loading_error=o,n(o)}))}var i=()=>{if(!Ze)return n("document not found");if(pp(t))return Si(e,t,n);var o=Ze.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=t,o.onload=u=>{o.__posthog_loading_callback_fired=!0,n(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,n(u)},e.config.prepare_external_dependency_script&&(o=e.config.prepare_external_dependency_script(o)),!o)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")Ze.head.appendChild(o);else{var l,c=Ze.querySelectorAll("body > script");c.length>0?(l=c[0].parentNode)==null||l.insertBefore(o,c[0]):Ze.body.appendChild(o)}};Ze!=null&&Ze.body?i():Ze==null||Ze.addEventListener("DOMContentLoaded",i)},Lf={},mN=(e,t)=>{var n="/static/"+t+".js?v="+e.version;if(t==="toolbar"){var a=3e5;n=n+"&t="+Math.floor(Date.now()/a)*a}return e.requestRouter.endpointFor("assets",n)};xn.__PosthogExtensions__=xn.__PosthogExtensions__||{},xn.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!=="remote-config"){var a=e.config.strict_script_versioning;if(a){var r=e.requestRouter.endpointFor("assets","/static/"+e.version+"/"+t+".js"),i=Lf[r];if(a==="fallback"&&i){if(pp(i))return void Si(e,i,n);delete Lf[r]}Si(e,r,a==="fallback"?(l,c)=>{if(l)if(typeof l=="string")n(l);else{var u,d=mN(e,t);Lf[r]=d;var h=pp(r);h==null||(u=h.parentNode)==null||u.removeChild(h),Si(e,d,n)}else n(void 0,c)}:n)}else Si(e,mN(e,t),n)}else{var o=e.requestRouter.endpointFor("assets","/array/"+e.config.token+"/config.js");Si(e,o,n)}},xn.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var a=e.requestRouter.endpointFor("api",t);Si(e,a,n)};ls.DEBUG=!1,ls.LIB_VERSION="1.418.6",ls.LIB_NAME="web";var LC="$people_distinct_id",Fs="distinct_id",kd="$device_id",Mf="$device_model",zo="__alias",kc="__timers",MC="$dead_clicks_enabled_server_side",Xv="$session_recording_remote_config",Uo="$sesid",DC="$session_is_sampled",qx="$enabled_feature_flags",Kx="$active_feature_flags",Jx="$feature_flag_details",Yx="$feature_flag_payloads",Zx="$feature_flag_request_id",zC="$minimal_flag_called_events",Xx="$stored_person_properties",wh="$stored_group_properties",UC="$groups",FC="$surveys_loaded_at",Xp="$flag_call_reported",Qx="$feature_flag_errors",Qp="$feature_flag_evaluated_at",ot="$user_state",Qv="$client_session_props",ey="$capture_rate_limit",ty="$initial_campaign_params",sy="$initial_referrer_info",mp="$initial_person_info",fp="$epp",Wu="$posthog_cookieless",GC="$cookieless_mode",WC="$sdk_debug_extensions_init_method",HC="$sdk_debug_extensions_init_time_ms",Ni="on_reject",$r="always",ss="anonymous",Ss="identified",ny="identified_only",fN="visibilitychange",gN="beforeunload",ic="$pageview",Df="$pageleave",zf="$identify",vN="$groupidentify";function Hu(e,t){It(e)&&e.forEach(t)}function Lt(e,t){if(!wi(e))if(It(e))e.forEach(t);else if(dU(e))e.forEach((a,r)=>t(a,r));else for(var n in e)mC.call(e,n)&&t(e[n],n)}var Bt=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;t>a;a++)n[a-1]=arguments[a];for(var r of n)for(var i in r)r[i]!==void 0&&(e[i]=r[i]);return e},EU=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),a=0;t>a;a++)n[a]=arguments[a];return e.apply(this,n)}catch(r){Ae.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ae.critical(r)}}},ej=function(e){var t={};return Lt(e,function(n,a){(As(n)&&n.length>0||Aa(n))&&(t[a]=n)}),t},_U=["herokuapp.com","vercel.app","netlify.app"];function CU(e){var t=e==null?void 0:e.hostname;if(!As(t))return!1;var n=t.split(".").slice(-2).join(".");for(var a of _U)if(n===a)return!1;return!0}function fa(e,t,n,a){var r=a??{},i=r.capture,o=r.passive;e==null||e.addEventListener(t,n,{capture:i!==void 0&&i,passive:o===void 0||o})}var BC=e=>{if(Ze){try{for(var t=e+"=",n=Ze.cookie.split(";").filter(i=>i.length),a=0;n.length>a;a++){for(var r=n[a];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Aa(e)&&isFinite(e)&&Math.floor(e)===e});class gp{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,a,r){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(a)||!Number.isInteger(r)||0>t||0>n||0>a||0>r||t>0xffffffffffff||n>4095||a>1073741823||r>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=t/Math.pow(2,40),i[1]=t/Math.pow(2,32),i[2]=t/Math.pow(2,24),i[3]=t/Math.pow(2,16),i[4]=t/256,i[5]=t,i[6]=112|n>>>8,i[7]=n,i[8]=128|a>>>24,i[9]=a>>>16,i[10]=a>>>8,i[11]=a,i[12]=r>>>24,i[13]=r>>>16,i[14]=r>>>8,i[15]=r,new gp(i)}toString(){for(var t="",n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new gp(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;16>n;n++){var a=this.bytes[n]-t.bytes[n];if(a!==0)return Math.sign(a)}return 0}}class TU{generate(){var t=this.generateOrAbort();if(!Ve(t))return t;this.Tr=0;var n=this.generateOrAbort();if(Ve(n))throw new Error("Could not generate UUID after timestamp reset");return n}generateOrAbort(){var t=Date.now();if(t>this.Tr)this.Tr=t,this.Ir();else{if(this.Tr>=t+1e4)return;this.Er++,this.Er>4398046511103&&(this.Tr++,this.Ir())}return gp.fromFieldsV7(this.Tr,Math.trunc(this.Er/Math.pow(2,30)),this.Er&Math.pow(2,30)-1,this.Rr.nextUint32())}Ir(){this.Er=1024*this.Rr.nextUint32()+(1023&this.Rr.nextUint32())}constructor(){this.Tr=0,this.Er=0,this.Rr=new RU}}var yN,VC=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Me&&!Ve(Me.crypto)&&crypto.getRandomValues&&(VC=e=>crypto.getRandomValues(e));class RU{nextUint32(){return this.ft.length>this.Ar||(VC(this.ft),this.Ar=0),this.ft[this.Ar++]}constructor(){this.ft=new Uint32Array(8),this.Ar=1/0}}var Ja=()=>IU().toString(),IU=()=>(yN||(yN=new TU)).generate(),oc="",AU=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ts={Lr:()=>!!Ze,Nr(e){Ae.error("cookieStore error: "+e)},Fr:BC,Pr(e){var t;try{t=JSON.parse(ts.Fr(e))||{}}catch{}return t},Or(e,t,n,a,r){if(!Ze)return!1;try{var i="",o="",l=function(d,h){if(h){var g=function(f,y){if(y===void 0&&(y=Ze),oc)return oc;if(!y||["localhost","127.0.0.1"].includes(f))return"";for(var b=f.split("."),m=Math.min(b.length,8),x="dmn_chk_"+Ja();!oc&&m--;){var j=b.slice(m).join("."),S=x+"=1;domain=."+j+";path=/";y.cookie=S+";max-age=3",y.cookie.includes(x)&&(y.cookie=S+";max-age=0",oc=j)}return oc}(d);if(!g){var v=(f=>{var y=f.match(AU);return y?y[0]:""})(d);v!==g&&Ae.info("Warning: cookie subdomain discovery mismatch",v,g),g=v}return g?"; domain=."+g:""}return""}(Ze.location.hostname,a);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),i="; expires="+c.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+i+"; SameSite=Lax; path=/"+l+o;return u.length>3686.4&&Ae.warn("cookieStore warning: large cookie, len="+u.length),Ze.cookie=u,!0}catch{return!1}},Dr(e,t){if(Ze!=null&&Ze.cookie)try{ts.Or(e,"",-1,t)}catch{return}}},Uf=null,Et={Lr(){if(!Sn(Uf))return Uf;var e=!0;if(Ve(Me))e=!1;else try{var t="__mplssupport__";Et.Or(t,"xyz"),Et.Fr(t)!=='"xyz"'&&(e=!1),Et.Dr(t)}catch{e=!1}return e||Ae.error("localStorage unsupported; falling back to cookie store"),Uf=e,e},Nr(e){Ae.error("localStorage error: "+e)},Fr(e){try{return Me==null?void 0:Me.localStorage.getItem(e)}catch(t){Et.Nr(t)}return null},Pr(e){try{return JSON.parse(Et.Fr(e))||{}}catch{}return null},Or(e,t){try{return Me==null||Me.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Et.Nr(n)}return!1},Dr(e){try{Me==null||Me.localStorage.removeItem(e)}catch(t){Et.Nr(t)}}},Ff=[Xx,Kx,qx,Jx,Yx,Zx,Qp,Qx,Xp],ki=[kd,Fs,Uo,DC,fp,mp,ot],vp=e=>e+"_cpm",PU=["__proto__","constructor","prototype"],Gf=e=>{if(!da(e))return{};var t={};return Object.keys(e).forEach(n=>{PU.indexOf(n)===-1&&(t[n]=e[n])}),t},Wf=function(e,t){t===void 0&&(t=[]);var n={};return[...ki,...t].forEach(a=>{var r=e[a];Ve(r)||Sn(r)||r===""||(n[a]=r)}),n},qC=e=>{for(var t=5381,n=2166136261,a=0;e.length>a;a++){var r=e.charCodeAt(a);t=33*t^r,n=Math.imul(n^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(n>>>0).toString(36)},xN=(e,t)=>({p:t,f:qC(JSON.stringify(e))}),jN=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var n=ts.Pr(vp(e)),a=(n==null?void 0:n.f)===qC(t)&&It(n.p);return{properties:a?n.p:[],isValid:a}}catch{return{properties:[],isValid:!1}}},Hf=(e,t)=>t+"|"+(ts.Fr(vp(e))||""),Bu={},$U={Lr:()=>!0,Nr(e){Ae.error("memoryStorage error: "+e)},Fr:e=>Bu[e]||null,Pr:e=>Bu[e]||null,Or:(e,t)=>(Bu[e]=t,!0),Dr(e){delete Bu[e]}},fi=null,Tt={Lr(){if(!Sn(fi))return fi;if(fi=!0,Ve(Me))fi=!1;else try{var e="__support__";Tt.Or(e,"xyz"),Tt.Fr(e)!=='"xyz"'&&(fi=!1),Tt.Dr(e)}catch{fi=!1}return fi},Nr(e){Ae.error("sessionStorage error: ",e)},Fr(e){try{return Me==null?void 0:Me.sessionStorage.getItem(e)}catch(t){Tt.Nr(t)}return null},Pr(e){try{return JSON.parse(Tt.Fr(e))||null}catch{}return null},Or(e,t){try{return Me==null||Me.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Tt.Nr(n)}return!1},Dr(e){try{Me==null||Me.sessionStorage.removeItem(e)}catch(t){Tt.Nr(t)}}};class OU{constructor(t){this._instance=t}get Oi(){return this._instance.config}get consent(){return this.Un()?0:this.Wn}isOptedOut(){return this.Oi.cookieless_mode===$r||this.isRejected()||this.consent===-1&&this.Oi.cookieless_mode===Ni}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Oi.opt_out_capturing_by_default}optInOut(t){this.Vn.Or(this.Gn,t?1:0,this.Oi.cookie_expiration,this.Oi.cross_subdomain_cookie,this.Oi.secure_cookie)}reset(){this.Vn.Dr(this.Gn,this.Oi.cross_subdomain_cookie)}get Gn(){var t=this._instance.config,n=t.token,a=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(a?a+n:"__ph_opt_in_out_"+n)}get Wn(){var t=this.Vn.Fr(this.Gn);return $f(t)?1:rt(mU,t)?0:-1}get Vn(){var t=this.Oi.opt_out_capturing_persistence_type,n=t==="localStorage"?Et:ts;if(!this.Zn||this.Zn!==n){this.Zn=n;var a=t==="localStorage"?ts:Et;a.Fr(this.Gn)&&(this.Zn.Fr(this.Gn)||this.optInOut($f(a.Fr(this.Gn))),a.Dr(this.Gn,this.Oi.cross_subdomain_cookie))}return this.Zn}Un(){return!!this.Oi.respect_dnt&&[wn==null?void 0:wn.doNotTrack,wn==null?void 0:wn.msDoNotTrack,xn.doNotTrack].some(t=>$f(t))}}var LU=["next","previous","prev",">","<","+","-","−","–"];ri("[Dead Clicks]");var MU=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(MC)),a=e.instance.config.capture_dead_clicks;return bo(a)?a:!!da(a)||n},Bf=ri("[SegmentIntegration]"),KC="posthog-js";function JC(e,t){var n=t===void 0?{}:t,a=n.organization,r=n.projectId,i=n.prefix,o=n.severityAllowList,l=o===void 0?["error"]:o,c=n.sendExceptionsToPostHog,u=c===void 0||c;return d=>{var h,g,v,f,y;if(l!=="*"&&!l.includes(d.level)||!e.__loaded)return d;d.tags||(d.tags={});var b=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());d.tags["PostHog Person URL"]=b,e.sessionRecordingStarted()&&(d.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var m,x=((h=d.exception)==null?void 0:h.values)||[],j=x.map(w=>Qe({},w,{stacktrace:w.stacktrace?Qe({},w.stacktrace,{type:"raw",frames:(w.stacktrace.frames||[]).map(C=>Qe({},C,{platform:"web:javascript"}))}):void 0})),S={$exception_message:((g=x[0])==null?void 0:g.value)||d.message,$exception_type:(v=x[0])==null?void 0:v.type,$exception_level:d.level,$exception_list:j,$sentry_event_id:d.event_id,$sentry_exception:d.exception,$sentry_exception_message:((f=x[0])==null?void 0:f.value)||d.message,$sentry_exception_type:(y=x[0])==null?void 0:y.type,$sentry_tags:d.tags};return a&&r&&(S.$sentry_url=(i||"https://sentry.io/organizations/")+a+"/issues/?project="+r+"&query="+d.event_id),u&&((m=e.exceptions)==null||m.sendExceptionEvent(S)),d}}class DU{constructor(t,n,a,r,i,o){this.name=KC,this.setupOnce=function(l){l(JC(t,{organization:n,projectId:a,prefix:r,severityAllowList:i,sendExceptionsToPostHog:o==null||o}))}}}class bN{constructor(t){this.Yn=(n,a,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength||r.crossTabAdoption)&&(Ae.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:r}),this.Xn=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.ts()}ts(){var t;this.es=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.Yn)}destroy(){var t;(t=this.es)==null||t.call(this),this.es=void 0}doPageView(t,n){var a,r=this.rs(t,n);return this.Xn={pathname:(a=Me==null?void 0:Me.location.pathname)!==null&&a!==void 0?a:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(t){var n;return this.rs(t,(n=this.Xn)==null?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Xn)==null?void 0:t.pageViewId}}rs(t,n){var a=this.Xn;if(!a)return{$pageview_id:n};var r={$pageview_id:n,$prev_pageview_id:a.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var o=i.maxScrollHeight,l=i.lastScrollY,c=i.maxScrollY,u=i.maxContentHeight,d=i.lastContentY,h=i.maxContentY;if(!(Ve(o)||Ve(l)||Ve(c)||Ve(u)||Ve(d)||Ve(h))){o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d),h=Math.ceil(h);var g=o>1?$i(l/o,0,1,Ae):1,v=o>1?$i(c/o,0,1,Ae):1,f=u>1?$i(d/u,0,1,Ae):1,y=u>1?$i(h/u,0,1,Ae):1;r=Bt(r,{$prev_pageview_last_scroll:l,$prev_pageview_last_scroll_percentage:g,$prev_pageview_max_scroll:c,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:f,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:y})}}return a.pathname&&(r.$prev_pageview_pathname=a.pathname),a.timestamp&&(r.$prev_pageview_duration=(t.getTime()-a.timestamp.getTime())/1e3),r}}var Vf=["flags","surveys"],zU={[LC]:{exposure:"hidden"},[zo]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[kc]:{exposure:"hidden"},$autocapture_disabled_server_side:{exposure:"event"},$heatmaps_enabled_server_side:{exposure:"hidden"},$exception_capture_enabled_server_side:{exposure:"event"},$error_tracking_suppression_rules:{exposure:"hidden"},$error_tracking_capture_extension_exceptions:{exposure:"event"},$web_vitals_enabled_server_side:{exposure:"event"},[MC]:{exposure:"event"},$product_tours_enabled_server_side:{exposure:"hidden"},$web_vitals_allowed_metrics:{exposure:"event"},[Xv]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Uo]:{exposure:"hidden"},[DC]:{exposure:"event"},$replay_sample_rate:{exposure:"event",shouldSkipFromEventProperties:e=>Sn(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[qx]:{exposure:"hidden",storageGroup:"flags"},[Kx]:{exposure:"hidden",storageGroup:"flags"},$early_access_features:{exposure:"hidden"},[Jx]:{exposure:"hidden",storageGroup:"flags"},[Yx]:{exposure:"hidden",storageGroup:"flags"},[Zx]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[zC]:{exposure:"hidden",storageGroup:"flags"},$override_feature_flags:{exposure:"hidden"},$override_feature_flag_payloads:{exposure:"hidden"},[Xx]:{exposure:"hidden"},[wh]:{exposure:"hidden"},$surveys:{exposure:"hidden",storageGroup:"surveys"},[FC]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},$surveys_activated:{exposure:"event"},$surveys_activated_session:{exposure:"hidden"},$surveys_activated_timestamps:{exposure:"hidden"},ph_product_tours:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[Xp]:{exposure:"hidden"},$flag_call_reported_session_id:{exposure:"hidden"},[UC]:{exposure:"event"},[Qx]:{exposure:"hidden"},[Qp]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ot]:{exposure:"hidden"},[Qv]:{exposure:"hidden"},[ey]:{exposure:"hidden"},[ty]:{exposure:"hidden"},[sy]:{exposure:"hidden"},[mp]:{exposure:"hidden"},[fp]:{exposure:"hidden"},$replay_override_sampling:{exposure:"event"},$replay_override_linked_flag:{exposure:"event"},$replay_override_url_trigger:{exposure:"event"},$replay_override_event_trigger:{exposure:"event"},[WC]:{exposure:"event"},[HC]:{exposure:"event"},$sdk_debug_recording_script_not_loaded:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},UU=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],wa=e=>{var t=zU[e];if(t)return t;for(var n of UU){var a=n[1];if(e.indexOf(n[0])===0)return a}},Fo=(e,t)=>{try{return JSON.stringify(e,(r,i)=>typeof i=="bigint"?i.toString():i,t)}catch{return a=[],(n=JSON.stringify(e,function(i,o){if(typeof o=="bigint")return o.toString();if(typeof o!="function"&&typeof o!="symbol"){if(o instanceof Error)return{name:o.name,message:o.message,stack:o.stack};if(o&&typeof o=="object"){for(;a.length>0&&a[a.length-1]!==this;)a.pop();if(a.includes(o))return"[Circular]";a.push(o)}return o}}))!==null&&n!==void 0?n:"null"}var n,a},Ed=e=>{var t=Ze==null?void 0:Ze.createElement("a");return Ve(t)?null:(t.href=e,t)},yp=function(e,t){for(var n,a=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;a.length>r;r++){var i=a[r].split("=");if(i[0]===t){n=i;break}}if(!It(n)||2>n.length)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{Ae.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},tj=function(e,t,n){if(!e||!t||!t.length)return e;for(var a=e.split("#"),r=a[1],i=(a[0]||"").split("?"),o=i[1],l=i[0],c=(o||"").split("&"),u=[],d=0;c.length>d;d++){var h=c[d].split("=");It(h)&&(t.includes(h[0])?u.push(h[0]+"="+n):u.push(c[d]))}var g=l;return o!=null&&(g+="?"+u.join("&")),r!=null&&(g+="#"+r),g},Vu="https?://(.*)",em=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],FU=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...em],sj="<masked>",GU=["li_fat_id"];function YC(e,t){var n=FU.concat(t||[]),a={};return Lt(n,function(r){var i=yp(e,r);a[r]=i||null}),a}function ZC(e){var t=function(i){return i?i.search(Vu+"google.([^/?]*)")===0?"google":i.search(Vu+"bing.com")===0?"bing":i.search(Vu+"yahoo.com")===0?"yahoo":i.search(Vu+"duckduckgo.com")===0?"duckduckgo":null:null}(e),n=t!="yahoo"?"q":"p",a={};if(!Sn(t)){a.$search_engine=t;var r=Ze?yp(Ze.referrer,n):"";r.length&&(a.ph_keyword=r)}return a}function wN(){return navigator.language||navigator.userLanguage}var xp="$direct";function XC(){return(Ze==null?void 0:Ze.referrer)||xp}function QC(e,t,n){n===void 0&&(n=!1);var a=e?[...em,...t||[]]:[],r=n?Vx(Kt==null?void 0:Kt.href):Kt==null?void 0:Kt.href,i=r==null?void 0:r.substring(0,1e3);return{r:XC().substring(0,1e3),u:i?tj(i,a,sj):void 0}}function eT(e,t){var n;t===void 0&&(t=!1);var a=e.r,r=e.u,i=t?Vx(r):r,o={$referrer:a,$referring_domain:a==null?void 0:a==xp?xp:(n=Ed(a))==null?void 0:n.host};if(i){o.$current_url=i;var l=Ed(i);o.$host=l==null?void 0:l.host,o.$pathname=l==null?void 0:l.pathname;var c=YC(i);Bt(o,c)}if(a){var u=ZC(a);Bt(o,u)}return o}function WU(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function HU(){try{return new Date().getTimezoneOffset()}catch{return}}var BU={flags:Qp,surveys:FC},VU=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],qu=e=>e+"_cookie_identity_change_pending",br="main",SN=(e,t)=>{Lt(e,(n,a)=>{var r=wa(a);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,a)||delete e[a]})};class qf{constructor(t,n,a){if(a===void 0&&(a=!0),this.ns={},this.ss=!1,this.os=!1,this.ls=!1,this.us=!1,this.Oi=t,this.hs=a,this.props={},this.ds=void 0,this.vs=(i=>{var o="";return i.token&&(o=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+o+"_posthog"})(t),this.Vn=this.cs(t),this.os=this.fs(t),this.load(),t.debug&&Ae.info("Persistence loaded",t.persistence,Qe({},this.props)),this.update_config(t,t,n),this.save(),Me){var r=()=>this.flush();fa(Me,"beforeunload",r,{capture:!1}),fa(Me,"pagehide",r,{capture:!1})}}ps(){var t,n=(t=this.Oi)==null?void 0:t.persistence_save_debounce_ms;return Aa(n)&&n>0?n:0}gs(t){if(this.Oi.cookieWinsOnConflict&&this.Oi.persistence.toLowerCase()==="localstorage+cookie")if(t)try{var n=Wf(t,this.Oi.cookie_persisted_properties||[]),a=xN(n,this.Oi.cookie_persisted_properties||[]),r=JSON.stringify(n)+"|"+JSON.stringify(a),i=ts.Fr(this.vs)||void 0;i&&Hf(this.vs,i)===r&&(this.ys=r,this.bs=i)}catch{}else try{var o=ts.Fr(this.vs)||void 0;this.ys=o?Hf(this.vs,o):void 0,this.bs=o}catch{}}syncCookieProperties(){return this._s(this.Oi)}_s(t,n){if(n===void 0&&(n=!1),this.ws&&!n||this.us||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;var a;try{a=ts.Fr(this.vs)||void 0}catch{}if(!a||a===this.bs)return!1;var r,i=Hf(this.vs,a);try{r=Gf(JSON.parse(a))}catch{return!1}if((ts.Fr(this.vs)||void 0)!==a)return!1;this.ys=i,this.bs=a;var o=jN(this.vs,a),l=[...ki,...o.properties],c={};if(Object.keys(r).forEach(y=>{var b=r[y];(Ve(b)||Sn(b)||b===""||y===ot&&b!==ss&&b!==Ss)&&(c[y]=!0,delete r[y])}),Za(r))return!1;var u=Fs in r||r[ot]===ss||r[ot]===Ss,d=this.props[Fs],h=this.props[ot],g=Bt({},this.props);[...ki,...t.cookie_persisted_properties||[]].forEach(y=>{if(l.indexOf(y)!==-1&&!(y in r)&&!c[y]&&(u||y!==Fs&&y!==ot)){var b=g[y];!o.isValid&&ki.indexOf(y)!==-1&&(b===!1||b===0)||delete g[y]}}),this.props=Bt(g,r),!u||ot in r||ot in this.props||this.ks(ot,ss);var v=this.props[Fs],f=this.props[ot];return!u||v===d&&f===h||(this.ls=!0,Tt.Or(qu(this.vs),!0),this.xs(Xx),this.xs(Kx),this.xs(qx),this.xs(Jx),this.xs(Yx),this.xs(Zx),this.xs(Qp),this.xs(Qx),this.xs(Xp),f===ss&&(h===Ss||r[ot]===ss||!Ve(d)&&v!==d)&&(SN(this.props,r),this.xs(wh)),f===Ss?this.props.$user_id=v:delete this.props.$user_id,this.xs(zo)),!0}consumeCookieIdentityChange(){var t=qu(this.vs),n=this.ls||!!Tt.Fr(t);return this.ls=!1,n&&Tt.Dr(t),n}Ss(t){return t===void 0&&(t=!1),!(this.us||this.ws&&!t||!this.Oi.cookieWinsOnConflict||this.Oi.persistence.toLowerCase()!=="localstorage+cookie"||(this.us=!0,0))}Cs(){this.us&&(Ve(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0),delete this.ns[br],this.Ms(!0))}Es(t){if(t===void 0&&(t=!0),this.us)try{t?this.Cs():Ve(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0)}finally{this.us=!1}}isDisabled(){return!!this.ws}cs(t){VU.indexOf(t.persistence.toLowerCase())===-1&&(Ae.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n,a=function(o,l){o===void 0&&(o=[]),l===void 0&&(l=!1);var c=[...ki,...o];return Qe({},Et,{Pr(u){try{var d,h={};try{d=ts.Fr(u)||void 0,h=d?Gf(JSON.parse(d)):{}}catch{}var g,v=JSON.parse(Et.Fr(u)||"{}");if(l){var f=jN(u,d),y=[...ki,...f.properties],b={};Object.keys(h).forEach(w=>{var C=h[w];Sn(C)||C===""||w===ot&&C!==ss&&C!==Ss||(b[w]=C)});var m=Fs in b||b[ot]===ss||b[ot]===Ss;if(Object.keys(b).length>0){var x,j=v[Fs],S=(x=v[ot])!==null&&x!==void 0?x:ss;c.forEach(w=>{if(y.indexOf(w)!==-1&&!(w in h)&&(m||w!==Fs&&w!==ot)){var C=v[w];!f.isValid&&ki.indexOf(w)!==-1&&(C===!1||C===0)||delete v[w]}}),!m||ot in h||ot in v||(v[ot]=ss),!m||(Fs in b?b[Fs]:v[Fs])===j&&(ot in b?b[ot]:v[ot])===S||(Ff.forEach(w=>delete v[w]),b[ot]===Ss&&Fs in b?v.$user_id=b[Fs]:delete v.$user_id,b[ot]!==Ss&&(delete v[UC],delete v[wh]),delete v.__alias)}g=Bt(v,b)}else g=Bt(h,v);return Et.Or(u,g),g}catch{}return null},Or(u,d,h,g,v,f){var y=Et.Or(u,d,void 0,void 0,f);try{var b=Wf(d,o);if(Object.keys(b).length){if(l){var m=vp(u),x=xN(b,o);if(ts.Or(m,x,h,g,v,f),ts.Fr(m)!==JSON.stringify(x)){ts.Dr(m,g);var j=Wf(d);return ts.Or(u,j,h,g,v,f),y}}ts.Or(u,b,h,g,v,f)}}catch(S){Et.Nr(S)}return y},Dr(u,d){try{Me==null||Me.localStorage.removeItem(u),ts.Dr(u,d),ts.Dr(vp(u),d)}catch(h){Et.Nr(h)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),r=!1,i=t.persistence.toLowerCase();return i==="localstorage"&&Et.Lr()?(n=Et,r=!0):i==="localstorage+cookie"&&a.Lr()?(n=a,r=!0):i==="sessionstorage"&&Tt.Lr()?n=Tt:i==="memory"?n=$U:i==="cookie"?n=ts:a.Lr()?(n=a,r=!0):n=ts,this.ss=r,n}Is(t){return this.vs+"__"+t}fs(t){return this.ss&&!!t.split_storage}properties(){var t={};return Lt(this.props,(n,a)=>{var r=wa(a);if(!r||r.exposure==="event"){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(n))return;t[a]=n}}),t}load(){if(!this.ws){var t=this.Oi.cookieWinsOnConflict&&this.Oi.persistence.toLowerCase()==="localstorage+cookie",n=t?Et.Pr(this.vs):null,a={};if(t)try{Lt(a=Gf(ts.Pr(this.vs)),(v,f)=>{(Ve(v)||Sn(v)||v==="")&&delete a[f]})}catch{}var r=this.Vn.Pr(this.vs);if(r&&(this.props=Bt({},r)),this.os&&this.Rs(),t&&r){var i,o,l=n==null?void 0:n[Fs],c=(i=n==null?void 0:n[ot])!==null&&i!==void 0?i:ss,u=r[Fs],d=(o=r[ot])!==null&&o!==void 0?o:ss;if(u!==l||d!==c){this.ls=!0,Tt.Or(qu(this.vs),!0);var h=Bt({},this.props);Ff.forEach(v=>delete h[v]),d===ss&&(c===Ss||a[ot]===ss||!Ve(l)&&u!==l)&&(SN(h,a),delete h[wh]),this.props=h;var g=new Set;Ff.forEach(v=>{var f,y=(f=wa(v))==null?void 0:f.storageGroup;y&&g.add(y)}),g.forEach(v=>{var f={};Lt(this.props,(y,b)=>{var m;((m=wa(b))==null?void 0:m.storageGroup)===v&&(f[b]=y)}),Za(f)?(Et.Dr(this.Is(v)),this.ns[v]={}):Et.Or(this.Is(v),f)&&(this.ns[v]={persisted:!0,fingerprint:this.Ps(f,v)})})}}Tt.Fr(qu(this.vs))&&(this.ls=!0)}}Rs(){for(var t of Vf){var n=Et.Pr(this.Is(t));if(n&&!Za(n)){var a=this.As(t);a.persisted=!0,this.Fs(t)||(a.fingerprint=this.Ps(n,t)),this.Os(t,n)||Bt(this.props,n)}}}Fs(t){return Object.keys(this.props).some(n=>{var a;return((a=wa(n))==null?void 0:a.storageGroup)===t})}Os(t,n){var a=BU[t];if(!a)return!1;var r=n[a],i=this.props[a];return Aa(r)&&Aa(i)&&i>r}refreshKey(t){var n;if(!this.ws){var a=this.os?(n=wa(t))==null?void 0:n.storageGroup:void 0,r=a?Et.Pr(this.Is(a)):this.Vn.Pr(this.vs);if(r&&t in r)this.ks(t,r[t]);else{if(a){var i=this.Vn.Pr(this.vs);if(i&&t in i)return void this.ks(t,i[t])}this.xs(t)}}}save(){if(!this.ws){var t=this.ps();t>0?Ve(this.Ts)&&(this.Ts=setTimeout(()=>{this.Ts=void 0,this.Ms()},t)):this.Ms()}}flush(){Ve(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0,this.Ms())}Ms(t){t===void 0&&(t=!1),this.ws||this.us&&!t||(t||this.syncCookieProperties(),this.os?this.Ls():this.$s(this.Vn,this.vs,this.props,br)&&this.gs(this.props))}Ls(){var t=this.Ds(),n=t.main,a=t.groups;for(var r of(this.$s(this.Vn,this.vs,n,br)&&this.gs(n),Vf)){var i,o=a[r];(!Za(o)||(i=this.ns[r])!=null&&i.persisted)&&this.$s(Et,this.Is(r),o,r)}}Ds(){var t={},n={flags:{},surveys:{}};return Lt(this.props,(a,r)=>{var i,o=(i=wa(r))==null?void 0:i.storageGroup;o?n[o][r]=a:t[r]=a}),{main:t,groups:n}}Ps(t,n){if(n===br)return JSON.stringify(t)+"|"+this.Ns+"|"+this.qs+"|"+this.js;var a={};return Lt(t,(r,i)=>{var o;a[i]=(o=wa(i))!=null&&o.volatile?"__volatile__":r}),JSON.stringify(a)}$s(t,n,a,r){var i,o=this.As(r);if(r!==br&&!o.dirty&&!Ve(o.fingerprint))return!1;try{if((i=this.Ps(a,r))===o.fingerprint)return o.dirty=!1,!1}catch{i=void 0}return t.Or(n,a,this.Ns,this.qs,this.js,this.Oi.debug)?(o.dirty=!1,r!==br&&(o.persisted=!0),Ve(i)||(o.fingerprint=i),!0):(this.Oi.debug&&Ae.warn('failed to persist storage entry "'+n+'"; will retry on next save'),!1)}remove(t){var n=(t===void 0?{}:t).keepGroupEntries,a=n!==void 0&&n;if(Ve(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0),this.Vn.Dr(this.vs,!1),this.Vn.Dr(this.vs,!0),!a&&this.hs)for(var r of Vf)Et.Dr(this.Is(r));a?delete this.ns[br]:this.ns={},this.ys=void 0,this.bs=void 0}clear(){this.remove(),this.props={}}register_once(t,n,a){if(da(t)){this.syncCookieProperties(),Ve(n)&&(n="None"),this.Ns=Ve(a)?this.Bs:a;var r=!1;if(Lt(t,(i,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.ks(o,i),r=!0)}),r)return this.save(),!0}return!1}register(t,n){if(da(t)){this.syncCookieProperties(),this.Ns=Ve(n)?this.Bs:n;var a=!1;if(Lt(t,(r,i)=>{t.hasOwnProperty(i)&&(this.props[i]!==r||da(r)||It(r))&&(this.ks(i,r),a=!0)}),a)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var n=typeof t=="string"?[t]:t,a=!1;for(var r of n)r in this.props&&(this.xs(r),a=!0);a&&this.save()}update_campaign_params(){var t=Ze==null?void 0:Ze.URL;if(t!==this.ds){var n=function(a,r,i){if(!Ze)return{};var o,l=r?[...em,...i||[]]:[],c=YC(tj(Ze.URL,l,sj),a),u=(o={},Lt(GU,function(d){var h=BC(d);o[d]=h||null}),o);return Bt(u,c)}(this.Oi.custom_campaign_params,this.Oi.mask_personal_data_properties,this.Oi.custom_personal_data_properties);Za(ej(n))||this.register(n),this.ds=t}}update_search_keyword(){var t;this.register((t=Ze==null?void 0:Ze.referrer)?ZC(t):{})}update_referrer_info(){var t;this.register_once({$referrer:XC(),$referring_domain:Ze!=null&&Ze.referrer&&((t=Ed(Ze.referrer))==null?void 0:t.host)||xp},void 0)}set_initial_person_info(){this.props[ty]||this.props[sy]||this.register_once({[mp]:QC(this.Oi.mask_personal_data_properties,this.Oi.custom_personal_data_properties,this.Oi.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Lt([sy,ty],r=>{var i=this.props[r];i&&Lt(i,function(o,l){t["$initial_"+qv(l)]=o})});var n=this.props[mp];if(n){var a=function(r,i){i===void 0&&(i=!1);var o=eT(r,i),l={};return Lt(o,function(c,u){l["$initial_"+qv(u)]=c}),l}(n,this.Oi.disable_capture_url_hashes);Bt(t,a)}return t}safe_merge(t){return Lt(this.props,function(n,a){a in t||(t[a]=n)}),t}update_config(t,n,a){var r=t.persistence!==n.persistence,i=!((y,b)=>{if(y.length!==b.length)return!1;var m=[...y].sort(),x=[...b].sort();return m.every((j,S)=>j===x[S])})(t.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),o=r||i,l=t.cookieWinsOnConflict!==n.cookieWinsOnConflict,c=t.disable_persistence||!!a,u=!!this.ws&&!c;c||this._s(n,u),this.Oi=t,!c&&(r||i||l)&&(this.ys=void 0,this.bs=void 0,this._s(Qe({},t,{cookie_persisted_properties:n.cookie_persisted_properties}),u));var d=o||l?this.cs(t):this.Vn,h=this.fs(t),g=o||h!==this.os,v=!c&&(g||t.cross_subdomain_cookie!==this.qs||t.secure_cookie!==this.js)&&this.Ss(u);try{if(this.Bs=this.Ns=t.cookie_expiration,this.set_disabled(c),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),g){var f=this.props;this.clear(),this.Vn=d,this.os=h,this.props=f,this.save()}else l&&(this.Vn=d,c||(delete this.ns[br],this.Ms()))}finally{v&&this.Es()}}set_disabled(t){this.ws=t,this.ws?this.remove():this.save()}set_cross_subdomain(t){t!==this.qs&&(this.qs=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.js&&(this.js=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,n){var a=this.props[kc]||{};a[t]=n,this.ks(kc,a),this.save()}remove_event_timer(t){var n=this.props[kc]||{},a=n[t];return Ve(a)||(delete n[t],this.ks(kc,n),this.save()),a}get_property(t){return this.props[t]}set_property(t,n){this.ks(t,n),this.save()}ks(t,n){var a;this.props[t]=n,(a=wa(t))!=null&&a.volatile||this.Hs(t)}xs(t){delete this.props[t],this.Hs(t)}Hs(t){var n,a=(n=wa(t))==null?void 0:n.storageGroup;a&&(this.As(a).dirty=!0)}As(t){return this.ns[t]||(this.ns[t]={})}}function Ku(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&Ea(n.then)&&n.then(void 0,()=>{})}}}}var gn={GZipJS:"gzip-js",Base64:"base64"},Ju={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Kf={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},qU={Popover:"popover"},KU={SHOWN:"product tour shown"},NN={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},kN=ri("[RateLimiter]");class JU{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var a=n.text;if(a&&a.length)try{(JSON.parse(a).quota_limited||[]).forEach(r=>{kN.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void kN.warn('could not rate limit - continuing. Error: "'+(r==null?void 0:r.message)+'"',{text:a})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var n,a,r;t===void 0&&(t=!1);var i=this.captureEventsBurstLimit,o=this.captureEventsPerSecond,l=new Date().getTime(),c=(n=(a=this.instance.persistence)==null?void 0:a.get_property(ey))!==null&&n!==void 0?n:{tokens:i,last:l};c.tokens+=(l-c.last)/1e3*o,c.last=l,c.tokens>i&&(c.tokens=i);var u=1>c.tokens;if(u||t||(c.tokens=Math.max(0,c.tokens-1)),u&&!t){var d=(Aa(c.dropped)?c.dropped:0)+1;c.dropped=d,!this.lastEventRateLimited&&this.zs(d)&&(c.dropped=0)}return this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(ey,c),{isRateLimited:u,remainingTokens:c.tokens}}Us(t){var n=this.instance.config.property_denylist;return!It(n)||!n.includes(t)}Ws(){var t;if(this.Us("$current_url")&&this.Us("$pathname")&&Kt!=null&&Kt.pathname)return""+((t=Kt.origin)!==null&&t!==void 0?t:"")+Kt.pathname}zs(t){var n,a,r=this.captureEventsBurstLimit,i=this.captureEventsPerSecond,o=this.Ws(),l=this.Us("$session_id")?(n=(a=this.instance).get_session_id)==null?void 0:n.call(a):void 0,c=[t+" event(s) dropped since the last warning",o?"triggered on "+o:void 0,l?"session "+l:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+c+". Config is set to "+i+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var wr=ri("[RemoteConfig]");class YU{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=xn._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Vs(t){var n,a;(n=xn.__PosthogExtensions__)!=null&&n.loadExternalDependency?(a=xn.__PosthogExtensions__)==null||a.loadExternalDependency==null||a.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Gs(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return wr.info("Using preloaded remote config",this.remoteConfig),this.Zs(this.remoteConfig),void this.Qs();if(this._instance._shouldDisableFlags())return void wr.warn("Remote config is disabled. Falling back to local config.");this.Vs(t=>{if(!t)return wr.info("No config found after loading remote JS config. Falling back to JSON."),void this.Gs(n=>{this.Zs(n.json,n),this.Qs()});this.Zs(t),this.Qs()})}catch(t){wr.error("Error loading remote config",t),this.Zs()}}stop(){this.Ks&&(clearInterval(this.Ks),this.Ks=void 0)}refresh(){!this._instance._shouldDisableFlags()&&Ze&&Ze.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Qs(){var t;if(!this.Ks){var n=(t=this._instance.config.remote_config_refresh_interval_ms)!==null&&t!==void 0?t:3e5;n!==0&&(this.Ks=setInterval(()=>{this.refresh()},n))}}Zs(t,n){!t&&n&&(n.statusCode===0?n.error||wr.warn("Failed to fetch remote config from PostHog."):wr.error("Failed to fetch remote config from PostHog."));try{this._instance.Zs(t?{ok:!0,config:t}:{ok:!1})}catch(r){wr.error("Error applying remote config",r)}if((t==null?void 0:t.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var a;(a=this._instance.featureFlags)==null||a.ensureFlagsLoaded()}catch(r){wr.error("Error loading feature flags",r)}}}var Un=Uint8Array,nn=Uint16Array,vl=Uint32Array,nj=new Un([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),aj=new Un([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),EN=new Un([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),tT=function(e,t){for(var n=new nn(31),a=0;31>a;++a)n[a]=t+=1<<e[a-1];var r=new vl(n[30]);for(a=1;30>a;++a)for(var i=n[a];n[a+1]>i;++i)r[i]=i-n[a]<<5|a;return[n,r]},sT=tT(nj,2),ay=sT[1];sT[0][28]=258,ay[258]=28;for(var _N=tT(aj,0)[1],nT=new nn(32768),Gt=0;32768>Gt;++Gt){var fo=(43690&Gt)>>>1|(21845&Gt)<<1;nT[Gt]=((65280&(fo=(61680&(fo=(52428&fo)>>>2|(13107&fo)<<2))>>>4|(3855&fo)<<4))>>>8|(255&fo)<<8)>>>1}var Xc=function(e,t,n){for(var a=e.length,r=0,i=new nn(t);a>r;++r)++i[e[r]-1];var o,l=new nn(t);for(r=0;t>r;++r)l[r]=l[r-1]+i[r-1]<<1;for(o=new nn(a),r=0;a>r;++r)o[r]=nT[l[e[r]-1]++]>>>15-e[r];return o},Ki=new Un(288);for(Gt=0;144>Gt;++Gt)Ki[Gt]=8;for(Gt=144;256>Gt;++Gt)Ki[Gt]=9;for(Gt=256;280>Gt;++Gt)Ki[Gt]=7;for(Gt=280;288>Gt;++Gt)Ki[Gt]=8;var jp=new Un(32);for(Gt=0;32>Gt;++Gt)jp[Gt]=5;var ZU=Xc(Ki,9),XU=Xc(jp,5),aT=function(e){return(e/8>>0)+(7&e&&1)},rT=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var a=new(e instanceof nn?nn:e instanceof vl?vl:Un)(n-t);return a.set(e.subarray(t,n)),a},Wa=function(e,t,n){var a=t/8>>0;e[a]|=n<<=7&t,e[a+1]|=n>>>8},lc=function(e,t,n){var a=t/8>>0;e[a]|=n<<=7&t,e[a+1]|=n>>>8,e[a+2]|=n>>>16},Jf=function(e,t){for(var n=[],a=0;e.length>a;++a)e[a]&&n.push({s:a,f:e[a]});var r=n.length,i=n.slice();if(!r)return[new Un(0),0];if(r==1){var o=new Un(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(w,C){return w.f-C.f}),n.push({s:-1,f:25001});var l=n[0],c=n[1],u=0,d=1,h=2;for(n[0]={s:-1,f:l.f+c.f,l,r:c};d!=r-1;)l=n[n[h].f>n[u].f?u++:h++],c=n[u!=d&&n[h].f>n[u].f?u++:h++],n[d++]={s:-1,f:l.f+c.f,l,r:c};var g=i[0].s;for(a=1;r>a;++a)i[a].s>g&&(g=i[a].s);var v=new nn(g+1),f=ry(n[d-1],v,0);if(f>t){a=0;var y=0,b=f-t,m=1<<b;for(i.sort(function(w,C){return v[C.s]-v[w.s]||w.f-C.f});r>a;++a){var x=i[a].s;if(t>=v[x])break;y+=m-(1<<f-v[x]),v[x]=t}for(y>>>=b;y>0;){var j=i[a].s;t>v[j]?y-=1<<t-v[j]++-1:++a}for(;a>=0&&y;--a){var S=i[a].s;v[S]==t&&(--v[S],++y)}f=t}return[new Un(v),f]},ry=function(e,t,n){return e.s==-1?Math.max(ry(e.l,t,n+1),ry(e.r,t,n+1)):t[e.s]=n},CN=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new nn(++t),a=0,r=e[0],i=1,o=function(c){n[a++]=c},l=1;t>=l;++l)if(e[l]==r&&l!=t)++i;else{if(!r&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(r),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(r);i=1,r=e[l]}return[n.subarray(0,a),t]},cc=function(e,t){for(var n=0,a=0;t.length>a;++a)n+=e[a]*t[a];return n},iy=function(e,t,n){var a=n.length,r=aT(t+2);e[r]=255&a,e[r+1]=a>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var i=0;a>i;++i)e[r+i+4]=n[i];return 8*(r+4+a)},TN=function(e,t,n,a,r,i,o,l,c,u,d){Wa(t,d++,n),++r[256];for(var h=Jf(r,15),g=h[0],v=h[1],f=Jf(i,15),y=f[0],b=f[1],m=CN(g),x=m[0],j=m[1],S=CN(y),w=S[0],C=S[1],k=new nn(19),N=0;x.length>N;++N)k[31&x[N]]++;for(N=0;w.length>N;++N)k[31&w[N]]++;for(var L=Jf(k,7),_=L[0],E=L[1],I=19;I>4&&!_[EN[I-1]];--I);var $,W,R,H,Y=u+5<<3,K=cc(r,Ki)+cc(i,jp)+o,ce=cc(r,g)+cc(i,y)+o+14+3*I+cc(k,_)+(2*k[16]+3*k[17]+7*k[18]);if(K>=Y&&ce>=Y)return iy(t,d,e.subarray(c,c+u));if(Wa(t,d,1+(K>ce)),d+=2,K>ce){$=Xc(g,v),W=g,R=Xc(y,b),H=y;var F=Xc(_,E);for(Wa(t,d,j-257),Wa(t,d+5,C-1),Wa(t,d+10,I-4),d+=14,N=0;I>N;++N)Wa(t,d+3*N,_[EN[N]]);d+=3*I;for(var ie=[x,w],ue=0;2>ue;++ue){var oe=ie[ue];for(N=0;oe.length>N;++N)Wa(t,d,F[B=31&oe[N]]),d+=_[B],B>15&&(Wa(t,d,oe[N]>>>5&127),d+=oe[N]>>>12)}}else $=ZU,W=Ki,R=XU,H=jp;for(N=0;l>N;++N)if(a[N]>255){var B;lc(t,d,$[257+(B=a[N]>>>18&31)]),d+=W[B+257],B>7&&(Wa(t,d,a[N]>>>23&31),d+=nj[B]);var Q=31&a[N];lc(t,d,R[Q]),d+=H[Q],Q>3&&(lc(t,d,a[N]>>>5&8191),d+=aj[Q])}else lc(t,d,$[a[N]]),d+=W[a[N]];return lc(t,d,$[256]),d+W[256]},QU=new vl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),e3=function(){for(var e=new vl(256),t=0;256>t;++t){for(var n=t,a=9;--a;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Yf=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function t3(e,t){t===void 0&&(t={});var n=function(){var h=4294967295;return{p(g){for(var v=h,f=0;g.length>f;++f)v=e3[255&v^g[f]]^v>>>8;h=v},d(){return 4294967295^h}}}(),a=e.length;n.p(e);var r,i,o,l,c,u=(l=10+((r=t).filename&&r.filename.length+1||0),c=8,function(h,g,v,f,y,b){var m=h.length,x=new Un(f+m+5*(1+Math.floor(m/7e3))+y),j=x.subarray(f,x.length-y),S=0;if(!g||8>m)for(var w=0;m>=w;w+=65535){var C=w+65535;m>C?S=iy(j,S,h.subarray(w,C)):(j[w]=!0,S=iy(j,S,h.subarray(w,m)))}else{for(var k=QU[g-1],N=k>>>13,L=8191&k,_=(1<<v)-1,E=new nn(32768),I=new nn(_+1),$=Math.ceil(v/3),W=2*$,R=function(xe){return(h[xe]^h[xe+1]<<$^h[xe+2]<<W)&_},H=new vl(25e3),Y=new nn(288),K=new nn(32),ce=0,F=0,ie=(w=0,0),ue=0,oe=0;m>w;++w){var B=R(w),Q=32767&w,X=I[B];if(E[Q]=X,I[B]=Q,w>=ue){var me=m-w;if((ce>7e3||ie>24576)&&me>423){S=TN(h,j,0,H,Y,K,F,ie,oe,w-oe,S),ie=ce=F=0,oe=w;for(var fe=0;286>fe;++fe)Y[fe]=0;for(fe=0;30>fe;++fe)K[fe]=0}var P=2,T=0,he=L,q=Q-X&32767;if(me>2&&B==R(w-q))for(var se=Math.min(N,me)-1,ge=Math.min(32767,w),de=Math.min(258,me);ge>=q&&--he&&Q!=X;){if(h[w+P]==h[w+P-q]){for(var Ne=0;de>Ne&&h[w+Ne]==h[w+Ne-q];++Ne);if(Ne>P){if(P=Ne,T=q,Ne>se)break;var Oe=Math.min(q,Ne-2),_e=0;for(fe=0;Oe>fe;++fe){var re=w-q+fe+32768&32767,V=re-E[re]+32768&32767;V>_e&&(_e=V,X=re)}}}q+=(Q=X)-(X=E[Q])+32768&32767}if(T){H[ie++]=268435456|ay[P]<<18|_N[T];var le=31&ay[P],ee=31&_N[T];F+=nj[le]+aj[ee],++Y[257+le],++K[ee],ue=w+P,++ce}else H[ie++]=h[w],++Y[h[w]]}}S=TN(h,j,!0,H,Y,K,F,ie,oe,w-oe,S)}return rT(x,0,f+aT(S)+y)}(i=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(i.length)))):12+o.mem,l,c)),d=u.length;return function(h,g){var v=g.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>g.level?4:g.level==9?2:0,h[9]=3,g.mtime!=0&&Yf(h,4,Math.floor(new Date(g.mtime||Date.now())/1e3)),v){h[3]=8;for(var f=0;v.length>=f;++f)h[f+10]=v.charCodeAt(f)}}(u,t),Yf(u,d-8,n.d()),Yf(u,d-4,a),u}var s3=!!Hv||!!Fx,iT="text/plain",Sh=!1,oT=(e,t)=>{var n=e.split("#"),a=n[1],r=n[0].split("?"),i=r[0],o=r[1];if(!o)return e;var l=o.split("&").filter(c=>c.split("=")[0]!==t).join("&");return i+(l?"?"+l:"")+(a?"#"+a:"")},tm=function(e,t,n){var a;n===void 0&&(n=!0);var r=e.split("?"),i=r[0],o=r[1],l=Qe({},t),c=(a=o==null?void 0:o.split("&").map(d=>{var h,g=d.split("="),v=g[0],f=n&&(h=l[v])!==null&&h!==void 0?h:g[1];return delete l[v],v+"="+f}))!==null&&a!==void 0?a:[],u=function(d,h){var g,v;h===void 0&&(h="&");var f=[];return Lt(d,function(y,b){Ve(y)||Ve(b)||b==="undefined"||(g=encodeURIComponent((m=>m instanceof File)(y)?y.name:y.toString()),v=encodeURIComponent(b),f[f.length]=v+"="+g)}),f.join(h)}(l);return u&&c.push(u),c.length>0?i+"?"+c.join("&"):i},Zf=e=>{if(e.Ys)return e.Ys;var t=e.data,n=e.compression;if(t){if(n===gn.GZipJS){var a=t3(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var d=new Un(l.length+(l.length>>>1)),h=0,g=function(b){d[h++]=b},v=0;u>v;++v){if(h+5>d.length){var f=new Un(h+8+(u-v<<1));f.set(d),d=f}var y=l.charCodeAt(v);128>y?g(y):2048>y?(g(192|y>>>6),g(128|63&y)):y>55295&&57344>y?(g(240|(y=65536+(1047552&y)|1023&l.charCodeAt(++v))>>>18),g(128|y>>>12&63),g(128|y>>>6&63),g(128|63&y)):(g(224|y>>>12),g(128|y>>>6&63),g(128|63&y))}return rT(d,0,h)}(Fo(t)),{mtime:0});return{contentType:iT,body:a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),estimatedSize:a.byteLength}}if(n===gn.Base64){var r=function(l){return l&&btoa(encodeURIComponent(l).replace(/%([0-9A-F]{2})/g,(c,u)=>String.fromCharCode(parseInt(u,16))))}(Fo(t)),i=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Fo(l)))(r);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}var o=Fo(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},lT=e=>{var t,n,a=()=>e.transport==="sendBeacon"?{url:tm(e.url,{compression:gn.Base64}),encodedBody:Zf(Qe({},e,{compression:gn.Base64,Ys:void 0}))}:{url:oT(e.url,"compression"),encodedBody:Zf(Qe({},e,{compression:void 0,Ys:void 0}))};try{t=Zf(e)}catch(r){if(iN(e.compression,yp(e.url,"compression")))return Ae.error("Failed to gzip request body, sending uncompressed payload",r),a();throw r}return t&&iN(e.compression,yp(e.url,"compression"))&&!((n=t.body)instanceof ArrayBuffer?Bv(new Uint8Array(n)):ArrayBuffer.isView(n)&&Bv(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(Sh=!0,a()):{url:e.url,encodedBody:t}},cT=e=>{try{return lT(e)}catch(t){return Ae.error(t),void(e.callback==null||e.callback({statusCode:0,error:t}))}},n3=function(){var e=hr(function*(t){var n=Fo(t.data),a=yield function(i,o,l){return Vv.apply(this,arguments)}(n,ls.DEBUG,{rethrow:!0});if(!a)return t;var r=yield a.arrayBuffer();return Qe({},t,{Ys:{contentType:iT,body:r,estimatedSize:r.byteLength}})});return function(t){return e.apply(this,arguments)}}(),a3=/Failed to fetch|NetworkError|Load failed/i,dT=e=>(e==null?void 0:e.name)==="TypeError"&&a3.test((e==null?void 0:e.message)||""),uT=e=>{var t=cT(e);if(t){var n=t.url,a=t.encodedBody,r=a??{},i=r.contentType,o=r.body,l=r.estimatedSize,c=new Headers;Lt(e.headers,function(f,y){c.append(y,f)}),i&&c.append("Content-Type",i);var u=null,d=!1;if(nN){var h=new nN;u={signal:h.signal,timeout:setTimeout(()=>{var f,y;d=!0,h.abort((f=e.timeout,(y=new Error("PostHog request timed out"+(f?" after "+f+"ms":""))).name="AbortError",y))},e.timeout)}}var g=f=>{d&&(f==null?void 0:f.name)==="AbortError"||dT(f)?Ae.warn(f):Ae.error(f),e.callback==null||e.callback({statusCode:0,error:f})};try{var v;Fx(n,Qe({method:(e==null?void 0:e.method)||"GET",headers:c,keepalive:e.method==="POST"&&!e.Xs&&52428.8>(l||0),body:o,signal:(v=u)==null?void 0:v.signal},e.fetchOptions)).then(f=>f.text().then(y=>{var b={statusCode:f.status,text:y};if(f.status===200)try{b.json=JSON.parse(y)}catch(m){Ae.error(m)}e.callback==null||e.callback(b)})).catch(g).finally(()=>u?clearTimeout(u.timeout):null)}catch(f){u&&clearTimeout(u.timeout),g(f)}}},oy=e=>{try{var t,n=lT(e),a=n.url,r=n.encodedBody,i=r??{},o=i.body,l=i.estimatedSize;if(!o)return;var c=o instanceof Blob?o:new Blob([o],{type:i.contentType});if(wn.sendBeacon(a,c))return;var u=It(e.data)?e.data:(t=e.data)==null?void 0:t.batch;if(It(u)&&u.length>1&&(l??0)>16384){var d=Math.ceil(u.length/2),h=g=>It(e.data)?g:Qe({},e.data,{batch:g});return oy(Qe({},e,{data:h(u.slice(0,d))})),void oy(Qe({},e,{data:h(u.slice(d))}))}Ae.warn("Beacon of ~"+(l??0)+" bytes was rejected by the browser, falling back to fetch"),uT(Qe({},e,{Xs:!0}))}catch(g){Ae.warn("Beacon send failed",g)}},RN=(e,t,n,a)=>{var r=a==="query"?t==="POST"?"sent_at":"_":void 0;return tm(n===gn.GZipJS?oT(e,"compression"):e,Qe({},r?{[r]:Date.now().toString()}:{},n===gn.GZipJS?{}:{compression:n}))},Nh=[];Fx&&Nh.push({transport:"fetch",method:uT}),Hv&&Nh.push({transport:"XHR",method(e){var t=cT(e);if(t){var n=new Hv,a=t.encodedBody;n.open(e.method||"GET",t.url,!0);var r=a??{},i=r.contentType,o=r.body;Lt(e.headers,function(l,c){n.setRequestHeader(c,l)}),i&&n.setRequestHeader("Content-Type",i),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var l={statusCode:n.status,text:n.responseText};if(n.status===200)try{l.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(l)}},n.send(o)}}}),wn!=null&&wn.sendBeacon&&Nh.push({transport:"sendBeacon",method:oy});var ly=3e3;class r3{constructor(t,n){this.eo=!0,this.io=[],this.ro=$i((n==null?void 0:n.flush_interval_ms)||ly,250,5e3,Ae.createLogger("flush interval"),ly),this.no=t}enqueue(t){this.io.push(t),this.so||this.oo()}unload(){this.ao();var t=this.io.length>0?this.lo():{},n=Object.values(t);[...n.filter(a=>a.url.indexOf("/e")===0),...n.filter(a=>a.url.indexOf("/e")!==0)].map(a=>{this.uo(Qe({},a,{transport:"sendBeacon"}))})}enable(){this.eo=!1,this.oo()}oo(){var t=this;this.eo||(this.so=setTimeout(()=>{if(this.ao(),this.io.length>0){var n=this.lo(),a=function(){var i=n[r],o=new Date().getTime();i.data&&It(i.data)&&Lt(i.data,l=>{l.offset=Math.abs(l.timestamp-o),delete l.timestamp}),t.uo(i)};for(var r in n)a()}},this.ro))}uo(t){try{this.no(t)}catch(n){Ae.error(n)}}ao(){clearTimeout(this.so),this.so=void 0}lo(){var t={};return Lt(this.io,n=>{var a,r=n,i=(r?r.batchKey:null)||r.url;Ve(t[i])&&(t[i]=Qe({},r,{data:[]})),(a=t[i].data)==null||a.push(r.data)}),this.io=[],t}}var i3=["retriesPerformedSoFar"];class o3{constructor(t){this.ho=!1,this.do=3e3,this.io=[],this._instance=t,this.io=[],this.vo=!0,!Ve(Me)&&"onLine"in Me.navigator&&(this.vo=Me.navigator.onLine,this.co=()=>{this.vo=!0,this.fo()},this.po=()=>{this.vo=!1},fa(Me,"online",this.co),fa(Me,"offline",this.po))}get length(){return this.io.length}retriableRequest(t){var n=t.retriesPerformedSoFar,a=function(r,i){if(r==null)return{};var o={};for(var l in r)if({}.hasOwnProperty.call(r,l)){if(i.indexOf(l)!==-1)continue;o[l]=r[l]}return o}(t,i3);Ha(n)&&(a.url=tm(a.url,{retry_count:n})),this._instance._send_request(Qe({},a,{callback:r=>{if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(n??0))return void this.bn(Qe({retriesPerformedSoFar:n},a));r.statusCode===0&&Ae.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}a.callback==null||a.callback(r)}}))}bn(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var a=function(o){var l=3e3*Math.pow(2,o),c=l/2,u=Math.min(18e5,l),d=Math.random()-.5;return Math.ceil(u+d*(u-c))}(n),r=Date.now()+a;this.io.push({retryAt:r,requestOptions:t});var i="Enqueued failed request for retry in "+a;navigator.onLine||(i+=" (Browser is offline)"),Ae.warn(i),this.ho||(this.ho=!0,this.mo())}mo(){if(this.yo&&clearTimeout(this.yo),this.io.length===0)return this.ho=!1,void(this.yo=void 0);this.yo=setTimeout(()=>{this.vo&&this.io.length>0&&this.fo(),this.mo()},this.do)}fo(){var t=Date.now(),n=[],a=this.io.filter(i=>t>i.retryAt||(n.push(i),!1));if(this.io=n,a.length>0)for(var r of a)this.retriableRequest(r.requestOptions)}unload(){for(var t of(this.yo&&(clearTimeout(this.yo),this.yo=void 0),this.ho=!1,Ve(Me)||(this.co&&(Me.removeEventListener("online",this.co),this.co=void 0),this.po&&(Me.removeEventListener("offline",this.po),this.po=void 0)),this.io)){var n=t.requestOptions;try{this._instance._send_request(Qe({},n,{transport:"sendBeacon"}))}catch(a){Ae.error(a)}}this.io=[]}}class l3{constructor(t){this.bo=()=>{var n,a,r,i;this._o||(this._o={});var o=this.scrollElement(),l=this.scrollY(),c=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=l+((o==null?void 0:o.clientHeight)||0),d=(o==null?void 0:o.scrollHeight)||0;this._o.lastScrollY=Math.ceil(l),this._o.maxScrollY=Math.max(l,(n=this._o.maxScrollY)!==null&&n!==void 0?n:0),this._o.maxScrollHeight=Math.max(c,(a=this._o.maxScrollHeight)!==null&&a!==void 0?a:0),this._o.lastContentY=u,this._o.maxContentY=Math.max(u,(r=this._o.maxContentY)!==null&&r!==void 0?r:0),this._o.maxContentHeight=Math.max(d,(i=this._o.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=t}get wo(){return this._instance.config.scroll_root_selector}getContext(){return this._o}resetContext(){var t=this._o;return setTimeout(this.bo,0),t}startMeasuringScrollPosition(){fa(Me,"scroll",this.bo,{capture:!0}),fa(Me,"scrollend",this.bo,{capture:!0}),fa(Me,"resize",this.bo)}scrollElement(){if(!this.wo)return Me==null?void 0:Me.document.documentElement;var t=It(this.wo)?this.wo:[this.wo];for(var n of t){var a=Me==null?void 0:Me.document.querySelector(n);if(a)return a}}ko(t){var n=t==="y"?"scrollTop":"scrollLeft";if(this.wo){var a=this.scrollElement();return a&&a[n]||0}return Me?t==="y"?Me.scrollY||Me.pageYOffset||Me.document.documentElement.scrollTop||0:Me.scrollX||Me.pageXOffset||Me.document.documentElement.scrollLeft||0:0}scrollY(){return this.ko("y")}scrollX(){return this.ko("x")}}var c3=e=>QC(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);class IN{constructor(t,n,a,r){this.ot=i=>{var o=this.xo();if(!o||o.sessionId!==i){var l={sessionId:i,props:this.So(this._instance)};this.Co.register({[Qv]:l})}},this._instance=t,this.To=n,this.Co=a,this.So=r||c3,this.To.onSessionId(this.ot)}xo(){return this.Co.props[Qv]}getSetOnceProps(){var t,n=(t=this.xo())==null?void 0:t.props;return n?"r"in n?eT(n,this._instance.config.disable_capture_url_hashes):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var t={};return Lt(ej(this.getSetOnceProps()),(n,a)=>{a==="$current_url"&&(a="url"),t["$session_entry_"+qv(a)]=n}),t}}class hT{on(t,n){return this.Mo[t]||(this.Mo[t]=[]),this.Mo[t].push(n),()=>{this.Mo[t]=this.Mo[t].filter(a=>a!==n)}}emit(t,n){for(var a of this.Mo[t]||[])a(n);for(var r of this.Mo["*"]||[])r(t,n)}constructor(){this.Mo={}}}var go=ri("[SessionId]"),AN=864e5;class PN{on(t,n){return this.Eo.on(t,n)}constructor(t,n,a){var r;if(this.Io=null,this.Ro=null,this.Po=[],this.Ao=void 0,this.Fo=!1,this.Eo=new hT,this.Oo=(c,u)=>!(!Ha(c)||!Ha(u))&&Math.abs(c-u)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===$r)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Oi=t.config,this.Co=t.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.Lo=void 0,this._sessionActivityTimestamp=null,this.$o=n||Ja,this.Do=a||Ja;var i=this.Oi.persistence_name||this.Oi.token;if(this._sessionTimeoutMs=1e3*$i(this.Oi.session_idle_timeout_seconds||1800,60,36e3,go.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.No(),this.qo="ph_"+i+"_window_id",this.jo="ph_"+i+"_primary_window_exists",this.Bo()){var o=Tt.Pr(this.qo),l=Tt.Pr(this.jo);o&&!l?this.st=o:Tt.Dr(this.qo),Tt.Or(this.jo,!0)}(r=this.Oi.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Oi.bootstrap.sessionID),this.Ho()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return Ve(this.Po)&&(this.Po=[]),this.Po.push(t),this._e&&t(this._e,this.st),()=>{this.Po=this.Po.filter(n=>n!==t)}}Bo(){return this.Oi.persistence!=="memory"&&!this.Co.ws&&Tt.Lr()}zo(t){t!==this.st&&(this.st=t,this.Bo()&&Tt.Or(this.qo,t))}Uo(){return this.st?this.st:this.Bo()?Tt.Pr(this.qo):null}Wo(t){var n=this.Io;return!Sn(n)&&!Sn(t)&&5e3>Math.abs(t-n)}Vo(t,n,a){var r=n!==this._sessionActivityTimestamp,i=!(t!==this._e||a!==this._sessionStartTimestamp);this._sessionStartTimestamp=a,this._sessionActivityTimestamp=n,this._e=t,i&&!r||i&&this.Wo(n)||(this.Io=n,this.Co.register({[Uo]:[n,t,a]}))}Go(){var t,n=(t=this.Oi)==null?void 0:t.persistence_save_debounce_ms;return Ha(n)&&n>0}Zo(){this.Go()?this.Co.refreshKey(Uo):(this.Co.flush(),this.Co.load())}Qo(){var t;if(!Sn(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Io){this.Zo();var n=this.Jo();n[1]===this._e&&n[2]===this._sessionStartTimestamp&&(this.Io=this._sessionActivityTimestamp,this.Co.register({[Uo]:[this._sessionActivityTimestamp,(t=this._e)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Co.flush())}}Ko(){var t=this.Jo()[0],n=Ha(t)?t:0,a=Ha(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,a)}Yo(t){return this.Zo(),this.Oo(t,this.Ko())}Jo(){var t=this.Co.props[Uo];return It(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Io=null,this.Lo=void 0,clearTimeout(this.Xo),this.Xo=void 0,this.Vo(null,null,null)}setBootstrapSessionId(t,n){n===void 0&&(n=!1);var a=function(r,i){i===void 0&&(i=new Date().getTime());try{var o=(l=>{var c=l.replace(/-/g,"");if(c.length!==32)throw new Error("Not a valid UUID");if(c[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(c.substring(0,12),16)})(r);return o>i+6e4?void go.error("Bootstrap sessionID cannot be in the future"):o}catch(l){return void go.error("Invalid sessionID in bootstrap",l)}}(t);return!Ve(a)&&(n?this.Lo={sessionId:t,sessionStartTimestamp:a}:this.Vo(t,new Date().getTime(),a),!0)}destroy(){this.Fo=!0,this.Qo(),clearTimeout(this.Xo),this.Xo=void 0,this.Ao&&Me&&(Me.removeEventListener(gN,this.Ao,{capture:!1}),this.Ao=void 0),this.Po=[]}Ho(){this.Ao=()=>{this.Qo(),this.Bo()&&Tt.Dr(this.jo)},fa(Me,gN,this.Ao,{capture:!1})}checkAndGetSessionAndWindowId(t,n,a){if(t===void 0&&(t=!1),n===void 0&&(n=null),a===void 0&&(a=!1),this.Oi.cookieless_mode===$r)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),i=this._e;if(a)this.Ro=r;else if(Sn(this.Ro)||this.Ro>r||r-this.Ro>=1e3){var o,l;(o=(l=this.Co).syncCookieProperties)==null||o.call(l),this.Ro=r}var c=this.Jo(),u=c[1],d=c[2],h=!Ve(i)&&u!==i,g=this.Ko(),v=this.Uo(),f=this.Lo,y=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>AN),b=f?y:Ha(d)&&Math.abs(r-d)>AN,m=!1,x=h,j=!u||!!f,S=u,w=!j&&!t&&this.Oo(r,g);if(w){(w=this.Yo(r))||go.info("cross-tab refresh kept the session alive",{sessionId:u});var C=this.Jo();u=C[1],d=C[2]}if(j||w||b){x=!1;var k=f&&!y;u=k?f.sessionId:this.$o(),v=this.Do(),go.info("new session ID assigned",{sessionId:u,windowId:v,bootstrapped:!!k,changeReason:{noSessionId:j,activityTimeout:w,sessionPastMaximumLength:b}}),d=k?f.sessionStartTimestamp:r,this.Lo=void 0,m=!0}else v||(v=this.Do(),m=!0),(x=x||u!==S)&&(go.info("adopted cross-tab session id",{sessionId:u,windowId:v}),m=!0);var N=Ha(g)&&t&&!b?g:r,L=Ha(d)?d:new Date().getTime();this.zo(v),this.Vo(u,N,L),t||this.No();var _={noSessionId:j,activityTimeout:w,sessionPastMaximumLength:b,crossTabAdoption:x};return m&&this.Po.forEach(E=>E(u,v,_)),{sessionId:u,windowId:v,sessionStartTimestamp:L,changeReason:m?_:void 0,lastActivityTimestamp:g}}No(){this.Fo||(clearTimeout(this.Xo),this.Xo=setTimeout(()=>{if(!this.Fo)if(this.Yo(new Date().getTime())){var t=this._e;this.resetSessionId(),this.Eo.emit("forcedIdleReset",{idleSessionId:t})}else this.No()},1.1*this.sessionTimeoutMs))}}function pT(){return(pT=hr(function*(){var e=wn==null?void 0:wn.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return As(n)&&n.length>0?n:void 0}catch(a){return void Ae.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",a)}})).apply(this,arguments)}function Xf(e,t,n){return Fo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var cy="custom",$N="i.posthog.com",d3=/^\/static\//,u3=["/s/","/e/","/i/"];class h3{constructor(t){this.ta={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,n=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+$N,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.ta[this.apiHost]||(this.ta[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":cy),this.ta[this.apiHost]}ea(t){if(d3.test(t)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}ia(t){var n=Ed(t);return n?n.protocol+"//"+n.host+n.pathname:void 0}ra(t,n,a){if(t==="ui")return a;var r=a,i=this.instance.config.rewriteRequestPath;if(i){var o,l=((o=Ed(a))==null?void 0:o.href)||a;r=i(new URL(l)).toString()}if(i&&t==="api"&&u3.some(g=>n.indexOf(g)===0)){var c=this.ia(r);if(c){var u,d=this.apiHost,h=this.na;((u=h)==null?void 0:u.apiHost)===d&&h.rewriteRequestPath===i||(h={apiHost:d,rewriteRequestPath:i,urls:new Set},this.na=h),h.urls.add(c)}}return r}isIngestionEndpoint(t){var n=this.na,a=this.ia(t);return(n==null?void 0:n.apiHost)===this.apiHost&&n.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!a&&n.urls.has(a)}endpointFor(t,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),t==="ui")return this.ra(t,n,this.uiHost+n);if(t==="flags")return this.ra(t,n,this.flagsApiHost+n);if(t==="assets"){var a=this.ea(n);if(a)return this.ra(t,n,""+a+n)}if(this.region===cy)return this.ra(t,n,this.apiHost+n);var r=$N+n;switch(t){case"assets":return this.ra(t,n,"https://"+this.region+"-assets."+r);case"api":return this.ra(t,n,"https://"+this.region+"."+r)}}}var p3=ri("[Surveys]"),m3={ignoreConditions:!1,ignoreDelay:!1,displayType:qU.Popover},f3=ri("[PostHog ExternalIntegrations]"),g3={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class v3{constructor(t){this._instance=t}Jn(t,n){var a;(a=xn.__PosthogExtensions__)==null||a.loadExternalDependency==null||a.loadExternalDependency(this._instance,t,r=>{if(r)return f3.error("failed to load script",r);n()})}startIfEnabledOrStop(){var t=this,n=function(){var i,o,l,c=a[0],u=a[1];!u||(i=xn.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[c]||t.Jn(g3[c],()=>{var d;(d=xn.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[c])==null||d.start(t._instance)}),!u&&(o=xn.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[c]&&((l=xn.__PosthogExtensions__)==null||(l=l.integrations)==null||(l=l[c])==null||l.stop())};for(var a of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;n()}}}class y3{constructor(t,n){this.I=t,this.sa=n,this.oa=new Map,this.aa=!1}add(t){var n=this;return hr(function*(){if(n.aa)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(n.oa.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');n.oa.set(t.name,t);try{var a=t.setup(n.sa);a&&(yield a)}catch(i){var r=n.oa.get(t.name)===t;r&&n.oa.delete(t.name),n.I.error('Failed to set up browser extension "'+t.name+'"',i),r&&n.la(t)}})()}dispose(){if(!this.aa){this.aa=!0;var t=Array.from(this.oa.values()).reverse();for(var n of(this.oa.clear(),t))this.la(n)}}la(t){try{var n=t.dispose==null?void 0:t.dispose();n&&Ea(n.then)&&n.then(void 0,a=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',a)})}catch(a){this.I.error('Failed to dispose browser extension "'+t.name+'"',a)}}}class x3{constructor(t){this._instance=t}initialize(){}get(t){var n=this._instance.persistence;if(typeof t=="string")return n==null?void 0:n.get_property(t);var a={};for(var r of t){var i=n==null?void 0:n.get_property(r);Ve(i)||(a[r]=i)}return a}set(t,n){var a;(a=this._instance.persistence)==null||a.register(typeof t=="string"?{[t]:n}:t)}remove(t){var n;(n=this._instance.persistence)==null||n.unregister(t)}}var ON="extensionsRemoteConfig";class j3{constructor(t){this.aa=!1,this.instance=t,this.I=Ae,this.ua=t.ha,this.kv=new x3(t),this.onEvent=n=>Ku(this.instance.on("eventCaptured",a=>{try{n({event:a.event,properties:a.properties})}catch(r){this.I.error("Browser extension event listener failed",r)}})),this.onRemoteConfig=n=>{if(this.aa)return Ku(()=>{});var a=i=>{try{n(i)}catch(o){this.I.error("Browser extension remote config listener failed",o)}},r=this.instance.da.on(ON,a);return this.ua&&a(this.ua),Ku(r)},this.va=new y3(Ae.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property(kd))!==null&&t!==void 0?t:this.distinctId}get deviceId(){var t=this.instance.get_property(kd);return typeof t=="string"?t:void 0}get library(){return{name:ls.LIB_NAME,version:ls.LIB_VERSION}}get initialPersonProperties(){var t,n;return(t=(n=this.instance.persistence)==null?void 0:n.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,n,a,r,i=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(n=i==null?void 0:i.sessionId)!==null&&n!==void 0?n:"",windowId:(a=i==null?void 0:i.windowId)!==null&&a!==void 0?a:"",sessionStartTimestamp:(r=i==null?void 0:i.sessionStartTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.va.add(t)}capture(t,n,a){var r=this;return hr(function*(){a?r.instance.capture(t,n,{timestamp:a.timestamp,uuid:a.uuid,$set:a.set,$set_once:a.setOnce}):r.instance.capture(t,n)})()}registerDynamicEventProperties(t){return Ku(this.instance.ca(t))}handleRemoteConfig(t){this.aa||(this.ua=t,this.instance.da.emit(ON,t))}sendRequest(t,n){var a=this;return hr(function*(){var r;n===void 0&&(n={});var i=a.instance.requestRouter.endpointFor((r=n.target)!==null&&r!==void 0?r:"api",t),o={method:n.method,url:n.query?tm(i,n.query):i,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,timestampMode:n.sentAt};return n.transport==="sendBeacon"?(a.instance._send_request(o),{statusCode:202}):new Promise(l=>{o.callback=l,a.instance._send_request(o)})})()}dispose(){this.aa||(this.aa=!0,this.va.dispose())}}var vo,Qc={},Qf=0,bp=()=>{},LN='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',dc="Surveys module not available",MN="sanitize_properties is deprecated. Use before_send instead",mT="Invalid value for property_denylist config: ",b3=["token","distinct_id",GC],wo="posthog",fT=!s3&&(Xs==null?void 0:Xs.indexOf("MSIE"))===-1&&(Xs==null?void 0:Xs.indexOf("Mozilla"))===-1,eg=e=>{var t;return Qe({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:CU(Ze==null?void 0:Ze.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:bp,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Kt&&As(Kt==null?void 0:Kt.search)&&Kt.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(Me==null||(t=Me.location)==null?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(n){Ae.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ny,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:ly},error_tracking:{},_onCapture:bp},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:LU,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(e))},w3=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],DN=e=>{var t={};for(var n of w3){var a=n[0],r=n[1];Ve(e[a])||(t[r]=e[a])}var i=Bt({},t,e),o=e.__preview_external_dependency_versioned_paths;return Ve(o)||(Ve(e.strict_script_versioning)&&(i.strict_script_versioning=!!o),As(o)&&Ve(e.asset_host)&&(i.asset_host=o)),It(e.property_blacklist)&&(Ve(e.property_denylist)?i.property_denylist=e.property_blacklist:It(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ae.error(mT+e.property_denylist)),i};class S3{constructor(){this.__forceAllowLocalhost=!1}get fa(){return this.__forceAllowLocalhost}set fa(t){Ae.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class $n{pa(t,n){if(t){var a=this.oa.indexOf(t);a!==-1&&this.oa.splice(a,1)}return this.oa.push(n),n.initialize==null||n.initialize(),n}ga(){return this.config.cookieless_mode===$r||this.config.cookieless_mode===Ni&&this.consent.isRejected()}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.webPerformance=new S3,this.ma=!1,this.version=ls.LIB_VERSION,this.ya=new Set,this.ba="",this.da=new hT,this.oa=[],this._a=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=eg(),this.SentryIntegration=DU,this.sentryIntegration=a=>function(r,i){var o=JC(r,i);return{name:KC,processEvent:l=>o(l)}}(this,a),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.wa=!1,this.ka=null,this.xa=null,this.Sa=null,this.scrollManager=new l3(this),this.pageViewManager=new bN(this),this.rateLimiter=new JU(this),this.requestRouter=new h3(this),this.consent=new OU(this),this.externalIntegrations=new v3(this);var n=(t=$n.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(a,r,i)=>{var o=As(a)?{[a]:r}:a;this.setPersonProperties(o),i==null||i({})},set_once:(a,r,i)=>{var o=As(a)?{[a]:r}:a;this.setPersonProperties(void 0,o),i==null||i({})}},this.on("eventCaptured",a=>Ae.info('send "'+(a==null?void 0:a.event)+'"',a))}init(t,n,a){if(a&&a!==wo){var r,i=(r=Qc[a])!==null&&r!==void 0?r:new $n;return i._init(t,n,a),Qc[a]=i,Qc[wo][a]=i,i}return this._init(t,n,a)}_init(t,n,a){var r,i;n===void 0&&(n={});var o,l=As(t)?t.trim():"";if(!l)return Ae.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return l!==((o=this.config)==null?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+l+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=eg(n.defaults),n.debug=this.Ca(n.debug),this.Ta=n,this.Ma=[],n.person_profiles?this.xa=n.person_profiles:n.process_person&&(this.xa=n.process_person);var c=eg(n.defaults),u=DN(n),d=Bt({},c,u,{name:a,token:l});da(c.rageclick)&&da(u.rageclick)&&(d.rageclick=Bt({},c.rageclick,u.rageclick)),da(c.session_recording)&&da(u.session_recording)&&(d.session_recording=Bt({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Ae.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:gn.GZipJS;var h=this.Ea();if(this.persistence=new qf(this.config,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new qf(Qe({},this.config,{persistence:"sessionStorage"}),h,!1),this.ba="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!h&&Tt.Lr()){var g=Tt.Pr(this.ba);It(g)&&g.forEach(C=>{As(C)&&this.ya.add(C)})}else Tt.Dr(this.ba);var v=Qe({},this.persistence.props),f=Qe({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ia=new r3(C=>this.Ra(C),this.config.request_queue_config),this.Pa=new o3(this),this.__request_queue=[];var y=this.ga();if(y||(this.sessionManager=new PN(this),this.sessionPropsManager=new IN(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((C,k,N)=>{(N!=null&&N.activityTimeout||N!=null&&N.sessionPastMaximumLength||N!=null&&N.crossTabAdoption)&&this.Aa()})),this.Fa(),this.config.__preview_deferred_init_extensions?(Ae.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Oa(y)},0)):(Ae.info("Initializing extensions synchronously"),this.Oa(y)),ls.DEBUG=ls.DEBUG||this.config.debug,ls.DEBUG&&Ae.info("Starting in debug mode",{this:this,config:n,thisC:Qe({},this.config),p:v,s:f}),!this.config.identity_distinct_id||(r=n.bootstrap)!=null&&r.distinctID||(n.bootstrap=Qe({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var b=n.bootstrap.distinctID,m=this.get_distinct_id(),x=this.persistence.get_property(ot);if(n.bootstrap.isIdentifiedID&&m!=null&&m!==b&&x===ss)this.identify(b);else if(n.bootstrap.isIdentifiedID&&m!=null&&m!==b&&x===Ss)Ae.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var j=this.config.get_device_id(Ja()),S=n.bootstrap.isIdentifiedID?j:b;this.persistence.set_property(ot,n.bootstrap.isIdentifiedID?Ss:ss),this.register({distinct_id:b,$device_id:S})}}if(y)this.register_once({distinct_id:Wu,$device_id:null},"");else if(!this.get_distinct_id()){var w=this.config.get_device_id(Ja());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(ot,ss)}return fa(Me,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?function(C,k){var N=C.config.segment;if(!N)return k();(function(L,_){var E=L.config.segment;if(!E)return _();var I=W=>{var R=()=>W.anonymousId()||Ja();L.config.get_device_id=R,W.id()&&(L.register({distinct_id:W.id(),$device_id:R()}),L.persistence.set_property(ot,Ss)),_()},$=E.user();"then"in $&&Ea($.then)?$.then(I):I($)})(C,()=>{N.register((L=>{typeof Promise<"u"&&Promise.resolve||Bf.warn("This browser does not have Promise support, and can not use the segment integration");var _=(E,I)=>{if(!I)return E;E.event.userId||E.event.anonymousId===L.get_distinct_id()||(Bf.info("No userId set, resetting PostHog"),L.reset()),E.event.userId&&E.event.userId!==L.get_distinct_id()&&(Bf.info("UserId set, identifying with PostHog"),L.identify(E.event.userId));var $=L.calculateEventProperties(I,E.event.properties);return E.event.properties=Object.assign({},$,E.event.properties),E};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:E=>_(E,E.event.event),page:E=>_(E,ic),identify:E=>_(E,zf),screen:E=>_(E,"$screen")}})(C)).then(()=>{k()})})}(this,()=>this.La()):this.La(),Ea(this.config._onCapture)&&this.config._onCapture!==bp&&(Ae.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",C=>this.config._onCapture(C.event,C))),this.config.ip&&Ae.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return pT.apply(this,arguments)}().then(C=>{C&&this.register({[Mf]:C})}).catch(bp),this}Fa(){var t,n,a,r,i,o,l=(t=(n=this.config.__extensionClasses)==null?void 0:n.featureFlags)!==null&&t!==void 0?t:(a=$n.__defaultExtensionClasses)==null?void 0:a.featureFlags;l&&(this.featureFlags&&this.featureFlags instanceof l||((r=this.$a)==null||r.call(this),this.$a=void 0,this.featureFlags=new l(this)),Ea(this.featureFlags.onReloading)&&Ea(this.featureFlags.setup)?this.$a||(this.$a=this.featureFlags.onReloading(()=>{this.da.emit("featureFlagsReloading",!0)}),this.Da().add(this.featureFlags)):(i=(o=this.featureFlags).initialize)==null||i.call(o))}Oa(t){var n,a,r,i,o,l,c,u=performance.now(),d=Qe({},$n.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.exceptions&&this.oa.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new d.exceptions(this)),d.historyAutocapture&&this.oa.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.oa.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this.oa.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!t&&this.oa.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),d.autocapture&&this.oa.push(this.autocapture=new d.autocapture(this)),d.surveys&&this.oa.push(this.surveys=(a=this.surveys)!==null&&a!==void 0?a:new d.surveys(this)),d.logs&&this.oa.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new d.logs(this)),d.metrics&&this.oa.push(this.metrics=(i=this.metrics)!==null&&i!==void 0?i:new d.metrics(this)),d.conversations&&this.oa.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new d.conversations(this)),d.productTours&&this.oa.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.oa.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.oa.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.oa.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.oa.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,MU)),d.toolbar&&this.oa.push(this.toolbar=(l=this.toolbar)!==null&&l!==void 0?l:new d.toolbar(this)),d.experiments&&this.oa.push(this.experiments=(c=this.experiments)!==null&&c!==void 0?c:new d.experiments(this)),this.oa.forEach(g=>{g.initialize&&h.push(()=>{g.initialize==null||g.initialize()})}),h.push(()=>{if(this.Na){var g=this.Na;this.Na=void 0,this.oa.forEach(v=>v.onRemoteConfig==null?void 0:v.onRemoteConfig(g))}}),this.qa(h,u)}qa(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout(()=>{this.qa(t,n)},0);var a=t.shift();if(a)try{a()}catch(i){Ae.error("Error initializing extension:",i)}}var r=Math.round(performance.now()-n);this.register_for_session({[WC]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[HC]:r}),this.config.__preview_deferred_init_extensions&&Ae.info("PostHog extensions initialized ("+r+"ms)")}Zs(t){var n;if(!Ze||!Ze.body)return Ae.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Zs(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Na=t),this.ha=t,this.compression=void 0,t.ok){var a,r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=rt(r.supportedCompression,gn.GZipJS)?gn.GZipJS:rt(r.supportedCompression,gn.Base64)?gn.Base64:void 0),(a=r.analytics)!=null&&a.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.xa?this.xa:ny}),(n=this.ja)==null||n.handleRemoteConfig(t),this.oa.forEach(i=>i.onRemoteConfig==null?void 0:i.onRemoteConfig(t))}La(){try{this.config.loaded(this)}catch(a){Ae.critical("`loaded` function failed",a)}if(this.Ba(),this.config.internal_or_test_user_hostname&&Kt!=null&&Kt.hostname){var t=Kt.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.ga())&&this.Ha()},1),this.za=new YU(this),this.za.load()}Ba(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Ia)==null||t.enable())}_dom_loaded(){this.is_capturing()&&Hu(this.__request_queue,t=>this.Ra(t)),this.__request_queue=[],this.Ba()}_handle_unload(){var t,n,a,r,i;(t=this.surveys)==null||t.handlePageUnload==null||t.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.Ua()&&this.capture(Df),(a=this.logs)==null||a.flushLogs("sendBeacon"),(r=this.Ia)==null||r.unload(),(i=this.Pa)==null||i.unload()):this.Ua()&&this.capture(Df,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?fT?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=Qe({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,(Ve(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var a,r,i,o=Qe({},n);o.timeout=o.timeout||6e4;var l,c,u,d,h,g=(a=o.transport)!==null&&a!==void 0?a:"fetch";g==="sendBeacon"&&Ve(o.compression)&&o.data&&(o.compression=gn.Base64),o.method==="POST"&&o.data&&(o.timestampMode==="capture-body"?o.data={api_key:(c=(h=(d=(It(l=o.data)?l:[l]).map(b=>Qe({},b,b.timestamp instanceof Date&&!isNaN(b.timestamp.getTime())?{timestamp:b.timestamp.toISOString()}:{})))[0])==null||(u=h.properties)==null?void 0:u.token)!==null&&c!==void 0?c:h==null?void 0:h.token,batch:d,sent_at:new Date().toISOString()}:o.timestampMode==="body"&&(o.data=function(b,m){return m===void 0&&(m=new Date().toISOString()),It(b)?b.map(x=>Qe({},x,{sent_at:m})):Qe({},b,{sent_at:m})}(o.data))),o.url=RN(o.url,o.method,o.compression,o.timestampMode);var v=Nh.filter(b=>!o.disableTransport||!b.transport||!o.disableTransport.includes(b.transport)),f=(r=(i=function(b,m){for(var x=0;b.length>x;x++)if(b[x].transport===g)return b[x]}(v))==null?void 0:i.method)!==null&&r!==void 0?r:v[0].method;if(!f)throw new Error("No available transport method");var y=b=>{try{f(b)}catch(m){dT(m)?Ae.warn(m):Ae.error(m),o.callback==null||o.callback({statusCode:0,error:m})}};g!=="sendBeacon"&&o.data&&o.compression===gn.GZipJS&&aU&&typeof Promise<"u"&&!Sh?n3(o).then(b=>{y(b)}).catch(b=>{if(oN(b))return Sh=!0,void y(Qe({},o,{compression:void 0,url:RN(n.url,n.method,void 0,n.timestampMode)}));(m=>{if(!m||typeof m!="object")return!1;var x="name"in m?String(m.name):"";return oN(m)||x===hC})(b)&&(Sh=!0),y(o)}):f(o)})(Qe({},t,{callback:n=>{var a,r;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(a=(r=this.config).on_request_error)==null||a.call(r,n),t.callback==null||t.callback(n)}}))):t.fireCallbackOnDrop&&(t.callback==null||t.callback({statusCode:0}))}Ra(t){this.Pa?this.Pa.retriableRequest(t):this._send_request(t)}_execute_array(t){Qf++;try{var n,a=[],r=[],i=[];Hu(t,l=>{if(l)if(It(n=l[0]))i.push(l);else if(Ea(l))try{l.call(this)}catch(c){Ae.error("Error executing queued PostHog call",l,c)}else It(l)&&n==="alias"?a.push(l):It(l)&&n.indexOf("capture")!==-1&&Ea(this[n])?i.push(l):r.push(l)});var o=function(l,c){Hu(l,function(u){try{if(It(u[0])){var d=c;Lt(u,function(h){d=d[h[0]].apply(d,h.slice(1))})}else c[u[0]].apply(c,u.slice(1))}catch(h){Ae.error("Error executing queued PostHog call",u,h)}})};o(a,this),o(r,this),o(i,this)}finally{Qf--}}push(t){if(Qf>0&&It(t)&&As(t[0])){var n=$n.prototype[t[0]];Ea(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,n,a){var r,i,o,l,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ia){if(this.is_capturing())if(!Ve(t)&&As(t)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var d=a!=null&&a.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(d==null||!d.isRateLimited){n!=null&&n.$current_url&&!As(n==null?void 0:n.$current_url)&&(Ae.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),t!=="$exception"||a!=null&&a._originatedFromCaptureException||Ae.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var h=new Date,g=(a==null?void 0:a.timestamp)||h,v=pN(a==null?void 0:a.uuid,Ja),f={uuid:v,event:t,properties:this.calculateEventProperties(t,n||{},g,v)};t===ic&&this.config.__preview_capture_bot_pageviews&&u&&(f.event="$bot_pageview",f.properties.$browser_type="bot"),d&&(f.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens);var y=t==="$feature_flag_called"&&f.properties.$feature_flag_has_experiment===!1&&this.get_property(zC)===!0;a!=null&&a.$set&&!y&&(f.$set=a==null?void 0:a.$set);var b=a==null?void 0:a.$unset;b&&(f.$unset=b);var m,x,j,S=y?void 0:this.Va(a==null?void 0:a.$set_once,t!==vN,t===zf);if(S&&(f.$set_once=S),a!=null&&a._noTruncate||(i=this.config.properties_string_max_length,o=f,l=I=>As(I)?I.slice(0,i):I,c=new Set,f=function I($,W){if($!==Object($))return l?l($):$;if(!c.has($)){var R;if(c.add($),It($))R=[],Hu($,Y=>{R.push(I(Y))});else{var H={};Lt($,(Y,K)=>{c.has(Y)||(H[K]=I(Y))}),R=H}return R}}(o)),f.timestamp=g,Ve(a==null?void 0:a.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=h),y&&(f.properties=function(I,$){$===void 0&&($=[]);var W={},R=H=>{I[H]!==void 0&&(W[H]=I[H])};return rU.forEach(R),$.forEach(R),W}(f.properties,b3)),t===Ju.DISMISSED||t===Ju.SENT){var w=n==null?void 0:n[Kf.SURVEY_ID],C=n==null?void 0:n[Kf.SURVEY_ITERATION];(I=>{try{var $=(W=>((R,H)=>"seenSurvey_"+function(Y){return Y.current_iteration&&Y.current_iteration>0?Y.id+"_"+Y.current_iteration:Y.id}(H))(0,W))(I);if(localStorage.getItem($))return;localStorage.setItem($,"true")}catch(W){p3.error("Failed to persist survey seen state",W)}})({id:w,current_iteration:C}),f.$set=Qe({},f.$set,{[(m={id:w,current_iteration:C},x=t===Ju.SENT?"responded":"dismissed",j="$survey_"+x+"/"+m.id,m.current_iteration&&m.current_iteration>0&&(j="$survey_"+x+"/"+m.id+"/"+m.current_iteration),j)]:!0})}else t===Ju.SHOWN&&(f.$set=Qe({},f.$set,{[Kf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(t===KU.SHOWN){var k=n==null?void 0:n[NN.TOUR_TYPE];k&&(f.$set=Qe({},f.$set,{[NN.TOUR_LAST_SEEN_DATE+"/"+k]:new Date().toISOString()}))}var N=Qe({},f.properties.$set,f.$set);if(Za(N)||this.setPersonPropertiesForFlags(N),!wi(this.config.before_send)){var L=this.mn(f);if(!L)return;(f=L).uuid=pN(f.uuid,Ja)}this.da.emit("eventCaptured",f);var _=(r=a==null?void 0:a._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),E={method:"POST",url:_,data:f,compression:"best-available",timestampMode:(a==null?void 0:a._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(_)?"body":"capture-body",batchKey:a==null?void 0:a._batchKey,transport:a==null?void 0:a.transport};return!this.config.request_batching||a&&(a==null||!a._batchKey)||a!=null&&a.send_instantly?this.Ra(E):this.Ia.enqueue(E),f}Ae.critical("This capture call is ignored due to client rate limiting.")}}else Ae.error("No event name provided to posthog.capture")}else Ae.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}Da(){var t;return(t=this.ja)!==null&&t!==void 0?t:this.ja=new j3(this)}ca(t){this._a.push(t);var n=!0;return()=>{if(n){n=!1;var a=this._a.indexOf(t);a!==-1&&this._a.splice(a,1)}}}Ga(t){var n,a,r;return t===void 0&&(t=!0),!((n=this.persistence)==null||!n.consumeCookieIdentityChange())&&(this.Sa=null,this.persistence.get_property(ot)===ss&&((r=this.sessionPersistence)==null||r.clear(),this.ya.clear(),this.Za()),(a=this.featureFlags)==null||a.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,a,r,i){if(a=a||new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.Ga();var o=i?void 0:this.persistence.remove_event_timer(t),l=Qe({},n);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this.ga()&&(l[GC]=!0),t==="$snapshot"){var c=Qe({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=c.distinct_id,(!As(l.distinct_id)&&!Aa(l.distinct_id)||cN(l.distinct_id))&&Ae.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var u,d=function(w,C,k,N){var L,_,E,I;if(N===void 0&&(N=!1),!Xs)return{};var $,W=w?[...em,...C||[]]:[],R=function(de){for(var Ne=0;uN.length>Ne;Ne++){var Oe=uN[Ne],_e=Oe[1],re=Oe[0].exec(de),V=re&&(Ea(_e)?_e(re,de):_e);if(V)return V}return["",""]}(Xs),H=R[0],Y=R[1],K=($=typeof navigator<"u"?navigator:void 0)!=null&&$.brave?{brave:!0}:{},ce={};Ve(k)||(ce.detectGoogleSearchApp=k);var F={},ie=(L=navigator)==null||(L=L.userAgentData)==null?void 0:L.platform,ue=(_=navigator)==null?void 0:_.maxTouchPoints,oe=Me==null||(E=Me.screen)==null?void 0:E.width,B=Me==null||(I=Me.screen)==null?void 0:I.height,Q=Me==null?void 0:Me.devicePixelRatio;Ve(ie)||(F.userAgentDataPlatform=ie),Ve(ue)||(F.maxTouchPoints=ue),Ve(oe)||(F.screenWidth=oe),Ve(B)||(F.screenHeight=B),Ve(Q)||(F.devicePixelRatio=Q);var X,me,fe,P,T,he,q,se,ge=Bt(ej({$os:H,$os_version:Y,$browser:$C(Xs,navigator.vendor,K,ce),$device:hN(Xs),$device_type:(me=Xs,fe=F,se=hN(me),se===gC||se===fC||se==="Kobo"||se==="Kindle Fire"||se===TC?fl:se===Sd||se===Qo||se===Nd||se===Jv?"Console":se===yC?"Wearable":se?En:(fe==null?void 0:fe.userAgentDataPlatform)==="Android"&&((P=fe==null?void 0:fe.maxTouchPoints)!==null&&P!==void 0?P:0)>0?600>Math.min((T=fe==null?void 0:fe.screenWidth)!==null&&T!==void 0?T:0,(he=fe==null?void 0:fe.screenHeight)!==null&&he!==void 0?he:0)/((q=fe==null?void 0:fe.devicePixelRatio)!==null&&q!==void 0?q:1)?En:fl:"Desktop"),$timezone:WU(),$timezone_offset:HU()}),{$current_url:tj(N?Vx(Kt==null?void 0:Kt.href):Kt==null?void 0:Kt.href,W,sj),$host:Kt==null?void 0:Kt.host,$pathname:Kt==null?void 0:Kt.pathname,$raw_user_agent:Xs.length>1e3?Xs.substring(0,997)+"...":Xs,$browser_version:SU(Xs,navigator.vendor,K,ce),$browser_language:wN(),$browser_language_prefix:(X=wN(),typeof X=="string"?X.split("-")[0]:void 0),$screen_height:Me==null?void 0:Me.screen.height,$screen_width:Me==null?void 0:Me.screen.width,$viewport_height:Me==null?void 0:Me.innerHeight,$viewport_width:Me==null?void 0:Me.innerWidth,$lib:ls.LIB_NAME,$lib_version:ls.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return ls.SDK_DIST_CHANNEL&&(ge.$sdk_dist_channel=ls.SDK_DIST_CHANNEL),ge}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(i,a.getTime(),!0),g=h.windowId;l.$session_id=h.sessionId,l.$window_id=g}this.sessionPropsManager&&Bt(l,this.sessionPropsManager.getSessionProps());try{var v;this.sessionRecording&&Bt(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=(v=this.Pa)==null?void 0:v.length}catch(w){l.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===cy&&(l.$lib_custom_api_host=this.config.api_host),u=t!==ic||i?t!==Df||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(a):this.pageViewManager.doPageView(a,r),l=Bt(l,u),t===ic&&Ze&&(l.title=Ze.title),!Ve(o)){var f=a.getTime()-o;l.$duration=parseFloat((f/1e3).toFixed(3))}Xs&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var y=this.persistence.properties(),b=this.sessionPersistence.properties();Lt(["$referrer","$referring_domain"],w=>{w in y&&delete b[w]});var m={};if(this._a.length>0)for(var x of this._a.slice())try{Bt(m,x())}catch(w){Ae.error("Failed to produce browser extension event properties",w)}(l=Bt({},d,y,b,Qe({},m,l))).$is_identified=this._isIdentified(),It(this.config.property_denylist)?Lt(this.config.property_denylist,function(w){delete l[w]}):Ae.error(mT+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var j=this.config.sanitize_properties;j&&(Ae.error(MN),l=j(l,t));var S=this.Qa();return l.$process_person_profile=S,S&&!i&&this.Ja("_calculate_event_properties"),l}Va(t,n,a){var r;if(n===void 0&&(n=!0),a===void 0&&(a=!1),!this.persistence||!this.Qa()||this.ma&&!a)return t;var i=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),l=Bt({},i,o||{},t||{}),c=this.config.sanitize_properties;return c&&(Ae.error(MN),l=c(l,"$set_once")),n&&(this.ma=!0),Za(l)?void 0:l}register(t,n){var a;(a=this.persistence)==null||a.register(t,n)}register_once(t,n,a){var r;(r=this.persistence)==null||r.register_once(t,n,a)}register_for_session(t){var n,a;(n=this.persistence)==null||n.syncCookieProperties(),this.Ga(),(a=this.sessionPersistence)==null||a.register(t),Object.keys(t).forEach(r=>this.ya.add(r)),this.Za()}unregister(t){var n;(n=this.persistence)==null||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)==null||n.unregister(t),this.ya.delete(t),this.Za()}Ka(t,n){this.register({[t]:n})}Aa(){this.ya.forEach(t=>{var n;(n=this.sessionPersistence)==null||n.unregister(t)}),this.ya.clear(),this.Za()}Za(){var t;if(this.ba)if(this.config.persistence==="memory"||(t=this.sessionPersistence)!=null&&t.ws||!Tt.Lr())Tt.Dr(this.ba);else{var n=[];this.ya.forEach(a=>n.push(a)),n.length>0?Tt.Or(this.ba,n):Tt.Dr(this.ba)}}getFeatureFlag(t,n){var a;return(a=this.featureFlags)==null?void 0:a.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var a;return(a=this.featureFlags)==null?void 0:a.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var a,r;return(a=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(t,n))!==null&&a!==void 0?a:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)==null||t.reloadFeatureFlags()}updateFlags(t,n,a){var r;(r=this.featureFlags)==null||r.updateFlags(t,n,a)}updateEarlyAccessFeatureEnrollment(t,n,a){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(t,n,a)}getEarlyAccessFeatures(t,n,a){var r;return n===void 0&&(n=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(t,n,a)}on(t,n){return this.da.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:dc}),()=>{})}onSessionId(t){var n,a;return(n=(a=this.sessionManager)==null?void 0:a.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:dc})}getActiveMatchingSurveys(t,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:dc})}renderSurvey(t,n){var a;(a=this.surveys)==null||a.renderSurvey(t,n)}displaySurvey(t,n){var a;n===void 0&&(n=m3),(a=this.surveys)==null||a.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)==null||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,a;return(n=(a=this.surveys)==null?void 0:a.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:dc}}canRenderSurveyAsync(t,n){var a,r;return n===void 0&&(n=!1),(a=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(t,n))!==null&&a!==void 0?a:Promise.resolve({visible:!1,disabledReason:dc})}Ya(t){return!t||cN(t)?(Ae.critical("Unique user id has not been set in posthog.identify"),!1):t===Wu?(Ae.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Ae.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,n,a){if(!this.__loaded||!this.persistence)return Ae.uninitializedWarning("posthog.identify");if(Aa(t)&&(t=t.toString(),Ae.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Ya(t)&&this.Ja("posthog.identify")){var r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.Ga(!1),l=this.persistence.Ss(),c=!1;try{var u=this.get_distinct_id();this.register({$user_id:t}),this.get_property(kd)||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property(zo)&&(this.unregister(zo),this.register({distinct_id:t}));var d,h=(this.persistence.get_property(ot)||ss)===ss,g=t!==u,v=!g&&h;if(g&&h)this.persistence.set_property(ot,Ss),this.setPersonPropertiesForFlags({$set:n||{},$set_once:a||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Cs(),this.capture(zf,{distinct_id:t,$anon_distinct_id:u},{$set:n||{},$set_once:a||{}}),this.Sa=Xf(t,n,a),(d=this.featureFlags)==null||d.setAnonymousDistinctId(u);else if(v){this.persistence.set_property(ot,Ss);var f=n||{},y=a||{};this.setPersonPropertiesForFlags({$set:f,$set_once:y},!1),this.config.cookieWinsOnConflict&&this.persistence.Cs(),this.capture("$set",{$set:f,$set_once:y}),this.Sa=Xf(t,n,a)}else(n||a)&&this.setPersonProperties(n,a);g||i||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Xp)):v&&(n||a)&&this.reloadFeatureFlags(),c=!0}finally{l&&this.persistence.Es(c)}}}setPersonProperties(t,n){if((t||n)&&this.Ja("posthog.setPersonProperties")){var a=Xf(this.get_distinct_id(),t,n);this.Sa!==a?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}}),this.Sa=a):Ae.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var n,a=(It(t)?t:[t]).filter(r=>As(r)&&r.length>0);a.length!==0&&this.Ja("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(a,!0),this.capture("$set",{$unset:a}),this.Sa=null)}group(t,n,a){var r;if(t&&n){(r=this.persistence)==null||r.syncCookieProperties(),this.Ga();var i=this.getGroups(),o=i[t]!==n;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:Qe({},i,{[t]:n})}),o||a){var l={$group_type:t,$group_key:n};a&&(l.$group_set=a),this.capture(vN,l)}a&&this.setGroupPropertiesForFlags({[t]:a}),o&&!a&&this.reloadFeatureFlags()}else Ae.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n){var a;n===void 0&&(n=!0),(a=this.featureFlags)==null||a.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n){var a;n===void 0&&(n=!0),this.Ja("posthog.setGroupPropertiesForFlags")&&((a=this.featureFlags)==null||a.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(t)}reset(t){var n=bo(t)?t:t==null?void 0:t.resetDeviceID,a=bo(t)||t==null?void 0:t.bootstrap;this.Xa(n,!1,a)}Xa(t,n,a){var r,i,o;if(n===void 0&&(n=!1),Ae.info("reset"),!this.__loaded)return Ae.uninitializedWarning("posthog.reset");var l=a==null?void 0:a.sessionID;this.config.bootstrap=a||((r=this.Ta)==null?void 0:r.bootstrap)||{},(i=this.featureFlags)==null||i.updateConfig==null||i.updateConfig(this.config,this._shouldDisableFlags());var c=this.get_property(kd),u=this.get_property(Mf),d=this.get_property(Xv),h=this.is_capturing();this.consent.reset(),n||!h||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var g=(o=this.persistence)==null||o.Ss==null?void 0:o.Ss(),v=!1;try{var f,y,b,m,x,j,S,w,C,k,N,L,_,E;if((f=this.persistence)==null||f.clear(),(y=this.sessionPersistence)==null||y.clear(),this.ya.clear(),this.Za(),Ve(d)||(N=this.persistence)==null||N.register({[Xv]:d}),(b=this.surveys)==null||b.reset(),(m=this.za)==null||m.stop(),(x=this.featureFlags)==null||x.reset(),(j=this.conversations)==null||j.reset(),(S=this.logs)==null||S.reset(),(w=this.metrics)==null||w.reset(),(C=this.persistence)==null||C.set_property(ot,ss),(k=this.sessionManager)==null||k.resetSessionId(),this.Sa=null,this.config.cookieless_mode===$r)this.register_once({distinct_id:Wu,$device_id:null},"");else{var I=this.config.get_device_id(Ja());this.register_once({distinct_id:I,$device_id:t?I:c},""),t||Ve(u)||this.register({[Mf]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),a&&(a.distinctID===void 0||this.ga()||((E=this.persistence)==null||E.set_property(ot,a.isIdentifiedID?Ss:ss),this.register({distinct_id:a.distinctID})),(L=this.featureFlags)==null||L.initialize(),!(Ve(l)||(_=this.sessionManager)!=null&&_.setBootstrapSessionId(l,!0)))){var $=Qe({},a);delete $.sessionID,this.config.bootstrap=$}delete this.config.identity_distinct_id,delete this.config.identity_hash,v=!0}finally{var W;g&&((W=this.persistence)==null||W.Es==null||W.Es(v))}this.reloadFeatureFlags()}shutdown(t){var n=this;return hr(function*(){var a,r,i,o,l,c,u;if(n.__loaded){(a=n.za)==null||a.stop(),(r=n.ja)==null||r.dispose(),(i=n.sessionRecording)==null||i.dispose(),(o=n.logs)==null||o.flushLogs("sendBeacon"),(l=n.metrics)==null||l.flush("sendBeacon"),(c=n.Ia)==null||c.unload(),(u=n.Pa)==null||u.unload();try{var d;(d=n.featureFlags)==null||d.destroy()}catch(h){Ae.error("Error while destroying feature flags",h)}}else Ae.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,n){var a;this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(a=this.conversations)==null||a._onIdentityChanged()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,(t=this.conversations)==null||t._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),a=n.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(t!=null&&t.withTimestamp&&a){var i,o=(i=t.timestampLookBack)!==null&&i!==void 0?i:10;if(!a)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-a)/1e3)-o,0)}return r}alias(t,n){return t===this.get_property(LC)?(Ae.critical("Attempting to create alias for existing People user - aborting."),-2):this.Ja("posthog.alias")?(Ve(n)&&(n=this.get_distinct_id()),t!==n?(this.Ka(zo,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(Ae.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n=Qe({},this.config);if(da(t)){var a,r,i,o,l,c,u,d,h,g,v,f;Bt(this.config,DN(t));var y=this.Ea();(a=this.persistence)==null||a.update_config(this.config,n,y),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new qf(Qe({},this.config,{persistence:"sessionStorage"}),y,!1);var b=this.Ca(this.config.debug);bo(b)&&(this.config.debug=b),bo(this.config.debug)&&(this.config.debug?(ls.DEBUG=!0,Et.Lr()&&Et.Or("ph_debug",!0),Ae.info("set_config",{config:t,oldConfig:n,newConfig:Qe({},this.config)})):(ls.DEBUG=!1,Et.Lr()&&Et.Dr("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this._shouldDisableFlags()),(i=this.exceptionObserver)==null||i.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(l=this.sessionRecording)==null||l.startIfEnabledOrStop(),(c=this.tracingHeaders)==null||c.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(d=this.heatmaps)==null||d.startIfEnabled(),(h=this.exceptionObserver)==null||h.startIfEnabledOrStop(),(g=this.deadClicksAutocapture)==null||g.startIfEnabledOrStop(),(v=this.surveys)==null||v.loadIfEnabled(),this.il(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(t,n){ls.LIB_NAME=t,ls.LIB_VERSION=n}startSessionRecording(t){var n,a,r,i,o,l=t===!0,c={sampling:l||!(t==null||!t.sampling),linked_flag:l||!(t==null||!t.linked_flag),url_trigger:l||!(t==null||!t.url_trigger),event_trigger:l||!(t==null||!t.event_trigger)};Object.values(c).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),c.sampling&&((a=this.sessionRecording)==null||a.overrideSampling()),c.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),c.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger("url")),c.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,n){if(this.exceptions){var a=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:a});return this.exceptions.sendExceptionEvent(Qe({},r,n))}}addExceptionStep(t,n){var a;(a=this.exceptions)==null||a.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)==null||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)==null?void 0:n.logger)!==null&&t!==void 0?t:$n.rl}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,a;return(n=(a=this.toolbar)==null?void 0:a.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)==null?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)==null?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:wo;return n!==wo&&(n=wo+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)==null?void 0:t.get_property(ot))===Ss||((n=this.sessionPersistence)==null?void 0:n.get_property(ot))===Ss}Qa(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===ny&&!this._isIdentified()&&Za(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[zo])&&((n=this.persistence)==null||(n=n.props)==null||!n[fp]))}Ua(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Qa()||this.Ja("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Ja("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Ja(t){return this.config.person_profiles==="never"?(Ae.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Ka(fp,!0),!0)}Ea(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Ni)}il(){var t,n,a,r,i=this.Ea();return((t=this.persistence)==null?void 0:t.ws)!==i&&((a=this.persistence)==null||a.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.ws)!==i&&((r=this.sessionPersistence)==null||r.set_disabled(i)),i&&(this.ya.clear(),this.Za()),i}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==$r){if(this.ga()){var a,r,i,o,l;this.Xa(!0,!0),(a=this.sessionManager)==null||a.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new PN(this),this.pageViewManager=new bN(this),this.persistence&&(this.sessionPropsManager=new IN(this,this.sessionManager,this.persistence));var c,u=(i=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&i!==void 0?i:(l=$n.__defaultExtensionClasses)==null?void 0:l.sessionRecording;u&&(this.sessionRecording=this.pa(this.sessionRecording,new u(this)),this.ha&&((c=this.sessionRecording)==null||c.onRemoteConfig==null||c.onRemoteConfig(this.ha)))}var d,h;this.consent.optInOut(!0),this.il(),this.Ba(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Ni&&((d=this.surveys)==null||d.loadIfEnabled()),(Ve(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((h=t==null?void 0:t.captureEventName)!==null&&h!==void 0?h:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ha()}else Ae.warn(LN)}opt_out_capturing(){var t,n,a;this.config.cookieless_mode!==$r?(this.config.cookieless_mode===Ni&&this.consent.isOptedIn()&&this.Xa(!0,!0),this.consent.optInOut(!1),this.il(),this.config.cookieless_mode===Ni&&(this.register({distinct_id:Wu,$device_id:null}),(t=this.sessionRecording)==null||t.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Ha(),this.Ba())):Ae.warn(LN)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===$r||(this.config.cookieless_mode===Ni?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.il()}_is_bot(){return wn?function(t,n){if(!t)return!1;var a=t.userAgent;if(a&&lN(a,n))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>lN(i==null?void 0:i.brand,n)))return!0}catch{}return!!t.webdriver}(wn,this.config.custom_blocked_useragents):void 0}Ha(){Ze&&(Ze.visibilityState==="visible"?this.wa||(this.wa=!0,this.capture(ic,{title:Ze.title},{send_instantly:!0}),this.ka&&(Ze.removeEventListener(fN,this.ka),this.ka=null)):this.ka||(this.ka=this.Ha.bind(this),fa(Ze,fN,this.ka)))}debug(t){t===!1?(Me==null||Me.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(Me==null||Me.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){var t=this.Ta||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(Ae.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(n,a,r,i,o){var l=a in n&&!wi(n[a]),c=r in n&&!wi(n[r]);return l?n[a]:!!c&&(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+a+"' instead. The old field will be removed in a future major version."),n[r])}(t,"advanced_disable_flags","advanced_disable_decide",0,Ae)}mn(t){var n;if(wi(this.config.before_send))return t;var a=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(hU),r=It(this.config.before_send)?this.config.before_send:[this.config.before_send],i=t;for(var o of r)try{if(i=o(i),wi(i)){var l="Event '"+t.event+"' was rejected in beforeSend function";return uU(t.event)?Ae.warn(l+". This can cause unexpected behavior."):Ae.info(l),null}i.properties&&!Za(i.properties)||Ae.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return Ae.error("Error in beforeSend function for event '"+t.event+"':",u),null}for(var c of a)if(i.properties&&wi(i.properties[c]))return Ae.warn("Event '"+t.event+"' had its '"+c+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return i}getPageViewId(){var t;return(t=this.pageViewManager.Xn)==null?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,a){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(a)})}Ca(t){var n=bo(t)&&!t,a=Et.Lr()&&Et.Fr("ph_debug")==="true";return!n&&(!!a||t)}}$n.__defaultExtensionClasses={},$n.rl={trace:vo=()=>{},debug:vo,info:vo,warn:vo,error:vo,fatal:vo},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=EU(e.prototype[t[n]])}($n,["identify"]);var Sr=function(){ls.SDK_DIST_CHANNEL="npm";var e=Qc[wo]=new $n;return function(){function t(){t.done||(t.done=!0,fT=!1,Lt(Qc,function(n){n._dom_loaded()}))}Ze!=null&&Ze.addEventListener?Ze.readyState==="complete"?t():fa(Ze,"DOMContentLoaded",t,{capture:!1}):Me&&Ae.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();function gT(e){return{...e.properties,event_id:e.eventId,event_timestamp:e.timestamp,prooflane_source:e.source,page_path:e.page,prooflane_session_id:e.sessionId,anonymous_id:e.anonymousId,organization_id:e.organizationId}}class N3{constructor(t,n={}){vt(this,"name","ga4");vt(this,"measurementId");vt(this,"document");vt(this,"window");vt(this,"loaded",!1);if(!/^G-[A-Z0-9]{4,20}$/.test(t))throw new Error("Invalid GA4 measurement ID.");this.measurementId=t,this.window=n.window??window,this.document=n.document??document}pageLocation(t=(n=>(n=this.window.location)==null?void 0:n.pathname)()){var r;const a=(r=this.window.location)==null?void 0:r.origin;if(!(!a||!(t!=null&&t.startsWith("/"))))return`${a}${t}`}pageReferrer(t=this.document.referrer){if(t)try{const n=new URL(t);return n.protocol!=="https:"&&n.protocol!=="http:"?void 0:`${n.origin}${n.pathname}`.slice(0,300)}catch{return}}initialize(){var i,o;if(this.loaded){(o=(i=this.window).gtag)==null||o.call(i,"consent","update",{analytics_storage:"granted"});return}this.loaded=!0,this.window.dataLayer=this.window.dataLayer??[];const t=this.window;this.window.gtag=this.window.gtag??function(){t.dataLayer.push(arguments)},this.window.gtag("consent","default",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}),this.window.gtag("consent","update",{analytics_storage:"granted"}),this.window.gtag("js",new Date);const n=this.pageLocation(),a=this.pageReferrer();this.window.gtag("config",this.measurementId,{send_page_view:!1,allow_google_signals:!1,allow_ad_personalization_signals:!1,...n?{page_location:n}:{},...a?{page_referrer:a}:{}});const r=this.document.createElement("script");r.async=!0,r.src=`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(this.measurementId)}`,r.dataset.prooflaneAnalytics="ga4",this.document.head.append(r)}track(t){var a,r,i,o,l;const n=gT(t);if(t.name==="marketing_page_view"||t.name==="register_page_view"){const c=this.pageLocation(t.page),u=typeof((a=t.properties)==null?void 0:a.referrer)=="string"?t.properties.referrer:void 0,d=this.pageReferrer(u);(i=(r=this.window).gtag)==null||i.call(r,"event","page_view",{...n,...c?{page_location:c}:{},...d?{page_referrer:d}:{}})}(l=(o=this.window).gtag)==null||l.call(o,"event",t.name,n)}identify(t){var n,a;(a=(n=this.window).gtag)==null||a.call(n,"set",{user_id:t})}reset(){var t,n;(n=(t=this.window).gtag)==null||n.call(t,"set",{user_id:null})}shutdown(){var t,n,a;(n=(t=this.window).gtag)==null||n.call(t,"consent","update",{analytics_storage:"denied"});for(const r of this.document.cookie.split(";")){const i=(a=r.split("=")[0])==null?void 0:a.trim();i!=null&&i.startsWith("_ga")&&(this.document.cookie=`${i}=; Max-Age=0; Path=/; SameSite=Lax`)}}}class k3{constructor(t){vt(this,"name","posthog");vt(this,"apiKey");vt(this,"apiHost");vt(this,"initialized",!1);vt(this,"everInitialized",!1);if(!/^phc_[A-Za-z0-9_-]{8,}$/.test(t.apiKey))throw new Error("Invalid PostHog project key.");const n=new URL(t.apiHost??"https://us.i.posthog.com");if(n.protocol!=="https:")throw new Error("PostHog API host must use HTTPS.");this.apiKey=t.apiKey,this.apiHost=n.origin}initialize(){if(!this.initialized){if(this.initialized=!0,this.everInitialized){Sr.opt_in_capturing();return}this.everInitialized=!0,Sr.init(this.apiKey,{api_host:this.apiHost,autocapture:!1,capture_pageview:!1,capture_pageleave:!1,disable_session_recording:!0,persistence:"localStorage",person_profiles:"identified_only",respect_dnt:!0,opt_out_capturing_by_default:!1}),Sr.opt_in_capturing()}}track(t){Sr.capture(t.name,gT(t))}identify(t,n){Sr.identify(t,n?{organization_id:n}:void 0),n&&Sr.group("organization",n)}reset(){this.initialized&&Sr.reset(!0)}shutdown(){this.initialized&&Sr.opt_out_capturing(),this.initialized=!1}}class E3{constructor(t){vt(this,"name","internal");vt(this,"endpoint");const n=new URL(t);if(n.protocol!=="https:"&&!["localhost","127.0.0.1"].includes(n.hostname))throw new Error("Internal analytics endpoint must use HTTPS.");this.endpoint=n.toString()}track(t){const n=JSON.stringify(t);if(typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(this.endpoint,new Blob([n],{type:"application/json"}));return}fetch(this.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:n,keepalive:!0})}}function _3(){return typeof location>"u"?"/":location.pathname||"/"}function C3(e){const t=new sU({policyVersion:e.policyVersion??cC,consentVersion:e.consentVersion??dC}),n=[];if(e.enabled){try{e.ga4MeasurementId&&n.push(new N3(e.ga4MeasurementId))}catch{}try{e.posthogKey&&n.push(new k3({apiKey:e.posthogKey,apiHost:e.posthogHost}))}catch{}try{e.internalEndpoint&&n.push(new E3(e.internalEndpoint))}catch{}}return{consent:t,configured:n.length>0,analytics:new nU({source:e.source,consent:t,adapters:n,enabled:e.enabled===!0,debug:e.debug===!0,page:_3})}}function T3(e,t={}){if(!e.configured||typeof document>"u")return()=>{};const n=t.container??document.body,a=document.createElement("style");a.dataset.prooflaneConsent="styles",a.textContent=`
|
|
78
|
-
.pl-consent{position:fixed;z-index:2147483000;inset:auto 18px 18px;max-width:620px;padding:20px;border:1px solid #3b4652;border-radius:14px;background:#11171d;color:#e7edf2;box-shadow:0 24px 70px rgba(0,0,0,.45);font:14px/1.5 system-ui,sans-serif}
|
|
79
|
-
.pl-consent[hidden]{display:none}.pl-consent h2{font-size:18px;margin:0 0 7px}.pl-consent p{margin:0 0 14px;color:#a9b5bf}.pl-consent a{color:#f0a537}.pl-consent-row{display:flex;gap:9px;flex-wrap:wrap}.pl-consent button{border:1px solid #53616e;border-radius:8px;padding:9px 13px;background:transparent;color:#edf2f5;font:inherit;cursor:pointer}.pl-consent button[data-accept]{background:#f0a537;border-color:#f0a537;color:#101418;font-weight:700}.pl-privacy-settings{position:fixed;z-index:2147482999;right:18px;bottom:18px;border:1px solid #53616e;border-radius:999px;padding:8px 12px;background:#11171d;color:#e7edf2;font:12px system-ui,sans-serif;cursor:pointer}.pl-consent-signal{font-size:12px;color:#f0c36c!important}
|
|
80
|
-
@media(max-width:640px){.pl-consent{inset:auto 10px 10px}.pl-privacy-settings{right:10px;bottom:10px}}
|
|
81
|
-
`,document.head.append(a);const r=document.createElement("section");r.className="pl-consent",r.setAttribute("role","dialog"),r.setAttribute("aria-label","Analytics privacy choices");const i=e.consent.isPrivacySignalActive()?'<p class="pl-consent-signal">Your browser privacy signal is active, so optional analytics remains off.</p>':"";r.innerHTML=`<h2>${t.title??"Your privacy choices"}</h2><p>Essential storage is always on. Optional, anonymous analytics is off until you allow it. Prooflane excludes credentials, prompts, tool data, retrieved content, and assurance evidence.</p>${i}<p><strong>Essential:</strong> ON <strong>Analytics:</strong> <span data-state>OFF</span></p><div class="pl-consent-row"><button type="button" data-reject>Reject optional</button><button type="button" data-accept>Accept analytics</button><a href="${t.privacyUrl??"https://prooflane.ai/privacy.html"}">Privacy notice</a></div>`,n.append(r);const o=document.createElement("button");o.type="button",o.className="pl-privacy-settings",o.textContent="Privacy settings",o.hidden=!e.consent.hasDecision(),n.append(o);const l=r.querySelector("[data-state]");let c=e.consent.hasDecision()?"privacy_settings":"banner";const u=()=>{l.textContent=e.consent.isAnalyticsAllowed()?"ON":"OFF",r.hidden=e.consent.hasDecision(),o.hidden=!r.hidden};return r.querySelector("[data-reject]").addEventListener("click",()=>{e.consent.updateAnalytics(!1,c),u()}),r.querySelector("[data-accept]").addEventListener("click",()=>{e.consent.updateAnalytics(!0,c),u()}),o.addEventListener("click",()=>{c="privacy_settings",r.hidden=!1,o.hidden=!0}),u(),()=>{r.remove(),o.remove(),a.remove()}}const zN="prooflane-analytics-inspector-first-launch";let cs=null,vT="development",yT="development",UN=!1;function xT(){const e=navigator.platform||"unknown",t=navigator.userAgent||"",n=/Windows/i.test(e)?"windows":/Mac/i.test(e)?"macos":/Linux/i.test(e)?"linux":"unknown",a=/arm64|aarch64/i.test(`${e} ${t}`)?"arm64":/x86_64|x64|Win64|Intel/i.test(`${e} ${t}`)?"x64":"unknown";return{os:n,architecture:a,release_channel:vT,version:yT}}function FN(){if(!(cs!=null&&cs.analytics.isEnabled())||UN)return;UN=!0;const e=xT();cs.analytics.track("inspector_launch_authorized",e);try{if(localStorage.getItem(zN)==="true")return;cs.analytics.track("inspector_first_launch",e).accepted&&localStorage.setItem(zN,"true")}catch{}}function R3(e){var t,n;return cs||!e||(vT=((t=e.releaseChannel)==null?void 0:t.trim().slice(0,40))||"development",yT=((n=e.version)==null?void 0:n.trim().slice(0,80))||"development",cs=C3({enabled:e.enabled===!0,debug:e.debug===!0,source:"inspector",policyVersion:e.policyVersion,consentVersion:e.consentVersion,ga4MeasurementId:e.ga4MeasurementId,posthogKey:e.posthogKey,posthogHost:e.posthogHost,internalEndpoint:e.internalEndpoint}),T3(cs,{privacyUrl:"https://prooflane.ai/privacy.html"}),cs.consent.subscribe(FN),FN()),cs}function uc(e,t={}){cs==null||cs.analytics.track(e,t)}function I3(e,t){e&&(cs==null||cs.analytics.identify(e,t))}function A3(){cs==null||cs.analytics.reset()}function P3(){return xT()}function tg(){try{for(const e of["kawach.gates","kawach.release.policies","kawach.release.policy","kawach.deploy.profile","kawach.rag.cases","kawach.rag.regressions","prooflane.security.latestScanId","prooflane.security.scope","prooflane.security.hosted-history","prooflane.rag.hosted-history","prooflane.intelligence.focusGeneration"])localStorage.removeItem(e)}catch{}g$()}const jT=[{label:"Overview",items:[{id:"observability",name:"Deployment Assurance"},{id:"runs",name:"Assurance History"}]},{label:"Target Discovery",items:[{id:"tools",name:"Target Discovery",live:!0},{id:"prompts",name:"Server prompts",live:!0}]},{label:"Assurance",items:[{id:"assurance",name:"Assurance Intelligence"},{id:"benchmark",name:"AI Benchmarking"},{id:"security",name:"Security"},{id:"rag",name:"RAG Assurance"},{id:"gates",name:"Gates"}]},{label:"Automation",items:[{id:"prompt-automation",name:"Prompts"},{id:"contracts",name:"Contracts"},{id:"performance",name:"Performance"}]},{label:"Static specs",items:[{id:"schemas",name:"Schemas"}]},{label:"Platform · preview",items:[{id:"policies",name:"Policies"},{id:"settings",name:"Settings"}]}],$3={security:{title:"Security",sub:"Runtime Security protects the AI system while it runs. Model & Supply Chain Security verifies the artifacts it is built from."},rag:{title:"RAG Assurance",sub:"Retrieval quality, tool selection, behavior, contracts, drift & end-to-end chain."},benchmark:{title:"AI Benchmarking",sub:"Compare complete AI deployment candidates with paired, decision-grade evidence."},runs:{title:"Assurance History",sub:"Search Runs, Gates, reports, recurring patterns, and governed regression lineage."},policies:{title:"Policies",sub:"Regression-gate rules for CI."},settings:{title:"Settings",sub:"Org, workspace and billing."}},O3={tools:{title:"Target Discovery",sub:"Inspect, invoke, automate, and diff the active target's normalized capability surface."},prompts:{title:"Server prompts",sub:"Render the server's prompt templates with argument substitution."},http:{title:"HTTP",sub:"Send REST requests and inspect status codes, headers and body — no MCP connection needed."},"prompt-automation":{title:"Prompts",sub:"Library, Test, Prompt Studio and Runs — explore a model and its MCP tools, then promote what you learn into reusable tests."},contracts:{title:"Contracts",sub:"Saved baselines — re-run and diff as a regression."},performance:{title:"Performance",sub:"Load-test an HTTP contract against an SLO. ≤5 virtual users local (free); more run hosted (Core)."},schemas:{title:"Schemas",sub:"OpenAPI import — browsable independent of any live connection."},observability:{title:"Deployment Assurance",sub:"Release readiness — what blocks shipping, what is optional, and the shortest path to green."},assurance:{title:"Assurance Intelligence",sub:"Profile the discovered surface, then recommend what to prove before shipping."},gates:{title:"Gates",sub:"Govern first-class Cloud Gates that pin exact signed Suite and Policy versions for the UI, CLI, and GitHub Actions."},...Object.fromEntries(Object.entries($3).map(([e,t])=>[e,{title:t.title,sub:t.sub}]))},L3=new Set(jT.flatMap(e=>e.items.map(t=>t.id))),M3=new Set(["observability","runs","security","rag","gates","benchmark","prompt-automation","contracts","performance","policies"]),GN=24,D3=24*60*60*1e3;function WN(e){return e<1e3?"under_1s":e<5e3?"1_to_5s":e<3e4?"5_to_30s":e<12e4?"30_to_120s":"over_120s"}const z3={rag:{featureType:"RAG",resourceId:"rag-assurance-default"},security:{featureType:"RUNTIME_SECURITY",resourceId:"runtime-security-default"},benchmark:{featureType:"BENCHMARK",resourceId:"benchmark-default"},contracts:{featureType:"CONTRACT",resourceId:"contracts-default"},performance:{featureType:"PERFORMANCE",resourceId:"performance-default"},"prompt-automation":{featureType:"PROMPT_TESTING",resourceId:"prompt-testing-default"},gates:{featureType:"GATE",resourceId:"gates-default"}};function U3(){const[e,t]=p.useState(()=>{if(new URLSearchParams(window.location.search).get("run"))return"gates";const De=localStorage.getItem("kawach.nav");return De&&L3.has(De)?De:"observability"}),n=p.useRef(new Set([e])),a=p.useRef(null);n.current.add(e);const[r,i]=p.useState(null),[o,l]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState(!1),[g,v]=p.useState(),[f,y]=p.useState(!1),[b,m]=p.useState(null),[x,j]=p.useState(null),[S,w]=p.useState(null),[C,k]=p.useState(!1),[N,L]=p.useState([]),[_,E]=p.useState([]),[I,$]=p.useState(null),[W,R]=p.useState(!1),[H,Y]=p.useState(!1),[K,ce]=p.useState(["MCP"]),[F,ie]=p.useState(!0),[ue,oe]=p.useState("default"),[B,Q]=p.useState("default"),[X,me]=p.useState(null),[fe,P]=p.useState(!1),[T,he]=p.useState(null),[q,se]=p.useState(!1),[ge,de]=p.useState({security:!1,rag:!1,gates:!1,deployment:!1}),[Ne,Oe]=p.useState(null),[_e,re]=p.useState(null),[V,le]=p.useState(),[ee,xe]=p.useState({provider:"none"}),[Fe,Be]=p.useState(null),[st,ae]=p.useState(null),[Ce,He]=p.useState(!1),[qe,dt]=p.useState(!1),[ye,Ke]=p.useState(!1),[U,te]=p.useState("legacy"),[ke,we]=p.useState(null),[Te,ve]=p.useState(null),[z,D]=p.useState(GN),[A,ne]=p.useState(!1),[Re,Ee]=p.useState(!1),[ze,wt]=p.useState(YD),[be,_t]=p.useState({}),[Dt,pe]=p.useState(0),Xe=p.useCallback(async()=>{var Se;const[je,De,et]=await Promise.all([O.capabilities(),O.mcpConnections(),O.targets()]);L(De.connections),E(et.targets),$(je.targetId??et.activeTargetId??null),Y(et.hasUsableTarget),R(!0),me(je.connectionId??null),h(je.connected),u(je.capabilities);const Ut=et.targets.find(Ge=>Ge.id===(je.targetId??et.activeTargetId)),M=De.connections.find(Ge=>Ge.id===je.connectionId);v((Ut==null?void 0:Ut.displayName)??(M==null?void 0:M.displayName)??((Se=je.capabilities)==null?void 0:Se.serverName))},[]);p.useEffect(()=>{localStorage.setItem("kawach.nav",e)},[e]),p.useEffect(()=>{try{ze?localStorage.setItem(Mv,ze):localStorage.removeItem(Mv)}catch{}},[ze]),p.useEffect(()=>{Ds().catch(()=>{})},[]),p.useEffect(()=>{(async()=>{var je,De,et,Ut,M,Se,Ge,lt,ft,js,Vn,El,_l,Cl,rj,ij,oj,lj,cj,dj,uj,hj,pj,mj;try{const gt=await O.config();if(R3(gt.analytics),xe(gt.auth),te(gt.intelligenceMode??"legacy"),He(!!((je=gt.cloudWorkspace)!=null&&je.enabled)),dt(!!((De=gt.cloudWorkspace)!=null&&De.configured)),Ke(!!((et=gt.cloudWorkspace)!=null&&et.eligible)),Be(((Ut=gt.cloudWorkspace)==null?void 0:Ut.localLifecycleKey)??null),ce(((M=gt.targetConnections)==null?void 0:M.availableTypes)??["MCP"]),ie(((Se=gt.targetConnections)==null?void 0:Se.flags.post_login_target_onboarding)!==!1),oe(((Ge=gt.workspace)==null?void 0:Ge.id)??((lt=gt.project)==null?void 0:lt.id)??"default"),Q(((ft=gt.project)==null?void 0:ft.id)??"default"),gt.auth.provider==="auth0"){const Tl=await b2(gt.auth);ae(Tl.error);const qn=Tl.user;if(qn!=null&&qn.email){const fj=localStorage.getItem("kawach.account"),gj=!!(fj&&fj!==qn.email);gj&&tg(),localStorage.setItem("kawach.account",qn.email),re(qn.email),le(qn.emailVerified);const jt=await O.config();I3((js=jt.plan)==null?void 0:js.subject,(Vn=jt.plan)==null?void 0:Vn.organizationId),Tl.freshLogin&&(uc("inspector_login_completed",P3()),uc("first_login_completed",{auth_method:"auth0",release_channel:((El=gt.analytics)==null?void 0:El.releaseChannel)??"development",version:((_l=gt.analytics)==null?void 0:_l.version)??"development"}));const Wd=(Cl=jt.cloudWorkspace)==null?void 0:Cl.localLifecycleKey;if(Be(Wd??null),Wd){j2(()=>{h(!1),u(null),v(void 0),y(!1),m(null),j(null),L([]),E([]),me(null),$(null),R(!1),Y(!1),tg(),of(),localStorage.removeItem("kawach.account"),re(null),O.localWorkspaceLifecycle(Wd,"token-expired",qn.email)}),(Tl.freshLogin||gj)&&(h(!1),u(null),v(void 0),await O.localWorkspaceLifecycle(Wd,"login",qn.email));let Xi=!1;if((rj=jt.cloudWorkspace)!=null&&rj.enabled&&qn.emailVerified)try{if((await O.runs(1)).length===0){const Rl=await O.workspaceRestore();Xi=!!Rl.ok&&Rl.restored.runs+Rl.restored.sessions+Rl.restored.snapshots+Rl.restored.prompts>0}}catch{}(Tl.freshLogin||Xi)&&(of(),Ds().catch(()=>{}))}if(He(!!((ij=jt.cloudWorkspace)!=null&&ij.enabled)),dt(!!((oj=jt.cloudWorkspace)!=null&&oj.configured)),Ke(!!((lj=jt.cloudWorkspace)!=null&&lj.eligible)),ce(((cj=jt.targetConnections)==null?void 0:cj.availableTypes)??["MCP"]),ie(((dj=jt.targetConnections)==null?void 0:dj.flags.post_login_target_onboarding)!==!1),oe(((uj=jt.workspace)==null?void 0:uj.id)??((hj=jt.project)==null?void 0:hj.id)??"default"),Q(((pj=jt.project)==null?void 0:pj.id)??"default"),te(jt.intelligenceMode??"legacy"),se(!!jt.entitlements.hosted),de({security:!!jt.entitlements.security,rag:!!jt.entitlements.rag,gates:!!jt.entitlements.gates,deployment:!!jt.entitlements.deployment}),Oe(jt.plan?{tier:jt.plan.tier,label:jt.plan.label,source:jt.plan.source,reason:jt.plan.reason,subject:jt.plan.subject,configuredTier:jt.plan.configuredTier,expiresAt:jt.plan.trialExpiresAt??jt.plan.expiresAt,trialUsed:jt.plan.trialUsed,trialDays:jt.plan.trialDays,trialDaysRemaining:jt.plan.trialDaysRemaining,trialStatus:jt.plan.trialStatus,entitlementVersion:jt.plan.entitlementVersion}:null),(mj=jt.cloudWorkspace)!=null&&mj.enabled)try{const Xi=await O.workspaceStatus();we(Xi.agreementAccepted),ve(Xi.automaticBackupAccepted),D(Xi.backupCadenceHours)}catch{we(!1),ve(!1)}else we(A5(qn.email)),ve(!1)}else se(!1)}else re(localStorage.getItem("kawach.account")),le(!0),we(!0),ve(!1),se(!!gt.entitlements.hosted),de({security:!!gt.entitlements.security,rag:!!gt.entitlements.rag,gates:!!gt.entitlements.gates,deployment:!!gt.entitlements.deployment}),Oe(gt.plan?{tier:gt.plan.tier,label:gt.plan.label,source:gt.plan.source,reason:gt.plan.reason,subject:gt.plan.subject,configuredTier:gt.plan.configuredTier,expiresAt:gt.plan.trialExpiresAt??gt.plan.expiresAt,trialUsed:gt.plan.trialUsed,trialDays:gt.plan.trialDays,trialDaysRemaining:gt.plan.trialDaysRemaining,trialStatus:gt.plan.trialStatus,entitlementVersion:gt.plan.entitlementVersion}:null)}catch{re(localStorage.getItem("kawach.account"))}finally{Ee(!0)}})()},[]);const St=async()=>{try{Fe?await O.localWorkspaceLifecycle(Fe,"logout",_e??void 0):await O.disconnect()}catch{try{await O.disconnect()}catch{}}h(!1),u(null),v(void 0),y(!1),m(null),j(null),L([]),E([]),me(null),$(null),R(!1),Y(!1),tg(),of(),localStorage.removeItem("kawach.account"),re(null),A3(),ee.provider==="auth0"&&await S2()},[kt,ht]=p.useState(()=>localStorage.getItem("kawach.theme")||"dark");p.useEffect(()=>{document.documentElement.setAttribute("data-theme",kt),localStorage.setItem("kawach.theme",kt)},[kt]);const xt=je=>{he(je),setTimeout(()=>he(null),2600)},rs=_e?`kawach.cloud-history.last-backup:${_e}`:null,Ye=_e?`kawach.cloud-history.remind-after:${_e}`:null;p.useEffect(()=>{if(!Ce||Te!==!0||!_e||V!==!0||!rs)return;let je=!1;const De=z*60*60*1e3,et=async()=>{const M=Date.parse(localStorage.getItem(rs)??"");if(!(Number.isFinite(M)&&Date.now()-M<De))try{await O.workspaceBackup(),je||localStorage.setItem(rs,new Date().toISOString())}catch{}};et();const Ut=window.setInterval(()=>{et()},15*60*1e3);return()=>{je=!0,window.clearInterval(Ut)}},[_e,Te,z,rs,Ce,V]);const Xt=async()=>{const je=await O.workspaceBackupPreference(GN);await O.workspaceBackup(),rs&&localStorage.setItem(rs,new Date().toISOString()),ve(je.automaticBackupAccepted),D(je.backupCadenceHours),Ye&&localStorage.removeItem(Ye),ne(!1),xt(`Cloud History enabled — Prooflane will back up approved artifacts every ${je.backupCadenceHours} hours while Inspector is open.`)},zs=()=>{Ye&&localStorage.setItem(Ye,String(Date.now()+D3)),ne(!1)},At=je=>{t(je);const De=Number(localStorage.getItem(Ye??"")),et=!Number.isFinite(De)||Date.now()>=De;Ce&&Te===!1&&et&&M3.has(je)&&ne(!0)};p.useEffect(()=>{_e&&Xe().catch(()=>R(!0))},[_e,Xe]);const es=(je,De,et=!1)=>{a.current=Date.now(),uc("target_connection_started",{target_type:je?"MCP":De??"UNSELECTED",feature:e}),m(je??null),j(null),w(je?"MCP":De??null),k(et&&!je&&!De),y(!0)},Js=je=>{if(je.type==="MCP"){const De=N.find(et=>et.id===je.discoveryMetadata.mcpConnectionId);if(De){es(De,"MCP");return}}m(null),j(je),w(je.type),k(!1),y(!0)},is=()=>{y(!1),m(null),j(null),w(null),k(!1)},ii=(je,De,et)=>{u(je),h(!0),Y(!0),v((et==null?void 0:et.displayName)??De),et&&(me(et.id),$(`target_mcp_${et.id}`),L(M=>[...M.filter(Se=>Se.id!==et.id),et].sort((Se,Ge)=>Se.createdAt.localeCompare(Ge.createdAt)||Se.id.localeCompare(Ge.id)))),is(),pe(M=>M+1),xt(`Connected to ${je.serverName??"server"}`);const Ut=a.current===null?0:Date.now()-a.current;uc("target_connected",{target_type:"MCP",feature:e,duration_bucket:WN(Ut)}),a.current=null,Xe().catch(()=>{})},Z=(je,De)=>{u(je),h(!0),v(De.displayName),$(De.id),E(Ut=>[...Ut.filter(M=>M.id!==De.id),De].sort((M,Se)=>M.createdAt.localeCompare(Se.createdAt)||M.id.localeCompare(Se.id))),Y(!0),is(),pe(Ut=>Ut+1),xt(`Connected to ${De.displayName}`);const et=a.current===null?0:Date.now()-a.current;uc("target_connected",{target_type:De.type,feature:e,duration_bucket:WN(et)}),a.current=null,Xe().catch(()=>{})},Ue=je=>{j(null),m(null),w(je.type),E(De=>De.filter(et=>et.id!==je.id)),I===je.id&&($(null),h(!1),u(null),v(void 0)),xt("That saved target no longer exists locally. Review the preserved values and create a new connection."),Xe().catch(()=>{})},$e=async je=>{if(!(!je||fe)){P(!0);try{const De=await O.targetActivate(je);$(De.target.id),me(De.target.discoveryMetadata.mcpConnectionId??null),u(De.capabilities),h(!0),v(De.target.displayName),xt(`Using ${De.target.displayName}`)}catch(De){xt(De instanceof Error?De.message:"The target could not be selected.")}finally{P(!1)}}},mt=async(je,De)=>{if(!je||fe)return;const et=De?be[De.featureType]:null,Ut=async()=>!De||!et||et.connectionId===je?!1:(await O.mcpDeleteBinding(De.featureType,De.resourceId),_t(M=>({...M,[De.featureType]:null})),!0);if(je===X){await Ut()&&xt("Server changed for this screen. Choose one of its tools to finish the target selection.");return}P(!0);try{const M=await O.mcpActivateConnection(je);me(M.connection.id),$(`target_mcp_${M.connection.id}`),u(M.capabilities),h(!0),v(M.connection.displayName);const Se=await Ut();xt(Se?`Using ${M.connection.displayName}. Choose one of its tools to finish the target selection.`:`Using ${M.connection.displayName}`)}catch(M){xt(M instanceof Error?M.message:"The MCP server could not be selected.")}finally{P(!1)}},Pt=async(je,De)=>{const et=await O.connect(je,De);return u(et.capabilities),h(!0),v(et.connection.displayName),me(et.connection.id),$(`target_mcp_${et.connection.id}`),L(Ut=>[...Ut.filter(M=>M.id!==et.connection.id),et.connection]),xt(`Connected to ${et.capabilities.serverName??De??"server"}`),et.capabilities},$t=async()=>{I?await O.targetDisconnect(I):X?await O.mcpDisconnectConnection(X):await O.disconnect(),h(!1),u(null),v(void 0),me(null),$(null),Y(_.some(je=>je.id!==I&&je.connectionStatus==="READY")),await Xe().catch(()=>{}),pe(je=>je+1),xt("Disconnected")},xs=O3[e],Ot=_.find(je=>je.id===I)??null,zt=(je,De)=>n.current.has(je)?s.jsx("div",{hidden:e!==je,"data-persistent-view":je,children:De}):null,xa=e==="security"&&ze==="model",Ts=e==="security"&&ze!=="runtime"?void 0:z3[e],Ua=Ts?be[Ts.featureType]:null,kl=(Ua==null?void 0:Ua.status)==="VALID"&&Ua.connectionId===X,fr=kl&&c?{...c,tools:c.tools.filter(je=>je.name===Ua.toolName)}:c,Gd=()=>{const je=document.getElementById("ms2-source");je&&(je.scrollIntoView({block:"center",behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}),je.focus())};return Re?_e?ee.provider==="auth0"&&V!==!0?s.jsx(GO,{email:_e,onSignOut:()=>{St()}}):ee.provider==="auth0"&&ke===null?s.jsx("div",{className:"app kawach-loader-screen",children:s.jsx(Bc,{label:"Checking your workspace agreement…"})}):ee.provider==="auth0"&&ke!==!0?s.jsx(O5,{account:_e,enabled:Ce,configured:qe,eligible:ye,planLabel:Ne==null?void 0:Ne.label,onAccepted:()=>we(!0)}):F&&!W?s.jsx("div",{className:"app kawach-loader-screen",children:s.jsx(Bc,{label:"Checking target connections…"})}):F&&!H?s.jsxs(s.Fragment,{children:[s.jsx(U5,{availableTypes:K,workspaceId:ue,projectId:B,targets:_,onChoose:je=>es(void 0,je),onImport:()=>es(void 0,void 0,!0),onReconnect:Js,onRemove:je=>{window.confirm("Remove this target connection? Governed history remains intact.")&&O.targetRemove(je.id).then(Xe).catch(De=>xt(De instanceof Error?De.message:"The target could not be removed."))},onSignOut:()=>{St()}}),f&&s.jsx(Lw,{onClose:is,onConnected:ii,onTargetConnected:Z,onReconnectTargetMissing:Ue,reconnectConnection:b,reconnectTarget:x,initialType:S,initialImport:C,availableTypes:K}),T&&s.jsx(Pw,{message:T})]}):s.jsxs("div",{className:"app",children:[s.jsxs("aside",{className:"sidebar",children:[s.jsx("div",{children:s.jsxs("div",{className:"brand",children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"agent assurance spine"})]})]})}),jT.map(je=>s.jsxs("div",{children:[s.jsx("div",{className:"nav-group-label",children:je.label}),je.items.map(De=>{if(De.id==="prompts"&&d&&((c==null?void 0:c.prompts.length)??0)===0)return null;const et=De.live&&!d,Ut=De.id==="tools"?c==null?void 0:c.tools.length:De.id==="prompts"?c==null?void 0:c.prompts.length:void 0;return s.jsxs("button",{className:`nav-item ${e===De.id?"active":""} ${et?"disabled":""}`,onClick:()=>At(De.id),children:[s.jsx("span",{children:De.name}),Ut!==void 0&&s.jsx("span",{className:"count",children:Ut}),De.soon&&s.jsx("span",{className:"soon",children:"soon"})]},De.id)})]},je.label)),s.jsxs("div",{className:"sidebar-footer",children:[s.jsxs("div",{className:"sidebar-footer-brand","aria-label":"Prooflane — Agent Assurance Spine",children:[s.jsx(ur,{}),s.jsxs("div",{children:[s.jsx("div",{className:"brand-name",children:"prooflane"}),s.jsx("div",{className:"brand-tag",children:"agent assurance spine"})]})]}),s.jsx("div",{className:"nav-group-label",children:"Appearance"}),s.jsxs("div",{className:"theme-toggle",role:"group","aria-label":"Theme",children:[s.jsx("button",{className:kt==="dark"?"active":"",onClick:()=>ht("dark"),"aria-pressed":kt==="dark",children:"◐ Dark"}),s.jsx("button",{className:kt==="light"?"active":"",onClick:()=>ht("light"),"aria-pressed":kt==="light",children:"○ Light"})]}),s.jsx("div",{className:"nav-group-label",style:{marginTop:14},children:"Account"}),s.jsxs("div",{className:"row spread",style:{gap:8,alignItems:"center"},children:[s.jsx("span",{className:"muted",style:{fontSize:11.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_e??void 0,children:_e??"—"}),s.jsx("button",{className:"btn sm ghost",onClick:St,style:{flexShrink:0},children:"Sign out"})]})]})]}),s.jsxs("main",{className:"main",children:[s.jsxs("div",{className:"topbar",children:[s.jsxs("div",{children:[s.jsx("div",{className:"screen-title",children:xs.title}),s.jsx("div",{className:"screen-sub",children:xs.sub})]}),s.jsxs("div",{className:"conn",children:[s.jsx("span",{className:`conn-dot ${d&&!xa?"on":""}`}),_.length?s.jsxs("label",{className:"mcp-server-picker",title:"Choose the current target for this project.",children:[s.jsx("span",{className:"sr-only",children:"Current target"}),s.jsxs("select",{className:"field",value:I??"",disabled:fe,onChange:je=>void $e(je.target.value),children:[s.jsx("option",{value:"",children:"Select target…"}),_.map(je=>s.jsxs("option",{value:je.id,disabled:je.connectionStatus!=="READY",children:[je.displayName," · ",je.type.replaceAll("_","/"),je.connectionStatus==="READY"?` · ${je.discoveryMetadata.capabilityCount} capabilities`:` · ${je.connectionStatus.toLowerCase().replaceAll("_"," ")}`]},je.id))]})]}):s.jsx("span",{className:"conn-name",children:xa?"No target needed for static artifact analysis":"Target · not connected"}),d&&(c==null?void 0:c.serverVersion)&&s.jsx("span",{className:"tag informational mono",title:"Discovered target version",children:c.serverVersion}),d&&s.jsx("button",{className:"btn sm ghost",onClick:$t,children:"Disconnect"}),xa&&s.jsx("button",{className:"btn sm primary",onClick:Gd,children:"Add model artifact"}),!d&&!xa&&s.jsx("button",{className:"btn sm primary",onClick:()=>es(),children:"Connect a target"})]})]}),s.jsx(W5,{plan:Ne,onStarted:()=>window.location.reload()}),Ts&&(Ot==null?void 0:Ot.type)==="MCP"&&s.jsx("div",{className:"mcp-feature-target",children:s.jsx(M5,{featureType:Ts.featureType,resourceId:Ts.resourceId,value:be[Ts.featureType],activeConnectionId:X,required:!0,onConnect:()=>es(),onManageConnections:()=>At("settings"),onConnectionSelect:je=>mt(je,Ts),onChange:(je,De)=>{_t(et=>({...et,[Ts.featureType]:je})),De&&(u(De.capabilities),h(!0),v(De.connection.displayName),me(De.connection.id),$(`target_mcp_${De.connection.id}`),xt(`Bound ${De.connection.displayName} / ${(je==null?void 0:je.toolName)??"tool"}`))}},`${Ts.featureType}:${Ts.resourceId}:${Dt}`)}),zt("tools",s.jsx(u$,{caps:c,connected:d,notify:xt,onConnect:()=>es(),onNavigatePrompts:()=>At("prompt-automation")})),zt("prompts",s.jsx(Q$,{caps:c,connected:d})),zt("http",s.jsx(zO,{notify:xt})),zt("prompt-automation",s.jsx(hO,{caps:fr,notify:xt,core:q,connected:d,onNavigate:je=>At(je)})),zt("contracts",s.jsx(mO,{connected:d,caps:fr,onConnect:Pt,notify:xt,onNavigateIntelligence:()=>At("assurance")})),zt("schemas",s.jsx(jO,{notify:xt,onNavigate:je=>At(je)})),zt("runs",s.jsx(VO,{})),zt("observability",ge.deployment?s.jsx(KO,{caps:c,connected:d,onNavigate:je=>At(je)}):s.jsx(Do,{...Ww})),zt("performance",s.jsx(hL,{core:q,caps:fr})),zt("benchmark",s.jsx(Fz,{})),zt("rag",ge.rag?s.jsx(NL,{caps:fr,connected:d,target:Ot,boundToolName:kl?Ua.toolName:void 0,hostedRunner:U==="hosted",notify:xt,onNavigateIntelligence:()=>At("assurance")}):s.jsx(Do,{...W$})),zt("assurance",s.jsx(Rz,{visible:e==="assurance",connected:d,targetRecord:Ot,hostedRunner:U==="hosted",onNavigateGates:(je,De)=>{i(je??null),l(De??null),At("gates")},onNavigateContracts:()=>At("contracts"),onNavigateRag:()=>At("rag"),onNavigateSecurity:()=>{wt("runtime"),At("security")}})),zt("security",s.jsx(ZD,{visible:e==="security",caps:fr,connected:d,target:Ot,hostedRunner:U==="hosted",entitled:ge.security,scope:ze,onScopeChange:wt,onNavigateIntelligence:()=>At("assurance")})),zt("gates",ge.gates?s.jsx(x5,{hostedRunner:U==="hosted",focusedLegacyGateId:r,onFocusedLegacyGateConsumed:()=>i(null),focusedSuiteSlug:o,onFocusedSuiteConsumed:()=>l(null)}):s.jsx(Do,{...H$})),zt("policies",ge.deployment?s.jsx(S5,{}):s.jsx(Do,{...Ww})),zt("settings",s.jsxs("div",{className:"stack",style:{gap:18},children:[s.jsx(D5,{onConnect:je=>es(void 0,je),onReconnect:Js,onChanged:()=>{pe(je=>je+1),Xe().catch(()=>{})}},Dt),s.jsx(L5,{account:_e,enabled:Ce,emailVerified:V===!0,caps:c,connected:d,planStatus:Ne,automaticBackupAccepted:Te,backupCadenceHours:z})]}))]}),f&&s.jsx(Lw,{onClose:is,onConnected:ii,onTargetConnected:Z,onReconnectTargetMissing:Ue,reconnectConnection:b,reconnectTarget:x,initialType:S,initialImport:C,availableTypes:K}),A&&s.jsx($5,{onEnabled:Xt,onClose:zs}),T&&s.jsx(Pw,{message:T})]}):s.jsx(FO,{provider:ee.provider,authError:st,onSignedIn:je=>{localStorage.setItem("kawach.account",je),re(je)}}):s.jsx("div",{className:"app kawach-loader-screen",children:s.jsx(Bc,{label:"Loading Prooflane Inspector…"})})}s1(document.getElementById("root")).render(s.jsx(zT.StrictMode,{children:s.jsx(U3,{})}));
|