From d6b52ba06c8b51907f5dee45f0d9df1fe401c7ff Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Fri, 3 Jul 2026 13:31:46 +0200 Subject: [PATCH] fix: capture popup non-persistance - Save and restore dialog open/closed state in sessionStorage (App.jsx) - Persist form data: locator, error, busy, jobStatus, jobUid (CaptureDialog.jsx) - Auto-resume polling if capture job was in progress before page refresh - Only clear form on fresh user click, not when restoring from refresh - Clean up sessionStorage when capture completes successfully Fixes: Capture pop-up disappears on page refresh with unsaved data --- .../static/assets/index-Bysig1_i.js | 40 ++++++ .../static/assets/index-MmGgQJvV.js | 40 ------ crates/archivr-server/static/index.html | 2 +- frontend/src/App.jsx | 10 +- frontend/src/components/CaptureDialog.jsx | 117 ++++++++++++++++-- 5 files changed, 158 insertions(+), 51 deletions(-) create mode 100644 crates/archivr-server/static/assets/index-Bysig1_i.js delete mode 100644 crates/archivr-server/static/assets/index-MmGgQJvV.js diff --git a/crates/archivr-server/static/assets/index-Bysig1_i.js b/crates/archivr-server/static/assets/index-Bysig1_i.js new file mode 100644 index 0000000..6671611 --- /dev/null +++ b/crates/archivr-server/static/assets/index-Bysig1_i.js @@ -0,0 +1,40 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var au={exports:{}},hl={},cu={exports:{}},$={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var dr=Symbol.for("react.element"),_c=Symbol.for("react.portal"),Tc=Symbol.for("react.fragment"),Pc=Symbol.for("react.strict_mode"),Lc=Symbol.for("react.profiler"),zc=Symbol.for("react.provider"),Rc=Symbol.for("react.context"),Dc=Symbol.for("react.forward_ref"),Oc=Symbol.for("react.suspense"),Fc=Symbol.for("react.memo"),Mc=Symbol.for("react.lazy"),Js=Symbol.iterator;function $c(e){return e===null||typeof e!="object"?null:(e=Js&&e[Js]||e["@@iterator"],typeof e=="function"?e:null)}var du={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},fu=Object.assign,pu={};function Nn(e,t,n){this.props=e,this.context=t,this.refs=pu,this.updater=n||du}Nn.prototype.isReactComponent={};Nn.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")};Nn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function mu(){}mu.prototype=Nn.prototype;function es(e,t,n){this.props=e,this.context=t,this.refs=pu,this.updater=n||du}var ts=es.prototype=new mu;ts.constructor=es;fu(ts,Nn.prototype);ts.isPureReactComponent=!0;var Xs=Array.isArray,hu=Object.prototype.hasOwnProperty,ns={current:null},vu={key:!0,ref:!0,__self:!0,__source:!0};function gu(e,t,n){var r,l={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)hu.call(t,r)&&!vu.hasOwnProperty(r)&&(l[r]=t[r]);var u=arguments.length-2;if(u===1)l.children=n;else if(1>>1,O=T[A];if(0>>1;Al(qe,D))Hel(F,qe)?(T[A]=F,T[He]=D,A=He):(T[A]=qe,T[ue]=D,A=ue);else if(Hel(F,D))T[A]=F,T[He]=D,A=He;else break e}}return N}function l(T,N){var D=T.sortIndex-N.sortIndex;return D!==0?D:T.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,u=s.now();e.unstable_now=function(){return s.now()-u}}var a=[],d=[],v=1,h=null,m=3,k=!1,x=!1,S=!1,R=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(T){for(var N=n(d);N!==null;){if(N.callback===null)r(d);else if(N.startTime<=T)r(d),N.sortIndex=N.expirationTime,t(a,N);else break;N=n(d)}}function y(T){if(S=!1,p(T),!x)if(n(a)!==null)x=!0,we(w);else{var N=n(d);N!==null&&Ve(y,N.startTime-T)}}function w(T,N){x=!1,S&&(S=!1,f(z),z=-1),k=!0;var D=m;try{for(p(N),h=n(a);h!==null&&(!(h.expirationTime>N)||T&&!M());){var A=h.callback;if(typeof A=="function"){h.callback=null,m=h.priorityLevel;var O=A(h.expirationTime<=N);N=e.unstable_now(),typeof O=="function"?h.callback=O:h===n(a)&&r(a),p(N)}else r(a);h=n(a)}if(h!==null)var pe=!0;else{var ue=n(d);ue!==null&&Ve(y,ue.startTime-N),pe=!1}return pe}finally{h=null,m=D,k=!1}}var E=!1,_=null,z=-1,I=5,C=-1;function M(){return!(e.unstable_now()-CT||125A?(T.sortIndex=D,t(d,T),n(a)===null&&T===n(d)&&(S?(f(z),z=-1):S=!0,Ve(y,D-A))):(T.sortIndex=O,t(a,T),x||k||(x=!0,we(w))),T},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(T){var N=m;return function(){var D=m;m=N;try{return T.apply(this,arguments)}finally{m=D}}}})(ku);Su.exports=ku;var Jc=Su.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Xc=g,Le=Jc;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oi=Object.prototype.hasOwnProperty,Gc=/^[: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]*$/,Zs={},qs={};function Zc(e){return oi.call(qs,e)?!0:oi.call(Zs,e)?!1:Gc.test(e)?qs[e]=!0:(Zs[e]=!0,!1)}function qc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function bc(e,t,n,r){if(t===null||typeof t>"u"||qc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ge(e,t,n,r,l,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){se[e]=new ge(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];se[t]=new ge(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){se[e]=new ge(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){se[e]=new ge(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){se[e]=new ge(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){se[e]=new ge(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){se[e]=new ge(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){se[e]=new ge(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){se[e]=new ge(e,5,!1,e.toLowerCase(),null,!1,!1)});var ls=/[\-:]([a-z])/g;function is(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(ls,is);se[t]=new ge(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(ls,is);se[t]=new ge(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(ls,is);se[t]=new ge(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){se[e]=new ge(e,1,!1,e.toLowerCase(),null,!1,!1)});se.xlinkHref=new ge("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){se[e]=new ge(e,1,!1,e.toLowerCase(),null,!0,!0)});function ss(e,t,n,r){var l=se.hasOwnProperty(t)?se[t]:null;(l!==null?l.type!==0:r||!(2u||l[s]!==i[u]){var a=` +`+l[s].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=s&&0<=u);break}}}finally{Ol=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?On(e):""}function ed(e){switch(e.tag){case 5:return On(e.type);case 16:return On("Lazy");case 13:return On("Suspense");case 19:return On("SuspenseList");case 0:case 2:case 15:return e=Fl(e.type,!1),e;case 11:return e=Fl(e.type.render,!1),e;case 1:return e=Fl(e.type,!0),e;default:return""}}function di(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 qt:return"Fragment";case Zt:return"Portal";case ui:return"Profiler";case os:return"StrictMode";case ai:return"Suspense";case ci:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Cu:return(e.displayName||"Context")+".Consumer";case ju:return(e._context.displayName||"Context")+".Provider";case us:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case as:return t=e.displayName||null,t!==null?t:di(e.type)||"Memo";case ht:t=e._payload,e=e._init;try{return di(e(t))}catch{}}return null}function td(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 di(t);case 8:return t===os?"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 Pt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _u(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function nd(e){var t=_u(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yr(e){e._valueTracker||(e._valueTracker=nd(e))}function Tu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=_u(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qr(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 fi(e,t){var n=t.checked;return X({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function eo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Pt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Pu(e,t){t=t.checked,t!=null&&ss(e,"checked",t,!1)}function pi(e,t){Pu(e,t);var n=Pt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?mi(e,t.type,n):t.hasOwnProperty("defaultValue")&&mi(e,t.type,Pt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function to(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function mi(e,t,n){(t!=="number"||Qr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fn=Array.isArray;function cn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=wr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Xn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Un={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},rd=["Webkit","ms","Moz","O"];Object.keys(Un).forEach(function(e){rd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Un[t]=Un[e]})});function Du(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Un.hasOwnProperty(e)&&Un[e]?(""+t).trim():t+"px"}function Ou(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Du(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ld=X({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 gi(e,t){if(t){if(ld[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function yi(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 wi=null;function cs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var xi=null,dn=null,fn=null;function lo(e){if(e=mr(e)){if(typeof xi!="function")throw Error(j(280));var t=e.stateNode;t&&(t=xl(t),xi(e.stateNode,e.type,t))}}function Fu(e){dn?fn?fn.push(e):fn=[e]:dn=e}function Mu(){if(dn){var e=dn,t=fn;if(fn=dn=null,lo(e),t)for(e=0;e>>=0,e===0?32:31-(hd(e)/vd|0)|0}var xr=64,Sr=4194304;function Mn(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 Xr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var u=s&~l;u!==0?r=Mn(u):(i&=s,i!==0&&(r=Mn(i)))}else s=n&~l,s!==0?r=Mn(s):i!==0&&(r=Mn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function fr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Xe(t),e[t]=n}function xd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Bn),mo=" ",ho=!1;function na(e,t){switch(e){case"keyup":return Jd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ra(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bt=!1;function Gd(e,t){switch(e){case"compositionend":return ra(t);case"keypress":return t.which!==32?null:(ho=!0,mo);case"textInput":return e=t.data,e===mo&&ho?null:e;default:return null}}function Zd(e,t){if(bt)return e==="compositionend"||!ys&&na(e,t)?(e=ea(),Mr=hs=wt=null,bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=wo(n)}}function oa(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?oa(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ua(){for(var e=window,t=Qr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qr(e.document)}return t}function ws(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 of(e){var t=ua(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&oa(n.ownerDocument.documentElement,n)){if(r!==null&&ws(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=xo(n,i);var s=xo(n,r);l&&s&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,en=null,Ei=null,Hn=null,_i=!1;function So(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;_i||en==null||en!==Qr(r)||(r=en,"selectionStart"in r&&ws(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Hn&&tr(Hn,r)||(Hn=r,r=qr(Ei,"onSelect"),0rn||(e.current=Di[rn],Di[rn]=null,rn--)}function H(e,t){rn++,Di[rn]=e.current,e.current=t}var Lt={},fe=Rt(Lt),Ne=Rt(!1),Ht=Lt;function gn(e,t){var n=e.type.contextTypes;if(!n)return Lt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function je(e){return e=e.childContextTypes,e!=null}function el(){Q(Ne),Q(fe)}function To(e,t,n){if(fe.current!==Lt)throw Error(j(168));H(fe,t),H(Ne,n)}function ga(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,td(e)||"Unknown",l));return X({},n,r)}function tl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Lt,Ht=fe.current,H(fe,e),H(Ne,Ne.current),!0}function Po(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=ga(e,t,Ht),r.__reactInternalMemoizedMergedChildContext=e,Q(Ne),Q(fe),H(fe,e)):Q(Ne),H(Ne,n)}var it=null,Sl=!1,Xl=!1;function ya(e){it===null?it=[e]:it.push(e)}function wf(e){Sl=!0,ya(e)}function Dt(){if(!Xl&&it!==null){Xl=!0;var e=0,t=V;try{var n=it;for(V=1;e>=s,l-=s,st=1<<32-Xe(t)+l|n<z?(I=_,_=null):I=_.sibling;var C=m(f,_,p[z],y);if(C===null){_===null&&(_=I);break}e&&_&&C.alternate===null&&t(f,_),c=i(C,c,z),E===null?w=C:E.sibling=C,E=C,_=I}if(z===p.length)return n(f,_),K&&Ft(f,z),w;if(_===null){for(;zz?(I=_,_=null):I=_.sibling;var M=m(f,_,C.value,y);if(M===null){_===null&&(_=I);break}e&&_&&M.alternate===null&&t(f,_),c=i(M,c,z),E===null?w=M:E.sibling=M,E=M,_=I}if(C.done)return n(f,_),K&&Ft(f,z),w;if(_===null){for(;!C.done;z++,C=p.next())C=h(f,C.value,y),C!==null&&(c=i(C,c,z),E===null?w=C:E.sibling=C,E=C);return K&&Ft(f,z),w}for(_=r(f,_);!C.done;z++,C=p.next())C=k(_,f,z,C.value,y),C!==null&&(e&&C.alternate!==null&&_.delete(C.key===null?z:C.key),c=i(C,c,z),E===null?w=C:E.sibling=C,E=C);return e&&_.forEach(function(oe){return t(f,oe)}),K&&Ft(f,z),w}function R(f,c,p,y){if(typeof p=="object"&&p!==null&&p.type===qt&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case gr:e:{for(var w=p.key,E=c;E!==null;){if(E.key===w){if(w=p.type,w===qt){if(E.tag===7){n(f,E.sibling),c=l(E,p.props.children),c.return=f,f=c;break e}}else if(E.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===ht&&Ro(w)===E.type){n(f,E.sibling),c=l(E,p.props),c.ref=zn(f,E,p),c.return=f,f=c;break e}n(f,E);break}else t(f,E);E=E.sibling}p.type===qt?(c=Vt(p.props.children,f.mode,y,p.key),c.return=f,f=c):(y=Wr(p.type,p.key,p.props,null,f.mode,y),y.ref=zn(f,c,p),y.return=f,f=y)}return s(f);case Zt:e:{for(E=p.key;c!==null;){if(c.key===E)if(c.tag===4&&c.stateNode.containerInfo===p.containerInfo&&c.stateNode.implementation===p.implementation){n(f,c.sibling),c=l(c,p.children||[]),c.return=f,f=c;break e}else{n(f,c);break}else t(f,c);c=c.sibling}c=ri(p,f.mode,y),c.return=f,f=c}return s(f);case ht:return E=p._init,R(f,c,E(p._payload),y)}if(Fn(p))return x(f,c,p,y);if(En(p))return S(f,c,p,y);Tr(f,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,c!==null&&c.tag===6?(n(f,c.sibling),c=l(c,p),c.return=f,f=c):(n(f,c),c=ni(p,f.mode,y),c.return=f,f=c),s(f)):n(f,c)}return R}var wn=ka(!0),Na=ka(!1),ll=Rt(null),il=null,on=null,Ns=null;function js(){Ns=on=il=null}function Cs(e){var t=ll.current;Q(ll),e._currentValue=t}function Mi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function mn(e,t){il=e,Ns=on=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ke=!0),e.firstContext=null)}function Ae(e){var t=e._currentValue;if(Ns!==e)if(e={context:e,memoizedValue:t,next:null},on===null){if(il===null)throw Error(j(308));on=e,il.dependencies={lanes:0,firstContext:e}}else on=on.next=e;return t}var It=null;function Es(e){It===null?It=[e]:It.push(e)}function ja(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Es(t)):(n.next=l.next,l.next=n),t.interleaved=n,dt(e,r)}function dt(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 vt=!1;function _s(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ca(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 ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ct(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,U&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,dt(e,n)}return l=r.interleaved,l===null?(t.next=t,Es(r)):(t.next=l.next,l.next=t),r.interleaved=t,dt(e,n)}function Ir(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fs(e,n)}}function Do(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function sl(e,t,n,r){var l=e.updateQueue;vt=!1;var i=l.firstBaseUpdate,s=l.lastBaseUpdate,u=l.shared.pending;if(u!==null){l.shared.pending=null;var a=u,d=a.next;a.next=null,s===null?i=d:s.next=d,s=a;var v=e.alternate;v!==null&&(v=v.updateQueue,u=v.lastBaseUpdate,u!==s&&(u===null?v.firstBaseUpdate=d:u.next=d,v.lastBaseUpdate=a))}if(i!==null){var h=l.baseState;s=0,v=d=a=null,u=i;do{var m=u.lane,k=u.eventTime;if((r&m)===m){v!==null&&(v=v.next={eventTime:k,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var x=e,S=u;switch(m=t,k=n,S.tag){case 1:if(x=S.payload,typeof x=="function"){h=x.call(k,h,m);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=S.payload,m=typeof x=="function"?x.call(k,h,m):x,m==null)break e;h=X({},h,m);break e;case 2:vt=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,m=l.effects,m===null?l.effects=[u]:m.push(u))}else k={eventTime:k,lane:m,tag:u.tag,payload:u.payload,callback:u.callback,next:null},v===null?(d=v=k,a=h):v=v.next=k,s|=m;if(u=u.next,u===null){if(u=l.shared.pending,u===null)break;m=u,u=m.next,m.next=null,l.lastBaseUpdate=m,l.shared.pending=null}}while(!0);if(v===null&&(a=h),l.baseState=a,l.firstBaseUpdate=d,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do s|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Kt|=s,e.lanes=s,e.memoizedState=h}}function Oo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Zl.transition;Zl.transition={};try{e(!1),t()}finally{V=n,Zl.transition=r}}function Va(){return Be().memoizedState}function Nf(e,t,n){var r=_t(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ha(e))Wa(t,n);else if(n=ja(e,t,n,r),n!==null){var l=he();Ge(n,e,r,l),Qa(n,t,r)}}function jf(e,t,n){var r=_t(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ha(e))Wa(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,u=i(s,n);if(l.hasEagerState=!0,l.eagerState=u,Ze(u,s)){var a=t.interleaved;a===null?(l.next=l,Es(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=ja(e,t,l,r),n!==null&&(l=he(),Ge(n,e,r,l),Qa(n,t,r))}}function Ha(e){var t=e.alternate;return e===J||t!==null&&t===J}function Wa(e,t){Wn=ul=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Qa(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fs(e,n)}}var al={readContext:Ae,useCallback:ae,useContext:ae,useEffect:ae,useImperativeHandle:ae,useInsertionEffect:ae,useLayoutEffect:ae,useMemo:ae,useReducer:ae,useRef:ae,useState:ae,useDebugValue:ae,useDeferredValue:ae,useTransition:ae,useMutableSource:ae,useSyncExternalStore:ae,useId:ae,unstable_isNewReconciler:!1},Cf={readContext:Ae,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:Ae,useEffect:Mo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ar(4194308,4,$a.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ar(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ar(4,2,e,t)},useMemo:function(e,t){var n=et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Nf.bind(null,J,e),[r.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:Fo,useDebugValue:Fs,useDeferredValue:function(e){return et().memoizedState=e},useTransition:function(){var e=Fo(!1),t=e[0];return e=kf.bind(null,e[1]),et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=J,l=et();if(K){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),ne===null)throw Error(j(349));Qt&30||Pa(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Mo(za.bind(null,r,i,e),[e]),r.flags|=2048,ar(9,La.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=et(),t=ne.identifierPrefix;if(K){var n=ot,r=st;n=(r&~(1<<32-Xe(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=or++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[tt]=t,e[lr]=r,tc(e,t,!1,!1),t.stateNode=e;e:{switch(s=yi(n,r),n){case"dialog":W("cancel",e),W("close",e),l=r;break;case"iframe":case"object":case"embed":W("load",e),l=r;break;case"video":case"audio":for(l=0;l<$n.length;l++)W($n[l],e);l=r;break;case"source":W("error",e),l=r;break;case"img":case"image":case"link":W("error",e),W("load",e),l=r;break;case"details":W("toggle",e),l=r;break;case"input":eo(e,r),l=fi(e,r),W("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=X({},r,{value:void 0}),W("invalid",e);break;case"textarea":no(e,r),l=hi(e,r),W("invalid",e);break;default:l=r}gi(n,l),u=l;for(i in u)if(u.hasOwnProperty(i)){var a=u[i];i==="style"?Ou(e,a):i==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,a!=null&&Ru(e,a)):i==="children"?typeof a=="string"?(n!=="textarea"||a!=="")&&Xn(e,a):typeof a=="number"&&Xn(e,""+a):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Jn.hasOwnProperty(i)?a!=null&&i==="onScroll"&&W("scroll",e):a!=null&&ss(e,i,a,s))}switch(n){case"input":yr(e),to(e,r,!1);break;case"textarea":yr(e),ro(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Pt(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?cn(e,!!r.multiple,i,!1):r.defaultValue!=null&&cn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=br)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return ce(t),null;case 6:if(e&&t.stateNode!=null)rc(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(j(166));if(n=Ut(sr.current),Ut(rt.current),_r(t)){if(r=t.stateNode,n=t.memoizedProps,r[tt]=t,(i=r.nodeValue!==n)&&(e=Pe,e!==null))switch(e.tag){case 3:Er(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Er(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[tt]=t,t.stateNode=r}return ce(t),null;case 13:if(Q(Y),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(K&&Te!==null&&t.mode&1&&!(t.flags&128))Sa(),yn(),t.flags|=98560,i=!1;else if(i=_r(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(j(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(j(317));i[tt]=t}else yn(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ce(t),i=!1}else Je!==null&&(qi(Je),Je=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Y.current&1?ee===0&&(ee=3):Vs())),t.updateQueue!==null&&(t.flags|=4),ce(t),null);case 4:return xn(),Wi(e,t),e===null&&nr(t.stateNode.containerInfo),ce(t),null;case 10:return Cs(t.type._context),ce(t),null;case 17:return je(t.type)&&el(),ce(t),null;case 19:if(Q(Y),i=t.memoizedState,i===null)return ce(t),null;if(r=(t.flags&128)!==0,s=i.rendering,s===null)if(r)Rn(i,!1);else{if(ee!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=ol(e),s!==null){for(t.flags|=128,Rn(i,!1),r=s.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,s=i.alternate,s===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=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,i.type=s.type,e=s.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return H(Y,Y.current&1|2),t.child}e=e.sibling}i.tail!==null&&Z()>kn&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304)}else{if(!r)if(e=ol(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Rn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!K)return ce(t),null}else 2*Z()-i.renderingStartTime>kn&&n!==1073741824&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Z(),t.sibling=null,n=Y.current,H(Y,r?n&1|2:n&1),t):(ce(t),null);case 22:case 23:return Bs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?_e&1073741824&&(ce(t),t.subtreeFlags&6&&(t.flags|=8192)):ce(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Df(e,t){switch(Ss(t),t.tag){case 1:return je(t.type)&&el(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xn(),Q(Ne),Q(fe),Ls(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ps(t),null;case 13:if(Q(Y),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));yn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Q(Y),null;case 4:return xn(),null;case 10:return Cs(t.type._context),null;case 22:case 23:return Bs(),null;case 24:return null;default:return null}}var Lr=!1,de=!1,Of=typeof WeakSet=="function"?WeakSet:Set,L=null;function un(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){G(e,t,r)}else n.current=null}function Qi(e,t,n){try{n()}catch(r){G(e,t,r)}}var Yo=!1;function Ff(e,t){if(Ti=Gr,e=ua(),ws(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,u=-1,a=-1,d=0,v=0,h=e,m=null;t:for(;;){for(var k;h!==n||l!==0&&h.nodeType!==3||(u=s+l),h!==i||r!==0&&h.nodeType!==3||(a=s+r),h.nodeType===3&&(s+=h.nodeValue.length),(k=h.firstChild)!==null;)m=h,h=k;for(;;){if(h===e)break t;if(m===n&&++d===l&&(u=s),m===i&&++v===r&&(a=s),(k=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=k}n=u===-1||a===-1?null:{start:u,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Pi={focusedElem:e,selectionRange:n},Gr=!1,L=t;L!==null;)if(t=L,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,L=e;else for(;L!==null;){t=L;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var S=x.memoizedProps,R=x.memoizedState,f=t.stateNode,c=f.getSnapshotBeforeUpdate(t.elementType===t.type?S:Ke(t.type,S),R);f.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var p=t.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(y){G(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,L=e;break}L=t.return}return x=Yo,Yo=!1,x}function Qn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Qi(t,n,i)}l=l.next}while(l!==r)}}function jl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ki(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 lc(e){var t=e.alternate;t!==null&&(e.alternate=null,lc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[tt],delete t[lr],delete t[Ri],delete t[gf],delete t[yf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ic(e){return e.tag===5||e.tag===3||e.tag===4}function Jo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ic(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Yi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=br));else if(r!==4&&(e=e.child,e!==null))for(Yi(e,t,n),e=e.sibling;e!==null;)Yi(e,t,n),e=e.sibling}function Ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ji(e,t,n),e=e.sibling;e!==null;)Ji(e,t,n),e=e.sibling}var le=null,Ye=!1;function mt(e,t,n){for(n=n.child;n!==null;)sc(e,t,n),n=n.sibling}function sc(e,t,n){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(vl,n)}catch{}switch(n.tag){case 5:de||un(n,t);case 6:var r=le,l=Ye;le=null,mt(e,t,n),le=r,Ye=l,le!==null&&(Ye?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&(Ye?(e=le,n=n.stateNode,e.nodeType===8?Jl(e.parentNode,n):e.nodeType===1&&Jl(e,n),bn(e)):Jl(le,n.stateNode));break;case 4:r=le,l=Ye,le=n.stateNode.containerInfo,Ye=!0,mt(e,t,n),le=r,Ye=l;break;case 0:case 11:case 14:case 15:if(!de&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Qi(n,t,s),l=l.next}while(l!==r)}mt(e,t,n);break;case 1:if(!de&&(un(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){G(n,t,u)}mt(e,t,n);break;case 21:mt(e,t,n);break;case 22:n.mode&1?(de=(r=de)||n.memoizedState!==null,mt(e,t,n),de=r):mt(e,t,n);break;default:mt(e,t,n)}}function Xo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Of),t.forEach(function(r){var l=Wf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Qe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=s),r&=~i}if(r=l,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$f(r/1960))-r,10e?16:e,xt===null)var r=!1;else{if(e=xt,xt=null,fl=0,U&6)throw Error(j(331));var l=U;for(U|=4,L=e.current;L!==null;){var i=L,s=i.child;if(L.flags&16){var u=i.deletions;if(u!==null){for(var a=0;aZ()-Us?Bt(e,0):Is|=n),Ce(e,t)}function mc(e,t){t===0&&(e.mode&1?(t=Sr,Sr<<=1,!(Sr&130023424)&&(Sr=4194304)):t=1);var n=he();e=dt(e,t),e!==null&&(fr(e,t,n),Ce(e,n))}function Hf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),mc(e,n)}function Wf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),mc(e,n)}var hc;hc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ne.current)ke=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ke=!1,zf(e,t,n);ke=!!(e.flags&131072)}else ke=!1,K&&t.flags&1048576&&wa(t,rl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Br(e,t),e=t.pendingProps;var l=gn(t,fe.current);mn(t,n),l=Rs(null,t,r,e,l,n);var i=Ds();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,je(r)?(i=!0,tl(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,_s(t),l.updater=Nl,t.stateNode=l,l._reactInternals=t,Ii(t,r,e,n),t=Bi(null,t,r,!0,i,n)):(t.tag=0,K&&i&&xs(t),me(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Br(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Kf(r),e=Ke(r,e),l){case 0:t=Ai(null,t,r,e,n);break e;case 1:t=Wo(null,t,r,e,n);break e;case 11:t=Vo(null,t,r,e,n);break e;case 14:t=Ho(null,t,r,Ke(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ke(r,l),Ai(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ke(r,l),Wo(e,t,r,l,n);case 3:e:{if(qa(t),e===null)throw Error(j(387));r=t.pendingProps,i=t.memoizedState,l=i.element,Ca(e,t),sl(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=Sn(Error(j(423)),t),t=Qo(e,t,r,n,l);break e}else if(r!==l){l=Sn(Error(j(424)),t),t=Qo(e,t,r,n,l);break e}else for(Te=jt(t.stateNode.containerInfo.firstChild),Pe=t,K=!0,Je=null,n=Na(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yn(),r===l){t=ft(e,t,n);break e}me(e,t,r,n)}t=t.child}return t;case 5:return Ea(t),e===null&&Fi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,s=l.children,Li(r,l)?s=null:i!==null&&Li(r,i)&&(t.flags|=32),Za(e,t),me(e,t,s,n),t.child;case 6:return e===null&&Fi(t),null;case 13:return ba(e,t,n);case 4:return Ts(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wn(t,null,r,n):me(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ke(r,l),Vo(e,t,r,l,n);case 7:return me(e,t,t.pendingProps,n),t.child;case 8:return me(e,t,t.pendingProps.children,n),t.child;case 12:return me(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,s=l.value,H(ll,r._currentValue),r._currentValue=s,i!==null)if(Ze(i.value,s)){if(i.children===l.children&&!Ne.current){t=ft(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){s=i.child;for(var a=u.firstContext;a!==null;){if(a.context===r){if(i.tag===1){a=ut(-1,n&-n),a.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var v=d.pending;v===null?a.next=a:(a.next=v.next,v.next=a),d.pending=a}}i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),Mi(i.return,n,t),u.lanes|=n;break}a=a.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(j(341));s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Mi(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}me(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,mn(t,n),l=Ae(l),r=r(l),t.flags|=1,me(e,t,r,n),t.child;case 14:return r=t.type,l=Ke(r,t.pendingProps),l=Ke(r.type,l),Ho(e,t,r,l,n);case 15:return Xa(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ke(r,l),Br(e,t),t.tag=1,je(r)?(e=!0,tl(t)):e=!1,mn(t,n),Ka(t,r,l),Ii(t,r,l,n),Bi(null,t,r,!0,e,n);case 19:return ec(e,t,n);case 22:return Ga(e,t,n)}throw Error(j(156,t.tag))};function vc(e,t){return Hu(e,t)}function Qf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ie(e,t,n,r){return new Qf(e,t,n,r)}function Hs(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Kf(e){if(typeof e=="function")return Hs(e)?1:0;if(e!=null){if(e=e.$$typeof,e===us)return 11;if(e===as)return 14}return 2}function Tt(e,t){var n=e.alternate;return n===null?(n=Ie(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 Wr(e,t,n,r,l,i){var s=2;if(r=e,typeof e=="function")Hs(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case qt:return Vt(n.children,l,i,t);case os:s=8,l|=8;break;case ui:return e=Ie(12,n,t,l|2),e.elementType=ui,e.lanes=i,e;case ai:return e=Ie(13,n,t,l),e.elementType=ai,e.lanes=i,e;case ci:return e=Ie(19,n,t,l),e.elementType=ci,e.lanes=i,e;case Eu:return El(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ju:s=10;break e;case Cu:s=9;break e;case us:s=11;break e;case as:s=14;break e;case ht:s=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=Ie(s,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Vt(e,t,n,r){return e=Ie(7,e,r,t),e.lanes=n,e}function El(e,t,n,r){return e=Ie(22,e,r,t),e.elementType=Eu,e.lanes=n,e.stateNode={isHidden:!1},e}function ni(e,t,n){return e=Ie(6,e,null,t),e.lanes=n,e}function ri(e,t,n){return t=Ie(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Yf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$l(0),this.expirationTimes=$l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$l(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Ws(e,t,n,r,l,i,s,u,a){return e=new Yf(e,t,n,u,a),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ie(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_s(i),e}function Jf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(xc)}catch(e){console.error(e)}}xc(),xu.exports=ze;var bf=xu.exports,Sc,ru=bf;Sc=ru.createRoot,ru.hydrateRoot;async function ye(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function ep(){return ye("/api/archives")}async function tp(e){return ye(`/api/archives/${e}/entries`)}async function np(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),ye(`/api/archives/${e}/entries/search?${r}`)}async function rp(e,t){return ye(`/api/archives/${e}/entries/${t}`)}async function lp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function li(e,t){return ye(`/api/archives/${e}/entries/${t}/tags`)}async function ip(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag_path:n})});if(!r.ok)throw new Error(`Failed to add tag (${r.status})`)}async function sp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function lu(e){return ye(`/api/archives/${e}/runs`)}async function ii(e){return ye(`/api/archives/${e}/tags`)}async function op(e,t){const n=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function iu(e,t){return ye(`/api/archives/${e}/capture_jobs/${t}`)}async function up(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function ap(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function cp(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function dp(){await fetch("/api/auth/logout",{method:"POST"})}async function fp(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function pp(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function mp(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function hp(){return ye("/api/auth/tokens")}async function vp(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function gp(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function yp(){return ye("/api/admin/instance-settings")}async function wp(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function xp(){return ye("/api/admin/users")}async function Sp(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function kp(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Np(){return ye("/api/admin/roles")}async function jp(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Cp(e){return ye(`/api/archives/${e}/collections`)}async function Ep(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}return l.json()}async function _p(e,t){return ye(`/api/archives/${e}/collections/${t}`)}async function Tp(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Pp(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function Lp(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function zp(e,t){return ye(`/api/archives/${e}/entries/${t}/collections`)}async function su(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Rp(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}const Dp=window.fetch;window.fetch=async(...e)=>{var n;const t=await Dp(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function Op({onLogin:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(null),[u,a]=g.useState(!1);async function d(v){v.preventDefault(),s(null),a(!0);try{const h=await cp(t,r);e(h)}catch(h){s(h.message)}finally{a(!1)}}return o.jsx("div",{className:"login-page",children:o.jsxs("div",{className:"login-card",children:[o.jsx("h1",{className:"login-brand",children:"Archivr"}),o.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),o.jsxs("form",{onSubmit:d,children:[o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),o.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:v=>n(v.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),o.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:v=>l(v.target.value),required:!0,autoComplete:"current-password"})]}),i&&o.jsx("p",{className:"login-error",children:i}),o.jsx("button",{className:"login-submit",type:"submit",disabled:u,children:u?"Signing in…":"Sign in"})]})]})})}function Fp({onComplete:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(""),[u,a]=g.useState(null),[d,v]=g.useState(!1);async function h(m){if(m.preventDefault(),r!==i){a("Passwords do not match");return}if(r.length<8){a("Password must be at least 8 characters");return}a(null),v(!0);try{await ap(t,r),e()}catch(k){a(k.message)}finally{v(!1)}}return o.jsx("div",{className:"setup-page",children:o.jsxs("div",{className:"setup-card",children:[o.jsx("h1",{className:"setup-brand",children:"Archivr"}),o.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),o.jsxs("form",{onSubmit:h,children:[o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),o.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:m=>n(m.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),o.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:m=>l(m.target.value),required:!0,autoComplete:"new-password"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),o.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:m=>s(m.target.value),required:!0,autoComplete:"new-password"})]}),u&&o.jsx("p",{className:"setup-error",children:u}),o.jsx("button",{className:"setup-submit",type:"submit",disabled:d,children:d?"Creating account…":"Create account"})]})]})})}function Mp({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){const{currentUser:s,setCurrentUser:u}=g.useContext(zl)??{},[a,d]=g.useState(!1);async function v(){d(!0),await dp(),u(null),window.location.reload()}return o.jsxs("header",{className:"topbar",children:[o.jsx("div",{className:"brand",children:"Archivr"}),o.jsx("div",{className:"switcher",children:o.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:h=>n(h.target.value),children:e.map(h=>o.jsx("option",{value:h.id,children:h.label},h.id))})}),o.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","runs","admin","tags","collections","settings"].map(h=>o.jsx("button",{className:`nav-link${r===h?" is-active":""}`,onClick:()=>l(h),children:h.charAt(0).toUpperCase()+h.slice(1)},h))}),o.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),s&&o.jsxs("div",{className:"user-menu",children:[o.jsx("span",{className:"user-name",children:s.display_name||s.username}),o.jsx("button",{className:"logout-btn",onClick:v,disabled:a,children:a?"Logging out…":"Log out"})]})]})}function $p({open:e,archiveId:t,onClose:n,onCaptured:r}){const l=g.useRef(null),i=g.useRef(!0),s=g.useRef(!1),[u,a]=g.useState(()=>sessionStorage.getItem("captureDialogLocator")||""),[d,v]=g.useState(()=>sessionStorage.getItem("captureDialogError")||null),[h,m]=g.useState(()=>sessionStorage.getItem("captureDialogBusy")==="true"),[k,x]=g.useState(()=>sessionStorage.getItem("captureDialogJobStatus")||null),[S,R]=g.useState(()=>sessionStorage.getItem("captureDialogJobUid")||null),f=g.useRef(null);g.useEffect(()=>{sessionStorage.setItem("captureDialogLocator",u)},[u]),g.useEffect(()=>{sessionStorage.setItem("captureDialogError",d||"")},[d]),g.useEffect(()=>{sessionStorage.setItem("captureDialogBusy",h)},[h]),g.useEffect(()=>{sessionStorage.setItem("captureDialogJobStatus",k||"")},[k]),g.useEffect(()=>{sessionStorage.setItem("captureDialogJobUid",S||"")},[S]),g.useEffect(()=>{s.current||!S||k!=="running"||!t||(s.current=!0,f.current=setInterval(async()=>{var w;try{const E=await iu(t,S);E.status==="completed"?(clearInterval(f.current),f.current=null,m(!1),x("completed"),c(),(w=l.current)==null||w.close(),r()):E.status==="failed"&&(clearInterval(f.current),f.current=null,m(!1),x("failed"),v(E.error_text||"Capture failed."))}catch(E){clearInterval(f.current),f.current=null,m(!1),v(E.message)}},500))},[S,k,t,r]),g.useEffect(()=>{const w=l.current;if(!w)return;const E=()=>{clearInterval(f.current),n()};return w.addEventListener("close",E),()=>w.removeEventListener("close",E)},[n]),g.useEffect(()=>{const w=l.current;w&&(e?(i.current||(a(""),v(null),x(null),m(!1),R(null),clearInterval(f.current)),i.current=!1,w.open||w.showModal()):w.open&&w.close())},[e]);function c(){sessionStorage.removeItem("captureDialogLocator"),sessionStorage.removeItem("captureDialogError"),sessionStorage.removeItem("captureDialogBusy"),sessionStorage.removeItem("captureDialogJobStatus"),sessionStorage.removeItem("captureDialogJobUid"),a(""),v(null),m(!1),x(null),R(null)}async function p(){if(!u.trim()){v("Enter a locator.");return}m(!0),v(null),x(null);try{const w=await op(t,u.trim());R(w.job_uid),x("running"),f.current=setInterval(async()=>{var E;try{const _=await iu(t,w.job_uid);_.status==="completed"?(clearInterval(f.current),f.current=null,m(!1),x("completed"),c(),(E=l.current)==null||E.close(),r()):_.status==="failed"&&(clearInterval(f.current),f.current=null,m(!1),x("failed"),v(_.error_text||"Capture failed."))}catch(_){clearInterval(f.current),f.current=null,m(!1),v(_.message)}},500)}catch(w){v(w.message),m(!1)}}function y(){return h?k==="running"?"Running…":"Capturing…":"Capture"}return o.jsx("dialog",{ref:l,className:"capture-dialog",children:o.jsxs("div",{className:"capture-dialog-inner",children:[o.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),o.jsx("label",{htmlFor:"capture-locator",className:"capture-label",children:"Locator"}),o.jsx("input",{id:"capture-locator",className:"capture-input",type:"text",placeholder:"tweet:1234567890 or https://...",value:u,onChange:w=>a(w.target.value),onKeyDown:w=>{w.key==="Enter"&&p()},autoComplete:"off"}),d&&o.jsx("div",{className:"capture-error",children:d}),o.jsxs("div",{className:"capture-actions",children:[o.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var w;return(w=l.current)==null?void 0:w.close()},children:"Cancel"}),o.jsx("button",{type:"button",className:"capture-submit",onClick:p,disabled:h,children:y()})]})]})})}function bi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&rString(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const ou={youtube:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Nc(e){return ou[e]??ou.other}function Ip({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,i]=g.useState(!1),u=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?o.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>i(!0),style:{objectFit:"contain"}}):o.jsx("span",{dangerouslySetInnerHTML:{__html:Nc(e.source_kind)}});return o.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:a=>{a.key==="Enter"&&r()},children:[o.jsx("div",{className:"col-added",children:kc(e.archived_at)}),o.jsxs("div",{className:"col-title",children:[o.jsx("span",{className:"source-icon",children:u}),o.jsx("span",{className:"entry-title",children:At(e.title)||At(e.entry_uid)})]}),o.jsx("div",{className:"col-type",children:o.jsx("span",{className:"type-pill",children:At(e.entity_kind)})}),o.jsxs("div",{className:"col-size",children:[o.jsx("span",{className:"size-total",children:bi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&o.jsxs("span",{className:"size-cached-pct",title:`${bi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),o.jsx("div",{className:"url-cell col-url",children:At(e.original_url)})]})}function Up({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return o.jsx("section",{id:"archive-view",className:"view is-active",children:o.jsxs("div",{className:"entry-table",children:[o.jsxs("div",{className:"entry-header-row",children:[o.jsx("div",{className:"col-added",children:"Added"}),o.jsx("div",{className:"col-title",children:"Title"}),o.jsx("div",{className:"col-type",children:"Type"}),o.jsx("div",{className:"col-size",children:"Size"}),o.jsx("div",{className:"col-url",children:"Original URL"})]}),o.jsx("div",{id:"entries-body",children:e.map(l=>o.jsx(Ip,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Ap(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function Bp({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="running"?"run-status--running":"";return o.jsx("span",{className:`run-status ${t}`,children:e||"—"})}function Vp({runs:e}){return o.jsx("section",{id:"runs-view",className:"view is-active",children:o.jsxs("table",{className:"entry-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Started"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Requested"}),o.jsx("th",{children:"Completed"}),o.jsx("th",{children:"Failed"})]})}),o.jsx("tbody",{children:e.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map((t,n)=>o.jsxs("tr",{children:[o.jsx("td",{children:Ap(t.started_at)}),o.jsx("td",{children:o.jsx(Bp,{status:t.status})}),o.jsx("td",{children:t.requested_count??"—"}),o.jsx("td",{children:t.completed_count??"—"}),o.jsx("td",{children:t.failed_count??"—"})]},n))})]})})}const Hp=4;function Wp({archives:e}){const{currentUser:t}=g.useContext(zl)??{},n=t&&(t.role_bits&Hp)!==0,[r,l]=g.useState("users"),[i,s]=g.useState([]),[u,a]=g.useState([]),[d,v]=g.useState(!1),[h,m]=g.useState(null),[k,x]=g.useState(""),[S,R]=g.useState(""),[f,c]=g.useState(""),[p,y]=g.useState(null),[w,E]=g.useState(!1),[_,z]=g.useState(""),[I,C]=g.useState(""),[M,oe]=g.useState(null),[re,De]=g.useState(!1),Oe=g.useCallback(async()=>{if(n){v(!0),m(null);try{const[N,D]=await Promise.all([xp(),Np()]);s(N),a(D)}catch(N){m(N.message)}finally{v(!1)}}},[n]);g.useEffect(()=>{Oe()},[Oe]);async function we(N){const D=N.status==="active"?"disabled":"active";try{await kp(N.user_uid,D),s(A=>A.map(O=>O.user_uid===N.user_uid?{...O,status:D}:O))}catch(A){m(A.message)}}async function Ve(N){if(N.preventDefault(),!k.trim()||!S){y("Username and password required");return}E(!0),y(null);try{await Sp(k.trim(),S,f.trim()||void 0),x(""),R(""),c(""),await Oe()}catch(D){y(D.message)}finally{E(!1)}}async function T(N){if(N.preventDefault(),!_.trim()||!I.trim()){oe("Slug and name required");return}De(!0),oe(null);try{await jp(_.trim(),I.trim()),z(""),C(""),await Oe()}catch(D){oe(D.message)}finally{De(!1)}}return n?o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsxs("div",{className:"view-tabs",children:[o.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),o.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),o.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),h&&o.jsx("div",{className:"form-msg form-msg--err",children:h}),r==="users"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Users"}),d?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Username"}),o.jsx("th",{children:"Email"}),o.jsx("th",{children:"Roles"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Actions"})]})}),o.jsx("tbody",{children:i.map(N=>o.jsxs("tr",{className:N.status==="disabled"?"admin-row-disabled":"",children:[o.jsx("td",{children:N.username}),o.jsx("td",{className:"muted",children:N.email||"—"}),o.jsx("td",{children:N.role_slugs.join(", ")||"—"}),o.jsx("td",{children:o.jsx("span",{className:`status-badge status-${N.status}`,children:N.status})}),o.jsx("td",{children:o.jsx("button",{className:"admin-action-btn",onClick:()=>we(N),children:N.status==="active"?"Ban":"Unban"})})]},N.user_uid))})]}),o.jsx("h3",{children:"Create User"}),o.jsxs("form",{className:"admin-form",onSubmit:Ve,children:[o.jsx("input",{className:"admin-input",placeholder:"Username",value:k,onChange:N=>x(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:S,onChange:N=>R(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:f,onChange:N=>c(N.target.value)}),p&&o.jsx("div",{className:"form-msg form-msg--err",children:p}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:w,children:w?"Creating…":"Create User"})]})]}),r==="roles"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Roles"}),d?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Slug"}),o.jsx("th",{children:"Name"}),o.jsx("th",{children:"Level"}),o.jsx("th",{children:"Bit"}),o.jsx("th",{children:"Built-in"})]})}),o.jsx("tbody",{children:u.map(N=>o.jsxs("tr",{children:[o.jsx("td",{children:o.jsx("code",{children:N.slug})}),o.jsx("td",{children:N.name}),o.jsx("td",{children:N.level}),o.jsx("td",{children:N.bit_position}),o.jsx("td",{children:N.is_builtin?"✓":""})]},N.role_uid))})]}),o.jsx("h3",{children:"Create Custom Role"}),o.jsxs("form",{className:"admin-form",onSubmit:T,children:[o.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:_,onChange:N=>z(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:I,onChange:N=>C(N.target.value),required:!0}),M&&o.jsx("div",{className:"form-msg form-msg--err",children:M}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:re,children:re?"Creating…":"Create Role"})]})]}),r==="archives"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})]}):o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})}function jc({node:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){var s;const l=t===e.tag.full_path;function i(){const u=l?null:e.tag.full_path;n(u),r("archive")}return o.jsxs("li",{children:[o.jsx("button",{className:`tag-node-btn${l?" is-active":""}`,title:e.tag.full_path,onClick:i,children:e.tag.name}),((s=e.children)==null?void 0:s.length)>0&&o.jsx("div",{className:"tag-children",children:o.jsx("ul",{className:"tag-tree-list",children:e.children.map(u=>o.jsx(jc,{node:u,tagFilter:t,onTagFilterSet:n,onViewChange:r},u.tag.tag_uid))})})]})}function Qp({tagNodes:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){return o.jsx("section",{id:"tags-view",className:"view is-active",children:o.jsxs("div",{className:"tag-tree",children:[o.jsxs("div",{className:"tag-tree-header",children:[o.jsx("span",{className:"tag-tree-title",children:"Tags"}),t&&o.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",t]})]}),e.length===0?o.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):o.jsx("ul",{className:"tag-tree-list",children:e.map(l=>o.jsx(jc,{node:l,tagFilter:t,onTagFilterSet:n,onViewChange:r},l.tag.tag_uid))})]})})}const In=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],Kp=e=>{var t;return((t=In.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function Yp({archiveId:e}){const[t,n]=g.useState([]),[r,l]=g.useState(!1),[i,s]=g.useState(null),[u,a]=g.useState(null),[d,v]=g.useState(null),[h,m]=g.useState(!1),[k,x]=g.useState(null),[S,R]=g.useState(""),[f,c]=g.useState(""),[p,y]=g.useState(2),[w,E]=g.useState(!1),[_,z]=g.useState(null),[I,C]=g.useState(""),[M,oe]=g.useState(2),[re,De]=g.useState(!1),[Oe,we]=g.useState(null),[Ve,T]=g.useState(!1),[N,D]=g.useState(""),A=g.useRef(null),O=t.find(P=>P.collection_uid===u)??null,pe=(O==null?void 0:O.slug)==="_default_",ue=g.useCallback(async()=>{if(e){l(!0),s(null);try{const P=await Cp(e);n(P)}catch(P){s(P.message)}finally{l(!1)}}},[e]),qe=g.useCallback(async P=>{if(!P){v(null);return}m(!0),x(null);try{const B=await _p(e,P);v(B)}catch(B){x(B.message)}finally{m(!1)}},[e]);g.useEffect(()=>{ue()},[ue]),g.useEffect(()=>{qe(u)},[u,qe]),g.useEffect(()=>{Ve&&A.current&&A.current.focus()},[Ve]);async function He(P){P.preventDefault();const B=S.trim(),We=f.trim();if(!(!B||!We)){E(!0),z(null);try{const Ot=await Ep(e,B,We,p);R(""),c(""),y(2),await ue(),a(Ot.collection_uid)}catch(Ot){z(Ot.message)}finally{E(!1)}}}async function F(){const P=N.trim();if(!P||!O){T(!1);return}try{await su(e,O.collection_uid,{name:P}),await ue(),v(B=>B&&{...B,name:P})}catch(B){s(B.message)}finally{T(!1)}}async function xe(P){if(O)try{await su(e,O.collection_uid,{default_visibility_bits:P}),await ue(),v(B=>B&&{...B,default_visibility_bits:P})}catch(B){s(B.message)}}async function Ee(){if(O&&window.confirm(`Delete collection "${O.name}"? Entries will not be deleted.`))try{await Rp(e,O.collection_uid),a(null),v(null),await ue()}catch(P){s(P.message)}}async function Fe(P){P.preventDefault();const B=I.trim();if(!(!B||!O)){De(!0),we(null);try{await Tp(e,O.collection_uid,B,M),C(""),await qe(O.collection_uid)}catch(We){we(We.message)}finally{De(!1)}}}async function Cc(P){if(O)try{await Pp(e,O.collection_uid,P),await qe(O.collection_uid)}catch(B){x(B.message)}}async function Ec(P,B){if(O)try{await Lp(e,O.collection_uid,P,B),v(We=>We&&{...We,entries:We.entries.map(Ot=>Ot.entry_uid===P?{...Ot,collection_visibility_bits:B}:Ot)})}catch(We){x(We.message)}}return e?o.jsxs("div",{className:"collections-view",children:[o.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&o.jsx("div",{className:"muted",children:"Loading…"}),i&&o.jsxs("div",{className:"collections-error",children:[i," ",o.jsx("button",{onClick:()=>s(null),className:"coll-dismiss",children:"×"})]}),o.jsxs("div",{className:"collections-layout",children:[o.jsxs("div",{className:"collections-sidebar",children:[t.map(P=>o.jsxs("button",{className:`coll-sidebar-row${u===P.collection_uid?" is-active":""}`,onClick:()=>a(P.collection_uid),children:[o.jsx("span",{className:"coll-row-name",children:P.name}),o.jsx("span",{className:"coll-row-meta",children:Kp(P.default_visibility_bits)})]},P.collection_uid)),t.length===0&&!r&&o.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),O?o.jsxs("div",{className:"coll-detail",children:[o.jsxs("div",{className:"coll-detail-header",children:[Ve?o.jsx("input",{ref:A,className:"coll-rename-input",value:N,onChange:P=>D(P.target.value),onBlur:F,onKeyDown:P=>{P.key==="Enter"&&F(),P.key==="Escape"&&T(!1)}}):o.jsxs("h3",{className:`coll-detail-name${pe?"":" coll-detail-name--editable"}`,title:pe?void 0:"Click to rename",onClick:()=>{pe||(D(O.name),T(!0))},children:[(d==null?void 0:d.name)??O.name,!pe&&o.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!pe&&o.jsx("button",{className:"coll-delete-btn",onClick:Ee,title:"Delete collection",children:"Delete"})]}),o.jsxs("div",{className:"coll-detail-vis",children:[o.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),o.jsx("select",{className:"coll-vis-select",value:(d==null?void 0:d.default_visibility_bits)??O.default_visibility_bits,onChange:P=>xe(Number(P.target.value)),disabled:pe,children:In.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))})]}),o.jsxs("div",{className:"coll-entries-section",children:[o.jsx("div",{className:"coll-section-heading",children:"Entries"}),h&&o.jsx("div",{className:"muted",children:"Loading…"}),k&&o.jsx("div",{className:"collections-error",children:k}),!h&&d&&(d.entries.length===0?o.jsx("div",{className:"muted",children:"No entries in this collection."}):o.jsx("ul",{className:"coll-entries-list",children:d.entries.map(P=>o.jsxs("li",{className:"coll-entry-row",children:[o.jsxs("div",{className:"coll-entry-info",children:[o.jsx("span",{className:"coll-entry-title",children:P.title||P.entry_uid}),o.jsx("span",{className:"coll-entry-kind muted",children:P.source_kind})]}),o.jsxs("div",{className:"coll-entry-actions",children:[o.jsx("select",{className:"coll-entry-vis-select",value:P.collection_visibility_bits,onChange:B=>Ec(P.entry_uid,Number(B.target.value)),children:In.map(B=>o.jsx("option",{value:B.value,children:B.label},B.value))}),!pe&&o.jsx("button",{className:"coll-entry-remove",onClick:()=>Cc(P.entry_uid),title:"Remove from collection",children:"×"})]})]},P.entry_uid))}))]}),!pe&&o.jsxs("form",{className:"coll-add-entry-form",onSubmit:Fe,children:[o.jsx("div",{className:"coll-section-heading",children:"Add entry"}),o.jsxs("div",{className:"coll-add-entry-row",children:[o.jsx("input",{className:"coll-add-entry-input",type:"text",value:I,onChange:P=>C(P.target.value),placeholder:"entry_uid",required:!0}),o.jsx("select",{className:"coll-vis-select",value:M,onChange:P=>oe(Number(P.target.value)),children:In.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))}),o.jsx("button",{className:"coll-add-btn",type:"submit",disabled:re,children:re?"…":"Add"})]}),Oe&&o.jsx("div",{className:"collections-error",style:{marginTop:4},children:Oe})]})]}):o.jsx("div",{className:"coll-detail coll-detail--empty",children:o.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),o.jsxs("details",{className:"coll-create-details",children:[o.jsx("summary",{children:"+ Create collection"}),o.jsxs("form",{className:"coll-create-form",onSubmit:He,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),o.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:S,onChange:P=>{R(P.target.value),f||c(P.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),o.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:f,onChange:P=>c(P.target.value),placeholder:"my-collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),o.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:p,onChange:P=>y(Number(P.target.value)),children:In.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))})]}),_&&o.jsx("div",{className:"collections-error",children:_}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:w,children:w?"Creating…":"Create collection"})]})]})]}):o.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const Jp=4;function Xp({tab:e,onTabChange:t}){const{currentUser:n,setCurrentUser:r}=g.useContext(zl)??{},l=n&&(n.role_bits&Jp)!==0,i=["profile","tokens",...l?["instance"]:[]],s={profile:"Profile",tokens:"API Tokens",instance:"Instance"};return o.jsxs("section",{className:"admin-view",children:[o.jsx("h1",{children:"Settings"}),o.jsx("div",{className:"view-tabs",children:i.map(u=>o.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:s[u]},u))}),e==="profile"&&o.jsx(Gp,{currentUser:n,setCurrentUser:r}),e==="tokens"&&o.jsx(Zp,{}),e==="instance"&&l&&o.jsx(qp,{})]})}function Gp({currentUser:e,setCurrentUser:t}){const[n,r]=g.useState((e==null?void 0:e.display_name)??""),[l,i]=g.useState(!1),[s,u]=g.useState(null),[a,d]=g.useState(""),[v,h]=g.useState(""),[m,k]=g.useState(""),[x,S]=g.useState(!1),[R,f]=g.useState(null);async function c(y){y.preventDefault(),i(!0),u(null);try{await pp(n),t(w=>({...w,display_name:n||null})),u({ok:!0,text:"Saved."})}catch(w){u({ok:!1,text:w.message})}finally{i(!1)}}async function p(y){if(y.preventDefault(),v!==m){f({ok:!1,text:"Passwords do not match."});return}S(!0),f(null);try{await mp(a,v),d(""),h(""),k(""),f({ok:!0,text:"Password changed."})}catch(w){f({ok:!1,text:w.message})}finally{S(!1)}}return o.jsxs("div",{style:{maxWidth:440},children:[o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Name"}),o.jsxs("form",{onSubmit:c,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),o.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:y=>r(y.target.value)})]}),s&&o.jsx("div",{className:`form-msg form-msg--${s.ok?"ok":"err"}`,children:s.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Change Password"}),o.jsxs("form",{onSubmit:p,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),o.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:a,onChange:y=>d(y.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),o.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:v,onChange:y=>h(y.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),o.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:m,onChange:y=>k(y.target.value),required:!0})]}),R&&o.jsx("div",{className:`form-msg form-msg--${R.ok?"ok":"err"}`,children:R.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function Zp(){const[e,t]=g.useState([]),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,u]=g.useState(""),[a,d]=g.useState(!1),[v,h]=g.useState(null),m=g.useCallback(async()=>{r(!0),i(null);try{t(await hp())}catch(S){i(S.message)}finally{r(!1)}},[]);g.useEffect(()=>{m()},[m]);async function k(S){if(S.preventDefault(),!!s.trim()){d(!0);try{const R=await vp(s.trim());h(R),u(""),m()}catch(R){i(R.message)}finally{d(!1)}}}async function x(S){try{await gp(S),t(R=>R.filter(f=>f.token_uid!==S))}catch(R){i(R.message)}}return o.jsx("div",{style:{maxWidth:600},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"API Tokens"}),v&&o.jsxs("div",{className:"token-banner",children:[o.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",o.jsx("code",{children:v.raw_token}),o.jsx("button",{className:"token-dismiss",onClick:()=>h(null),children:"Dismiss"})]}),o.jsxs("form",{className:"token-create-row",onSubmit:k,children:[o.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:s,onChange:S=>u(S.target.value),required:!0}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Creating…":"Create token"})]}),l&&o.jsx("div",{className:"form-msg form-msg--err",children:l}),n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):o.jsxs("div",{children:[e.length===0&&o.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(S=>o.jsxs("div",{className:"token-row",children:[o.jsxs("div",{className:"token-row-info",children:[o.jsx("strong",{children:S.name}),o.jsxs("div",{className:"muted",children:["Created ",S.created_at.slice(0,10),S.last_used_at&&` · Last used ${S.last_used_at.slice(0,10)}`]})]}),o.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(S.token_uid),children:"Revoke"})]},S.token_uid))]})]})})}function qp(){const[e,t]=g.useState(null),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,u]=g.useState(!1),[a,d]=g.useState(null);g.useEffect(()=>{(async()=>{try{t(await yp())}catch(h){i(h.message)}finally{r(!1)}})()},[]);async function v(h){h.preventDefault(),u(!0),d(null);try{await wp(e),d({ok:!0,text:"Saved."})}catch(m){d({ok:!1,text:m.message})}finally{u(!1)}}return n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):l?o.jsx("div",{className:"form-msg form-msg--err",children:l}):e?o.jsx("div",{style:{maxWidth:440},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Instance Settings"}),o.jsxs("form",{onSubmit:v,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([h,m])=>o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:!!e[h],onChange:k=>t(x=>({...x,[h]:k.target.checked}))}),m]},h)),o.jsxs("div",{className:"form-field",style:{marginTop:4},children:[o.jsx("label",{className:"form-label",children:"Default entry visibility"}),o.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:h=>t(m=>({...m,default_entry_visibility:Number(h.target.value)})),children:[o.jsx("option",{value:0,children:"Private"}),o.jsx("option",{value:2,children:"Unlisted"}),o.jsx("option",{value:3,children:"Public"})]})]}),a&&o.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:s,children:s?"Saving…":"Save Settings"})]})]})}):null}const uu={0:"Private",1:"Public",2:"Users only",3:"Public"},bp=()=>o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function em({archiveId:e,selectedEntry:t,onTagFilterSet:n,tagNodes:r,onTagsRefresh:l,onEntryTitleChange:i}){const[s,u]=g.useState(null),[a,d]=g.useState([]),[v,h]=g.useState(""),[m,k]=g.useState([]),[x,S]=g.useState(""),R=g.useRef(0),f=g.useRef(!1),[c,p]=g.useState(!1),[y,w]=g.useState("");g.useEffect(()=>{if(!t||!e){u(null),d([]),k([]);return}p(!1),w(""),f.current=!1;const C=++R.current;u(null),d([]),Promise.all([rp(e,t.entry_uid),li(e,t.entry_uid),zp(e,t.entry_uid)]).then(([M,oe,re])=>{C===R.current&&(u(M),d(oe),k(re))}).catch(()=>{})},[t,e]);async function E(){const C=y.trim()||null;try{await lp(e,t.entry_uid,C),u(M=>M&&{...M,summary:{...M.summary,title:C}}),i==null||i(t.entry_uid,C)}catch{}finally{p(!1)}}async function _(){const C=v.trim();if(!(!C||!t))try{await ip(e,t.entry_uid,C),h(""),S("");const M=await li(e,t.entry_uid);d(M),l()}catch(M){S(M.message)}}async function z(C){try{await sp(e,t.entry_uid,C);const M=await li(e,t.entry_uid);d(M),l()}catch{}}const I=s?[["Added",kc(s.summary.archived_at)],["Source",s.summary.source_kind],["Type",s.summary.entity_kind],["Visibility",uu[s.summary.visibility]??s.summary.visibility],["Root",s.structured_root_relpath]]:[];return o.jsxs("aside",{className:"context-rail",children:[o.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?s?o.jsxs(o.Fragment,{children:[c?o.jsx("input",{className:"rail-title-input",autoFocus:!0,value:y,onChange:C=>w(C.target.value),onKeyDown:C=>{C.key==="Enter"&&C.currentTarget.blur(),C.key==="Escape"&&(f.current=!0,C.currentTarget.blur())},onBlur:()=>{f.current?p(!1):E(),f.current=!1}}):o.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{w(s.summary.title??""),p(!0)},children:[At(s.summary.title)||At(s.summary.entry_uid),o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),s.summary.original_url&&o.jsxs("a",{className:"url-tile",href:s.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[o.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Nc(s.summary.source_kind)}}),o.jsx("span",{className:"u-text",children:s.summary.original_url}),o.jsx("span",{className:"ext",children:o.jsx(bp,{})})]}),o.jsx("div",{className:"meta-list",children:I.filter(([,C])=>C!=null&&C!=="").map(([C,M])=>o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-k",children:C}),o.jsx("span",{className:`meta-v${C==="Root"?" mono":""}`,children:At(M)})]},C))}),s.artifacts.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",o.jsx("span",{className:"num",children:s.artifacts.length})]}),o.jsx("ul",{className:"artifact-list",children:s.artifacts.map((C,M)=>o.jsx("li",{children:o.jsxs("a",{href:`/api/archives/${e}/entries/${s.summary.entry_uid}/artifacts/${M}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[o.jsx("span",{className:"artifact-name",children:C.artifact_role.replace(/_/g," ")}),o.jsx("span",{className:"artifact-size",children:C.byte_size!=null?bi(C.byte_size):"—"})]})},M))})]})]}):o.jsx("p",{className:"tags-empty",children:"Loading…"}):o.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Tags"}),a.length===0?o.jsx("p",{className:"tags-empty",children:"No tags yet."}):o.jsx("div",{className:"tags-wrap",children:a.map(C=>o.jsxs("span",{className:"tag-pill",title:C.full_path,children:[C.name,o.jsx("button",{className:"remove",title:`Remove tag ${C.full_path}`,onClick:()=>z(C.tag_uid),children:"×"})]},C.tag_uid))}),x&&o.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:x}),o.jsxs("div",{className:"tag-input-wrap",children:[o.jsx("span",{className:"hash",children:"/"}),o.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:v,onChange:C=>h(C.target.value),onKeyDown:C=>{C.key==="Enter"&&_()}}),o.jsx("button",{className:"tag-add-btn",onClick:_,children:"Add"})]})]}),m.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Collections"}),m.map(C=>o.jsxs("div",{className:"coll-row",children:[o.jsx("span",{className:"coll-name",children:C.collection_uid}),o.jsx("span",{className:"vis-badge",children:uu[C.visibility_bits]??`bits:${C.visibility_bits}`})]},C.collection_uid))]})]})]})}const zl=g.createContext(null),tm=["archive","runs","admin","tags","collections","settings"],nm=["profile","tokens","instance"];function si(){const e=window.location.pathname.split("/").filter(Boolean),t=tm.includes(e[0])?e[0]:"archive",n=t==="settings"&&nm.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function rm(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function lm(){const[e,t]=g.useState("loading"),[n,r]=g.useState(null);g.useEffect(()=>{(async()=>{if(await up()){t("setup");return}const xe=await fp();if(!xe){t("login");return}r(xe),t("authenticated")})()},[]),g.useEffect(()=>{const F=()=>{r(null),t("login")};return window.addEventListener("auth:expired",F),()=>window.removeEventListener("auth:expired",F)},[]),g.useEffect(()=>{const F=()=>{const{view:xe,settingsTab:Ee}=si();f(xe),p(Ee)};return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[]);const[l,i]=g.useState([]),[s,u]=g.useState(null),[a,d]=g.useState([]),[v,h]=g.useState(null),[m,k]=g.useState(null),[x,S]=g.useState(null),[R,f]=g.useState(()=>si().view),[c,p]=g.useState(()=>si().settingsTab),[y,w]=g.useState(""),[E,_]=g.useState(""),[z,I]=g.useState(!1),[C,M]=g.useState([]),[oe,re]=g.useState([]),[De,Oe]=g.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true");g.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",De)},[De]);const we=g.useCallback(async(F,xe,Ee)=>{if(F){I(!0);try{let Fe;xe||Ee?Fe=await np(F,xe,Ee):Fe=await tp(F),d(Fe),_(Fe.length===0?"No results":`${Fe.length} result${Fe.length===1?"":"s"}`)}catch{d([]),_("Search failed. Try again.")}finally{I(!1)}}},[]);g.useEffect(()=>{e==="authenticated"&&ep().then(F=>{if(i(F),F.length>0){const xe=F[0].id;u(xe)}})},[e]),g.useEffect(()=>{s&&(S(null),k(null),h(null),Promise.all([we(s,"",null),lu(s).then(M),ii(s).then(re)]))},[s]),g.useEffect(()=>{if(s===null)return;const F=setTimeout(()=>{we(s,y,x)},300);return()=>clearTimeout(F)},[y,s]),g.useEffect(()=>{s!==null&&(x!==null&&f("archive"),we(s,y,x))},[x,s]);const Ve=g.useCallback(F=>{u(F)},[]),T=g.useCallback(F=>{f(F),F==="tags"&&s&&ii(s).then(re)},[s]);g.useEffect(()=>{const F=rm(R,c);window.location.pathname!==F&&history.pushState(null,"",F)},[R,c]);const N=g.useCallback(F=>{h(F?F.entry_uid:null),k(F)},[]),D=g.useCallback(F=>{S(F)},[]),A=g.useCallback(()=>{S(null)},[]),O=g.useCallback(()=>{s&&ii(s).then(re)},[s]),pe=g.useCallback((F,xe)=>{d(Ee=>Ee.map(Fe=>Fe.entry_uid===F?{...Fe,title:xe}:Fe)),k(Ee=>Ee&&Ee.entry_uid===F?{...Ee,title:xe}:Ee)},[]),ue=g.useCallback(()=>{Oe(!0)},[]),qe=g.useCallback(()=>{Oe(!1)},[]),He=g.useCallback(()=>{s&&Promise.all([we(s,y,x),lu(s).then(M)])},[s,y,x,we]);return e==="loading"?o.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?o.jsx(Fp,{onComplete:()=>t("login")}):e==="login"?o.jsx(Op,{onLogin:F=>{r(F),t("authenticated")}}):o.jsx(zl.Provider,{value:{currentUser:n,setCurrentUser:r},children:o.jsxs(o.Fragment,{children:[o.jsx(Mp,{archives:l,archiveId:s,onArchiveChange:Ve,view:R,onViewChange:T,onCaptureClick:ue}),o.jsxs("main",{className:"app-shell",children:[o.jsxs("div",{className:"workspace",children:[R==="archive"&&o.jsxs("div",{className:"toolbar",children:[o.jsxs("div",{className:"search-field",children:[o.jsx("span",{className:"ico","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"7"}),o.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),o.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":z,placeholder:"Search titles, URLs, types, tags…",value:y,onChange:F=>w(F.target.value)}),o.jsx("span",{className:"kbd",children:"⌘K"})]}),o.jsxs("span",{className:"result-count",children:[E&&o.jsxs(o.Fragment,{children:[o.jsx("b",{children:E.split(" ")[0]})," ",E.split(" ").slice(1).join(" ")]}),x&&o.jsxs("button",{className:"tag-filter-badge",onClick:A,children:["× ",x]})]})]}),R==="archive"&&o.jsx(Up,{entries:a,selectedEntryUid:v,onSelectEntry:N,archiveId:s,tagFilter:x,onClearTagFilter:A,searchQuery:y,onSearchChange:w,resultCount:E,searchBusy:z}),R==="runs"&&o.jsx(Vp,{runs:C}),R==="admin"&&o.jsx(Wp,{archives:l}),R==="tags"&&o.jsx(Qp,{tagNodes:oe,tagFilter:x,onTagFilterSet:D,onViewChange:T}),R==="collections"&&o.jsx(Yp,{archiveId:s}),R==="settings"&&o.jsx(Xp,{tab:c,onTabChange:p})]}),o.jsx(em,{archiveId:s,selectedEntry:m,onTagFilterSet:D,tagNodes:oe,onTagsRefresh:O,onEntryTitleChange:pe})]}),o.jsx($p,{open:De,archiveId:s,onClose:qe,onCaptured:He})]})})}Sc(document.getElementById("root")).render(o.jsx(g.StrictMode,{children:o.jsx(lm,{})})); diff --git a/crates/archivr-server/static/assets/index-MmGgQJvV.js b/crates/archivr-server/static/assets/index-MmGgQJvV.js deleted file mode 100644 index f653147..0000000 --- a/crates/archivr-server/static/assets/index-MmGgQJvV.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var uu={exports:{}},ml={},au={exports:{}},$={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var dr=Symbol.for("react.element"),_c=Symbol.for("react.portal"),Ec=Symbol.for("react.fragment"),Tc=Symbol.for("react.strict_mode"),Pc=Symbol.for("react.profiler"),Lc=Symbol.for("react.provider"),zc=Symbol.for("react.context"),Rc=Symbol.for("react.forward_ref"),Oc=Symbol.for("react.suspense"),Dc=Symbol.for("react.memo"),Fc=Symbol.for("react.lazy"),Xs=Symbol.iterator;function Mc(e){return e===null||typeof e!="object"?null:(e=Xs&&e[Xs]||e["@@iterator"],typeof e=="function"?e:null)}var cu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},du=Object.assign,fu={};function Nn(e,t,n){this.props=e,this.context=t,this.refs=fu,this.updater=n||cu}Nn.prototype.isReactComponent={};Nn.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")};Nn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function pu(){}pu.prototype=Nn.prototype;function es(e,t,n){this.props=e,this.context=t,this.refs=fu,this.updater=n||cu}var ts=es.prototype=new pu;ts.constructor=es;du(ts,Nn.prototype);ts.isPureReactComponent=!0;var Gs=Array.isArray,hu=Object.prototype.hasOwnProperty,ns={current:null},mu={key:!0,ref:!0,__self:!0,__source:!0};function vu(e,t,n){var r,l={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)hu.call(t,r)&&!mu.hasOwnProperty(r)&&(l[r]=t[r]);var u=arguments.length-2;if(u===1)l.children=n;else if(1>>1,D=E[A];if(0>>1;Al(qe,O))Bel(F,qe)?(E[A]=F,E[Be]=O,A=Be):(E[A]=qe,E[ue]=O,A=ue);else if(Bel(F,O))E[A]=F,E[Be]=O,A=Be;else break e}}return k}function l(E,k){var O=E.sortIndex-k.sortIndex;return O!==0?O:E.id-k.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,u=s.now();e.unstable_now=function(){return s.now()-u}}var a=[],d=[],v=1,m=null,h=3,w=!1,x=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(E){for(var k=n(d);k!==null;){if(k.callback===null)r(d);else if(k.startTime<=E)r(d),k.sortIndex=k.expirationTime,t(a,k);else break;k=n(d)}}function y(E){if(S=!1,p(E),!x)if(n(a)!==null)x=!0,we(C);else{var k=n(d);k!==null&&Ve(y,k.startTime-E)}}function C(E,k){x=!1,S&&(S=!1,f(R),R=-1),w=!0;var O=h;try{for(p(k),m=n(a);m!==null&&(!(m.expirationTime>k)||E&&!M());){var A=m.callback;if(typeof A=="function"){m.callback=null,h=m.priorityLevel;var D=A(m.expirationTime<=k);k=e.unstable_now(),typeof D=="function"?m.callback=D:m===n(a)&&r(a),p(k)}else r(a);m=n(a)}if(m!==null)var pe=!0;else{var ue=n(d);ue!==null&&Ve(y,ue.startTime-k),pe=!1}return pe}finally{m=null,h=O,w=!1}}var T=!1,P=null,R=-1,I=5,j=-1;function M(){return!(e.unstable_now()-jE||125A?(E.sortIndex=O,t(d,E),n(a)===null&&E===n(d)&&(S?(f(R),R=-1):S=!0,Ve(y,O-A))):(E.sortIndex=D,t(a,E),x||w||(x=!0,we(C))),E},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(E){var k=h;return function(){var O=h;h=k;try{return E.apply(this,arguments)}finally{h=O}}}})(Su);xu.exports=Su;var Yc=xu.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Xc=g,Le=Yc;function N(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),oi=Object.prototype.hasOwnProperty,Gc=/^[: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]*$/,Zs={},qs={};function Jc(e){return oi.call(qs,e)?!0:oi.call(Zs,e)?!1:Gc.test(e)?qs[e]=!0:(Zs[e]=!0,!1)}function Zc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function qc(e,t,n,r){if(t===null||typeof t>"u"||Zc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ge(e,t,n,r,l,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){se[e]=new ge(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];se[t]=new ge(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){se[e]=new ge(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){se[e]=new ge(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){se[e]=new ge(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){se[e]=new ge(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){se[e]=new ge(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){se[e]=new ge(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){se[e]=new ge(e,5,!1,e.toLowerCase(),null,!1,!1)});var ls=/[\-:]([a-z])/g;function is(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(ls,is);se[t]=new ge(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(ls,is);se[t]=new ge(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(ls,is);se[t]=new ge(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){se[e]=new ge(e,1,!1,e.toLowerCase(),null,!1,!1)});se.xlinkHref=new ge("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){se[e]=new ge(e,1,!1,e.toLowerCase(),null,!0,!0)});function ss(e,t,n,r){var l=se.hasOwnProperty(t)?se[t]:null;(l!==null?l.type!==0:r||!(2u||l[s]!==i[u]){var a=` -`+l[s].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=s&&0<=u);break}}}finally{Dl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Dn(e):""}function bc(e){switch(e.tag){case 5:return Dn(e.type);case 16:return Dn("Lazy");case 13:return Dn("Suspense");case 19:return Dn("SuspenseList");case 0:case 2:case 15:return e=Fl(e.type,!1),e;case 11:return e=Fl(e.type.render,!1),e;case 1:return e=Fl(e.type,!0),e;default:return""}}function di(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 qt:return"Fragment";case Zt:return"Portal";case ui:return"Profiler";case os:return"StrictMode";case ai:return"Suspense";case ci:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ju:return(e.displayName||"Context")+".Consumer";case Nu:return(e._context.displayName||"Context")+".Provider";case us:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case as:return t=e.displayName||null,t!==null?t:di(e.type)||"Memo";case mt:t=e._payload,e=e._init;try{return di(e(t))}catch{}}return null}function ed(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 di(t);case 8:return t===os?"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 Pt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _u(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function td(e){var t=_u(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yr(e){e._valueTracker||(e._valueTracker=td(e))}function Eu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=_u(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qr(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 fi(e,t){var n=t.checked;return G({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function eo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Pt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Tu(e,t){t=t.checked,t!=null&&ss(e,"checked",t,!1)}function pi(e,t){Tu(e,t);var n=Pt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?hi(e,t.type,n):t.hasOwnProperty("defaultValue")&&hi(e,t.type,Pt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function to(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function hi(e,t,n){(t!=="number"||Qr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fn=Array.isArray;function cn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=wr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Gn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Un={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},nd=["Webkit","ms","Moz","O"];Object.keys(Un).forEach(function(e){nd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Un[t]=Un[e]})});function Ru(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Un.hasOwnProperty(e)&&Un[e]?(""+t).trim():t+"px"}function Ou(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Ru(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var rd=G({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 gi(e,t){if(t){if(rd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(N(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(N(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(N(61))}if(t.style!=null&&typeof t.style!="object")throw Error(N(62))}}function yi(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 wi=null;function cs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var xi=null,dn=null,fn=null;function lo(e){if(e=hr(e)){if(typeof xi!="function")throw Error(N(280));var t=e.stateNode;t&&(t=xl(t),xi(e.stateNode,e.type,t))}}function Du(e){dn?fn?fn.push(e):fn=[e]:dn=e}function Fu(){if(dn){var e=dn,t=fn;if(fn=dn=null,lo(e),t)for(e=0;e>>=0,e===0?32:31-(hd(e)/md|0)|0}var xr=64,Sr=4194304;function Mn(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 Gr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var u=s&~l;u!==0?r=Mn(u):(i&=s,i!==0&&(r=Mn(i)))}else s=n&~l,s!==0?r=Mn(s):i!==0&&(r=Mn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function fr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Xe(t),e[t]=n}function wd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Vn),ho=" ",mo=!1;function ta(e,t){switch(e){case"keyup":return Yd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function na(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bt=!1;function Gd(e,t){switch(e){case"compositionend":return na(t);case"keypress":return t.which!==32?null:(mo=!0,ho);case"textInput":return e=t.data,e===ho&&mo?null:e;default:return null}}function Jd(e,t){if(bt)return e==="compositionend"||!ys&&ta(e,t)?(e=bu(),Mr=ms=wt=null,bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=wo(n)}}function sa(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?sa(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function oa(){for(var e=window,t=Qr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qr(e.document)}return t}function ws(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 sf(e){var t=oa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&sa(n.ownerDocument.documentElement,n)){if(r!==null&&ws(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=xo(n,i);var s=xo(n,r);l&&s&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,en=null,_i=null,Hn=null,Ei=!1;function So(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ei||en==null||en!==Qr(r)||(r=en,"selectionStart"in r&&ws(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Hn&&tr(Hn,r)||(Hn=r,r=qr(_i,"onSelect"),0rn||(e.current=Oi[rn],Oi[rn]=null,rn--)}function H(e,t){rn++,Oi[rn]=e.current,e.current=t}var Lt={},fe=Rt(Lt),Ne=Rt(!1),Ht=Lt;function gn(e,t){var n=e.type.contextTypes;if(!n)return Lt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function je(e){return e=e.childContextTypes,e!=null}function el(){Q(Ne),Q(fe)}function To(e,t,n){if(fe.current!==Lt)throw Error(N(168));H(fe,t),H(Ne,n)}function va(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(N(108,ed(e)||"Unknown",l));return G({},n,r)}function tl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Lt,Ht=fe.current,H(fe,e),H(Ne,Ne.current),!0}function Po(e,t,n){var r=e.stateNode;if(!r)throw Error(N(169));n?(e=va(e,t,Ht),r.__reactInternalMemoizedMergedChildContext=e,Q(Ne),Q(fe),H(fe,e)):Q(Ne),H(Ne,n)}var it=null,Sl=!1,Gl=!1;function ga(e){it===null?it=[e]:it.push(e)}function yf(e){Sl=!0,ga(e)}function Ot(){if(!Gl&&it!==null){Gl=!0;var e=0,t=B;try{var n=it;for(B=1;e>=s,l-=s,st=1<<32-Xe(t)+l|n<R?(I=P,P=null):I=P.sibling;var j=h(f,P,p[R],y);if(j===null){P===null&&(P=I);break}e&&P&&j.alternate===null&&t(f,P),c=i(j,c,R),T===null?C=j:T.sibling=j,T=j,P=I}if(R===p.length)return n(f,P),K&&Ft(f,R),C;if(P===null){for(;RR?(I=P,P=null):I=P.sibling;var M=h(f,P,j.value,y);if(M===null){P===null&&(P=I);break}e&&P&&M.alternate===null&&t(f,P),c=i(M,c,R),T===null?C=M:T.sibling=M,T=M,P=I}if(j.done)return n(f,P),K&&Ft(f,R),C;if(P===null){for(;!j.done;R++,j=p.next())j=m(f,j.value,y),j!==null&&(c=i(j,c,R),T===null?C=j:T.sibling=j,T=j);return K&&Ft(f,R),C}for(P=r(f,P);!j.done;R++,j=p.next())j=w(P,f,R,j.value,y),j!==null&&(e&&j.alternate!==null&&P.delete(j.key===null?R:j.key),c=i(j,c,R),T===null?C=j:T.sibling=j,T=j);return e&&P.forEach(function(oe){return t(f,oe)}),K&&Ft(f,R),C}function _(f,c,p,y){if(typeof p=="object"&&p!==null&&p.type===qt&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case gr:e:{for(var C=p.key,T=c;T!==null;){if(T.key===C){if(C=p.type,C===qt){if(T.tag===7){n(f,T.sibling),c=l(T,p.props.children),c.return=f,f=c;break e}}else if(T.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===mt&&Ro(C)===T.type){n(f,T.sibling),c=l(T,p.props),c.ref=zn(f,T,p),c.return=f,f=c;break e}n(f,T);break}else t(f,T);T=T.sibling}p.type===qt?(c=Bt(p.props.children,f.mode,y,p.key),c.return=f,f=c):(y=Wr(p.type,p.key,p.props,null,f.mode,y),y.ref=zn(f,c,p),y.return=f,f=y)}return s(f);case Zt:e:{for(T=p.key;c!==null;){if(c.key===T)if(c.tag===4&&c.stateNode.containerInfo===p.containerInfo&&c.stateNode.implementation===p.implementation){n(f,c.sibling),c=l(c,p.children||[]),c.return=f,f=c;break e}else{n(f,c);break}else t(f,c);c=c.sibling}c=ri(p,f.mode,y),c.return=f,f=c}return s(f);case mt:return T=p._init,_(f,c,T(p._payload),y)}if(Fn(p))return x(f,c,p,y);if(_n(p))return S(f,c,p,y);Tr(f,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,c!==null&&c.tag===6?(n(f,c.sibling),c=l(c,p),c.return=f,f=c):(n(f,c),c=ni(p,f.mode,y),c.return=f,f=c),s(f)):n(f,c)}return _}var wn=Sa(!0),ka=Sa(!1),ll=Rt(null),il=null,on=null,Ns=null;function js(){Ns=on=il=null}function Cs(e){var t=ll.current;Q(ll),e._currentValue=t}function Mi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function hn(e,t){il=e,Ns=on=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ke=!0),e.firstContext=null)}function Ue(e){var t=e._currentValue;if(Ns!==e)if(e={context:e,memoizedValue:t,next:null},on===null){if(il===null)throw Error(N(308));on=e,il.dependencies={lanes:0,firstContext:e}}else on=on.next=e;return t}var It=null;function _s(e){It===null?It=[e]:It.push(e)}function Na(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,_s(t)):(n.next=l.next,l.next=n),t.interleaved=n,dt(e,r)}function dt(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 vt=!1;function Es(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ja(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 ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ct(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,U&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,dt(e,n)}return l=r.interleaved,l===null?(t.next=t,_s(r)):(t.next=l.next,l.next=t),r.interleaved=t,dt(e,n)}function Ir(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fs(e,n)}}function Oo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function sl(e,t,n,r){var l=e.updateQueue;vt=!1;var i=l.firstBaseUpdate,s=l.lastBaseUpdate,u=l.shared.pending;if(u!==null){l.shared.pending=null;var a=u,d=a.next;a.next=null,s===null?i=d:s.next=d,s=a;var v=e.alternate;v!==null&&(v=v.updateQueue,u=v.lastBaseUpdate,u!==s&&(u===null?v.firstBaseUpdate=d:u.next=d,v.lastBaseUpdate=a))}if(i!==null){var m=l.baseState;s=0,v=d=a=null,u=i;do{var h=u.lane,w=u.eventTime;if((r&h)===h){v!==null&&(v=v.next={eventTime:w,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var x=e,S=u;switch(h=t,w=n,S.tag){case 1:if(x=S.payload,typeof x=="function"){m=x.call(w,m,h);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=S.payload,h=typeof x=="function"?x.call(w,m,h):x,h==null)break e;m=G({},m,h);break e;case 2:vt=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[u]:h.push(u))}else w={eventTime:w,lane:h,tag:u.tag,payload:u.payload,callback:u.callback,next:null},v===null?(d=v=w,a=m):v=v.next=w,s|=h;if(u=u.next,u===null){if(u=l.shared.pending,u===null)break;h=u,u=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(v===null&&(a=m),l.baseState=a,l.firstBaseUpdate=d,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do s|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Kt|=s,e.lanes=s,e.memoizedState=m}}function Do(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Zl.transition;Zl.transition={};try{e(!1),t()}finally{B=n,Zl.transition=r}}function Va(){return Ae().memoizedState}function kf(e,t,n){var r=Et(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ba(e))Ha(t,n);else if(n=Na(e,t,n,r),n!==null){var l=me();Ge(n,e,r,l),Wa(n,t,r)}}function Nf(e,t,n){var r=Et(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ba(e))Ha(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,u=i(s,n);if(l.hasEagerState=!0,l.eagerState=u,Je(u,s)){var a=t.interleaved;a===null?(l.next=l,_s(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=Na(e,t,l,r),n!==null&&(l=me(),Ge(n,e,r,l),Wa(n,t,r))}}function Ba(e){var t=e.alternate;return e===X||t!==null&&t===X}function Ha(e,t){Wn=ul=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Wa(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fs(e,n)}}var al={readContext:Ue,useCallback:ae,useContext:ae,useEffect:ae,useImperativeHandle:ae,useInsertionEffect:ae,useLayoutEffect:ae,useMemo:ae,useReducer:ae,useRef:ae,useState:ae,useDebugValue:ae,useDeferredValue:ae,useTransition:ae,useMutableSource:ae,useSyncExternalStore:ae,useId:ae,unstable_isNewReconciler:!1},jf={readContext:Ue,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:Ue,useEffect:Mo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ar(4194308,4,Ma.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ar(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ar(4,2,e,t)},useMemo:function(e,t){var n=et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=kf.bind(null,X,e),[r.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:Fo,useDebugValue:Fs,useDeferredValue:function(e){return et().memoizedState=e},useTransition:function(){var e=Fo(!1),t=e[0];return e=Sf.bind(null,e[1]),et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=X,l=et();if(K){if(n===void 0)throw Error(N(407));n=n()}else{if(n=t(),ne===null)throw Error(N(349));Qt&30||Ta(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Mo(La.bind(null,r,i,e),[e]),r.flags|=2048,ar(9,Pa.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=et(),t=ne.identifierPrefix;if(K){var n=ot,r=st;n=(r&~(1<<32-Xe(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=or++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[tt]=t,e[lr]=r,ec(e,t,!1,!1),t.stateNode=e;e:{switch(s=yi(n,r),n){case"dialog":W("cancel",e),W("close",e),l=r;break;case"iframe":case"object":case"embed":W("load",e),l=r;break;case"video":case"audio":for(l=0;l<$n.length;l++)W($n[l],e);l=r;break;case"source":W("error",e),l=r;break;case"img":case"image":case"link":W("error",e),W("load",e),l=r;break;case"details":W("toggle",e),l=r;break;case"input":eo(e,r),l=fi(e,r),W("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=G({},r,{value:void 0}),W("invalid",e);break;case"textarea":no(e,r),l=mi(e,r),W("invalid",e);break;default:l=r}gi(n,l),u=l;for(i in u)if(u.hasOwnProperty(i)){var a=u[i];i==="style"?Ou(e,a):i==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,a!=null&&zu(e,a)):i==="children"?typeof a=="string"?(n!=="textarea"||a!=="")&&Gn(e,a):typeof a=="number"&&Gn(e,""+a):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Xn.hasOwnProperty(i)?a!=null&&i==="onScroll"&&W("scroll",e):a!=null&&ss(e,i,a,s))}switch(n){case"input":yr(e),to(e,r,!1);break;case"textarea":yr(e),ro(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Pt(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?cn(e,!!r.multiple,i,!1):r.defaultValue!=null&&cn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=br)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return ce(t),null;case 6:if(e&&t.stateNode!=null)nc(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(N(166));if(n=Ut(sr.current),Ut(rt.current),Er(t)){if(r=t.stateNode,n=t.memoizedProps,r[tt]=t,(i=r.nodeValue!==n)&&(e=Pe,e!==null))switch(e.tag){case 3:_r(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&_r(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[tt]=t,t.stateNode=r}return ce(t),null;case 13:if(Q(Y),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(K&&Te!==null&&t.mode&1&&!(t.flags&128))xa(),yn(),t.flags|=98560,i=!1;else if(i=Er(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(N(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(N(317));i[tt]=t}else yn(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ce(t),i=!1}else Ye!==null&&(qi(Ye),Ye=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Y.current&1?ee===0&&(ee=3):Bs())),t.updateQueue!==null&&(t.flags|=4),ce(t),null);case 4:return xn(),Wi(e,t),e===null&&nr(t.stateNode.containerInfo),ce(t),null;case 10:return Cs(t.type._context),ce(t),null;case 17:return je(t.type)&&el(),ce(t),null;case 19:if(Q(Y),i=t.memoizedState,i===null)return ce(t),null;if(r=(t.flags&128)!==0,s=i.rendering,s===null)if(r)Rn(i,!1);else{if(ee!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=ol(e),s!==null){for(t.flags|=128,Rn(i,!1),r=s.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,s=i.alternate,s===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=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,i.type=s.type,e=s.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return H(Y,Y.current&1|2),t.child}e=e.sibling}i.tail!==null&&Z()>kn&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304)}else{if(!r)if(e=ol(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Rn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!K)return ce(t),null}else 2*Z()-i.renderingStartTime>kn&&n!==1073741824&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Z(),t.sibling=null,n=Y.current,H(Y,r?n&1|2:n&1),t):(ce(t),null);case 22:case 23:return Vs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ee&1073741824&&(ce(t),t.subtreeFlags&6&&(t.flags|=8192)):ce(t),null;case 24:return null;case 25:return null}throw Error(N(156,t.tag))}function Rf(e,t){switch(Ss(t),t.tag){case 1:return je(t.type)&&el(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xn(),Q(Ne),Q(fe),Ls(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ps(t),null;case 13:if(Q(Y),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(N(340));yn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Q(Y),null;case 4:return xn(),null;case 10:return Cs(t.type._context),null;case 22:case 23:return Vs(),null;case 24:return null;default:return null}}var Lr=!1,de=!1,Of=typeof WeakSet=="function"?WeakSet:Set,z=null;function un(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){J(e,t,r)}else n.current=null}function Qi(e,t,n){try{n()}catch(r){J(e,t,r)}}var Yo=!1;function Df(e,t){if(Ti=Jr,e=oa(),ws(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,u=-1,a=-1,d=0,v=0,m=e,h=null;t:for(;;){for(var w;m!==n||l!==0&&m.nodeType!==3||(u=s+l),m!==i||r!==0&&m.nodeType!==3||(a=s+r),m.nodeType===3&&(s+=m.nodeValue.length),(w=m.firstChild)!==null;)h=m,m=w;for(;;){if(m===e)break t;if(h===n&&++d===l&&(u=s),h===i&&++v===r&&(a=s),(w=m.nextSibling)!==null)break;m=h,h=m.parentNode}m=w}n=u===-1||a===-1?null:{start:u,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(Pi={focusedElem:e,selectionRange:n},Jr=!1,z=t;z!==null;)if(t=z,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,z=e;else for(;z!==null;){t=z;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var S=x.memoizedProps,_=x.memoizedState,f=t.stateNode,c=f.getSnapshotBeforeUpdate(t.elementType===t.type?S:Qe(t.type,S),_);f.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var p=t.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(y){J(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,z=e;break}z=t.return}return x=Yo,Yo=!1,x}function Qn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Qi(t,n,i)}l=l.next}while(l!==r)}}function jl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ki(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 rc(e){var t=e.alternate;t!==null&&(e.alternate=null,rc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[tt],delete t[lr],delete t[Ri],delete t[vf],delete t[gf])),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 lc(e){return e.tag===5||e.tag===3||e.tag===4}function Xo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||lc(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 Yi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=br));else if(r!==4&&(e=e.child,e!==null))for(Yi(e,t,n),e=e.sibling;e!==null;)Yi(e,t,n),e=e.sibling}function Xi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Xi(e,t,n),e=e.sibling;e!==null;)Xi(e,t,n),e=e.sibling}var le=null,Ke=!1;function ht(e,t,n){for(n=n.child;n!==null;)ic(e,t,n),n=n.sibling}function ic(e,t,n){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(vl,n)}catch{}switch(n.tag){case 5:de||un(n,t);case 6:var r=le,l=Ke;le=null,ht(e,t,n),le=r,Ke=l,le!==null&&(Ke?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&(Ke?(e=le,n=n.stateNode,e.nodeType===8?Xl(e.parentNode,n):e.nodeType===1&&Xl(e,n),bn(e)):Xl(le,n.stateNode));break;case 4:r=le,l=Ke,le=n.stateNode.containerInfo,Ke=!0,ht(e,t,n),le=r,Ke=l;break;case 0:case 11:case 14:case 15:if(!de&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Qi(n,t,s),l=l.next}while(l!==r)}ht(e,t,n);break;case 1:if(!de&&(un(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){J(n,t,u)}ht(e,t,n);break;case 21:ht(e,t,n);break;case 22:n.mode&1?(de=(r=de)||n.memoizedState!==null,ht(e,t,n),de=r):ht(e,t,n);break;default:ht(e,t,n)}}function Go(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Of),t.forEach(function(r){var l=Hf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function We(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=s),r&=~i}if(r=l,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Mf(r/1960))-r,10e?16:e,xt===null)var r=!1;else{if(e=xt,xt=null,fl=0,U&6)throw Error(N(331));var l=U;for(U|=4,z=e.current;z!==null;){var i=z,s=i.child;if(z.flags&16){var u=i.deletions;if(u!==null){for(var a=0;aZ()-Us?Vt(e,0):Is|=n),Ce(e,t)}function pc(e,t){t===0&&(e.mode&1?(t=Sr,Sr<<=1,!(Sr&130023424)&&(Sr=4194304)):t=1);var n=me();e=dt(e,t),e!==null&&(fr(e,t,n),Ce(e,n))}function Bf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),pc(e,n)}function Hf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(N(314))}r!==null&&r.delete(t),pc(e,n)}var hc;hc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ne.current)ke=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ke=!1,Lf(e,t,n);ke=!!(e.flags&131072)}else ke=!1,K&&t.flags&1048576&&ya(t,rl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vr(e,t),e=t.pendingProps;var l=gn(t,fe.current);hn(t,n),l=Rs(null,t,r,e,l,n);var i=Os();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,je(r)?(i=!0,tl(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Es(t),l.updater=Nl,t.stateNode=l,l._reactInternals=t,Ii(t,r,e,n),t=Vi(null,t,r,!0,i,n)):(t.tag=0,K&&i&&xs(t),he(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Qf(r),e=Qe(r,e),l){case 0:t=Ai(null,t,r,e,n);break e;case 1:t=Wo(null,t,r,e,n);break e;case 11:t=Bo(null,t,r,e,n);break e;case 14:t=Ho(null,t,r,Qe(r.type,e),n);break e}throw Error(N(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),Ai(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),Wo(e,t,r,l,n);case 3:e:{if(Za(t),e===null)throw Error(N(387));r=t.pendingProps,i=t.memoizedState,l=i.element,ja(e,t),sl(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=Sn(Error(N(423)),t),t=Qo(e,t,r,n,l);break e}else if(r!==l){l=Sn(Error(N(424)),t),t=Qo(e,t,r,n,l);break e}else for(Te=jt(t.stateNode.containerInfo.firstChild),Pe=t,K=!0,Ye=null,n=ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yn(),r===l){t=ft(e,t,n);break e}he(e,t,r,n)}t=t.child}return t;case 5:return Ca(t),e===null&&Fi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,s=l.children,Li(r,l)?s=null:i!==null&&Li(r,i)&&(t.flags|=32),Ja(e,t),he(e,t,s,n),t.child;case 6:return e===null&&Fi(t),null;case 13:return qa(e,t,n);case 4:return Ts(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wn(t,null,r,n):he(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),Bo(e,t,r,l,n);case 7:return he(e,t,t.pendingProps,n),t.child;case 8:return he(e,t,t.pendingProps.children,n),t.child;case 12:return he(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,s=l.value,H(ll,r._currentValue),r._currentValue=s,i!==null)if(Je(i.value,s)){if(i.children===l.children&&!Ne.current){t=ft(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){s=i.child;for(var a=u.firstContext;a!==null;){if(a.context===r){if(i.tag===1){a=ut(-1,n&-n),a.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var v=d.pending;v===null?a.next=a:(a.next=v.next,v.next=a),d.pending=a}}i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),Mi(i.return,n,t),u.lanes|=n;break}a=a.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(N(341));s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Mi(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}he(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,hn(t,n),l=Ue(l),r=r(l),t.flags|=1,he(e,t,r,n),t.child;case 14:return r=t.type,l=Qe(r,t.pendingProps),l=Qe(r.type,l),Ho(e,t,r,l,n);case 15:return Xa(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Qe(r,l),Vr(e,t),t.tag=1,je(r)?(e=!0,tl(t)):e=!1,hn(t,n),Qa(t,r,l),Ii(t,r,l,n),Vi(null,t,r,!0,e,n);case 19:return ba(e,t,n);case 22:return Ga(e,t,n)}throw Error(N(156,t.tag))};function mc(e,t){return Bu(e,t)}function Wf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $e(e,t,n,r){return new Wf(e,t,n,r)}function Hs(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qf(e){if(typeof e=="function")return Hs(e)?1:0;if(e!=null){if(e=e.$$typeof,e===us)return 11;if(e===as)return 14}return 2}function Tt(e,t){var n=e.alternate;return n===null?(n=$e(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wr(e,t,n,r,l,i){var s=2;if(r=e,typeof e=="function")Hs(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case qt:return Bt(n.children,l,i,t);case os:s=8,l|=8;break;case ui:return e=$e(12,n,t,l|2),e.elementType=ui,e.lanes=i,e;case ai:return e=$e(13,n,t,l),e.elementType=ai,e.lanes=i,e;case ci:return e=$e(19,n,t,l),e.elementType=ci,e.lanes=i,e;case Cu:return _l(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Nu:s=10;break e;case ju:s=9;break e;case us:s=11;break e;case as:s=14;break e;case mt:s=16,r=null;break e}throw Error(N(130,e==null?e:typeof e,""))}return t=$e(s,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Bt(e,t,n,r){return e=$e(7,e,r,t),e.lanes=n,e}function _l(e,t,n,r){return e=$e(22,e,r,t),e.elementType=Cu,e.lanes=n,e.stateNode={isHidden:!1},e}function ni(e,t,n){return e=$e(6,e,null,t),e.lanes=n,e}function ri(e,t,n){return t=$e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Kf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$l(0),this.expirationTimes=$l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$l(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Ws(e,t,n,r,l,i,s,u,a){return e=new Kf(e,t,n,u,a),t===1?(t=1,i===!0&&(t|=8)):t=0,i=$e(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Es(i),e}function Yf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(wc)}catch(e){console.error(e)}}wc(),wu.exports=ze;var qf=wu.exports,xc,ru=qf;xc=ru.createRoot,ru.hydrateRoot;async function ye(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function bf(){return ye("/api/archives")}async function ep(e){return ye(`/api/archives/${e}/entries`)}async function tp(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),ye(`/api/archives/${e}/entries/search?${r}`)}async function np(e,t){return ye(`/api/archives/${e}/entries/${t}`)}async function rp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function li(e,t){return ye(`/api/archives/${e}/entries/${t}/tags`)}async function lp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag_path:n})});if(!r.ok)throw new Error(`Failed to add tag (${r.status})`)}async function ip(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function lu(e){return ye(`/api/archives/${e}/runs`)}async function ii(e){return ye(`/api/archives/${e}/tags`)}async function sp(e,t){const n=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function op(e,t){return ye(`/api/archives/${e}/capture_jobs/${t}`)}async function up(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function ap(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function cp(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function dp(){await fetch("/api/auth/logout",{method:"POST"})}async function fp(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function pp(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function hp(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function mp(){return ye("/api/auth/tokens")}async function vp(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function gp(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function yp(){return ye("/api/admin/instance-settings")}async function wp(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function xp(){return ye("/api/admin/users")}async function Sp(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function kp(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Np(){return ye("/api/admin/roles")}async function jp(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Cp(e){return ye(`/api/archives/${e}/collections`)}async function _p(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}return l.json()}async function Ep(e,t){return ye(`/api/archives/${e}/collections/${t}`)}async function Tp(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Pp(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function Lp(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function zp(e,t){return ye(`/api/archives/${e}/entries/${t}/collections`)}async function iu(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Rp(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}const Op=window.fetch;window.fetch=async(...e)=>{var n;const t=await Op(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function Dp({onLogin:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(null),[u,a]=g.useState(!1);async function d(v){v.preventDefault(),s(null),a(!0);try{const m=await cp(t,r);e(m)}catch(m){s(m.message)}finally{a(!1)}}return o.jsx("div",{className:"login-page",children:o.jsxs("div",{className:"login-card",children:[o.jsx("h1",{className:"login-brand",children:"Archivr"}),o.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),o.jsxs("form",{onSubmit:d,children:[o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),o.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:v=>n(v.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),o.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:v=>l(v.target.value),required:!0,autoComplete:"current-password"})]}),i&&o.jsx("p",{className:"login-error",children:i}),o.jsx("button",{className:"login-submit",type:"submit",disabled:u,children:u?"Signing in…":"Sign in"})]})]})})}function Fp({onComplete:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(""),[u,a]=g.useState(null),[d,v]=g.useState(!1);async function m(h){if(h.preventDefault(),r!==i){a("Passwords do not match");return}if(r.length<8){a("Password must be at least 8 characters");return}a(null),v(!0);try{await ap(t,r),e()}catch(w){a(w.message)}finally{v(!1)}}return o.jsx("div",{className:"setup-page",children:o.jsxs("div",{className:"setup-card",children:[o.jsx("h1",{className:"setup-brand",children:"Archivr"}),o.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),o.jsxs("form",{onSubmit:m,children:[o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),o.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:h=>n(h.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),o.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:h=>l(h.target.value),required:!0,autoComplete:"new-password"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),o.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:h=>s(h.target.value),required:!0,autoComplete:"new-password"})]}),u&&o.jsx("p",{className:"setup-error",children:u}),o.jsx("button",{className:"setup-submit",type:"submit",disabled:d,children:d?"Creating account…":"Create account"})]})]})})}function Mp({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){const{currentUser:s,setCurrentUser:u}=g.useContext(zl)??{},[a,d]=g.useState(!1);async function v(){d(!0),await dp(),u(null),window.location.reload()}return o.jsxs("header",{className:"topbar",children:[o.jsx("div",{className:"brand",children:"Archivr"}),o.jsx("div",{className:"switcher",children:o.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:m=>n(m.target.value),children:e.map(m=>o.jsx("option",{value:m.id,children:m.label},m.id))})}),o.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","runs","admin","tags","collections","settings"].map(m=>o.jsx("button",{className:`nav-link${r===m?" is-active":""}`,onClick:()=>l(m),children:m.charAt(0).toUpperCase()+m.slice(1)},m))}),o.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),s&&o.jsxs("div",{className:"user-menu",children:[o.jsx("span",{className:"user-name",children:s.display_name||s.username}),o.jsx("button",{className:"logout-btn",onClick:v,disabled:a,children:a?"Logging out…":"Log out"})]})]})}function $p({open:e,archiveId:t,onClose:n,onCaptured:r}){const l=g.useRef(null),[i,s]=g.useState(""),[u,a]=g.useState(null),[d,v]=g.useState(!1),[m,h]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{const _=l.current;if(!_)return;const f=()=>{clearInterval(w.current),n()};return _.addEventListener("close",f),()=>_.removeEventListener("close",f)},[n]),g.useEffect(()=>{const _=l.current;_&&(e?(s(""),a(null),h(null),v(!1),clearInterval(w.current),_.open||_.showModal()):_.open&&_.close())},[e]);async function x(){if(!i.trim()){a("Enter a locator.");return}v(!0),a(null),h(null);try{const _=await sp(t,i.trim());h("running"),w.current=setInterval(async()=>{var f;try{const c=await op(t,_.job_uid);c.status==="completed"?(clearInterval(w.current),w.current=null,v(!1),h("completed"),(f=l.current)==null||f.close(),r()):c.status==="failed"&&(clearInterval(w.current),w.current=null,v(!1),h("failed"),a(c.error_text||"Capture failed."))}catch(c){clearInterval(w.current),w.current=null,v(!1),a(c.message)}},500)}catch(_){a(_.message),v(!1)}}function S(){return d?m==="running"?"Running…":"Capturing…":"Capture"}return o.jsx("dialog",{ref:l,className:"capture-dialog",children:o.jsxs("div",{className:"capture-dialog-inner",children:[o.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),o.jsx("label",{htmlFor:"capture-locator",className:"capture-label",children:"Locator"}),o.jsx("input",{id:"capture-locator",className:"capture-input",type:"text",placeholder:"tweet:1234567890 or https://...",value:i,onChange:_=>s(_.target.value),onKeyDown:_=>{_.key==="Enter"&&x()},autoComplete:"off"}),u&&o.jsx("div",{className:"capture-error",children:u}),o.jsxs("div",{className:"capture-actions",children:[o.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var _;return(_=l.current)==null?void 0:_.close()},children:"Cancel"}),o.jsx("button",{type:"button",className:"capture-submit",onClick:x,disabled:d,children:S()})]})]})})}function bi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&rString(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const su={youtube:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function kc(e){return su[e]??su.other}function Ip({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,i]=g.useState(!1),u=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?o.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>i(!0),style:{objectFit:"contain"}}):o.jsx("span",{dangerouslySetInnerHTML:{__html:kc(e.source_kind)}});return o.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:a=>{a.key==="Enter"&&r()},children:[o.jsx("div",{className:"col-added",children:Sc(e.archived_at)}),o.jsxs("div",{className:"col-title",children:[o.jsx("span",{className:"source-icon",children:u}),o.jsx("span",{className:"entry-title",children:At(e.title)||At(e.entry_uid)})]}),o.jsx("div",{className:"col-type",children:o.jsx("span",{className:"type-pill",children:At(e.entity_kind)})}),o.jsxs("div",{className:"col-size",children:[o.jsx("span",{className:"size-total",children:bi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&o.jsxs("span",{className:"size-cached-pct",title:`${bi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),o.jsx("div",{className:"url-cell col-url",children:At(e.original_url)})]})}function Up({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return o.jsx("section",{id:"archive-view",className:"view is-active",children:o.jsxs("div",{className:"entry-table",children:[o.jsxs("div",{className:"entry-header-row",children:[o.jsx("div",{className:"col-added",children:"Added"}),o.jsx("div",{className:"col-title",children:"Title"}),o.jsx("div",{className:"col-type",children:"Type"}),o.jsx("div",{className:"col-size",children:"Size"}),o.jsx("div",{className:"col-url",children:"Original URL"})]}),o.jsx("div",{id:"entries-body",children:e.map(l=>o.jsx(Ip,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Ap(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function Vp({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="running"?"run-status--running":"";return o.jsx("span",{className:`run-status ${t}`,children:e||"—"})}function Bp({runs:e}){return o.jsx("section",{id:"runs-view",className:"view is-active",children:o.jsxs("table",{className:"entry-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Started"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Requested"}),o.jsx("th",{children:"Completed"}),o.jsx("th",{children:"Failed"})]})}),o.jsx("tbody",{children:e.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map((t,n)=>o.jsxs("tr",{children:[o.jsx("td",{children:Ap(t.started_at)}),o.jsx("td",{children:o.jsx(Vp,{status:t.status})}),o.jsx("td",{children:t.requested_count??"—"}),o.jsx("td",{children:t.completed_count??"—"}),o.jsx("td",{children:t.failed_count??"—"})]},n))})]})})}const Hp=4;function Wp({archives:e}){const{currentUser:t}=g.useContext(zl)??{},n=t&&(t.role_bits&Hp)!==0,[r,l]=g.useState("users"),[i,s]=g.useState([]),[u,a]=g.useState([]),[d,v]=g.useState(!1),[m,h]=g.useState(null),[w,x]=g.useState(""),[S,_]=g.useState(""),[f,c]=g.useState(""),[p,y]=g.useState(null),[C,T]=g.useState(!1),[P,R]=g.useState(""),[I,j]=g.useState(""),[M,oe]=g.useState(null),[re,Ze]=g.useState(!1),Oe=g.useCallback(async()=>{if(n){v(!0),h(null);try{const[k,O]=await Promise.all([xp(),Np()]);s(k),a(O)}catch(k){h(k.message)}finally{v(!1)}}},[n]);g.useEffect(()=>{Oe()},[Oe]);async function we(k){const O=k.status==="active"?"disabled":"active";try{await kp(k.user_uid,O),s(A=>A.map(D=>D.user_uid===k.user_uid?{...D,status:O}:D))}catch(A){h(A.message)}}async function Ve(k){if(k.preventDefault(),!w.trim()||!S){y("Username and password required");return}T(!0),y(null);try{await Sp(w.trim(),S,f.trim()||void 0),x(""),_(""),c(""),await Oe()}catch(O){y(O.message)}finally{T(!1)}}async function E(k){if(k.preventDefault(),!P.trim()||!I.trim()){oe("Slug and name required");return}Ze(!0),oe(null);try{await jp(P.trim(),I.trim()),R(""),j(""),await Oe()}catch(O){oe(O.message)}finally{Ze(!1)}}return n?o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsxs("div",{className:"view-tabs",children:[o.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),o.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),o.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&o.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Users"}),d?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Username"}),o.jsx("th",{children:"Email"}),o.jsx("th",{children:"Roles"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Actions"})]})}),o.jsx("tbody",{children:i.map(k=>o.jsxs("tr",{className:k.status==="disabled"?"admin-row-disabled":"",children:[o.jsx("td",{children:k.username}),o.jsx("td",{className:"muted",children:k.email||"—"}),o.jsx("td",{children:k.role_slugs.join(", ")||"—"}),o.jsx("td",{children:o.jsx("span",{className:`status-badge status-${k.status}`,children:k.status})}),o.jsx("td",{children:o.jsx("button",{className:"admin-action-btn",onClick:()=>we(k),children:k.status==="active"?"Ban":"Unban"})})]},k.user_uid))})]}),o.jsx("h3",{children:"Create User"}),o.jsxs("form",{className:"admin-form",onSubmit:Ve,children:[o.jsx("input",{className:"admin-input",placeholder:"Username",value:w,onChange:k=>x(k.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:S,onChange:k=>_(k.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:f,onChange:k=>c(k.target.value)}),p&&o.jsx("div",{className:"form-msg form-msg--err",children:p}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:C,children:C?"Creating…":"Create User"})]})]}),r==="roles"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Roles"}),d?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Slug"}),o.jsx("th",{children:"Name"}),o.jsx("th",{children:"Level"}),o.jsx("th",{children:"Bit"}),o.jsx("th",{children:"Built-in"})]})}),o.jsx("tbody",{children:u.map(k=>o.jsxs("tr",{children:[o.jsx("td",{children:o.jsx("code",{children:k.slug})}),o.jsx("td",{children:k.name}),o.jsx("td",{children:k.level}),o.jsx("td",{children:k.bit_position}),o.jsx("td",{children:k.is_builtin?"✓":""})]},k.role_uid))})]}),o.jsx("h3",{children:"Create Custom Role"}),o.jsxs("form",{className:"admin-form",onSubmit:E,children:[o.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:P,onChange:k=>R(k.target.value),required:!0}),o.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:I,onChange:k=>j(k.target.value),required:!0}),M&&o.jsx("div",{className:"form-msg form-msg--err",children:M}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:re,children:re?"Creating…":"Create Role"})]})]}),r==="archives"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(k=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:k.label}),o.jsx("div",{className:"muted",children:k.archive_path})]},k.id))})]})]}):o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(k=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:k.label}),o.jsx("div",{className:"muted",children:k.archive_path})]},k.id))})]})}function Nc({node:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){var s;const l=t===e.tag.full_path;function i(){const u=l?null:e.tag.full_path;n(u),r("archive")}return o.jsxs("li",{children:[o.jsx("button",{className:`tag-node-btn${l?" is-active":""}`,title:e.tag.full_path,onClick:i,children:e.tag.name}),((s=e.children)==null?void 0:s.length)>0&&o.jsx("div",{className:"tag-children",children:o.jsx("ul",{className:"tag-tree-list",children:e.children.map(u=>o.jsx(Nc,{node:u,tagFilter:t,onTagFilterSet:n,onViewChange:r},u.tag.tag_uid))})})]})}function Qp({tagNodes:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){return o.jsx("section",{id:"tags-view",className:"view is-active",children:o.jsxs("div",{className:"tag-tree",children:[o.jsxs("div",{className:"tag-tree-header",children:[o.jsx("span",{className:"tag-tree-title",children:"Tags"}),t&&o.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",t]})]}),e.length===0?o.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):o.jsx("ul",{className:"tag-tree-list",children:e.map(l=>o.jsx(Nc,{node:l,tagFilter:t,onTagFilterSet:n,onViewChange:r},l.tag.tag_uid))})]})})}const In=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],Kp=e=>{var t;return((t=In.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function Yp({archiveId:e}){const[t,n]=g.useState([]),[r,l]=g.useState(!1),[i,s]=g.useState(null),[u,a]=g.useState(null),[d,v]=g.useState(null),[m,h]=g.useState(!1),[w,x]=g.useState(null),[S,_]=g.useState(""),[f,c]=g.useState(""),[p,y]=g.useState(2),[C,T]=g.useState(!1),[P,R]=g.useState(null),[I,j]=g.useState(""),[M,oe]=g.useState(2),[re,Ze]=g.useState(!1),[Oe,we]=g.useState(null),[Ve,E]=g.useState(!1),[k,O]=g.useState(""),A=g.useRef(null),D=t.find(L=>L.collection_uid===u)??null,pe=(D==null?void 0:D.slug)==="_default_",ue=g.useCallback(async()=>{if(e){l(!0),s(null);try{const L=await Cp(e);n(L)}catch(L){s(L.message)}finally{l(!1)}}},[e]),qe=g.useCallback(async L=>{if(!L){v(null);return}h(!0),x(null);try{const V=await Ep(e,L);v(V)}catch(V){x(V.message)}finally{h(!1)}},[e]);g.useEffect(()=>{ue()},[ue]),g.useEffect(()=>{qe(u)},[u,qe]),g.useEffect(()=>{Ve&&A.current&&A.current.focus()},[Ve]);async function Be(L){L.preventDefault();const V=S.trim(),He=f.trim();if(!(!V||!He)){T(!0),R(null);try{const Dt=await _p(e,V,He,p);_(""),c(""),y(2),await ue(),a(Dt.collection_uid)}catch(Dt){R(Dt.message)}finally{T(!1)}}}async function F(){const L=k.trim();if(!L||!D){E(!1);return}try{await iu(e,D.collection_uid,{name:L}),await ue(),v(V=>V&&{...V,name:L})}catch(V){s(V.message)}finally{E(!1)}}async function xe(L){if(D)try{await iu(e,D.collection_uid,{default_visibility_bits:L}),await ue(),v(V=>V&&{...V,default_visibility_bits:L})}catch(V){s(V.message)}}async function _e(){if(D&&window.confirm(`Delete collection "${D.name}"? Entries will not be deleted.`))try{await Rp(e,D.collection_uid),a(null),v(null),await ue()}catch(L){s(L.message)}}async function De(L){L.preventDefault();const V=I.trim();if(!(!V||!D)){Ze(!0),we(null);try{await Tp(e,D.collection_uid,V,M),j(""),await qe(D.collection_uid)}catch(He){we(He.message)}finally{Ze(!1)}}}async function jc(L){if(D)try{await Pp(e,D.collection_uid,L),await qe(D.collection_uid)}catch(V){x(V.message)}}async function Cc(L,V){if(D)try{await Lp(e,D.collection_uid,L,V),v(He=>He&&{...He,entries:He.entries.map(Dt=>Dt.entry_uid===L?{...Dt,collection_visibility_bits:V}:Dt)})}catch(He){x(He.message)}}return e?o.jsxs("div",{className:"collections-view",children:[o.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&o.jsx("div",{className:"muted",children:"Loading…"}),i&&o.jsxs("div",{className:"collections-error",children:[i," ",o.jsx("button",{onClick:()=>s(null),className:"coll-dismiss",children:"×"})]}),o.jsxs("div",{className:"collections-layout",children:[o.jsxs("div",{className:"collections-sidebar",children:[t.map(L=>o.jsxs("button",{className:`coll-sidebar-row${u===L.collection_uid?" is-active":""}`,onClick:()=>a(L.collection_uid),children:[o.jsx("span",{className:"coll-row-name",children:L.name}),o.jsx("span",{className:"coll-row-meta",children:Kp(L.default_visibility_bits)})]},L.collection_uid)),t.length===0&&!r&&o.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),D?o.jsxs("div",{className:"coll-detail",children:[o.jsxs("div",{className:"coll-detail-header",children:[Ve?o.jsx("input",{ref:A,className:"coll-rename-input",value:k,onChange:L=>O(L.target.value),onBlur:F,onKeyDown:L=>{L.key==="Enter"&&F(),L.key==="Escape"&&E(!1)}}):o.jsxs("h3",{className:`coll-detail-name${pe?"":" coll-detail-name--editable"}`,title:pe?void 0:"Click to rename",onClick:()=>{pe||(O(D.name),E(!0))},children:[(d==null?void 0:d.name)??D.name,!pe&&o.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!pe&&o.jsx("button",{className:"coll-delete-btn",onClick:_e,title:"Delete collection",children:"Delete"})]}),o.jsxs("div",{className:"coll-detail-vis",children:[o.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),o.jsx("select",{className:"coll-vis-select",value:(d==null?void 0:d.default_visibility_bits)??D.default_visibility_bits,onChange:L=>xe(Number(L.target.value)),disabled:pe,children:In.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))})]}),o.jsxs("div",{className:"coll-entries-section",children:[o.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&o.jsx("div",{className:"muted",children:"Loading…"}),w&&o.jsx("div",{className:"collections-error",children:w}),!m&&d&&(d.entries.length===0?o.jsx("div",{className:"muted",children:"No entries in this collection."}):o.jsx("ul",{className:"coll-entries-list",children:d.entries.map(L=>o.jsxs("li",{className:"coll-entry-row",children:[o.jsxs("div",{className:"coll-entry-info",children:[o.jsx("span",{className:"coll-entry-title",children:L.title||L.entry_uid}),o.jsx("span",{className:"coll-entry-kind muted",children:L.source_kind})]}),o.jsxs("div",{className:"coll-entry-actions",children:[o.jsx("select",{className:"coll-entry-vis-select",value:L.collection_visibility_bits,onChange:V=>Cc(L.entry_uid,Number(V.target.value)),children:In.map(V=>o.jsx("option",{value:V.value,children:V.label},V.value))}),!pe&&o.jsx("button",{className:"coll-entry-remove",onClick:()=>jc(L.entry_uid),title:"Remove from collection",children:"×"})]})]},L.entry_uid))}))]}),!pe&&o.jsxs("form",{className:"coll-add-entry-form",onSubmit:De,children:[o.jsx("div",{className:"coll-section-heading",children:"Add entry"}),o.jsxs("div",{className:"coll-add-entry-row",children:[o.jsx("input",{className:"coll-add-entry-input",type:"text",value:I,onChange:L=>j(L.target.value),placeholder:"entry_uid",required:!0}),o.jsx("select",{className:"coll-vis-select",value:M,onChange:L=>oe(Number(L.target.value)),children:In.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))}),o.jsx("button",{className:"coll-add-btn",type:"submit",disabled:re,children:re?"…":"Add"})]}),Oe&&o.jsx("div",{className:"collections-error",style:{marginTop:4},children:Oe})]})]}):o.jsx("div",{className:"coll-detail coll-detail--empty",children:o.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),o.jsxs("details",{className:"coll-create-details",children:[o.jsx("summary",{children:"+ Create collection"}),o.jsxs("form",{className:"coll-create-form",onSubmit:Be,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),o.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:S,onChange:L=>{_(L.target.value),f||c(L.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),o.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:f,onChange:L=>c(L.target.value),placeholder:"my-collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),o.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:p,onChange:L=>y(Number(L.target.value)),children:In.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))})]}),P&&o.jsx("div",{className:"collections-error",children:P}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:C,children:C?"Creating…":"Create collection"})]})]})]}):o.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const Xp=4;function Gp({tab:e,onTabChange:t}){const{currentUser:n,setCurrentUser:r}=g.useContext(zl)??{},l=n&&(n.role_bits&Xp)!==0,i=["profile","tokens",...l?["instance"]:[]],s={profile:"Profile",tokens:"API Tokens",instance:"Instance"};return o.jsxs("section",{className:"admin-view",children:[o.jsx("h1",{children:"Settings"}),o.jsx("div",{className:"view-tabs",children:i.map(u=>o.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:s[u]},u))}),e==="profile"&&o.jsx(Jp,{currentUser:n,setCurrentUser:r}),e==="tokens"&&o.jsx(Zp,{}),e==="instance"&&l&&o.jsx(qp,{})]})}function Jp({currentUser:e,setCurrentUser:t}){const[n,r]=g.useState((e==null?void 0:e.display_name)??""),[l,i]=g.useState(!1),[s,u]=g.useState(null),[a,d]=g.useState(""),[v,m]=g.useState(""),[h,w]=g.useState(""),[x,S]=g.useState(!1),[_,f]=g.useState(null);async function c(y){y.preventDefault(),i(!0),u(null);try{await pp(n),t(C=>({...C,display_name:n||null})),u({ok:!0,text:"Saved."})}catch(C){u({ok:!1,text:C.message})}finally{i(!1)}}async function p(y){if(y.preventDefault(),v!==h){f({ok:!1,text:"Passwords do not match."});return}S(!0),f(null);try{await hp(a,v),d(""),m(""),w(""),f({ok:!0,text:"Password changed."})}catch(C){f({ok:!1,text:C.message})}finally{S(!1)}}return o.jsxs("div",{style:{maxWidth:440},children:[o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Name"}),o.jsxs("form",{onSubmit:c,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),o.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:y=>r(y.target.value)})]}),s&&o.jsx("div",{className:`form-msg form-msg--${s.ok?"ok":"err"}`,children:s.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Change Password"}),o.jsxs("form",{onSubmit:p,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),o.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:a,onChange:y=>d(y.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),o.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:v,onChange:y=>m(y.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),o.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:h,onChange:y=>w(y.target.value),required:!0})]}),_&&o.jsx("div",{className:`form-msg form-msg--${_.ok?"ok":"err"}`,children:_.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function Zp(){const[e,t]=g.useState([]),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,u]=g.useState(""),[a,d]=g.useState(!1),[v,m]=g.useState(null),h=g.useCallback(async()=>{r(!0),i(null);try{t(await mp())}catch(S){i(S.message)}finally{r(!1)}},[]);g.useEffect(()=>{h()},[h]);async function w(S){if(S.preventDefault(),!!s.trim()){d(!0);try{const _=await vp(s.trim());m(_),u(""),h()}catch(_){i(_.message)}finally{d(!1)}}}async function x(S){try{await gp(S),t(_=>_.filter(f=>f.token_uid!==S))}catch(_){i(_.message)}}return o.jsx("div",{style:{maxWidth:600},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"API Tokens"}),v&&o.jsxs("div",{className:"token-banner",children:[o.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",o.jsx("code",{children:v.raw_token}),o.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),o.jsxs("form",{className:"token-create-row",onSubmit:w,children:[o.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:s,onChange:S=>u(S.target.value),required:!0}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Creating…":"Create token"})]}),l&&o.jsx("div",{className:"form-msg form-msg--err",children:l}),n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):o.jsxs("div",{children:[e.length===0&&o.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(S=>o.jsxs("div",{className:"token-row",children:[o.jsxs("div",{className:"token-row-info",children:[o.jsx("strong",{children:S.name}),o.jsxs("div",{className:"muted",children:["Created ",S.created_at.slice(0,10),S.last_used_at&&` · Last used ${S.last_used_at.slice(0,10)}`]})]}),o.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(S.token_uid),children:"Revoke"})]},S.token_uid))]})]})})}function qp(){const[e,t]=g.useState(null),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,u]=g.useState(!1),[a,d]=g.useState(null);g.useEffect(()=>{(async()=>{try{t(await yp())}catch(m){i(m.message)}finally{r(!1)}})()},[]);async function v(m){m.preventDefault(),u(!0),d(null);try{await wp(e),d({ok:!0,text:"Saved."})}catch(h){d({ok:!1,text:h.message})}finally{u(!1)}}return n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):l?o.jsx("div",{className:"form-msg form-msg--err",children:l}):e?o.jsx("div",{style:{maxWidth:440},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Instance Settings"}),o.jsxs("form",{onSubmit:v,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([m,h])=>o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:!!e[m],onChange:w=>t(x=>({...x,[m]:w.target.checked}))}),h]},m)),o.jsxs("div",{className:"form-field",style:{marginTop:4},children:[o.jsx("label",{className:"form-label",children:"Default entry visibility"}),o.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(h=>({...h,default_entry_visibility:Number(m.target.value)})),children:[o.jsx("option",{value:0,children:"Private"}),o.jsx("option",{value:2,children:"Unlisted"}),o.jsx("option",{value:3,children:"Public"})]})]}),a&&o.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:s,children:s?"Saving…":"Save Settings"})]})]})}):null}const ou={0:"Private",1:"Public",2:"Users only",3:"Public"},bp=()=>o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function eh({archiveId:e,selectedEntry:t,onTagFilterSet:n,tagNodes:r,onTagsRefresh:l,onEntryTitleChange:i}){const[s,u]=g.useState(null),[a,d]=g.useState([]),[v,m]=g.useState(""),[h,w]=g.useState([]),[x,S]=g.useState(""),_=g.useRef(0),f=g.useRef(!1),[c,p]=g.useState(!1),[y,C]=g.useState("");g.useEffect(()=>{if(!t||!e){u(null),d([]),w([]);return}p(!1),C(""),f.current=!1;const j=++_.current;u(null),d([]),Promise.all([np(e,t.entry_uid),li(e,t.entry_uid),zp(e,t.entry_uid)]).then(([M,oe,re])=>{j===_.current&&(u(M),d(oe),w(re))}).catch(()=>{})},[t,e]);async function T(){const j=y.trim()||null;try{await rp(e,t.entry_uid,j),u(M=>M&&{...M,summary:{...M.summary,title:j}}),i==null||i(t.entry_uid,j)}catch{}finally{p(!1)}}async function P(){const j=v.trim();if(!(!j||!t))try{await lp(e,t.entry_uid,j),m(""),S("");const M=await li(e,t.entry_uid);d(M),l()}catch(M){S(M.message)}}async function R(j){try{await ip(e,t.entry_uid,j);const M=await li(e,t.entry_uid);d(M),l()}catch{}}const I=s?[["Added",Sc(s.summary.archived_at)],["Source",s.summary.source_kind],["Type",s.summary.entity_kind],["Visibility",ou[s.summary.visibility]??s.summary.visibility],["Root",s.structured_root_relpath]]:[];return o.jsxs("aside",{className:"context-rail",children:[o.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?s?o.jsxs(o.Fragment,{children:[c?o.jsx("input",{className:"rail-title-input",autoFocus:!0,value:y,onChange:j=>C(j.target.value),onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(f.current=!0,j.currentTarget.blur())},onBlur:()=>{f.current?p(!1):T(),f.current=!1}}):o.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{C(s.summary.title??""),p(!0)},children:[At(s.summary.title)||At(s.summary.entry_uid),o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),s.summary.original_url&&o.jsxs("a",{className:"url-tile",href:s.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[o.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:kc(s.summary.source_kind)}}),o.jsx("span",{className:"u-text",children:s.summary.original_url}),o.jsx("span",{className:"ext",children:o.jsx(bp,{})})]}),o.jsx("div",{className:"meta-list",children:I.filter(([,j])=>j!=null&&j!=="").map(([j,M])=>o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-k",children:j}),o.jsx("span",{className:`meta-v${j==="Root"?" mono":""}`,children:At(M)})]},j))}),s.artifacts.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",o.jsx("span",{className:"num",children:s.artifacts.length})]}),o.jsx("ul",{className:"artifact-list",children:s.artifacts.map((j,M)=>o.jsx("li",{children:o.jsxs("a",{href:`/api/archives/${e}/entries/${s.summary.entry_uid}/artifacts/${M}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[o.jsx("span",{className:"artifact-name",children:j.artifact_role.replace(/_/g," ")}),o.jsx("span",{className:"artifact-size",children:j.byte_size!=null?bi(j.byte_size):"—"})]})},M))})]})]}):o.jsx("p",{className:"tags-empty",children:"Loading…"}):o.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Tags"}),a.length===0?o.jsx("p",{className:"tags-empty",children:"No tags yet."}):o.jsx("div",{className:"tags-wrap",children:a.map(j=>o.jsxs("span",{className:"tag-pill",title:j.full_path,children:[j.name,o.jsx("button",{className:"remove",title:`Remove tag ${j.full_path}`,onClick:()=>R(j.tag_uid),children:"×"})]},j.tag_uid))}),x&&o.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:x}),o.jsxs("div",{className:"tag-input-wrap",children:[o.jsx("span",{className:"hash",children:"/"}),o.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:v,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Enter"&&P()}}),o.jsx("button",{className:"tag-add-btn",onClick:P,children:"Add"})]})]}),h.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Collections"}),h.map(j=>o.jsxs("div",{className:"coll-row",children:[o.jsx("span",{className:"coll-name",children:j.collection_uid}),o.jsx("span",{className:"vis-badge",children:ou[j.visibility_bits]??`bits:${j.visibility_bits}`})]},j.collection_uid))]})]})]})}const zl=g.createContext(null),th=["archive","runs","admin","tags","collections","settings"],nh=["profile","tokens","instance"];function si(){const e=window.location.pathname.split("/").filter(Boolean),t=th.includes(e[0])?e[0]:"archive",n=t==="settings"&&nh.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function rh(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function lh(){const[e,t]=g.useState("loading"),[n,r]=g.useState(null);g.useEffect(()=>{(async()=>{if(await up()){t("setup");return}const xe=await fp();if(!xe){t("login");return}r(xe),t("authenticated")})()},[]),g.useEffect(()=>{const F=()=>{r(null),t("login")};return window.addEventListener("auth:expired",F),()=>window.removeEventListener("auth:expired",F)},[]),g.useEffect(()=>{const F=()=>{const{view:xe,settingsTab:_e}=si();f(xe),p(_e)};return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[]);const[l,i]=g.useState([]),[s,u]=g.useState(null),[a,d]=g.useState([]),[v,m]=g.useState(null),[h,w]=g.useState(null),[x,S]=g.useState(null),[_,f]=g.useState(()=>si().view),[c,p]=g.useState(()=>si().settingsTab),[y,C]=g.useState(""),[T,P]=g.useState(""),[R,I]=g.useState(!1),[j,M]=g.useState([]),[oe,re]=g.useState([]),[Ze,Oe]=g.useState(!1),we=g.useCallback(async(F,xe,_e)=>{if(F){I(!0);try{let De;xe||_e?De=await tp(F,xe,_e):De=await ep(F),d(De),P(De.length===0?"No results":`${De.length} result${De.length===1?"":"s"}`)}catch{d([]),P("Search failed. Try again.")}finally{I(!1)}}},[]);g.useEffect(()=>{e==="authenticated"&&bf().then(F=>{if(i(F),F.length>0){const xe=F[0].id;u(xe)}})},[e]),g.useEffect(()=>{s&&(S(null),w(null),m(null),Promise.all([we(s,"",null),lu(s).then(M),ii(s).then(re)]))},[s]),g.useEffect(()=>{if(s===null)return;const F=setTimeout(()=>{we(s,y,x)},300);return()=>clearTimeout(F)},[y,s]),g.useEffect(()=>{s!==null&&(x!==null&&f("archive"),we(s,y,x))},[x,s]);const Ve=g.useCallback(F=>{u(F)},[]),E=g.useCallback(F=>{f(F),F==="tags"&&s&&ii(s).then(re)},[s]);g.useEffect(()=>{const F=rh(_,c);window.location.pathname!==F&&history.pushState(null,"",F)},[_,c]);const k=g.useCallback(F=>{m(F?F.entry_uid:null),w(F)},[]),O=g.useCallback(F=>{S(F)},[]),A=g.useCallback(()=>{S(null)},[]),D=g.useCallback(()=>{s&&ii(s).then(re)},[s]),pe=g.useCallback((F,xe)=>{d(_e=>_e.map(De=>De.entry_uid===F?{...De,title:xe}:De)),w(_e=>_e&&_e.entry_uid===F?{..._e,title:xe}:_e)},[]),ue=g.useCallback(()=>{Oe(!0)},[]),qe=g.useCallback(()=>{Oe(!1)},[]),Be=g.useCallback(()=>{s&&Promise.all([we(s,y,x),lu(s).then(M)])},[s,y,x,we]);return e==="loading"?o.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?o.jsx(Fp,{onComplete:()=>t("login")}):e==="login"?o.jsx(Dp,{onLogin:F=>{r(F),t("authenticated")}}):o.jsx(zl.Provider,{value:{currentUser:n,setCurrentUser:r},children:o.jsxs(o.Fragment,{children:[o.jsx(Mp,{archives:l,archiveId:s,onArchiveChange:Ve,view:_,onViewChange:E,onCaptureClick:ue}),o.jsxs("main",{className:"app-shell",children:[o.jsxs("div",{className:"workspace",children:[_==="archive"&&o.jsxs("div",{className:"toolbar",children:[o.jsxs("div",{className:"search-field",children:[o.jsx("span",{className:"ico","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"7"}),o.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),o.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":R,placeholder:"Search titles, URLs, types, tags…",value:y,onChange:F=>C(F.target.value)}),o.jsx("span",{className:"kbd",children:"⌘K"})]}),o.jsxs("span",{className:"result-count",children:[T&&o.jsxs(o.Fragment,{children:[o.jsx("b",{children:T.split(" ")[0]})," ",T.split(" ").slice(1).join(" ")]}),x&&o.jsxs("button",{className:"tag-filter-badge",onClick:A,children:["× ",x]})]})]}),_==="archive"&&o.jsx(Up,{entries:a,selectedEntryUid:v,onSelectEntry:k,archiveId:s,tagFilter:x,onClearTagFilter:A,searchQuery:y,onSearchChange:C,resultCount:T,searchBusy:R}),_==="runs"&&o.jsx(Bp,{runs:j}),_==="admin"&&o.jsx(Wp,{archives:l}),_==="tags"&&o.jsx(Qp,{tagNodes:oe,tagFilter:x,onTagFilterSet:O,onViewChange:E}),_==="collections"&&o.jsx(Yp,{archiveId:s}),_==="settings"&&o.jsx(Gp,{tab:c,onTabChange:p})]}),o.jsx(eh,{archiveId:s,selectedEntry:h,onTagFilterSet:O,tagNodes:oe,onTagsRefresh:D,onEntryTitleChange:pe})]}),o.jsx($p,{open:Ze,archiveId:s,onClose:qe,onCaptured:Be})]})})}xc(document.getElementById("root")).render(o.jsx(g.StrictMode,{children:o.jsx(lh,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 8f7a83f..f20b23c 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -4,7 +4,7 @@ Archivr - + diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 845d42c..1388a3b 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -76,7 +76,15 @@ export default function App() { const [searchBusy, setSearchBusy] = useState(false) const [runs, setRuns] = useState([]) const [tagNodes, setTagNodes] = useState([]) - const [captureDialogOpen, setCaptureDialogOpen] = useState(false) + const [captureDialogOpen, setCaptureDialogOpen] = useState(() => { + const saved = sessionStorage.getItem('captureDialogOpen') + return saved === 'true' + }) + + // Persist captureDialogOpen to sessionStorage + useEffect(() => { + sessionStorage.setItem('captureDialogOpen', captureDialogOpen) + }, [captureDialogOpen]) const loadEntries = useCallback(async (aid, q, tag) => { if (!aid) return diff --git a/frontend/src/components/CaptureDialog.jsx b/frontend/src/components/CaptureDialog.jsx index 9942a71..caba828 100644 --- a/frontend/src/components/CaptureDialog.jsx +++ b/frontend/src/components/CaptureDialog.jsx @@ -3,12 +3,89 @@ import { submitCapture, pollCaptureJob } from '../api' export default function CaptureDialog({ open, archiveId, onClose, onCaptured }) { const dialogRef = useRef(null) - const [locator, setLocator] = useState('') - const [error, setError] = useState(null) - const [busy, setBusy] = useState(false) - const [jobStatus, setJobStatus] = useState(null) // null | 'running' | 'completed' | 'failed' + const isFirstRenderRef = useRef(true) + const hasResumedPollingRef = useRef(false) + + const [locator, setLocator] = useState(() => { + const saved = sessionStorage.getItem('captureDialogLocator') + return saved || '' + }) + const [error, setError] = useState(() => { + const saved = sessionStorage.getItem('captureDialogError') + return saved || null + }) + const [busy, setBusy] = useState(() => { + const saved = sessionStorage.getItem('captureDialogBusy') + return saved === 'true' + }) + const [jobStatus, setJobStatus] = useState(() => { + const saved = sessionStorage.getItem('captureDialogJobStatus') + return saved || null + }) + const [jobUid, setJobUid] = useState(() => { + const saved = sessionStorage.getItem('captureDialogJobUid') + return saved || null + }) const pollRef = useRef(null) + // Persist state to sessionStorage + useEffect(() => { + sessionStorage.setItem('captureDialogLocator', locator) + }, [locator]) + + useEffect(() => { + sessionStorage.setItem('captureDialogError', error || '') + }, [error]) + + useEffect(() => { + sessionStorage.setItem('captureDialogBusy', busy) + }, [busy]) + + useEffect(() => { + sessionStorage.setItem('captureDialogJobStatus', jobStatus || '') + }, [jobStatus]) + + useEffect(() => { + sessionStorage.setItem('captureDialogJobUid', jobUid || '') + }, [jobUid]) + + // On mount, resume polling if a job was in progress before page refresh + useEffect(() => { + if (hasResumedPollingRef.current) return + if (!jobUid || jobStatus !== 'running' || !archiveId) return + + hasResumedPollingRef.current = true + + // Resume polling for the saved job + pollRef.current = setInterval(async () => { + try { + const updated = await pollCaptureJob(archiveId, jobUid) + if (updated.status === 'completed') { + clearInterval(pollRef.current) + pollRef.current = null + setBusy(false) + setJobStatus('completed') + clearCaptureState() + dialogRef.current?.close() + onCaptured() + } else if (updated.status === 'failed') { + clearInterval(pollRef.current) + pollRef.current = null + setBusy(false) + setJobStatus('failed') + setError(updated.error_text || 'Capture failed.') + } + // pending / running: keep polling + } catch (pollErr) { + clearInterval(pollRef.current) + pollRef.current = null + setBusy(false) + setError(pollErr.message) + } + }, 500) + }, [jobUid, jobStatus, archiveId, onCaptured]) + + // Handle dialog close event useEffect(() => { const dialog = dialogRef.current if (!dialog) return @@ -20,21 +97,41 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured }) return () => dialog.removeEventListener('close', handleClose) }, [onClose]) + // Handle open/close from parent useEffect(() => { const dialog = dialogRef.current if (!dialog) return + if (open) { - setLocator('') - setError(null) - setJobStatus(null) - setBusy(false) - clearInterval(pollRef.current) + // Only clear state if this is a fresh open from user click (not a restore on first render) + if (!isFirstRenderRef.current) { + setLocator('') + setError(null) + setJobStatus(null) + setBusy(false) + setJobUid(null) + clearInterval(pollRef.current) + } + isFirstRenderRef.current = false if (!dialog.open) dialog.showModal() } else { if (dialog.open) dialog.close() } }, [open]) + function clearCaptureState() { + sessionStorage.removeItem('captureDialogLocator') + sessionStorage.removeItem('captureDialogError') + sessionStorage.removeItem('captureDialogBusy') + sessionStorage.removeItem('captureDialogJobStatus') + sessionStorage.removeItem('captureDialogJobUid') + setLocator('') + setError(null) + setBusy(false) + setJobStatus(null) + setJobUid(null) + } + async function handleSubmit() { if (!locator.trim()) { setError('Enter a locator.'); return } setBusy(true) @@ -42,6 +139,7 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured }) setJobStatus(null) try { const job = await submitCapture(archiveId, locator.trim()) + setJobUid(job.job_uid) setJobStatus('running') pollRef.current = setInterval(async () => { try { @@ -51,6 +149,7 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured }) pollRef.current = null setBusy(false) setJobStatus('completed') + clearCaptureState() dialogRef.current?.close() onCaptured() } else if (updated.status === 'failed') {