1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-10-09 21:03:17 +02:00
archivr/crates/archivr-server/static/assets/index-DdftptO_.js
TheGeneralist 77e8cf41a7
feat(frontend): render Summary rail section + provider selector
New "Summary" rail section between the URL/Preview controls and .meta-list.
A completed summary renders as bold tl;dr, body paragraph, tag chips, and a
provider · model footer; missing or failed shows Generate; pending/running
shows an inline spinner and polls GET every 1500 ms until terminal.

- api.js: fetchEntrySummary + requestEntrySummary. The POST helper unwraps
  ApiError's { "error": ... } body so the missing-env-var message reaches
  the user verbatim rather than as a bare status code.
- ContextRail.jsx: state seeds from detail.latest_summary so the section
  renders immediately on selection. Polling is anchored on the summary
  status rather than started inside the click handler, so a job still
  running when the user navigates away and back is picked up again. A
  transient poll failure is swallowed — the next tick retries, and a real
  failure arrives as status === 'failed'.
- Regenerate passes force:true only when a completed summary is already
  shown; otherwise the request can take the server's 200 cache-hit path.
- Provider choice persists in sessionStorage under archivr:summary:provider,
  with try/catch around both accessors for private-mode browsers.
- Public sessions never see the selector or the Generate button, and the
  section renders at all only when a completed summary made it through the
  server's visibility gate.
- styles.css: .rail-summary-* only; spacing and the action button reuse
  .rail-section and .rail-rearchive-btn. The spinner honours
  prefers-reduced-motion — the text alone conveys the state.
- AGENTS.md: document the summary env vars alongside the existing
  external-tool convention.

Smoke-tested end to end against a scratch archive with a seeded markdown
entry: claude_cli produced a real summary (pending → running → completed in
~11s); a local mock server exercised the openai_compatible transport and
confirmed the Bearer header, model, and system/user role split on the wire;
unconfigured providers return 400 naming the exact variable; a video entry
returns 400 "v1 unsupported"; a repeat POST returns 200 from cache without
adding a row.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 15:47:17 +02:00

47 lines
302 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(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 a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).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 Fu={exports:{}},Ss={},Bu={exports:{}},re={};/**
* @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 dl=Symbol.for("react.element"),ff=Symbol.for("react.portal"),pf=Symbol.for("react.fragment"),hf=Symbol.for("react.strict_mode"),mf=Symbol.for("react.profiler"),gf=Symbol.for("react.provider"),yf=Symbol.for("react.context"),vf=Symbol.for("react.forward_ref"),xf=Symbol.for("react.suspense"),wf=Symbol.for("react.memo"),kf=Symbol.for("react.lazy"),go=Symbol.iterator;function jf(e){return e===null||typeof e!="object"?null:(e=go&&e[go]||e["@@iterator"],typeof e=="function"?e:null)}var Uu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hu=Object.assign,Wu={};function xr(e,t,n){this.props=e,this.context=t,this.refs=Wu,this.updater=n||Uu}xr.prototype.isReactComponent={};xr.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")};xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Vu(){}Vu.prototype=xr.prototype;function ga(e,t,n){this.props=e,this.context=t,this.refs=Wu,this.updater=n||Uu}var ya=ga.prototype=new Vu;ya.constructor=ga;Hu(ya,xr.prototype);ya.isPureReactComponent=!0;var yo=Array.isArray,Qu=Object.prototype.hasOwnProperty,va={current:null},qu={key:!0,ref:!0,__self:!0,__source:!0};function Ku(e,t,n){var r,l={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)Qu.call(t,r)&&!qu.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1<o){for(var u=Array(o),c=0;c<o;c++)u[c]=arguments[c+2];l.children=u}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)l[r]===void 0&&(l[r]=o[r]);return{$$typeof:dl,type:e,key:i,ref:a,props:l,_owner:va.current}}function Sf(e,t){return{$$typeof:dl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function xa(e){return typeof e=="object"&&e!==null&&e.$$typeof===dl}function Nf(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var vo=/\/+/g;function Vs(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Nf(""+e.key):t.toString(36)}function Ol(e,t,n,r,l){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case dl:case ff:a=!0}}if(a)return a=e,l=l(a),e=r===""?"."+Vs(a,0):r,yo(l)?(n="",e!=null&&(n=e.replace(vo,"$&/")+"/"),Ol(l,t,n,"",function(c){return c})):l!=null&&(xa(l)&&(l=Sf(l,n+(!l.key||a&&a.key===l.key?"":(""+l.key).replace(vo,"$&/")+"/")+e)),t.push(l)),1;if(a=0,r=r===""?".":r+":",yo(e))for(var o=0;o<e.length;o++){i=e[o];var u=r+Vs(i,o);a+=Ol(i,t,n,u,l)}else if(u=jf(e),typeof u=="function")for(e=u.call(e),o=0;!(i=e.next()).done;)i=i.value,u=r+Vs(i,o++),a+=Ol(i,t,n,u,l);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function vl(e,t,n){if(e==null)return e;var r=[],l=0;return Ol(e,r,"","",function(i){return t.call(n,i,l++)}),r}function _f(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Ze={current:null},Al={transition:null},Cf={ReactCurrentDispatcher:Ze,ReactCurrentBatchConfig:Al,ReactCurrentOwner:va};function Xu(){throw Error("act(...) is not supported in production builds of React.")}re.Children={map:vl,forEach:function(e,t,n){vl(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return vl(e,function(){t++}),t},toArray:function(e){return vl(e,function(t){return t})||[]},only:function(e){if(!xa(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};re.Component=xr;re.Fragment=pf;re.Profiler=mf;re.PureComponent=ga;re.StrictMode=hf;re.Suspense=xf;re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Cf;re.act=Xu;re.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Hu({},e.props),l=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=va.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(u in t)Qu.call(t,u)&&!qu.hasOwnProperty(u)&&(r[u]=t[u]===void 0&&o!==void 0?o[u]:t[u])}var u=arguments.length-2;if(u===1)r.children=n;else if(1<u){o=Array(u);for(var c=0;c<u;c++)o[c]=arguments[c+2];r.children=o}return{$$typeof:dl,type:e.type,key:l,ref:i,props:r,_owner:a}};re.createContext=function(e){return e={$$typeof:yf,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:gf,_context:e},e.Consumer=e};re.createElement=Ku;re.createFactory=function(e){var t=Ku.bind(null,e);return t.type=e,t};re.createRef=function(){return{current:null}};re.forwardRef=function(e){return{$$typeof:vf,render:e}};re.isValidElement=xa;re.lazy=function(e){return{$$typeof:kf,_payload:{_status:-1,_result:e},_init:_f}};re.memo=function(e,t){return{$$typeof:wf,type:e,compare:t===void 0?null:t}};re.startTransition=function(e){var t=Al.transition;Al.transition={};try{e()}finally{Al.transition=t}};re.unstable_act=Xu;re.useCallback=function(e,t){return Ze.current.useCallback(e,t)};re.useContext=function(e){return Ze.current.useContext(e)};re.useDebugValue=function(){};re.useDeferredValue=function(e){return Ze.current.useDeferredValue(e)};re.useEffect=function(e,t){return Ze.current.useEffect(e,t)};re.useId=function(){return Ze.current.useId()};re.useImperativeHandle=function(e,t,n){return Ze.current.useImperativeHandle(e,t,n)};re.useInsertionEffect=function(e,t){return Ze.current.useInsertionEffect(e,t)};re.useLayoutEffect=function(e,t){return Ze.current.useLayoutEffect(e,t)};re.useMemo=function(e,t){return Ze.current.useMemo(e,t)};re.useReducer=function(e,t,n){return Ze.current.useReducer(e,t,n)};re.useRef=function(e){return Ze.current.useRef(e)};re.useState=function(e){return Ze.current.useState(e)};re.useSyncExternalStore=function(e,t,n){return Ze.current.useSyncExternalStore(e,t,n)};re.useTransition=function(){return Ze.current.useTransition()};re.version="18.3.1";Bu.exports=re;var d=Bu.exports;/**
* @license React
* react-jsx-runtime.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 Ef=d,bf=Symbol.for("react.element"),Tf=Symbol.for("react.fragment"),Pf=Object.prototype.hasOwnProperty,Lf=Ef.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rf={key:!0,ref:!0,__self:!0,__source:!0};function Ju(e,t,n){var r,l={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)Pf.call(t,r)&&!Rf.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:bf,type:e,key:i,ref:a,props:l,_owner:Lf.current}}Ss.Fragment=Tf;Ss.jsx=Ju;Ss.jsxs=Ju;Fu.exports=Ss;var s=Fu.exports,Gu={exports:{}},ft={},Yu={exports:{}},Zu={};/**
* @license React
* scheduler.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.
*/(function(e){function t(D,L){var Q=D.length;D.push(L);e:for(;0<Q;){var K=Q-1>>>1,ee=D[K];if(0<l(ee,L))D[K]=L,D[Q]=ee,Q=K;else break e}}function n(D){return D.length===0?null:D[0]}function r(D){if(D.length===0)return null;var L=D[0],Q=D.pop();if(Q!==L){D[0]=Q;e:for(var K=0,ee=D.length,De=ee>>>1;K<De;){var te=2*(K+1)-1,je=D[te],se=te+1,Pe=D[se];if(0>l(je,Q))se<ee&&0>l(Pe,je)?(D[K]=Pe,D[se]=Q,K=se):(D[K]=je,D[te]=Q,K=te);else if(se<ee&&0>l(Pe,Q))D[K]=Pe,D[se]=Q,K=se;else break e}}return L}function l(D,L){var Q=D.sortIndex-L.sortIndex;return Q!==0?Q:D.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var u=[],c=[],y=1,g=null,h=3,v=!1,x=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(D){for(var L=n(c);L!==null;){if(L.callback===null)r(c);else if(L.startTime<=D)r(c),L.sortIndex=L.expirationTime,t(u,L);else break;L=n(c)}}function w(D){if(S=!1,m(D),!x)if(n(u)!==null)x=!0,$e(E);else{var L=n(c);L!==null&&ge(w,L.startTime-D)}}function E(D,L){x=!1,S&&(S=!1,p(k),k=-1),v=!0;var Q=h;try{for(m(L),g=n(u);g!==null&&(!(g.expirationTime>L)||D&&!G());){var K=g.callback;if(typeof K=="function"){g.callback=null,h=g.priorityLevel;var ee=K(g.expirationTime<=L);L=e.unstable_now(),typeof ee=="function"?g.callback=ee:g===n(u)&&r(u),m(L)}else r(u);g=n(u)}if(g!==null)var De=!0;else{var te=n(c);te!==null&&ge(w,te.startTime-L),De=!1}return De}finally{g=null,h=Q,v=!1}}var b=!1,T=null,k=-1,P=5,R=-1;function G(){return!(e.unstable_now()-R<P)}function B(){if(T!==null){var D=e.unstable_now();R=D;var L=!0;try{L=T(!0,D)}finally{L?Y():(b=!1,T=null)}}else b=!1}var Y;if(typeof f=="function")Y=function(){f(B)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,ce=ne.port2;ne.port1.onmessage=B,Y=function(){ce.postMessage(null)}}else Y=function(){_(B,0)};function $e(D){T=D,b||(b=!0,Y())}function ge(D,L){k=_(function(){D(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(D){D.callback=null},e.unstable_continueExecution=function(){x||v||(x=!0,$e(E))},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(D){switch(h){case 1:case 2:case 3:var L=3;break;default:L=h}var Q=h;h=L;try{return D()}finally{h=Q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(D,L){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var Q=h;h=D;try{return L()}finally{h=Q}},e.unstable_scheduleCallback=function(D,L,Q){var K=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?K+Q:K):Q=K,D){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=Q+ee,D={id:y++,callback:L,priorityLevel:D,startTime:Q,expirationTime:ee,sortIndex:-1},Q>K?(D.sortIndex=Q,t(c,D),n(u)===null&&D===n(c)&&(S?(p(k),k=-1):S=!0,ge(w,Q-K))):(D.sortIndex=ee,t(u,D),x||v||(x=!0,$e(E))),D},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(D){var L=h;return function(){var Q=h;h=L;try{return D.apply(this,arguments)}finally{h=Q}}}})(Zu);Yu.exports=Zu;var zf=Yu.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 If=d,dt=zf;function I(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var ec=new Set,qr={};function On(e,t){fr(e,t),fr(e+"Capture",t)}function fr(e,t){for(qr[e]=t,e=0;e<t.length;e++)ec.add(t[e])}var qt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Si=Object.prototype.hasOwnProperty,$f=/^[: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]*$/,xo={},wo={};function Df(e){return Si.call(wo,e)?!0:Si.call(xo,e)?!1:$f.test(e)?wo[e]=!0:(xo[e]=!0,!1)}function Of(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 Af(e,t,n,r){if(t===null||typeof t>"u"||Of(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 et(e,t,n,r,l,i,a){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=a}var He={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){He[e]=new et(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];He[t]=new et(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){He[e]=new et(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){He[e]=new et(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){He[e]=new et(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){He[e]=new et(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){He[e]=new et(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){He[e]=new et(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){He[e]=new et(e,5,!1,e.toLowerCase(),null,!1,!1)});var wa=/[\-:]([a-z])/g;function ka(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(wa,ka);He[t]=new et(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(wa,ka);He[t]=new et(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(wa,ka);He[t]=new et(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){He[e]=new et(e,1,!1,e.toLowerCase(),null,!1,!1)});He.xlinkHref=new et("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){He[e]=new et(e,1,!1,e.toLowerCase(),null,!0,!0)});function ja(e,t,n,r){var l=He.hasOwnProperty(t)?He[t]:null;(l!==null?l.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Af(t,n,l,r)&&(n=null),r||l===null?Df(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):l.mustUseProperty?e[l.propertyName]=n===null?l.type===3?!1:"":n:(t=l.attributeName,r=l.attributeNamespace,n===null?e.removeAttribute(t):(l=l.type,n=l===3||l===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Gt=If.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,xl=Symbol.for("react.element"),qn=Symbol.for("react.portal"),Kn=Symbol.for("react.fragment"),Sa=Symbol.for("react.strict_mode"),Ni=Symbol.for("react.profiler"),tc=Symbol.for("react.provider"),nc=Symbol.for("react.context"),Na=Symbol.for("react.forward_ref"),_i=Symbol.for("react.suspense"),Ci=Symbol.for("react.suspense_list"),_a=Symbol.for("react.memo"),tn=Symbol.for("react.lazy"),rc=Symbol.for("react.offscreen"),ko=Symbol.iterator;function Sr(e){return e===null||typeof e!="object"?null:(e=ko&&e[ko]||e["@@iterator"],typeof e=="function"?e:null)}var ke=Object.assign,Qs;function Rr(e){if(Qs===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Qs=t&&t[1]||""}return`
`+Qs+e}var qs=!1;function Ks(e,t){if(!e||qs)return"";qs=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var l=c.stack.split(`
`),i=r.stack.split(`
`),a=l.length-1,o=i.length-1;1<=a&&0<=o&&l[a]!==i[o];)o--;for(;1<=a&&0<=o;a--,o--)if(l[a]!==i[o]){if(a!==1||o!==1)do if(a--,o--,0>o||l[a]!==i[o]){var u=`
`+l[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=o);break}}}finally{qs=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Rr(e):""}function Mf(e){switch(e.tag){case 5:return Rr(e.type);case 16:return Rr("Lazy");case 13:return Rr("Suspense");case 19:return Rr("SuspenseList");case 0:case 2:case 15:return e=Ks(e.type,!1),e;case 11:return e=Ks(e.type.render,!1),e;case 1:return e=Ks(e.type,!0),e;default:return""}}function Ei(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 Kn:return"Fragment";case qn:return"Portal";case Ni:return"Profiler";case Sa:return"StrictMode";case _i:return"Suspense";case Ci:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case nc:return(e.displayName||"Context")+".Consumer";case tc:return(e._context.displayName||"Context")+".Provider";case Na:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _a:return t=e.displayName||null,t!==null?t:Ei(e.type)||"Memo";case tn:t=e._payload,e=e._init;try{return Ei(e(t))}catch{}}return null}function Ff(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 Ei(t);case 8:return t===Sa?"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 gn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function lc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Bf(e){var t=lc(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(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wl(e){e._valueTracker||(e._valueTracker=Bf(e))}function sc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=lc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Gl(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 bi(e,t){var n=t.checked;return ke({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function jo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=gn(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 ic(e,t){t=t.checked,t!=null&&ja(e,"checked",t,!1)}function Ti(e,t){ic(e,t);var n=gn(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")?Pi(e,t.type,n):t.hasOwnProperty("defaultValue")&&Pi(e,t.type,gn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function So(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 Pi(e,t,n){(t!=="number"||Gl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zr=Array.isArray;function sr(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t["$"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty("$"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=""+gn(n),t=null,l=0;l<e.length;l++){if(e[l].value===n){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Li(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(I(91));return ke({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function No(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(I(92));if(zr(n)){if(1<n.length)throw Error(I(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:gn(n)}}function ac(e,t){var n=gn(t.value),r=gn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function _o(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function oc(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ri(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?oc(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var kl,uc=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,l)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(kl=kl||document.createElement("div"),kl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=kl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Kr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ar={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},Uf=["Webkit","ms","Moz","O"];Object.keys(Ar).forEach(function(e){Uf.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ar[t]=Ar[e]})});function cc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ar.hasOwnProperty(e)&&Ar[e]?(""+t).trim():t+"px"}function dc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=cc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Hf=ke({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 zi(e,t){if(t){if(Hf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(I(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(I(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(I(61))}if(t.style!=null&&typeof t.style!="object")throw Error(I(62))}}function Ii(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 $i=null;function Ca(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Di=null,ir=null,ar=null;function Co(e){if(e=hl(e)){if(typeof Di!="function")throw Error(I(280));var t=e.stateNode;t&&(t=bs(t),Di(e.stateNode,e.type,t))}}function fc(e){ir?ar?ar.push(e):ar=[e]:ir=e}function pc(){if(ir){var e=ir,t=ar;if(ar=ir=null,Co(e),t)for(e=0;e<t.length;e++)Co(t[e])}}function hc(e,t){return e(t)}function mc(){}var Xs=!1;function gc(e,t,n){if(Xs)return e(t,n);Xs=!0;try{return hc(e,t,n)}finally{Xs=!1,(ir!==null||ar!==null)&&(mc(),pc())}}function Xr(e,t){var n=e.stateNode;if(n===null)return null;var r=bs(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(I(231,t,typeof n));return n}var Oi=!1;if(qt)try{var Nr={};Object.defineProperty(Nr,"passive",{get:function(){Oi=!0}}),window.addEventListener("test",Nr,Nr),window.removeEventListener("test",Nr,Nr)}catch{Oi=!1}function Wf(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(y){this.onError(y)}}var Mr=!1,Yl=null,Zl=!1,Ai=null,Vf={onError:function(e){Mr=!0,Yl=e}};function Qf(e,t,n,r,l,i,a,o,u){Mr=!1,Yl=null,Wf.apply(Vf,arguments)}function qf(e,t,n,r,l,i,a,o,u){if(Qf.apply(this,arguments),Mr){if(Mr){var c=Yl;Mr=!1,Yl=null}else throw Error(I(198));Zl||(Zl=!0,Ai=c)}}function An(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function yc(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Eo(e){if(An(e)!==e)throw Error(I(188))}function Kf(e){var t=e.alternate;if(!t){if(t=An(e),t===null)throw Error(I(188));return t!==e?null:e}for(var n=e,r=t;;){var l=n.return;if(l===null)break;var i=l.alternate;if(i===null){if(r=l.return,r!==null){n=r;continue}break}if(l.child===i.child){for(i=l.child;i;){if(i===n)return Eo(l),e;if(i===r)return Eo(l),t;i=i.sibling}throw Error(I(188))}if(n.return!==r.return)n=l,r=i;else{for(var a=!1,o=l.child;o;){if(o===n){a=!0,n=l,r=i;break}if(o===r){a=!0,r=l,n=i;break}o=o.sibling}if(!a){for(o=i.child;o;){if(o===n){a=!0,n=i,r=l;break}if(o===r){a=!0,r=i,n=l;break}o=o.sibling}if(!a)throw Error(I(189))}}if(n.alternate!==r)throw Error(I(190))}if(n.tag!==3)throw Error(I(188));return n.stateNode.current===n?e:t}function vc(e){return e=Kf(e),e!==null?xc(e):null}function xc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=xc(e);if(t!==null)return t;e=e.sibling}return null}var wc=dt.unstable_scheduleCallback,bo=dt.unstable_cancelCallback,Xf=dt.unstable_shouldYield,Jf=dt.unstable_requestPaint,_e=dt.unstable_now,Gf=dt.unstable_getCurrentPriorityLevel,Ea=dt.unstable_ImmediatePriority,kc=dt.unstable_UserBlockingPriority,es=dt.unstable_NormalPriority,Yf=dt.unstable_LowPriority,jc=dt.unstable_IdlePriority,Ns=null,Ot=null;function Zf(e){if(Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot(Ns,e,void 0,(e.current.flags&128)===128)}catch{}}var Ct=Math.clz32?Math.clz32:np,ep=Math.log,tp=Math.LN2;function np(e){return e>>>=0,e===0?32:31-(ep(e)/tp|0)|0}var jl=64,Sl=4194304;function Ir(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 ts(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var o=a&~l;o!==0?r=Ir(o):(i&=a,i!==0&&(r=Ir(i)))}else a=n&~l,a!==0?r=Ir(a):i!==0&&(r=Ir(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;0<t;)n=31-Ct(t),l=1<<n,r|=e[n],t&=~l;return r}function rp(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function lp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Ct(i),o=1<<a,u=l[a];u===-1?(!(o&n)||o&r)&&(l[a]=rp(o,t)):u<=t&&(e.expiredLanes|=o),i&=~o}}function Mi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Sc(){var e=jl;return jl<<=1,!(jl&4194240)&&(jl=64),e}function Js(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function fl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ct(t),e[t]=n}function sp(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<n;){var l=31-Ct(n),i=1<<l;t[l]=0,r[l]=-1,e[l]=-1,n&=~i}}function ba(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ct(n),l=1<<r;l&t|e[r]&t&&(e[r]|=t),n&=~l}}var ue=0;function Nc(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var _c,Ta,Cc,Ec,bc,Fi=!1,Nl=[],on=null,un=null,cn=null,Jr=new Map,Gr=new Map,rn=[],ip="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function To(e,t){switch(e){case"focusin":case"focusout":on=null;break;case"dragenter":case"dragleave":un=null;break;case"mouseover":case"mouseout":cn=null;break;case"pointerover":case"pointerout":Jr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gr.delete(t.pointerId)}}function _r(e,t,n,r,l,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[l]},t!==null&&(t=hl(t),t!==null&&Ta(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function ap(e,t,n,r,l){switch(t){case"focusin":return on=_r(on,e,t,n,r,l),!0;case"dragenter":return un=_r(un,e,t,n,r,l),!0;case"mouseover":return cn=_r(cn,e,t,n,r,l),!0;case"pointerover":var i=l.pointerId;return Jr.set(i,_r(Jr.get(i)||null,e,t,n,r,l)),!0;case"gotpointercapture":return i=l.pointerId,Gr.set(i,_r(Gr.get(i)||null,e,t,n,r,l)),!0}return!1}function Tc(e){var t=Cn(e.target);if(t!==null){var n=An(t);if(n!==null){if(t=n.tag,t===13){if(t=yc(n),t!==null){e.blockedOn=t,bc(e.priority,function(){Cc(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ml(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Bi(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);$i=r,n.target.dispatchEvent(r),$i=null}else return t=hl(n),t!==null&&Ta(t),e.blockedOn=n,!1;t.shift()}return!0}function Po(e,t,n){Ml(e)&&n.delete(t)}function op(){Fi=!1,on!==null&&Ml(on)&&(on=null),un!==null&&Ml(un)&&(un=null),cn!==null&&Ml(cn)&&(cn=null),Jr.forEach(Po),Gr.forEach(Po)}function Cr(e,t){e.blockedOn===t&&(e.blockedOn=null,Fi||(Fi=!0,dt.unstable_scheduleCallback(dt.unstable_NormalPriority,op)))}function Yr(e){function t(l){return Cr(l,e)}if(0<Nl.length){Cr(Nl[0],e);for(var n=1;n<Nl.length;n++){var r=Nl[n];r.blockedOn===e&&(r.blockedOn=null)}}for(on!==null&&Cr(on,e),un!==null&&Cr(un,e),cn!==null&&Cr(cn,e),Jr.forEach(t),Gr.forEach(t),n=0;n<rn.length;n++)r=rn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<rn.length&&(n=rn[0],n.blockedOn===null);)Tc(n),n.blockedOn===null&&rn.shift()}var or=Gt.ReactCurrentBatchConfig,ns=!0;function up(e,t,n,r){var l=ue,i=or.transition;or.transition=null;try{ue=1,Pa(e,t,n,r)}finally{ue=l,or.transition=i}}function cp(e,t,n,r){var l=ue,i=or.transition;or.transition=null;try{ue=4,Pa(e,t,n,r)}finally{ue=l,or.transition=i}}function Pa(e,t,n,r){if(ns){var l=Bi(e,t,n,r);if(l===null)ii(e,t,r,rs,n),To(e,r);else if(ap(l,e,t,n,r))r.stopPropagation();else if(To(e,r),t&4&&-1<ip.indexOf(e)){for(;l!==null;){var i=hl(l);if(i!==null&&_c(i),i=Bi(e,t,n,r),i===null&&ii(e,t,r,rs,n),i===l)break;l=i}l!==null&&r.stopPropagation()}else ii(e,t,r,null,n)}}var rs=null;function Bi(e,t,n,r){if(rs=null,e=Ca(r),e=Cn(e),e!==null)if(t=An(e),t===null)e=null;else if(n=t.tag,n===13){if(e=yc(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return rs=e,null}function Pc(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Gf()){case Ea:return 1;case kc:return 4;case es:case Yf:return 16;case jc:return 536870912;default:return 16}default:return 16}}var sn=null,La=null,Fl=null;function Lc(){if(Fl)return Fl;var e,t=La,n=t.length,r,l="value"in sn?sn.value:sn.textContent,i=l.length;for(e=0;e<n&&t[e]===l[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===l[i-r];r++);return Fl=l.slice(e,1<r?1-r:void 0)}function Bl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function _l(){return!0}function Lo(){return!1}function pt(e){function t(n,r,l,i,a){this._reactName=n,this._targetInst=l,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(n=e[o],this[o]=n?n(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?_l:Lo,this.isPropagationStopped=Lo,this}return ke(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=_l)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=_l)},persist:function(){},isPersistent:_l}),t}var wr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ra=pt(wr),pl=ke({},wr,{view:0,detail:0}),dp=pt(pl),Gs,Ys,Er,_s=ke({},pl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:za,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Er&&(Er&&e.type==="mousemove"?(Gs=e.screenX-Er.screenX,Ys=e.screenY-Er.screenY):Ys=Gs=0,Er=e),Gs)},movementY:function(e){return"movementY"in e?e.movementY:Ys}}),Ro=pt(_s),fp=ke({},_s,{dataTransfer:0}),pp=pt(fp),hp=ke({},pl,{relatedTarget:0}),Zs=pt(hp),mp=ke({},wr,{animationName:0,elapsedTime:0,pseudoElement:0}),gp=pt(mp),yp=ke({},wr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),vp=pt(yp),xp=ke({},wr,{data:0}),zo=pt(xp),wp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kp={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},jp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sp(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=jp[e])?!!t[e]:!1}function za(){return Sp}var Np=ke({},pl,{key:function(e){if(e.key){var t=wp[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Bl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?kp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:za,charCode:function(e){return e.type==="keypress"?Bl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Bl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),_p=pt(Np),Cp=ke({},_s,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Io=pt(Cp),Ep=ke({},pl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:za}),bp=pt(Ep),Tp=ke({},wr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Pp=pt(Tp),Lp=ke({},_s,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Rp=pt(Lp),zp=[9,13,27,32],Ia=qt&&"CompositionEvent"in window,Fr=null;qt&&"documentMode"in document&&(Fr=document.documentMode);var Ip=qt&&"TextEvent"in window&&!Fr,Rc=qt&&(!Ia||Fr&&8<Fr&&11>=Fr),$o=" ",Do=!1;function zc(e,t){switch(e){case"keyup":return zp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ic(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xn=!1;function $p(e,t){switch(e){case"compositionend":return Ic(t);case"keypress":return t.which!==32?null:(Do=!0,$o);case"textInput":return e=t.data,e===$o&&Do?null:e;default:return null}}function Dp(e,t){if(Xn)return e==="compositionend"||!Ia&&zc(e,t)?(e=Lc(),Fl=La=sn=null,Xn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Rc&&t.locale!=="ko"?null:t.data;default:return null}}var Op={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Oo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Op[e.type]:t==="textarea"}function $c(e,t,n,r){fc(r),t=ls(t,"onChange"),0<t.length&&(n=new Ra("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Br=null,Zr=null;function Ap(e){Qc(e,0)}function Cs(e){var t=Yn(e);if(sc(t))return e}function Mp(e,t){if(e==="change")return t}var Dc=!1;if(qt){var ei;if(qt){var ti="oninput"in document;if(!ti){var Ao=document.createElement("div");Ao.setAttribute("oninput","return;"),ti=typeof Ao.oninput=="function"}ei=ti}else ei=!1;Dc=ei&&(!document.documentMode||9<document.documentMode)}function Mo(){Br&&(Br.detachEvent("onpropertychange",Oc),Zr=Br=null)}function Oc(e){if(e.propertyName==="value"&&Cs(Zr)){var t=[];$c(t,Zr,e,Ca(e)),gc(Ap,t)}}function Fp(e,t,n){e==="focusin"?(Mo(),Br=t,Zr=n,Br.attachEvent("onpropertychange",Oc)):e==="focusout"&&Mo()}function Bp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Cs(Zr)}function Up(e,t){if(e==="click")return Cs(t)}function Hp(e,t){if(e==="input"||e==="change")return Cs(t)}function Wp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var bt=typeof Object.is=="function"?Object.is:Wp;function el(e,t){if(bt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var l=n[r];if(!Si.call(t,l)||!bt(e[l],t[l]))return!1}return!0}function Fo(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Bo(e,t){var n=Fo(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=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=Fo(n)}}function Ac(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ac(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Mc(){for(var e=window,t=Gl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gl(e.document)}return t}function $a(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 Vp(e){var t=Mc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ac(n.ownerDocument.documentElement,n)){if(r!==null&&$a(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=Bo(n,i);var a=Bo(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Qp=qt&&"documentMode"in document&&11>=document.documentMode,Jn=null,Ui=null,Ur=null,Hi=!1;function Uo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hi||Jn==null||Jn!==Gl(r)||(r=Jn,"selectionStart"in r&&$a(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}),Ur&&el(Ur,r)||(Ur=r,r=ls(Ui,"onSelect"),0<r.length&&(t=new Ra("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Jn)))}function Cl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Gn={animationend:Cl("Animation","AnimationEnd"),animationiteration:Cl("Animation","AnimationIteration"),animationstart:Cl("Animation","AnimationStart"),transitionend:Cl("Transition","TransitionEnd")},ni={},Fc={};qt&&(Fc=document.createElement("div").style,"AnimationEvent"in window||(delete Gn.animationend.animation,delete Gn.animationiteration.animation,delete Gn.animationstart.animation),"TransitionEvent"in window||delete Gn.transitionend.transition);function Es(e){if(ni[e])return ni[e];if(!Gn[e])return e;var t=Gn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Fc)return ni[e]=t[n];return e}var Bc=Es("animationend"),Uc=Es("animationiteration"),Hc=Es("animationstart"),Wc=Es("transitionend"),Vc=new Map,Ho="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function vn(e,t){Vc.set(e,t),On(t,[e])}for(var ri=0;ri<Ho.length;ri++){var li=Ho[ri],qp=li.toLowerCase(),Kp=li[0].toUpperCase()+li.slice(1);vn(qp,"on"+Kp)}vn(Bc,"onAnimationEnd");vn(Uc,"onAnimationIteration");vn(Hc,"onAnimationStart");vn("dblclick","onDoubleClick");vn("focusin","onFocus");vn("focusout","onBlur");vn(Wc,"onTransitionEnd");fr("onMouseEnter",["mouseout","mouseover"]);fr("onMouseLeave",["mouseout","mouseover"]);fr("onPointerEnter",["pointerout","pointerover"]);fr("onPointerLeave",["pointerout","pointerover"]);On("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));On("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));On("onBeforeInput",["compositionend","keypress","textInput","paste"]);On("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));On("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));On("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $r="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xp=new Set("cancel close invalid load scroll toggle".split(" ").concat($r));function Wo(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,qf(r,t,void 0,e),e.currentTarget=null}function Qc(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],l=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var o=r[a],u=o.instance,c=o.currentTarget;if(o=o.listener,u!==i&&l.isPropagationStopped())break e;Wo(l,o,c),i=u}else for(a=0;a<r.length;a++){if(o=r[a],u=o.instance,c=o.currentTarget,o=o.listener,u!==i&&l.isPropagationStopped())break e;Wo(l,o,c),i=u}}}if(Zl)throw e=Ai,Zl=!1,Ai=null,e}function he(e,t){var n=t[Ki];n===void 0&&(n=t[Ki]=new Set);var r=e+"__bubble";n.has(r)||(qc(t,e,2,!1),n.add(r))}function si(e,t,n){var r=0;t&&(r|=4),qc(n,e,r,t)}var El="_reactListening"+Math.random().toString(36).slice(2);function tl(e){if(!e[El]){e[El]=!0,ec.forEach(function(n){n!=="selectionchange"&&(Xp.has(n)||si(n,!1,e),si(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[El]||(t[El]=!0,si("selectionchange",!1,t))}}function qc(e,t,n,r){switch(Pc(t)){case 1:var l=up;break;case 4:l=cp;break;default:l=Pa}n=l.bind(null,t,n,e),l=void 0,!Oi||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),r?l!==void 0?e.addEventListener(t,n,{capture:!0,passive:l}):e.addEventListener(t,n,!0):l!==void 0?e.addEventListener(t,n,{passive:l}):e.addEventListener(t,n,!1)}function ii(e,t,n,r,l){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var o=r.stateNode.containerInfo;if(o===l||o.nodeType===8&&o.parentNode===l)break;if(a===4)for(a=r.return;a!==null;){var u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===l||u.nodeType===8&&u.parentNode===l))return;a=a.return}for(;o!==null;){if(a=Cn(o),a===null)return;if(u=a.tag,u===5||u===6){r=i=a;continue e}o=o.parentNode}}r=r.return}gc(function(){var c=i,y=Ca(n),g=[];e:{var h=Vc.get(e);if(h!==void 0){var v=Ra,x=e;switch(e){case"keypress":if(Bl(n)===0)break e;case"keydown":case"keyup":v=_p;break;case"focusin":x="focus",v=Zs;break;case"focusout":x="blur",v=Zs;break;case"beforeblur":case"afterblur":v=Zs;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":v=Ro;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=pp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=bp;break;case Bc:case Uc:case Hc:v=gp;break;case Wc:v=Pp;break;case"scroll":v=dp;break;case"wheel":v=Rp;break;case"copy":case"cut":case"paste":v=vp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=Io}var S=(t&4)!==0,_=!S&&e==="scroll",p=S?h!==null?h+"Capture":null:h;S=[];for(var f=c,m;f!==null;){m=f;var w=m.stateNode;if(m.tag===5&&w!==null&&(m=w,p!==null&&(w=Xr(f,p),w!=null&&S.push(nl(f,w,m)))),_)break;f=f.return}0<S.length&&(h=new v(h,x,null,n,y),g.push({event:h,listeners:S}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",h&&n!==$i&&(x=n.relatedTarget||n.fromElement)&&(Cn(x)||x[Kt]))break e;if((v||h)&&(h=y.window===y?y:(h=y.ownerDocument)?h.defaultView||h.parentWindow:window,v?(x=n.relatedTarget||n.toElement,v=c,x=x?Cn(x):null,x!==null&&(_=An(x),x!==_||x.tag!==5&&x.tag!==6)&&(x=null)):(v=null,x=c),v!==x)){if(S=Ro,w="onMouseLeave",p="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(S=Io,w="onPointerLeave",p="onPointerEnter",f="pointer"),_=v==null?h:Yn(v),m=x==null?h:Yn(x),h=new S(w,f+"leave",v,n,y),h.target=_,h.relatedTarget=m,w=null,Cn(y)===c&&(S=new S(p,f+"enter",x,n,y),S.target=m,S.relatedTarget=_,w=S),_=w,v&&x)t:{for(S=v,p=x,f=0,m=S;m;m=Vn(m))f++;for(m=0,w=p;w;w=Vn(w))m++;for(;0<f-m;)S=Vn(S),f--;for(;0<m-f;)p=Vn(p),m--;for(;f--;){if(S===p||p!==null&&S===p.alternate)break t;S=Vn(S),p=Vn(p)}S=null}else S=null;v!==null&&Vo(g,h,v,S,!1),x!==null&&_!==null&&Vo(g,_,x,S,!0)}}e:{if(h=c?Yn(c):window,v=h.nodeName&&h.nodeName.toLowerCase(),v==="select"||v==="input"&&h.type==="file")var E=Mp;else if(Oo(h))if(Dc)E=Hp;else{E=Bp;var b=Fp}else(v=h.nodeName)&&v.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(E=Up);if(E&&(E=E(e,c))){$c(g,E,n,y);break e}b&&b(e,h,c),e==="focusout"&&(b=h._wrapperState)&&b.controlled&&h.type==="number"&&Pi(h,"number",h.value)}switch(b=c?Yn(c):window,e){case"focusin":(Oo(b)||b.contentEditable==="true")&&(Jn=b,Ui=c,Ur=null);break;case"focusout":Ur=Ui=Jn=null;break;case"mousedown":Hi=!0;break;case"contextmenu":case"mouseup":case"dragend":Hi=!1,Uo(g,n,y);break;case"selectionchange":if(Qp)break;case"keydown":case"keyup":Uo(g,n,y)}var T;if(Ia)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Xn?zc(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(Rc&&n.locale!=="ko"&&(Xn||k!=="onCompositionStart"?k==="onCompositionEnd"&&Xn&&(T=Lc()):(sn=y,La="value"in sn?sn.value:sn.textContent,Xn=!0)),b=ls(c,k),0<b.length&&(k=new zo(k,e,null,n,y),g.push({event:k,listeners:b}),T?k.data=T:(T=Ic(n),T!==null&&(k.data=T)))),(T=Ip?$p(e,n):Dp(e,n))&&(c=ls(c,"onBeforeInput"),0<c.length&&(y=new zo("onBeforeInput","beforeinput",null,n,y),g.push({event:y,listeners:c}),y.data=T))}Qc(g,t)})}function nl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ls(e,t){for(var n=t+"Capture",r=[];e!==null;){var l=e,i=l.stateNode;l.tag===5&&i!==null&&(l=i,i=Xr(e,n),i!=null&&r.unshift(nl(e,i,l)),i=Xr(e,t),i!=null&&r.push(nl(e,i,l))),e=e.return}return r}function Vn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Vo(e,t,n,r,l){for(var i=t._reactName,a=[];n!==null&&n!==r;){var o=n,u=o.alternate,c=o.stateNode;if(u!==null&&u===r)break;o.tag===5&&c!==null&&(o=c,l?(u=Xr(n,i),u!=null&&a.unshift(nl(n,u,o))):l||(u=Xr(n,i),u!=null&&a.push(nl(n,u,o)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var Jp=/\r\n?/g,Gp=/\u0000|\uFFFD/g;function Qo(e){return(typeof e=="string"?e:""+e).replace(Jp,`
`).replace(Gp,"")}function bl(e,t,n){if(t=Qo(t),Qo(e)!==t&&n)throw Error(I(425))}function ss(){}var Wi=null,Vi=null;function Qi(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var qi=typeof setTimeout=="function"?setTimeout:void 0,Yp=typeof clearTimeout=="function"?clearTimeout:void 0,qo=typeof Promise=="function"?Promise:void 0,Zp=typeof queueMicrotask=="function"?queueMicrotask:typeof qo<"u"?function(e){return qo.resolve(null).then(e).catch(eh)}:qi;function eh(e){setTimeout(function(){throw e})}function ai(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(r===0){e.removeChild(l),Yr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=l}while(n);Yr(t)}function dn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Ko(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var kr=Math.random().toString(36).slice(2),Dt="__reactFiber$"+kr,rl="__reactProps$"+kr,Kt="__reactContainer$"+kr,Ki="__reactEvents$"+kr,th="__reactListeners$"+kr,nh="__reactHandles$"+kr;function Cn(e){var t=e[Dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Kt]||n[Dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ko(e);e!==null;){if(n=e[Dt])return n;e=Ko(e)}return t}e=n,n=e.parentNode}return null}function hl(e){return e=e[Dt]||e[Kt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Yn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(I(33))}function bs(e){return e[rl]||null}var Xi=[],Zn=-1;function xn(e){return{current:e}}function me(e){0>Zn||(e.current=Xi[Zn],Xi[Zn]=null,Zn--)}function fe(e,t){Zn++,Xi[Zn]=e.current,e.current=t}var yn={},Ke=xn(yn),rt=xn(!1),Rn=yn;function pr(e,t){var n=e.type.contextTypes;if(!n)return yn;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 lt(e){return e=e.childContextTypes,e!=null}function is(){me(rt),me(Ke)}function Xo(e,t,n){if(Ke.current!==yn)throw Error(I(168));fe(Ke,t),fe(rt,n)}function Kc(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(I(108,Ff(e)||"Unknown",l));return ke({},n,r)}function as(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||yn,Rn=Ke.current,fe(Ke,e),fe(rt,rt.current),!0}function Jo(e,t,n){var r=e.stateNode;if(!r)throw Error(I(169));n?(e=Kc(e,t,Rn),r.__reactInternalMemoizedMergedChildContext=e,me(rt),me(Ke),fe(Ke,e)):me(rt),fe(rt,n)}var Ht=null,Ts=!1,oi=!1;function Xc(e){Ht===null?Ht=[e]:Ht.push(e)}function rh(e){Ts=!0,Xc(e)}function wn(){if(!oi&&Ht!==null){oi=!0;var e=0,t=ue;try{var n=Ht;for(ue=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ht=null,Ts=!1}catch(l){throw Ht!==null&&(Ht=Ht.slice(e+1)),wc(Ea,wn),l}finally{ue=t,oi=!1}}return null}var er=[],tr=0,os=null,us=0,gt=[],yt=0,zn=null,Wt=1,Vt="";function Nn(e,t){er[tr++]=us,er[tr++]=os,os=e,us=t}function Jc(e,t,n){gt[yt++]=Wt,gt[yt++]=Vt,gt[yt++]=zn,zn=e;var r=Wt;e=Vt;var l=32-Ct(r)-1;r&=~(1<<l),n+=1;var i=32-Ct(t)+l;if(30<i){var a=l-l%5;i=(r&(1<<a)-1).toString(32),r>>=a,l-=a,Wt=1<<32-Ct(t)+l|n<<l|r,Vt=i+e}else Wt=1<<i|n<<l|r,Vt=e}function Da(e){e.return!==null&&(Nn(e,1),Jc(e,1,0))}function Oa(e){for(;e===os;)os=er[--tr],er[tr]=null,us=er[--tr],er[tr]=null;for(;e===zn;)zn=gt[--yt],gt[yt]=null,Vt=gt[--yt],gt[yt]=null,Wt=gt[--yt],gt[yt]=null}var ct=null,ut=null,ve=!1,_t=null;function Gc(e,t){var n=vt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Go(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ct=e,ut=dn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ct=e,ut=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=zn!==null?{id:Wt,overflow:Vt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=vt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ct=e,ut=null,!0):!1;default:return!1}}function Ji(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Gi(e){if(ve){var t=ut;if(t){var n=t;if(!Go(e,t)){if(Ji(e))throw Error(I(418));t=dn(n.nextSibling);var r=ct;t&&Go(e,t)?Gc(r,n):(e.flags=e.flags&-4097|2,ve=!1,ct=e)}}else{if(Ji(e))throw Error(I(418));e.flags=e.flags&-4097|2,ve=!1,ct=e}}}function Yo(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ct=e}function Tl(e){if(e!==ct)return!1;if(!ve)return Yo(e),ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Qi(e.type,e.memoizedProps)),t&&(t=ut)){if(Ji(e))throw Yc(),Error(I(418));for(;t;)Gc(e,t),t=dn(t.nextSibling)}if(Yo(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(I(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ut=dn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ut=null}}else ut=ct?dn(e.stateNode.nextSibling):null;return!0}function Yc(){for(var e=ut;e;)e=dn(e.nextSibling)}function hr(){ut=ct=null,ve=!1}function Aa(e){_t===null?_t=[e]:_t.push(e)}var lh=Gt.ReactCurrentBatchConfig;function br(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(I(309));var r=n.stateNode}if(!r)throw Error(I(147,e));var l=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var o=l.refs;a===null?delete o[i]:o[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(I(284));if(!n._owner)throw Error(I(290,e))}return e}function Pl(e,t){throw e=Object.prototype.toString.call(t),Error(I(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Zo(e){var t=e._init;return t(e._payload)}function Zc(e){function t(p,f){if(e){var m=p.deletions;m===null?(p.deletions=[f],p.flags|=16):m.push(f)}}function n(p,f){if(!e)return null;for(;f!==null;)t(p,f),f=f.sibling;return null}function r(p,f){for(p=new Map;f!==null;)f.key!==null?p.set(f.key,f):p.set(f.index,f),f=f.sibling;return p}function l(p,f){return p=mn(p,f),p.index=0,p.sibling=null,p}function i(p,f,m){return p.index=m,e?(m=p.alternate,m!==null?(m=m.index,m<f?(p.flags|=2,f):m):(p.flags|=2,f)):(p.flags|=1048576,f)}function a(p){return e&&p.alternate===null&&(p.flags|=2),p}function o(p,f,m,w){return f===null||f.tag!==6?(f=mi(m,p.mode,w),f.return=p,f):(f=l(f,m),f.return=p,f)}function u(p,f,m,w){var E=m.type;return E===Kn?y(p,f,m.props.children,w,m.key):f!==null&&(f.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===tn&&Zo(E)===f.type)?(w=l(f,m.props),w.ref=br(p,f,m),w.return=p,w):(w=Kl(m.type,m.key,m.props,null,p.mode,w),w.ref=br(p,f,m),w.return=p,w)}function c(p,f,m,w){return f===null||f.tag!==4||f.stateNode.containerInfo!==m.containerInfo||f.stateNode.implementation!==m.implementation?(f=gi(m,p.mode,w),f.return=p,f):(f=l(f,m.children||[]),f.return=p,f)}function y(p,f,m,w,E){return f===null||f.tag!==7?(f=Ln(m,p.mode,w,E),f.return=p,f):(f=l(f,m),f.return=p,f)}function g(p,f,m){if(typeof f=="string"&&f!==""||typeof f=="number")return f=mi(""+f,p.mode,m),f.return=p,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case xl:return m=Kl(f.type,f.key,f.props,null,p.mode,m),m.ref=br(p,null,f),m.return=p,m;case qn:return f=gi(f,p.mode,m),f.return=p,f;case tn:var w=f._init;return g(p,w(f._payload),m)}if(zr(f)||Sr(f))return f=Ln(f,p.mode,m,null),f.return=p,f;Pl(p,f)}return null}function h(p,f,m,w){var E=f!==null?f.key:null;if(typeof m=="string"&&m!==""||typeof m=="number")return E!==null?null:o(p,f,""+m,w);if(typeof m=="object"&&m!==null){switch(m.$$typeof){case xl:return m.key===E?u(p,f,m,w):null;case qn:return m.key===E?c(p,f,m,w):null;case tn:return E=m._init,h(p,f,E(m._payload),w)}if(zr(m)||Sr(m))return E!==null?null:y(p,f,m,w,null);Pl(p,m)}return null}function v(p,f,m,w,E){if(typeof w=="string"&&w!==""||typeof w=="number")return p=p.get(m)||null,o(f,p,""+w,E);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case xl:return p=p.get(w.key===null?m:w.key)||null,u(f,p,w,E);case qn:return p=p.get(w.key===null?m:w.key)||null,c(f,p,w,E);case tn:var b=w._init;return v(p,f,m,b(w._payload),E)}if(zr(w)||Sr(w))return p=p.get(m)||null,y(f,p,w,E,null);Pl(f,w)}return null}function x(p,f,m,w){for(var E=null,b=null,T=f,k=f=0,P=null;T!==null&&k<m.length;k++){T.index>k?(P=T,T=null):P=T.sibling;var R=h(p,T,m[k],w);if(R===null){T===null&&(T=P);break}e&&T&&R.alternate===null&&t(p,T),f=i(R,f,k),b===null?E=R:b.sibling=R,b=R,T=P}if(k===m.length)return n(p,T),ve&&Nn(p,k),E;if(T===null){for(;k<m.length;k++)T=g(p,m[k],w),T!==null&&(f=i(T,f,k),b===null?E=T:b.sibling=T,b=T);return ve&&Nn(p,k),E}for(T=r(p,T);k<m.length;k++)P=v(T,p,k,m[k],w),P!==null&&(e&&P.alternate!==null&&T.delete(P.key===null?k:P.key),f=i(P,f,k),b===null?E=P:b.sibling=P,b=P);return e&&T.forEach(function(G){return t(p,G)}),ve&&Nn(p,k),E}function S(p,f,m,w){var E=Sr(m);if(typeof E!="function")throw Error(I(150));if(m=E.call(m),m==null)throw Error(I(151));for(var b=E=null,T=f,k=f=0,P=null,R=m.next();T!==null&&!R.done;k++,R=m.next()){T.index>k?(P=T,T=null):P=T.sibling;var G=h(p,T,R.value,w);if(G===null){T===null&&(T=P);break}e&&T&&G.alternate===null&&t(p,T),f=i(G,f,k),b===null?E=G:b.sibling=G,b=G,T=P}if(R.done)return n(p,T),ve&&Nn(p,k),E;if(T===null){for(;!R.done;k++,R=m.next())R=g(p,R.value,w),R!==null&&(f=i(R,f,k),b===null?E=R:b.sibling=R,b=R);return ve&&Nn(p,k),E}for(T=r(p,T);!R.done;k++,R=m.next())R=v(T,p,k,R.value,w),R!==null&&(e&&R.alternate!==null&&T.delete(R.key===null?k:R.key),f=i(R,f,k),b===null?E=R:b.sibling=R,b=R);return e&&T.forEach(function(B){return t(p,B)}),ve&&Nn(p,k),E}function _(p,f,m,w){if(typeof m=="object"&&m!==null&&m.type===Kn&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case xl:e:{for(var E=m.key,b=f;b!==null;){if(b.key===E){if(E=m.type,E===Kn){if(b.tag===7){n(p,b.sibling),f=l(b,m.props.children),f.return=p,p=f;break e}}else if(b.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===tn&&Zo(E)===b.type){n(p,b.sibling),f=l(b,m.props),f.ref=br(p,b,m),f.return=p,p=f;break e}n(p,b);break}else t(p,b);b=b.sibling}m.type===Kn?(f=Ln(m.props.children,p.mode,w,m.key),f.return=p,p=f):(w=Kl(m.type,m.key,m.props,null,p.mode,w),w.ref=br(p,f,m),w.return=p,p=w)}return a(p);case qn:e:{for(b=m.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(p,f.sibling),f=l(f,m.children||[]),f.return=p,p=f;break e}else{n(p,f);break}else t(p,f);f=f.sibling}f=gi(m,p.mode,w),f.return=p,p=f}return a(p);case tn:return b=m._init,_(p,f,b(m._payload),w)}if(zr(m))return x(p,f,m,w);if(Sr(m))return S(p,f,m,w);Pl(p,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(p,f.sibling),f=l(f,m),f.return=p,p=f):(n(p,f),f=mi(m,p.mode,w),f.return=p,p=f),a(p)):n(p,f)}return _}var mr=Zc(!0),ed=Zc(!1),cs=xn(null),ds=null,nr=null,Ma=null;function Fa(){Ma=nr=ds=null}function Ba(e){var t=cs.current;me(cs),e._currentValue=t}function Yi(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 ur(e,t){ds=e,Ma=nr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(nt=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(Ma!==e)if(e={context:e,memoizedValue:t,next:null},nr===null){if(ds===null)throw Error(I(308));nr=e,ds.dependencies={lanes:0,firstContext:e}}else nr=nr.next=e;return t}var En=null;function Ua(e){En===null?En=[e]:En.push(e)}function td(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ua(t)):(n.next=l.next,l.next=n),t.interleaved=n,Xt(e,r)}function Xt(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 nn=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function nd(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 Qt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function fn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,le&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Xt(e,n)}return l=r.interleaved,l===null?(t.next=t,Ua(r)):(t.next=l.next,l.next=t),r.interleaved=t,Xt(e,n)}function Ul(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,ba(e,n)}}function eu(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 a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=a:i=i.next=a,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 fs(e,t,n,r){var l=e.updateQueue;nn=!1;var i=l.firstBaseUpdate,a=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var u=o,c=u.next;u.next=null,a===null?i=c:a.next=c,a=u;var y=e.alternate;y!==null&&(y=y.updateQueue,o=y.lastBaseUpdate,o!==a&&(o===null?y.firstBaseUpdate=c:o.next=c,y.lastBaseUpdate=u))}if(i!==null){var g=l.baseState;a=0,y=c=u=null,o=i;do{var h=o.lane,v=o.eventTime;if((r&h)===h){y!==null&&(y=y.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var x=e,S=o;switch(h=t,v=n,S.tag){case 1:if(x=S.payload,typeof x=="function"){g=x.call(v,g,h);break e}g=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=S.payload,h=typeof x=="function"?x.call(v,g,h):x,h==null)break e;g=ke({},g,h);break e;case 2:nn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[o]:h.push(o))}else v={eventTime:v,lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},y===null?(c=y=v,u=g):y=y.next=v,a|=h;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;h=o,o=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(y===null&&(u=g),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=y,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);$n|=a,e.lanes=a,e.memoizedState=g}}function tu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],l=r.callback;if(l!==null){if(r.callback=null,r=n,typeof l!="function")throw Error(I(191,l));l.call(r)}}}var ml={},At=xn(ml),ll=xn(ml),sl=xn(ml);function bn(e){if(e===ml)throw Error(I(174));return e}function Wa(e,t){switch(fe(sl,t),fe(ll,e),fe(At,ml),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ri(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ri(t,e)}me(At),fe(At,t)}function gr(){me(At),me(ll),me(sl)}function rd(e){bn(sl.current);var t=bn(At.current),n=Ri(t,e.type);t!==n&&(fe(ll,e),fe(At,n))}function Va(e){ll.current===e&&(me(At),me(ll))}var xe=xn(0);function ps(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ui=[];function Qa(){for(var e=0;e<ui.length;e++)ui[e]._workInProgressVersionPrimary=null;ui.length=0}var Hl=Gt.ReactCurrentDispatcher,ci=Gt.ReactCurrentBatchConfig,In=0,we=null,ze=null,Me=null,hs=!1,Hr=!1,il=0,sh=0;function Ve(){throw Error(I(321))}function qa(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!bt(e[n],t[n]))return!1;return!0}function Ka(e,t,n,r,l,i){if(In=i,we=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Hl.current=e===null||e.memoizedState===null?uh:ch,e=n(r,l),Hr){i=0;do{if(Hr=!1,il=0,25<=i)throw Error(I(301));i+=1,Me=ze=null,t.updateQueue=null,Hl.current=dh,e=n(r,l)}while(Hr)}if(Hl.current=ms,t=ze!==null&&ze.next!==null,In=0,Me=ze=we=null,hs=!1,t)throw Error(I(300));return e}function Xa(){var e=il!==0;return il=0,e}function $t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?we.memoizedState=Me=e:Me=Me.next=e,Me}function kt(){if(ze===null){var e=we.alternate;e=e!==null?e.memoizedState:null}else e=ze.next;var t=Me===null?we.memoizedState:Me.next;if(t!==null)Me=t,ze=e;else{if(e===null)throw Error(I(310));ze=e,e={memoizedState:ze.memoizedState,baseState:ze.baseState,baseQueue:ze.baseQueue,queue:ze.queue,next:null},Me===null?we.memoizedState=Me=e:Me=Me.next=e}return Me}function al(e,t){return typeof t=="function"?t(e):t}function di(e){var t=kt(),n=t.queue;if(n===null)throw Error(I(311));n.lastRenderedReducer=e;var r=ze,l=r.baseQueue,i=n.pending;if(i!==null){if(l!==null){var a=l.next;l.next=i.next,i.next=a}r.baseQueue=l=i,n.pending=null}if(l!==null){i=l.next,r=r.baseState;var o=a=null,u=null,c=i;do{var y=c.lane;if((In&y)===y)u!==null&&(u=u.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var g={lane:y,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};u===null?(o=u=g,a=r):u=u.next=g,we.lanes|=y,$n|=y}c=c.next}while(c!==null&&c!==i);u===null?a=r:u.next=o,bt(r,t.memoizedState)||(nt=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=u,n.lastRenderedState=r}if(e=n.interleaved,e!==null){l=e;do i=l.lane,we.lanes|=i,$n|=i,l=l.next;while(l!==e)}else l===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function fi(e){var t=kt(),n=t.queue;if(n===null)throw Error(I(311));n.lastRenderedReducer=e;var r=n.dispatch,l=n.pending,i=t.memoizedState;if(l!==null){n.pending=null;var a=l=l.next;do i=e(i,a.action),a=a.next;while(a!==l);bt(i,t.memoizedState)||(nt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function ld(){}function sd(e,t){var n=we,r=kt(),l=t(),i=!bt(r.memoizedState,l);if(i&&(r.memoizedState=l,nt=!0),r=r.queue,Ja(od.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Me!==null&&Me.memoizedState.tag&1){if(n.flags|=2048,ol(9,ad.bind(null,n,r,l,t),void 0,null),Fe===null)throw Error(I(349));In&30||id(n,t,l)}return l}function id(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=we.updateQueue,t===null?(t={lastEffect:null,stores:null},we.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ad(e,t,n,r){t.value=n,t.getSnapshot=r,ud(t)&&cd(e)}function od(e,t,n){return n(function(){ud(t)&&cd(e)})}function ud(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!bt(e,n)}catch{return!0}}function cd(e){var t=Xt(e,1);t!==null&&Et(t,e,1,-1)}function nu(e){var t=$t();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:e},t.queue=e,e=e.dispatch=oh.bind(null,we,e),[t.memoizedState,e]}function ol(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=we.updateQueue,t===null?(t={lastEffect:null,stores:null},we.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function dd(){return kt().memoizedState}function Wl(e,t,n,r){var l=$t();we.flags|=e,l.memoizedState=ol(1|t,n,void 0,r===void 0?null:r)}function Ps(e,t,n,r){var l=kt();r=r===void 0?null:r;var i=void 0;if(ze!==null){var a=ze.memoizedState;if(i=a.destroy,r!==null&&qa(r,a.deps)){l.memoizedState=ol(t,n,i,r);return}}we.flags|=e,l.memoizedState=ol(1|t,n,i,r)}function ru(e,t){return Wl(8390656,8,e,t)}function Ja(e,t){return Ps(2048,8,e,t)}function fd(e,t){return Ps(4,2,e,t)}function pd(e,t){return Ps(4,4,e,t)}function hd(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function md(e,t,n){return n=n!=null?n.concat([e]):null,Ps(4,4,hd.bind(null,t,e),n)}function Ga(){}function gd(e,t){var n=kt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&qa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function yd(e,t){var n=kt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&qa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function vd(e,t,n){return In&21?(bt(n,t)||(n=Sc(),we.lanes|=n,$n|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,nt=!0),e.memoizedState=n)}function ih(e,t){var n=ue;ue=n!==0&&4>n?n:4,e(!0);var r=ci.transition;ci.transition={};try{e(!1),t()}finally{ue=n,ci.transition=r}}function xd(){return kt().memoizedState}function ah(e,t,n){var r=hn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},wd(e))kd(t,n);else if(n=td(e,t,n,r),n!==null){var l=Ye();Et(n,e,r,l),jd(n,t,r)}}function oh(e,t,n){var r=hn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(wd(e))kd(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,o=i(a,n);if(l.hasEagerState=!0,l.eagerState=o,bt(o,a)){var u=t.interleaved;u===null?(l.next=l,Ua(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=td(e,t,l,r),n!==null&&(l=Ye(),Et(n,e,r,l),jd(n,t,r))}}function wd(e){var t=e.alternate;return e===we||t!==null&&t===we}function kd(e,t){Hr=hs=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function jd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ba(e,n)}}var ms={readContext:wt,useCallback:Ve,useContext:Ve,useEffect:Ve,useImperativeHandle:Ve,useInsertionEffect:Ve,useLayoutEffect:Ve,useMemo:Ve,useReducer:Ve,useRef:Ve,useState:Ve,useDebugValue:Ve,useDeferredValue:Ve,useTransition:Ve,useMutableSource:Ve,useSyncExternalStore:Ve,useId:Ve,unstable_isNewReconciler:!1},uh={readContext:wt,useCallback:function(e,t){return $t().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:ru,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Wl(4194308,4,hd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Wl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Wl(4,2,e,t)},useMemo:function(e,t){var n=$t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=$t();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=ah.bind(null,we,e),[r.memoizedState,e]},useRef:function(e){var t=$t();return e={current:e},t.memoizedState=e},useState:nu,useDebugValue:Ga,useDeferredValue:function(e){return $t().memoizedState=e},useTransition:function(){var e=nu(!1),t=e[0];return e=ih.bind(null,e[1]),$t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=we,l=$t();if(ve){if(n===void 0)throw Error(I(407));n=n()}else{if(n=t(),Fe===null)throw Error(I(349));In&30||id(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,ru(od.bind(null,r,i,e),[e]),r.flags|=2048,ol(9,ad.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=$t(),t=Fe.identifierPrefix;if(ve){var n=Vt,r=Wt;n=(r&~(1<<32-Ct(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=il++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=sh++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ch={readContext:wt,useCallback:gd,useContext:wt,useEffect:Ja,useImperativeHandle:md,useInsertionEffect:fd,useLayoutEffect:pd,useMemo:yd,useReducer:di,useRef:dd,useState:function(){return di(al)},useDebugValue:Ga,useDeferredValue:function(e){var t=kt();return vd(t,ze.memoizedState,e)},useTransition:function(){var e=di(al)[0],t=kt().memoizedState;return[e,t]},useMutableSource:ld,useSyncExternalStore:sd,useId:xd,unstable_isNewReconciler:!1},dh={readContext:wt,useCallback:gd,useContext:wt,useEffect:Ja,useImperativeHandle:md,useInsertionEffect:fd,useLayoutEffect:pd,useMemo:yd,useReducer:fi,useRef:dd,useState:function(){return fi(al)},useDebugValue:Ga,useDeferredValue:function(e){var t=kt();return ze===null?t.memoizedState=e:vd(t,ze.memoizedState,e)},useTransition:function(){var e=fi(al)[0],t=kt().memoizedState;return[e,t]},useMutableSource:ld,useSyncExternalStore:sd,useId:xd,unstable_isNewReconciler:!1};function St(e,t){if(e&&e.defaultProps){t=ke({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Zi(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ke({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ls={isMounted:function(e){return(e=e._reactInternals)?An(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ye(),l=hn(e),i=Qt(r,l);i.payload=t,n!=null&&(i.callback=n),t=fn(e,i,l),t!==null&&(Et(t,e,l,r),Ul(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ye(),l=hn(e),i=Qt(r,l);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=fn(e,i,l),t!==null&&(Et(t,e,l,r),Ul(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ye(),r=hn(e),l=Qt(n,r);l.tag=2,t!=null&&(l.callback=t),t=fn(e,l,r),t!==null&&(Et(t,e,r,n),Ul(t,e,r))}};function lu(e,t,n,r,l,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!el(n,r)||!el(l,i):!0}function Sd(e,t,n){var r=!1,l=yn,i=t.contextType;return typeof i=="object"&&i!==null?i=wt(i):(l=lt(t)?Rn:Ke.current,r=t.contextTypes,i=(r=r!=null)?pr(e,l):yn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ls,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function su(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ls.enqueueReplaceState(t,t.state,null)}function ea(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs={},Ha(e);var i=t.contextType;typeof i=="object"&&i!==null?l.context=wt(i):(i=lt(t)?Rn:Ke.current,l.context=pr(e,i)),l.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Zi(e,t,i,n),l.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof l.getSnapshotBeforeUpdate=="function"||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(t=l.state,typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount(),t!==l.state&&Ls.enqueueReplaceState(l,l.state,null),fs(e,n,l,r),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function yr(e,t){try{var n="",r=t;do n+=Mf(r),r=r.return;while(r);var l=n}catch(i){l=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:l,digest:null}}function pi(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ta(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var fh=typeof WeakMap=="function"?WeakMap:Map;function Nd(e,t,n){n=Qt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ys||(ys=!0,da=r),ta(e,t)},n}function _d(e,t,n){n=Qt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){ta(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){ta(e,t),typeof r!="function"&&(pn===null?pn=new Set([this]):pn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function iu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new fh;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=Ch.bind(null,e,t,n),t.then(e,e))}function au(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function ou(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Qt(-1,1),t.tag=2,fn(n,t,1))),n.lanes|=1),e)}var ph=Gt.ReactCurrentOwner,nt=!1;function Ge(e,t,n,r){t.child=e===null?ed(t,null,n,r):mr(t,e.child,n,r)}function uu(e,t,n,r,l){n=n.render;var i=t.ref;return ur(t,l),r=Ka(e,t,n,r,i,l),n=Xa(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Jt(e,t,l)):(ve&&n&&Da(t),t.flags|=1,Ge(e,t,r,l),t.child)}function cu(e,t,n,r,l){if(e===null){var i=n.type;return typeof i=="function"&&!so(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Cd(e,t,i,r,l)):(e=Kl(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&l)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:el,n(a,r)&&e.ref===t.ref)return Jt(e,t,l)}return t.flags|=1,e=mn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Cd(e,t,n,r,l){if(e!==null){var i=e.memoizedProps;if(el(i,r)&&e.ref===t.ref)if(nt=!1,t.pendingProps=r=i,(e.lanes&l)!==0)e.flags&131072&&(nt=!0);else return t.lanes=e.lanes,Jt(e,t,l)}return na(e,t,n,r,l)}function Ed(e,t,n){var r=t.pendingProps,l=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},fe(lr,at),at|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,fe(lr,at),at|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,fe(lr,at),at|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,fe(lr,at),at|=r;return Ge(e,t,l,n),t.child}function bd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function na(e,t,n,r,l){var i=lt(n)?Rn:Ke.current;return i=pr(t,i),ur(t,l),n=Ka(e,t,n,r,i,l),r=Xa(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Jt(e,t,l)):(ve&&r&&Da(t),t.flags|=1,Ge(e,t,n,l),t.child)}function du(e,t,n,r,l){if(lt(n)){var i=!0;as(t)}else i=!1;if(ur(t,l),t.stateNode===null)Vl(e,t),Sd(t,n,r),ea(t,n,r,l),r=!0;else if(e===null){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,c=n.contextType;typeof c=="object"&&c!==null?c=wt(c):(c=lt(n)?Rn:Ke.current,c=pr(t,c));var y=n.getDerivedStateFromProps,g=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function";g||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==r||u!==c)&&su(t,a,r,c),nn=!1;var h=t.memoizedState;a.state=h,fs(t,r,a,l),u=t.memoizedState,o!==r||h!==u||rt.current||nn?(typeof y=="function"&&(Zi(t,n,y,r),u=t.memoizedState),(o=nn||lu(t,n,o,r,h,u,c))?(g||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=c,r=o):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,nd(e,t),o=t.memoizedProps,c=t.type===t.elementType?o:St(t.type,o),a.props=c,g=t.pendingProps,h=a.context,u=n.contextType,typeof u=="object"&&u!==null?u=wt(u):(u=lt(n)?Rn:Ke.current,u=pr(t,u));var v=n.getDerivedStateFromProps;(y=typeof v=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==g||h!==u)&&su(t,a,r,u),nn=!1,h=t.memoizedState,a.state=h,fs(t,r,a,l);var x=t.memoizedState;o!==g||h!==x||rt.current||nn?(typeof v=="function"&&(Zi(t,n,v,r),x=t.memoizedState),(c=nn||lu(t,n,c,r,h,x,u)||!1)?(y||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,x,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,x,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||o===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),a.props=r,a.state=x,a.context=u,r=c):(typeof a.componentDidUpdate!="function"||o===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return ra(e,t,n,r,i,l)}function ra(e,t,n,r,l,i){bd(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return l&&Jo(t,n,!1),Jt(e,t,i);r=t.stateNode,ph.current=t;var o=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=mr(t,e.child,null,i),t.child=mr(t,null,o,i)):Ge(e,t,o,i),t.memoizedState=r.state,l&&Jo(t,n,!0),t.child}function Td(e){var t=e.stateNode;t.pendingContext?Xo(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Xo(e,t.context,!1),Wa(e,t.containerInfo)}function fu(e,t,n,r,l){return hr(),Aa(l),t.flags|=256,Ge(e,t,n,r),t.child}var la={dehydrated:null,treeContext:null,retryLane:0};function sa(e){return{baseLanes:e,cachePool:null,transitions:null}}function Pd(e,t,n){var r=t.pendingProps,l=xe.current,i=!1,a=(t.flags&128)!==0,o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:(l&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),fe(xe,l&1),e===null)return Gi(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Is(a,r,0,null),e=Ln(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=sa(n),t.memoizedState=la,e):Ya(t,a));if(l=e.memoizedState,l!==null&&(o=l.dehydrated,o!==null))return hh(e,t,a,r,o,l,n);if(i){i=r.fallback,a=t.mode,l=e.child,o=l.sibling;var u={mode:"hidden",children:r.children};return!(a&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=mn(l,u),r.subtreeFlags=l.subtreeFlags&14680064),o!==null?i=mn(o,i):(i=Ln(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?sa(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=la,r}return i=e.child,e=i.sibling,r=mn(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ya(e,t){return t=Is({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ll(e,t,n,r){return r!==null&&Aa(r),mr(t,e.child,null,n),e=Ya(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function hh(e,t,n,r,l,i,a){if(n)return t.flags&256?(t.flags&=-257,r=pi(Error(I(422))),Ll(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,l=t.mode,r=Is({mode:"visible",children:r.children},l,0,null),i=Ln(i,l,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&mr(t,e.child,null,a),t.child.memoizedState=sa(a),t.memoizedState=la,i);if(!(t.mode&1))return Ll(e,t,a,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(I(419)),r=pi(i,r,void 0),Ll(e,t,a,r)}if(o=(a&e.childLanes)!==0,nt||o){if(r=Fe,r!==null){switch(a&-a){case 4:l=2;break;case 16:l=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|a)?0:l,l!==0&&l!==i.retryLane&&(i.retryLane=l,Xt(e,l),Et(r,e,l,-1))}return lo(),r=pi(Error(I(421))),Ll(e,t,a,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Eh.bind(null,e),l._reactRetry=t,null):(e=i.treeContext,ut=dn(l.nextSibling),ct=t,ve=!0,_t=null,e!==null&&(gt[yt++]=Wt,gt[yt++]=Vt,gt[yt++]=zn,Wt=e.id,Vt=e.overflow,zn=t),t=Ya(t,r.children),t.flags|=4096,t)}function pu(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Yi(e.return,t,n)}function hi(e,t,n,r,l){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=l)}function Ld(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(Ge(e,t,r.children,n),r=xe.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&pu(e,n,t);else if(e.tag===19)pu(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(fe(xe,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(n=t.child,l=null;n!==null;)e=n.alternate,e!==null&&ps(e)===null&&(l=n),n=n.sibling;n=l,n===null?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),hi(t,!1,l,n,i);break;case"backwards":for(n=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&ps(e)===null){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}hi(t,!0,n,null,i);break;case"together":hi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Vl(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Jt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$n|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(I(153));if(t.child!==null){for(e=t.child,n=mn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=mn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function mh(e,t,n){switch(t.tag){case 3:Td(t),hr();break;case 5:rd(t);break;case 1:lt(t.type)&&as(t);break;case 4:Wa(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;fe(cs,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(fe(xe,xe.current&1),t.flags|=128,null):n&t.child.childLanes?Pd(e,t,n):(fe(xe,xe.current&1),e=Jt(e,t,n),e!==null?e.sibling:null);fe(xe,xe.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Ld(e,t,n);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),fe(xe,xe.current),r)break;return null;case 22:case 23:return t.lanes=0,Ed(e,t,n)}return Jt(e,t,n)}var Rd,ia,zd,Id;Rd=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};ia=function(){};zd=function(e,t,n,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,bn(At.current);var i=null;switch(n){case"input":l=bi(e,l),r=bi(e,r),i=[];break;case"select":l=ke({},l,{value:void 0}),r=ke({},r,{value:void 0}),i=[];break;case"textarea":l=Li(e,l),r=Li(e,r),i=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ss)}zi(n,r);var a;n=null;for(c in l)if(!r.hasOwnProperty(c)&&l.hasOwnProperty(c)&&l[c]!=null)if(c==="style"){var o=l[c];for(a in o)o.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(qr.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in r){var u=r[c];if(o=l!=null?l[c]:void 0,r.hasOwnProperty(c)&&u!==o&&(u!=null||o!=null))if(c==="style")if(o){for(a in o)!o.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in u)u.hasOwnProperty(a)&&o[a]!==u[a]&&(n||(n={}),n[a]=u[a])}else n||(i||(i=[]),i.push(c,n)),n=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,o=o?o.__html:void 0,u!=null&&o!==u&&(i=i||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(qr.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&he("scroll",e),i||o===u||(i=[])):(i=i||[]).push(c,u))}n&&(i=i||[]).push("style",n);var c=i;(t.updateQueue=c)&&(t.flags|=4)}};Id=function(e,t,n,r){n!==r&&(t.flags|=4)};function Tr(e,t){if(!ve)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Qe(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function gh(e,t,n){var r=t.pendingProps;switch(Oa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qe(t),null;case 1:return lt(t.type)&&is(),Qe(t),null;case 3:return r=t.stateNode,gr(),me(rt),me(Ke),Qa(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Tl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,_t!==null&&(ha(_t),_t=null))),ia(e,t),Qe(t),null;case 5:Va(t);var l=bn(sl.current);if(n=t.type,e!==null&&t.stateNode!=null)zd(e,t,n,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(I(166));return Qe(t),null}if(e=bn(At.current),Tl(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Dt]=t,r[rl]=i,e=(t.mode&1)!==0,n){case"dialog":he("cancel",r),he("close",r);break;case"iframe":case"object":case"embed":he("load",r);break;case"video":case"audio":for(l=0;l<$r.length;l++)he($r[l],r);break;case"source":he("error",r);break;case"img":case"image":case"link":he("error",r),he("load",r);break;case"details":he("toggle",r);break;case"input":jo(r,i),he("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},he("invalid",r);break;case"textarea":No(r,i),he("invalid",r)}zi(n,i),l=null;for(var a in i)if(i.hasOwnProperty(a)){var o=i[a];a==="children"?typeof o=="string"?r.textContent!==o&&(i.suppressHydrationWarning!==!0&&bl(r.textContent,o,e),l=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&bl(r.textContent,o,e),l=["children",""+o]):qr.hasOwnProperty(a)&&o!=null&&a==="onScroll"&&he("scroll",r)}switch(n){case"input":wl(r),So(r,i,!0);break;case"textarea":wl(r),_o(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=ss)}r=l,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=oc(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Dt]=t,e[rl]=r,Rd(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ii(n,r),n){case"dialog":he("cancel",e),he("close",e),l=r;break;case"iframe":case"object":case"embed":he("load",e),l=r;break;case"video":case"audio":for(l=0;l<$r.length;l++)he($r[l],e);l=r;break;case"source":he("error",e),l=r;break;case"img":case"image":case"link":he("error",e),he("load",e),l=r;break;case"details":he("toggle",e),l=r;break;case"input":jo(e,r),l=bi(e,r),he("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=ke({},r,{value:void 0}),he("invalid",e);break;case"textarea":No(e,r),l=Li(e,r),he("invalid",e);break;default:l=r}zi(n,l),o=l;for(i in o)if(o.hasOwnProperty(i)){var u=o[i];i==="style"?dc(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&uc(e,u)):i==="children"?typeof u=="string"?(n!=="textarea"||u!=="")&&Kr(e,u):typeof u=="number"&&Kr(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(qr.hasOwnProperty(i)?u!=null&&i==="onScroll"&&he("scroll",e):u!=null&&ja(e,i,u,a))}switch(n){case"input":wl(e),So(e,r,!1);break;case"textarea":wl(e),_o(e);break;case"option":r.value!=null&&e.setAttribute("value",""+gn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?sr(e,!!r.multiple,i,!1):r.defaultValue!=null&&sr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=ss)}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 Qe(t),null;case 6:if(e&&t.stateNode!=null)Id(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(I(166));if(n=bn(sl.current),bn(At.current),Tl(t)){if(r=t.stateNode,n=t.memoizedProps,r[Dt]=t,(i=r.nodeValue!==n)&&(e=ct,e!==null))switch(e.tag){case 3:bl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&bl(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Dt]=t,t.stateNode=r}return Qe(t),null;case 13:if(me(xe),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ve&&ut!==null&&t.mode&1&&!(t.flags&128))Yc(),hr(),t.flags|=98560,i=!1;else if(i=Tl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(I(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(I(317));i[Dt]=t}else hr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Qe(t),i=!1}else _t!==null&&(ha(_t),_t=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||xe.current&1?Ie===0&&(Ie=3):lo())),t.updateQueue!==null&&(t.flags|=4),Qe(t),null);case 4:return gr(),ia(e,t),e===null&&tl(t.stateNode.containerInfo),Qe(t),null;case 10:return Ba(t.type._context),Qe(t),null;case 17:return lt(t.type)&&is(),Qe(t),null;case 19:if(me(xe),i=t.memoizedState,i===null)return Qe(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Tr(i,!1);else{if(Ie!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ps(e),a!==null){for(t.flags|=128,Tr(i,!1),r=a.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,a=i.alternate,a===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=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return fe(xe,xe.current&1|2),t.child}e=e.sibling}i.tail!==null&&_e()>vr&&(t.flags|=128,r=!0,Tr(i,!1),t.lanes=4194304)}else{if(!r)if(e=ps(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Tr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ve)return Qe(t),null}else 2*_e()-i.renderingStartTime>vr&&n!==1073741824&&(t.flags|=128,r=!0,Tr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=_e(),t.sibling=null,n=xe.current,fe(xe,r?n&1|2:n&1),t):(Qe(t),null);case 22:case 23:return ro(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?at&1073741824&&(Qe(t),t.subtreeFlags&6&&(t.flags|=8192)):Qe(t),null;case 24:return null;case 25:return null}throw Error(I(156,t.tag))}function yh(e,t){switch(Oa(t),t.tag){case 1:return lt(t.type)&&is(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gr(),me(rt),me(Ke),Qa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Va(t),null;case 13:if(me(xe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(I(340));hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return me(xe),null;case 4:return gr(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return ro(),null;case 24:return null;default:return null}}var Rl=!1,qe=!1,vh=typeof WeakSet=="function"?WeakSet:Set,H=null;function rr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ne(e,t,r)}else n.current=null}function aa(e,t,n){try{n()}catch(r){Ne(e,t,r)}}var hu=!1;function xh(e,t){if(Wi=ns,e=Mc(),$a(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 a=0,o=-1,u=-1,c=0,y=0,g=e,h=null;t:for(;;){for(var v;g!==n||l!==0&&g.nodeType!==3||(o=a+l),g!==i||r!==0&&g.nodeType!==3||(u=a+r),g.nodeType===3&&(a+=g.nodeValue.length),(v=g.firstChild)!==null;)h=g,g=v;for(;;){if(g===e)break t;if(h===n&&++c===l&&(o=a),h===i&&++y===r&&(u=a),(v=g.nextSibling)!==null)break;g=h,h=g.parentNode}g=v}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Vi={focusedElem:e,selectionRange:n},ns=!1,H=t;H!==null;)if(t=H,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,H=e;else for(;H!==null;){t=H;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,p=t.stateNode,f=p.getSnapshotBeforeUpdate(t.elementType===t.type?S:St(t.type,S),_);p.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(I(163))}}catch(w){Ne(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,H=e;break}H=t.return}return x=hu,hu=!1,x}function Wr(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&&aa(t,n,i)}l=l.next}while(l!==r)}}function Rs(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 oa(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 $d(e){var t=e.alternate;t!==null&&(e.alternate=null,$d(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Dt],delete t[rl],delete t[Ki],delete t[th],delete t[nh])),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 Dd(e){return e.tag===5||e.tag===3||e.tag===4}function mu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Dd(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 ua(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=ss));else if(r!==4&&(e=e.child,e!==null))for(ua(e,t,n),e=e.sibling;e!==null;)ua(e,t,n),e=e.sibling}function ca(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(ca(e,t,n),e=e.sibling;e!==null;)ca(e,t,n),e=e.sibling}var Be=null,Nt=!1;function en(e,t,n){for(n=n.child;n!==null;)Od(e,t,n),n=n.sibling}function Od(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Ns,n)}catch{}switch(n.tag){case 5:qe||rr(n,t);case 6:var r=Be,l=Nt;Be=null,en(e,t,n),Be=r,Nt=l,Be!==null&&(Nt?(e=Be,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Be.removeChild(n.stateNode));break;case 18:Be!==null&&(Nt?(e=Be,n=n.stateNode,e.nodeType===8?ai(e.parentNode,n):e.nodeType===1&&ai(e,n),Yr(e)):ai(Be,n.stateNode));break;case 4:r=Be,l=Nt,Be=n.stateNode.containerInfo,Nt=!0,en(e,t,n),Be=r,Nt=l;break;case 0:case 11:case 14:case 15:if(!qe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&aa(n,t,a),l=l.next}while(l!==r)}en(e,t,n);break;case 1:if(!qe&&(rr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){Ne(n,t,o)}en(e,t,n);break;case 21:en(e,t,n);break;case 22:n.mode&1?(qe=(r=qe)||n.memoizedState!==null,en(e,t,n),qe=r):en(e,t,n);break;default:en(e,t,n)}}function gu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new vh),t.forEach(function(r){var l=bh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function jt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];try{var i=e,a=t,o=a;e:for(;o!==null;){switch(o.tag){case 5:Be=o.stateNode,Nt=!1;break e;case 3:Be=o.stateNode.containerInfo,Nt=!0;break e;case 4:Be=o.stateNode.containerInfo,Nt=!0;break e}o=o.return}if(Be===null)throw Error(I(160));Od(i,a,l),Be=null,Nt=!1;var u=l.alternate;u!==null&&(u.return=null),l.return=null}catch(c){Ne(l,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Ad(t,e),t=t.sibling}function Ad(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(jt(t,e),zt(e),r&4){try{Wr(3,e,e.return),Rs(3,e)}catch(S){Ne(e,e.return,S)}try{Wr(5,e,e.return)}catch(S){Ne(e,e.return,S)}}break;case 1:jt(t,e),zt(e),r&512&&n!==null&&rr(n,n.return);break;case 5:if(jt(t,e),zt(e),r&512&&n!==null&&rr(n,n.return),e.flags&32){var l=e.stateNode;try{Kr(l,"")}catch(S){Ne(e,e.return,S)}}if(r&4&&(l=e.stateNode,l!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,o=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&ic(l,i),Ii(o,a);var c=Ii(o,i);for(a=0;a<u.length;a+=2){var y=u[a],g=u[a+1];y==="style"?dc(l,g):y==="dangerouslySetInnerHTML"?uc(l,g):y==="children"?Kr(l,g):ja(l,y,g,c)}switch(o){case"input":Ti(l,i);break;case"textarea":ac(l,i);break;case"select":var h=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!i.multiple;var v=i.value;v!=null?sr(l,!!i.multiple,v,!1):h!==!!i.multiple&&(i.defaultValue!=null?sr(l,!!i.multiple,i.defaultValue,!0):sr(l,!!i.multiple,i.multiple?[]:"",!1))}l[rl]=i}catch(S){Ne(e,e.return,S)}}break;case 6:if(jt(t,e),zt(e),r&4){if(e.stateNode===null)throw Error(I(162));l=e.stateNode,i=e.memoizedProps;try{l.nodeValue=i}catch(S){Ne(e,e.return,S)}}break;case 3:if(jt(t,e),zt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Yr(t.containerInfo)}catch(S){Ne(e,e.return,S)}break;case 4:jt(t,e),zt(e);break;case 13:jt(t,e),zt(e),l=e.child,l.flags&8192&&(i=l.memoizedState!==null,l.stateNode.isHidden=i,!i||l.alternate!==null&&l.alternate.memoizedState!==null||(to=_e())),r&4&&gu(e);break;case 22:if(y=n!==null&&n.memoizedState!==null,e.mode&1?(qe=(c=qe)||y,jt(t,e),qe=c):jt(t,e),zt(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!y&&e.mode&1)for(H=e,y=e.child;y!==null;){for(g=H=y;H!==null;){switch(h=H,v=h.child,h.tag){case 0:case 11:case 14:case 15:Wr(4,h,h.return);break;case 1:rr(h,h.return);var x=h.stateNode;if(typeof x.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(S){Ne(r,n,S)}}break;case 5:rr(h,h.return);break;case 22:if(h.memoizedState!==null){vu(g);continue}}v!==null?(v.return=h,H=v):vu(g)}y=y.sibling}e:for(y=null,g=e;;){if(g.tag===5){if(y===null){y=g;try{l=g.stateNode,c?(i=l.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=g.stateNode,u=g.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,o.style.display=cc("display",a))}catch(S){Ne(e,e.return,S)}}}else if(g.tag===6){if(y===null)try{g.stateNode.nodeValue=c?"":g.memoizedProps}catch(S){Ne(e,e.return,S)}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===e)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===e)break e;for(;g.sibling===null;){if(g.return===null||g.return===e)break e;y===g&&(y=null),g=g.return}y===g&&(y=null),g.sibling.return=g.return,g=g.sibling}}break;case 19:jt(t,e),zt(e),r&4&&gu(e);break;case 21:break;default:jt(t,e),zt(e)}}function zt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Dd(n)){var r=n;break e}n=n.return}throw Error(I(160))}switch(r.tag){case 5:var l=r.stateNode;r.flags&32&&(Kr(l,""),r.flags&=-33);var i=mu(e);ca(e,i,l);break;case 3:case 4:var a=r.stateNode.containerInfo,o=mu(e);ua(e,o,a);break;default:throw Error(I(161))}}catch(u){Ne(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wh(e,t,n){H=e,Md(e)}function Md(e,t,n){for(var r=(e.mode&1)!==0;H!==null;){var l=H,i=l.child;if(l.tag===22&&r){var a=l.memoizedState!==null||Rl;if(!a){var o=l.alternate,u=o!==null&&o.memoizedState!==null||qe;o=Rl;var c=qe;if(Rl=a,(qe=u)&&!c)for(H=l;H!==null;)a=H,u=a.child,a.tag===22&&a.memoizedState!==null?xu(l):u!==null?(u.return=a,H=u):xu(l);for(;i!==null;)H=i,Md(i),i=i.sibling;H=l,Rl=o,qe=c}yu(e)}else l.subtreeFlags&8772&&i!==null?(i.return=l,H=i):yu(e)}}function yu(e){for(;H!==null;){var t=H;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:qe||Rs(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!qe)if(n===null)r.componentDidMount();else{var l=t.elementType===t.type?n.memoizedProps:St(t.type,n.memoizedProps);r.componentDidUpdate(l,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&tu(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}tu(t,a,n)}break;case 5:var o=t.stateNode;if(n===null&&t.flags&4){n=o;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&n.focus();break;case"img":u.src&&(n.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var y=c.memoizedState;if(y!==null){var g=y.dehydrated;g!==null&&Yr(g)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(I(163))}qe||t.flags&512&&oa(t)}catch(h){Ne(t,t.return,h)}}if(t===e){H=null;break}if(n=t.sibling,n!==null){n.return=t.return,H=n;break}H=t.return}}function vu(e){for(;H!==null;){var t=H;if(t===e){H=null;break}var n=t.sibling;if(n!==null){n.return=t.return,H=n;break}H=t.return}}function xu(e){for(;H!==null;){var t=H;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Rs(4,t)}catch(u){Ne(t,n,u)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var l=t.return;try{r.componentDidMount()}catch(u){Ne(t,l,u)}}var i=t.return;try{oa(t)}catch(u){Ne(t,i,u)}break;case 5:var a=t.return;try{oa(t)}catch(u){Ne(t,a,u)}}}catch(u){Ne(t,t.return,u)}if(t===e){H=null;break}var o=t.sibling;if(o!==null){o.return=t.return,H=o;break}H=t.return}}var kh=Math.ceil,gs=Gt.ReactCurrentDispatcher,Za=Gt.ReactCurrentOwner,xt=Gt.ReactCurrentBatchConfig,le=0,Fe=null,Te=null,Ue=0,at=0,lr=xn(0),Ie=0,ul=null,$n=0,zs=0,eo=0,Vr=null,tt=null,to=0,vr=1/0,Ut=null,ys=!1,da=null,pn=null,zl=!1,an=null,vs=0,Qr=0,fa=null,Ql=-1,ql=0;function Ye(){return le&6?_e():Ql!==-1?Ql:Ql=_e()}function hn(e){return e.mode&1?le&2&&Ue!==0?Ue&-Ue:lh.transition!==null?(ql===0&&(ql=Sc()),ql):(e=ue,e!==0||(e=window.event,e=e===void 0?16:Pc(e.type)),e):1}function Et(e,t,n,r){if(50<Qr)throw Qr=0,fa=null,Error(I(185));fl(e,n,r),(!(le&2)||e!==Fe)&&(e===Fe&&(!(le&2)&&(zs|=n),Ie===4&&ln(e,Ue)),st(e,r),n===1&&le===0&&!(t.mode&1)&&(vr=_e()+500,Ts&&wn()))}function st(e,t){var n=e.callbackNode;lp(e,t);var r=ts(e,e===Fe?Ue:0);if(r===0)n!==null&&bo(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&bo(n),t===1)e.tag===0?rh(wu.bind(null,e)):Xc(wu.bind(null,e)),Zp(function(){!(le&6)&&wn()}),n=null;else{switch(Nc(r)){case 1:n=Ea;break;case 4:n=kc;break;case 16:n=es;break;case 536870912:n=jc;break;default:n=es}n=qd(n,Fd.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Fd(e,t){if(Ql=-1,ql=0,le&6)throw Error(I(327));var n=e.callbackNode;if(cr()&&e.callbackNode!==n)return null;var r=ts(e,e===Fe?Ue:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=xs(e,r);else{t=r;var l=le;le|=2;var i=Ud();(Fe!==e||Ue!==t)&&(Ut=null,vr=_e()+500,Pn(e,t));do try{Nh();break}catch(o){Bd(e,o)}while(!0);Fa(),gs.current=i,le=l,Te!==null?t=0:(Fe=null,Ue=0,t=Ie)}if(t!==0){if(t===2&&(l=Mi(e),l!==0&&(r=l,t=pa(e,l))),t===1)throw n=ul,Pn(e,0),ln(e,r),st(e,_e()),n;if(t===6)ln(e,r);else{if(l=e.current.alternate,!(r&30)&&!jh(l)&&(t=xs(e,r),t===2&&(i=Mi(e),i!==0&&(r=i,t=pa(e,i))),t===1))throw n=ul,Pn(e,0),ln(e,r),st(e,_e()),n;switch(e.finishedWork=l,e.finishedLanes=r,t){case 0:case 1:throw Error(I(345));case 2:_n(e,tt,Ut);break;case 3:if(ln(e,r),(r&130023424)===r&&(t=to+500-_e(),10<t)){if(ts(e,0)!==0)break;if(l=e.suspendedLanes,(l&r)!==r){Ye(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=qi(_n.bind(null,e,tt,Ut),t);break}_n(e,tt,Ut);break;case 4:if(ln(e,r),(r&4194240)===r)break;for(t=e.eventTimes,l=-1;0<r;){var a=31-Ct(r);i=1<<a,a=t[a],a>l&&(l=a),r&=~i}if(r=l,r=_e()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*kh(r/1960))-r,10<r){e.timeoutHandle=qi(_n.bind(null,e,tt,Ut),r);break}_n(e,tt,Ut);break;case 5:_n(e,tt,Ut);break;default:throw Error(I(329))}}}return st(e,_e()),e.callbackNode===n?Fd.bind(null,e):null}function pa(e,t){var n=Vr;return e.current.memoizedState.isDehydrated&&(Pn(e,t).flags|=256),e=xs(e,t),e!==2&&(t=tt,tt=n,t!==null&&ha(t)),e}function ha(e){tt===null?tt=e:tt.push.apply(tt,e)}function jh(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var l=n[r],i=l.getSnapshot;l=l.value;try{if(!bt(i(),l))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ln(e,t){for(t&=~eo,t&=~zs,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ct(t),r=1<<n;e[n]=-1,t&=~r}}function wu(e){if(le&6)throw Error(I(327));cr();var t=ts(e,0);if(!(t&1))return st(e,_e()),null;var n=xs(e,t);if(e.tag!==0&&n===2){var r=Mi(e);r!==0&&(t=r,n=pa(e,r))}if(n===1)throw n=ul,Pn(e,0),ln(e,t),st(e,_e()),n;if(n===6)throw Error(I(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,_n(e,tt,Ut),st(e,_e()),null}function no(e,t){var n=le;le|=1;try{return e(t)}finally{le=n,le===0&&(vr=_e()+500,Ts&&wn())}}function Dn(e){an!==null&&an.tag===0&&!(le&6)&&cr();var t=le;le|=1;var n=xt.transition,r=ue;try{if(xt.transition=null,ue=1,e)return e()}finally{ue=r,xt.transition=n,le=t,!(le&6)&&wn()}}function ro(){at=lr.current,me(lr)}function Pn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Yp(n)),Te!==null)for(n=Te.return;n!==null;){var r=n;switch(Oa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&is();break;case 3:gr(),me(rt),me(Ke),Qa();break;case 5:Va(r);break;case 4:gr();break;case 13:me(xe);break;case 19:me(xe);break;case 10:Ba(r.type._context);break;case 22:case 23:ro()}n=n.return}if(Fe=e,Te=e=mn(e.current,null),Ue=at=t,Ie=0,ul=null,eo=zs=$n=0,tt=Vr=null,En!==null){for(t=0;t<En.length;t++)if(n=En[t],r=n.interleaved,r!==null){n.interleaved=null;var l=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=l,r.next=a}n.pending=r}En=null}return e}function Bd(e,t){do{var n=Te;try{if(Fa(),Hl.current=ms,hs){for(var r=we.memoizedState;r!==null;){var l=r.queue;l!==null&&(l.pending=null),r=r.next}hs=!1}if(In=0,Me=ze=we=null,Hr=!1,il=0,Za.current=null,n===null||n.return===null){Ie=1,ul=t,Te=null;break}e:{var i=e,a=n.return,o=n,u=t;if(t=Ue,o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var c=u,y=o,g=y.tag;if(!(y.mode&1)&&(g===0||g===11||g===15)){var h=y.alternate;h?(y.updateQueue=h.updateQueue,y.memoizedState=h.memoizedState,y.lanes=h.lanes):(y.updateQueue=null,y.memoizedState=null)}var v=au(a);if(v!==null){v.flags&=-257,ou(v,a,o,i,t),v.mode&1&&iu(i,c,t),t=v,u=c;var x=t.updateQueue;if(x===null){var S=new Set;S.add(u),t.updateQueue=S}else x.add(u);break e}else{if(!(t&1)){iu(i,c,t),lo();break e}u=Error(I(426))}}else if(ve&&o.mode&1){var _=au(a);if(_!==null){!(_.flags&65536)&&(_.flags|=256),ou(_,a,o,i,t),Aa(yr(u,o));break e}}i=u=yr(u,o),Ie!==4&&(Ie=2),Vr===null?Vr=[i]:Vr.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var p=Nd(i,u,t);eu(i,p);break e;case 1:o=u;var f=i.type,m=i.stateNode;if(!(i.flags&128)&&(typeof f.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(pn===null||!pn.has(m)))){i.flags|=65536,t&=-t,i.lanes|=t;var w=_d(i,o,t);eu(i,w);break e}}i=i.return}while(i!==null)}Wd(n)}catch(E){t=E,Te===n&&n!==null&&(Te=n=n.return);continue}break}while(!0)}function Ud(){var e=gs.current;return gs.current=ms,e===null?ms:e}function lo(){(Ie===0||Ie===3||Ie===2)&&(Ie=4),Fe===null||!($n&268435455)&&!(zs&268435455)||ln(Fe,Ue)}function xs(e,t){var n=le;le|=2;var r=Ud();(Fe!==e||Ue!==t)&&(Ut=null,Pn(e,t));do try{Sh();break}catch(l){Bd(e,l)}while(!0);if(Fa(),le=n,gs.current=r,Te!==null)throw Error(I(261));return Fe=null,Ue=0,Ie}function Sh(){for(;Te!==null;)Hd(Te)}function Nh(){for(;Te!==null&&!Xf();)Hd(Te)}function Hd(e){var t=Qd(e.alternate,e,at);e.memoizedProps=e.pendingProps,t===null?Wd(e):Te=t,Za.current=null}function Wd(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=yh(n,t),n!==null){n.flags&=32767,Te=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ie=6,Te=null;return}}else if(n=gh(n,t,at),n!==null){Te=n;return}if(t=t.sibling,t!==null){Te=t;return}Te=t=e}while(t!==null);Ie===0&&(Ie=5)}function _n(e,t,n){var r=ue,l=xt.transition;try{xt.transition=null,ue=1,_h(e,t,n,r)}finally{xt.transition=l,ue=r}return null}function _h(e,t,n,r){do cr();while(an!==null);if(le&6)throw Error(I(327));n=e.finishedWork;var l=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(I(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(sp(e,i),e===Fe&&(Te=Fe=null,Ue=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||zl||(zl=!0,qd(es,function(){return cr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=xt.transition,xt.transition=null;var a=ue;ue=1;var o=le;le|=4,Za.current=null,xh(e,n),Ad(n,e),Vp(Vi),ns=!!Wi,Vi=Wi=null,e.current=n,wh(n),Jf(),le=o,ue=a,xt.transition=i}else e.current=n;if(zl&&(zl=!1,an=e,vs=l),i=e.pendingLanes,i===0&&(pn=null),Zf(n.stateNode),st(e,_e()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)l=t[n],r(l.value,{componentStack:l.stack,digest:l.digest});if(ys)throw ys=!1,e=da,da=null,e;return vs&1&&e.tag!==0&&cr(),i=e.pendingLanes,i&1?e===fa?Qr++:(Qr=0,fa=e):Qr=0,wn(),null}function cr(){if(an!==null){var e=Nc(vs),t=xt.transition,n=ue;try{if(xt.transition=null,ue=16>e?16:e,an===null)var r=!1;else{if(e=an,an=null,vs=0,le&6)throw Error(I(331));var l=le;for(le|=4,H=e.current;H!==null;){var i=H,a=i.child;if(H.flags&16){var o=i.deletions;if(o!==null){for(var u=0;u<o.length;u++){var c=o[u];for(H=c;H!==null;){var y=H;switch(y.tag){case 0:case 11:case 15:Wr(8,y,i)}var g=y.child;if(g!==null)g.return=y,H=g;else for(;H!==null;){y=H;var h=y.sibling,v=y.return;if($d(y),y===c){H=null;break}if(h!==null){h.return=v,H=h;break}H=v}}}var x=i.alternate;if(x!==null){var S=x.child;if(S!==null){x.child=null;do{var _=S.sibling;S.sibling=null,S=_}while(S!==null)}}H=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,H=a;else e:for(;H!==null;){if(i=H,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Wr(9,i,i.return)}var p=i.sibling;if(p!==null){p.return=i.return,H=p;break e}H=i.return}}var f=e.current;for(H=f;H!==null;){a=H;var m=a.child;if(a.subtreeFlags&2064&&m!==null)m.return=a,H=m;else e:for(a=f;H!==null;){if(o=H,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:Rs(9,o)}}catch(E){Ne(o,o.return,E)}if(o===a){H=null;break e}var w=o.sibling;if(w!==null){w.return=o.return,H=w;break e}H=o.return}}if(le=l,wn(),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot(Ns,e)}catch{}r=!0}return r}finally{ue=n,xt.transition=t}}return!1}function ku(e,t,n){t=yr(n,t),t=Nd(e,t,1),e=fn(e,t,1),t=Ye(),e!==null&&(fl(e,1,t),st(e,t))}function Ne(e,t,n){if(e.tag===3)ku(e,e,n);else for(;t!==null;){if(t.tag===3){ku(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(pn===null||!pn.has(r))){e=yr(n,e),e=_d(t,e,1),t=fn(t,e,1),e=Ye(),t!==null&&(fl(t,1,e),st(t,e));break}}t=t.return}}function Ch(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ye(),e.pingedLanes|=e.suspendedLanes&n,Fe===e&&(Ue&n)===n&&(Ie===4||Ie===3&&(Ue&130023424)===Ue&&500>_e()-to?Pn(e,0):eo|=n),st(e,t)}function Vd(e,t){t===0&&(e.mode&1?(t=Sl,Sl<<=1,!(Sl&130023424)&&(Sl=4194304)):t=1);var n=Ye();e=Xt(e,t),e!==null&&(fl(e,t,n),st(e,n))}function Eh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Vd(e,n)}function bh(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(I(314))}r!==null&&r.delete(t),Vd(e,n)}var Qd;Qd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||rt.current)nt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return nt=!1,mh(e,t,n);nt=!!(e.flags&131072)}else nt=!1,ve&&t.flags&1048576&&Jc(t,us,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vl(e,t),e=t.pendingProps;var l=pr(t,Ke.current);ur(t,n),l=Ka(null,t,r,e,l,n);var i=Xa();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,lt(r)?(i=!0,as(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ha(t),l.updater=Ls,t.stateNode=l,l._reactInternals=t,ea(t,r,e,n),t=ra(null,t,r,!0,i,n)):(t.tag=0,ve&&i&&Da(t),Ge(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Ph(r),e=St(r,e),l){case 0:t=na(null,t,r,e,n);break e;case 1:t=du(null,t,r,e,n);break e;case 11:t=uu(null,t,r,e,n);break e;case 14:t=cu(null,t,r,St(r.type,e),n);break e}throw Error(I(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),na(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),du(e,t,r,l,n);case 3:e:{if(Td(t),e===null)throw Error(I(387));r=t.pendingProps,i=t.memoizedState,l=i.element,nd(e,t),fs(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=yr(Error(I(423)),t),t=fu(e,t,r,n,l);break e}else if(r!==l){l=yr(Error(I(424)),t),t=fu(e,t,r,n,l);break e}else for(ut=dn(t.stateNode.containerInfo.firstChild),ct=t,ve=!0,_t=null,n=ed(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(hr(),r===l){t=Jt(e,t,n);break e}Ge(e,t,r,n)}t=t.child}return t;case 5:return rd(t),e===null&&Gi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,Qi(r,l)?a=null:i!==null&&Qi(r,i)&&(t.flags|=32),bd(e,t),Ge(e,t,a,n),t.child;case 6:return e===null&&Gi(t),null;case 13:return Pd(e,t,n);case 4:return Wa(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=mr(t,null,r,n):Ge(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),uu(e,t,r,l,n);case 7:return Ge(e,t,t.pendingProps,n),t.child;case 8:return Ge(e,t,t.pendingProps.children,n),t.child;case 12:return Ge(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,a=l.value,fe(cs,r._currentValue),r._currentValue=a,i!==null)if(bt(i.value,a)){if(i.children===l.children&&!rt.current){t=Jt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){a=i.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Qt(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var y=c.pending;y===null?u.next=u:(u.next=y.next,y.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Yi(i.return,n,t),o.lanes|=n;break}u=u.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(I(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),Yi(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Ge(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,ur(t,n),l=wt(l),r=r(l),t.flags|=1,Ge(e,t,r,n),t.child;case 14:return r=t.type,l=St(r,t.pendingProps),l=St(r.type,l),cu(e,t,r,l,n);case 15:return Cd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:St(r,l),Vl(e,t),t.tag=1,lt(r)?(e=!0,as(t)):e=!1,ur(t,n),Sd(t,r,l),ea(t,r,l,n),ra(null,t,r,!0,e,n);case 19:return Ld(e,t,n);case 22:return Ed(e,t,n)}throw Error(I(156,t.tag))};function qd(e,t){return wc(e,t)}function Th(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 vt(e,t,n,r){return new Th(e,t,n,r)}function so(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ph(e){if(typeof e=="function")return so(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Na)return 11;if(e===_a)return 14}return 2}function mn(e,t){var n=e.alternate;return n===null?(n=vt(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 Kl(e,t,n,r,l,i){var a=2;if(r=e,typeof e=="function")so(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Kn:return Ln(n.children,l,i,t);case Sa:a=8,l|=8;break;case Ni:return e=vt(12,n,t,l|2),e.elementType=Ni,e.lanes=i,e;case _i:return e=vt(13,n,t,l),e.elementType=_i,e.lanes=i,e;case Ci:return e=vt(19,n,t,l),e.elementType=Ci,e.lanes=i,e;case rc:return Is(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case tc:a=10;break e;case nc:a=9;break e;case Na:a=11;break e;case _a:a=14;break e;case tn:a=16,r=null;break e}throw Error(I(130,e==null?e:typeof e,""))}return t=vt(a,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Ln(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Is(e,t,n,r){return e=vt(22,e,r,t),e.elementType=rc,e.lanes=n,e.stateNode={isHidden:!1},e}function mi(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function gi(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Lh(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=Js(0),this.expirationTimes=Js(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Js(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function io(e,t,n,r,l,i,a,o,u){return e=new Lh(e,t,n,o,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=vt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ha(i),e}function Rh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:qn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Kd(e){if(!e)return yn;e=e._reactInternals;e:{if(An(e)!==e||e.tag!==1)throw Error(I(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(lt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(I(171))}if(e.tag===1){var n=e.type;if(lt(n))return Kc(e,n,t)}return t}function Xd(e,t,n,r,l,i,a,o,u){return e=io(n,r,!0,e,l,i,a,o,u),e.context=Kd(null),n=e.current,r=Ye(),l=hn(n),i=Qt(r,l),i.callback=t??null,fn(n,i,l),e.current.lanes=l,fl(e,l,r),st(e,r),e}function $s(e,t,n,r){var l=t.current,i=Ye(),a=hn(l);return n=Kd(n),t.context===null?t.context=n:t.pendingContext=n,t=Qt(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=fn(l,t,a),e!==null&&(Et(e,l,a,i),Ul(e,l,a)),a}function ws(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function ju(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ao(e,t){ju(e,t),(e=e.alternate)&&ju(e,t)}function zh(){return null}var Jd=typeof reportError=="function"?reportError:function(e){console.error(e)};function oo(e){this._internalRoot=e}Ds.prototype.render=oo.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(I(409));$s(e,t,null,null)};Ds.prototype.unmount=oo.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Dn(function(){$s(null,e,null,null)}),t[Kt]=null}};function Ds(e){this._internalRoot=e}Ds.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ec();e={blockedOn:null,target:e,priority:t};for(var n=0;n<rn.length&&t!==0&&t<rn[n].priority;n++);rn.splice(n,0,e),n===0&&Tc(e)}};function uo(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Os(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Su(){}function Ih(e,t,n,r,l){if(l){if(typeof r=="function"){var i=r;r=function(){var c=ws(a);i.call(c)}}var a=Xd(t,r,e,0,null,!1,!1,"",Su);return e._reactRootContainer=a,e[Kt]=a.current,tl(e.nodeType===8?e.parentNode:e),Dn(),a}for(;l=e.lastChild;)e.removeChild(l);if(typeof r=="function"){var o=r;r=function(){var c=ws(u);o.call(c)}}var u=io(e,0,!1,null,null,!1,!1,"",Su);return e._reactRootContainer=u,e[Kt]=u.current,tl(e.nodeType===8?e.parentNode:e),Dn(function(){$s(t,u,n,r)}),u}function As(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i;if(typeof l=="function"){var o=l;l=function(){var u=ws(a);o.call(u)}}$s(t,a,e,l)}else a=Ih(n,t,e,l,r);return ws(a)}_c=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ir(t.pendingLanes);n!==0&&(ba(t,n|1),st(t,_e()),!(le&6)&&(vr=_e()+500,wn()))}break;case 13:Dn(function(){var r=Xt(e,1);if(r!==null){var l=Ye();Et(r,e,1,l)}}),ao(e,1)}};Ta=function(e){if(e.tag===13){var t=Xt(e,134217728);if(t!==null){var n=Ye();Et(t,e,134217728,n)}ao(e,134217728)}};Cc=function(e){if(e.tag===13){var t=hn(e),n=Xt(e,t);if(n!==null){var r=Ye();Et(n,e,t,r)}ao(e,t)}};Ec=function(){return ue};bc=function(e,t){var n=ue;try{return ue=e,t()}finally{ue=n}};Di=function(e,t,n){switch(t){case"input":if(Ti(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var l=bs(r);if(!l)throw Error(I(90));sc(r),Ti(r,l)}}}break;case"textarea":ac(e,n);break;case"select":t=n.value,t!=null&&sr(e,!!n.multiple,t,!1)}};hc=no;mc=Dn;var $h={usingClientEntryPoint:!1,Events:[hl,Yn,bs,fc,pc,no]},Pr={findFiberByHostInstance:Cn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Dh={bundleType:Pr.bundleType,version:Pr.version,rendererPackageName:Pr.rendererPackageName,rendererConfig:Pr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Gt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=vc(e),e===null?null:e.stateNode},findFiberByHostInstance:Pr.findFiberByHostInstance||zh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Il=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Il.isDisabled&&Il.supportsFiber)try{Ns=Il.inject(Dh),Ot=Il}catch{}}ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$h;ft.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!uo(t))throw Error(I(200));return Rh(e,t,null,n)};ft.createRoot=function(e,t){if(!uo(e))throw Error(I(299));var n=!1,r="",l=Jd;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(l=t.onRecoverableError)),t=io(e,1,!1,null,null,n,!1,r,l),e[Kt]=t.current,tl(e.nodeType===8?e.parentNode:e),new oo(t)};ft.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(I(188)):(e=Object.keys(e).join(","),Error(I(268,e)));return e=vc(t),e=e===null?null:e.stateNode,e};ft.flushSync=function(e){return Dn(e)};ft.hydrate=function(e,t,n){if(!Os(t))throw Error(I(200));return As(null,e,t,!0,n)};ft.hydrateRoot=function(e,t,n){if(!uo(e))throw Error(I(405));var r=n!=null&&n.hydratedSources||null,l=!1,i="",a=Jd;if(n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=Xd(t,null,e,1,n??null,l,!1,i,a),e[Kt]=t.current,tl(e),r)for(e=0;e<r.length;e++)n=r[e],l=n._getVersion,l=l(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,l]:t.mutableSourceEagerHydrationData.push(n,l);return new Ds(t)};ft.render=function(e,t,n){if(!Os(t))throw Error(I(200));return As(null,e,t,!1,n)};ft.unmountComponentAtNode=function(e){if(!Os(e))throw Error(I(40));return e._reactRootContainer?(Dn(function(){As(null,null,e,!1,function(){e._reactRootContainer=null,e[Kt]=null})}),!0):!1};ft.unstable_batchedUpdates=no;ft.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Os(n))throw Error(I(200));if(e==null||e._reactInternals===void 0)throw Error(I(38));return As(e,t,n,!1,r)};ft.version="18.3.1-next-f1338f8080-20240426";function Gd(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Gd)}catch(e){console.error(e)}}Gd(),Gu.exports=ft;var Oh=Gu.exports,Yd,Nu=Oh;Yd=Nu.createRoot,Nu.hydrateRoot;async function Ce(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function _u(){return Ce("/api/archives")}async function Cu(e,t=null){const n=t?`/api/archives/${e}/entries?collection=${encodeURIComponent(t)}`:`/api/archives/${e}/entries`;return Ce(n)}async function Ah(e,t,n,r=null){const l=new URLSearchParams;return t&&l.set("q",t),n&&l.set("tag",n),r&&l.set("collection",r),Ce(`/api/archives/${e}/entries/search?${l}`)}async function Dr(e,t){return Ce(`/api/archives/${e}/entries/${t}`)}async function Mh(e,t){return Ce(`/api/archives/${e}/entries/${t}/summary`)}async function Fh(e,t,{provider:n,force:r=!1}={}){const l=await fetch(`/api/archives/${e}/entries/${t}/summary`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,force:r})});if(!l.ok){const i=await l.text();let a=i.trim();try{a=JSON.parse(i).error||a}catch{}throw new Error(a||`Summary request failed (${l.status})`)}return l.json()}async function Bh(e,t){return Ce(`/api/archives/${e}/entries/${t}/children`)}function Uh(e,t,n){return Promise.all(n.map(r=>Ce(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function Hh(e){if(!e||e.length===0)return{};const t=await fetch("/api/util/resolve-tco",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?t.json():{}}async function Wh(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 $l(e,t){return Ce(`/api/archives/${e}/entries/${t}/tags`)}async function Eu(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 Vh(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 bu(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function Qh(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function qh(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function Kh(e,t){const n=await fetch(`/api/archives/${e}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!n.ok)throw new Error(await n.text());return n.json()}async function Xh(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent_uid:n??null})});if(!r.ok)throw new Error(await r.text());return r.json()}async function yi(e){return Ce(`/api/archives/${e}/runs`)}async function Dl(e){return Ce(`/api/archives/${e}/tags`)}async function Jh(e,t,n=null,r=null){const l={locator:t};n&&n!=="best"&&(l.quality=n),r&&(typeof r.ublock_enabled=="boolean"&&(l.ublock_enabled=r.ublock_enabled),typeof r.reader_mode=="boolean"&&(l.reader_mode=r.reader_mode),typeof r.cookie_ext_enabled=="boolean"&&(l.cookie_ext_enabled=r.cookie_ext_enabled),typeof r.modal_closer_enabled=="boolean"&&(l.modal_closer_enabled=r.modal_closer_enabled),typeof r.via_freedium=="boolean"&&(l.via_freedium=r.via_freedium),r.per_item_quality&&typeof r.per_item_quality=="object"&&Object.keys(r.per_item_quality).length>0&&(l.per_item_quality=r.per_item_quality),r.sync===!0&&(l.sync=!0));const i=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok){const a=await i.json().catch(()=>({})),o=new Error(a.error||`HTTP ${i.status}`);throw o.status=i.status,o}return i.json()}async function Gh(e,t){return Ce(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function Yh(e,t){const n=await fetch(`/api/archives/${e}/captures/probe-playlist`,{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 Zd(e,t){return Ce(`/api/archives/${e}/capture_jobs/${t}`)}async function Zh(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function em(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 tm(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 nm(){await fetch("/api/auth/logout",{method:"POST"})}async function rm(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function lm(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 sm(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function im(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 am(){return Ce("/api/auth/tokens")}async function om(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 um(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function co(){return Ce("/api/admin/instance-settings")}async function Xl(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 cm(){return Ce("/api/admin/users")}async function dm(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 fm(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 pm(){return Ce("/api/admin/roles")}async function hm(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 fo(e){return Ce(`/api/archives/${e}/collections`)}async function mm(e,t,n,r=2,l=!0){const i=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r,requires_auth:l})});if(!i.ok){const a=await i.json().catch(()=>({error:i.statusText}));throw new Error(a.error||i.statusText)}return i.json()}async function gm(e,t){return Ce(`/api/archives/${e}/collections/${t}`)}async function ma(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 ym(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 vm(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 Tu(e,t){return Ce(`/api/archives/${e}/entries/${t}/collections`)}async function vi(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 xm(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)}}async function wm(e){return Ce(`/api/archives/${e}/blob-cleanup`)}async function km(e){const t=await fetch(`/api/archives/${e}/blob-cleanup`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error??t.statusText)}return t.json()}async function jm(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}/rearchive`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`rearchive failed: ${n.status}`)}return n.json()}async function Sm(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/artifacts/${n}/media-token`,{method:"POST"});if(!r.ok)throw new Error(`media-token ${r.status}`);return r.json()}async function Nm(){return Ce("/api/admin/cookie-rules")}async function _m(e,t,n){const r=await fetch("/api/admin/cookie-rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url_pattern:e||null,pattern_kind:t,cookies_json:n})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.message||`HTTP ${r.status}`)}return r.json()}async function Cm(e,t){const n=await fetch(`/api/admin/cookie-rules/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}async function Em(e){const t=await fetch(`/api/admin/cookie-rules/${e}`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.message||`HTTP ${t.status}`)}}function bm(e,t,n){let r;return{promise:new Promise((i,a)=>{const o=new FormData;o.append("file",t),r=new XMLHttpRequest,r.open("POST",`/api/archives/${e}/uploads`),r.upload.addEventListener("progress",u=>{u.lengthComputable&&n&&n(Math.round(u.loaded/u.total*100))}),r.addEventListener("load",()=>{if(r.status>=200&&r.status<300)try{i(JSON.parse(r.responseText))}catch{a(new Error("Invalid server response"))}else{let u=`Upload failed (${r.status})`;try{u=JSON.parse(r.responseText).message||u}catch{}a(new Error(u))}}),r.addEventListener("error",()=>a(new Error("Network error during upload"))),r.addEventListener("abort",()=>a(new Error("Upload cancelled"))),r.send(o)}),abort:()=>r==null?void 0:r.abort()}}async function xi(e,t){try{await fetch(`/api/archives/${e}/uploads`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})})}catch{}}const Tm=window.fetch;window.fetch=async(...e)=>{var n;const t=await Tm(...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 Pm({onLogin:e}){const[t,n]=d.useState(""),[r,l]=d.useState(""),[i,a]=d.useState(null),[o,u]=d.useState(!1);async function c(y){y.preventDefault(),a(null),u(!0);try{const g=await tm(t,r);e(g)}catch(g){a(g.message)}finally{u(!1)}}return s.jsx("div",{className:"login-page",children:s.jsxs("div",{className:"login-card",children:[s.jsx("h1",{className:"login-brand",children:"Archivr"}),s.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),s.jsxs("form",{onSubmit:c,children:[s.jsxs("div",{className:"login-field",children:[s.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),s.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:y=>n(y.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),s.jsxs("div",{className:"login-field",children:[s.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),s.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:y=>l(y.target.value),required:!0,autoComplete:"current-password"})]}),i&&s.jsx("p",{className:"login-error",children:i}),s.jsx("button",{className:"login-submit",type:"submit",disabled:o,children:o?"Signing in…":"Sign in"})]})]})})}function Lm({onComplete:e}){const[t,n]=d.useState(""),[r,l]=d.useState(""),[i,a]=d.useState(""),[o,u]=d.useState(null),[c,y]=d.useState(!1);async function g(h){if(h.preventDefault(),r!==i){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),y(!0);try{await em(t,r),e()}catch(v){u(v.message)}finally{y(!1)}}return s.jsx("div",{className:"setup-page",children:s.jsxs("div",{className:"setup-card",children:[s.jsx("h1",{className:"setup-brand",children:"Archivr"}),s.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),s.jsxs("form",{onSubmit:g,children:[s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),s.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:h=>n(h.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),s.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:h=>l(h.target.value),required:!0,autoComplete:"new-password"})]}),s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),s.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:h=>a(h.target.value),required:!0,autoComplete:"new-password"})]}),o&&s.jsx("p",{className:"setup-error",children:o}),s.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Rm({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i,collections:a,selectedCollectionUid:o,onCollectionChange:u,isPublicSession:c,onSignInClick:y}){const{currentUser:g,setCurrentUser:h}=d.useContext(Fs)??{},[v,x]=d.useState(!1);async function S(){x(!0),await nm(),h(null),window.location.reload()}const _=a.find(m=>m.slug==="_default_"),p=!c||!!_&&!_.requires_auth,f=a.filter(m=>m.slug!=="_default_").filter(m=>!c||!m.requires_auth);return s.jsxs("header",{className:"topbar",children:[s.jsx("div",{className:"brand",children:"Archivr"}),s.jsxs("div",{className:"switchers",children:[!c&&s.jsx("div",{className:"switcher",children:s.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:m=>n(m.target.value),children:e.map(m=>s.jsx("option",{value:m.id,children:m.label},m.id))})}),f.length>0&&s.jsx("div",{className:"switcher",children:s.jsxs("select",{"aria-label":"Select collection",value:o??"",onChange:m=>u(m.target.value||null),children:[p&&s.jsx("option",{value:"",children:"All entries"}),f.map(m=>s.jsx("option",{value:m.collection_uid,children:m.name},m.collection_uid))]})})]}),c?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"logout-btn",onClick:y,children:"Sign in"})]}):s.jsxs(s.Fragment,{children:[s.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(m=>s.jsx("button",{className:`nav-link${r===m?" is-active":""}`,onClick:()=>l(m),children:m.charAt(0).toUpperCase()+m.slice(1)},m))}),s.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),g&&s.jsxs("div",{className:"user-menu",children:[s.jsx("span",{className:"user-name",children:g.display_name||g.username}),s.jsx("button",{className:"logout-btn",onClick:S,disabled:v,children:v?"Logging out…":"Log out"})]})]})]})}let ks=1;function ef(e){const t=e.trim(),n=t.toLowerCase();for(const r of["yt:","youtube:"])if(n.startsWith(r)){const l=n.slice(r.length);return!!(l.startsWith("video/")||l.startsWith("short/")||l.startsWith("shorts/")||/^[a-z0-9_-]{11}$/i.test(l))}if(n.startsWith("ytm:"))return!n.slice(4).startsWith("playlist/");for(const r of["x:","twitter:","tweet:"])if(n.startsWith(r))return n.slice(r.length).startsWith("media:");if(n.startsWith("spotify:"))return!1;if(n.startsWith("instagram:")||n.startsWith("facebook:")||n.startsWith("tiktok:")||n.startsWith("reddit:")||n.startsWith("snapchat:"))return!0;if(n.startsWith("http://")||n.startsWith("https://")){if(/^https?:\/\/music\.youtube\.com\/watch/.test(n)||/^https?:\/\/(?:www\.)?(?:youtu\.be\/[0-9A-Za-z_-]+|youtube\.com\/watch\?v=[0-9A-Za-z_-]+|youtube\.com\/shorts\/[0-9A-Za-z_-]+)/.test(t)||n.startsWith("https://x.com/")||n.startsWith("http://x.com/")||/^https?:\/\/(?:www\.)?instagram\.com\//.test(n)||/^https?:\/\/(?:www\.)?facebook\.com\//.test(n)||n.startsWith("https://fb.watch/")||n.startsWith("http://fb.watch/")||/^https?:\/\/(?:www\.)?tiktok\.com\//.test(n)||/^https?:\/\/(?:www\.)?reddit\.com\//.test(n)||n.startsWith("https://redd.it/")||n.startsWith("http://redd.it/")||/^https?:\/\/(?:www\.)?snapchat\.com\//.test(n))return!0;if(n.startsWith("https://open.spotify.com/")||n.startsWith("http://open.spotify.com/"))return!1}return!1}function Tn(e){const t=e.trim(),n=t.toLowerCase();for(const r of["yt:","youtube:"])if(n.startsWith(r)){const l=n.slice(r.length);return l.startsWith("playlist/")||l.startsWith("@")||l.startsWith("channel/")||l.startsWith("c/")||l.startsWith("user/")}if(n.startsWith("ytm:"))return n.slice(4).startsWith("playlist/");if(n.startsWith("spotify:")){const r=n.slice(8);return r.startsWith("album:")||r.startsWith("playlist:")}if(n.startsWith("http://")||n.startsWith("https://"))try{const r=new URL(t),l=r.hostname;if((l==="youtube.com"||l==="www.youtube.com")&&(r.pathname==="/playlist"&&r.searchParams.has("list")||r.pathname.startsWith("/@")||r.pathname.startsWith("/channel/")||r.pathname.startsWith("/c/")||r.pathname.startsWith("/user/"))||l==="music.youtube.com"&&r.pathname==="/playlist"&&r.searchParams.has("list")||l==="open.spotify.com"&&(r.pathname.startsWith("/album/")||r.pathname.startsWith("/playlist/")))return!0}catch{}return!1}function Qn(e=""){return{id:ks++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null,playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1,syncEnabled:!1}}function zm(e){return{id:ks++,kind:"file",filename:e,uploadProgress:0,uploadStatus:"uploading",uploadLocator:null,uploadError:null,locator:"",quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1,syncEnabled:!1,error:null,status:"idle"}}function Im(e,t){return e==="best"?t.map(n=>({...n,quality:"best"})):e==="audio"?t.map(n=>n.has_audio?{...n,quality:"audio"}:n.quality!==null?n:{...n,quality:null}):t.map(n=>n.qualities.includes(e)?{...n,quality:e}:n.quality!==null?n:{...n,quality:null})}function Pu(e){return Array.isArray(e.playlistItems)&&e.playlistItems.some(t=>t.quality===null)}function $m({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l,onJobStarted:i,onJobSettled:a,activeJobs:o=[]}){const u=d.useRef(null),c=d.useRef(!0),y=d.useRef(new Map),g=d.useRef(new Map),h=d.useRef(new Map),v=d.useRef(t);d.useEffect(()=>{v.current=t},[t]);const x=d.useRef(null),[S,_]=d.useState(!1),p=d.useRef([]),f=d.useRef(!1),m=d.useRef(new Map),w=d.useRef(r),E=d.useRef(l);d.useEffect(()=>{w.current=r},[r]),d.useEffect(()=>{E.current=l},[l]);const b=d.useRef(i),T=d.useRef(a);d.useEffect(()=>{b.current=i},[i]),d.useEffect(()=>{T.current=a},[a]);const[k,P]=d.useState(()=>{try{const j=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(j)&&j.length>0){const U=j.filter(M=>!M.status||M.status==="idle");if(U.length>0)return U.forEach(M=>{M.id>=ks&&(ks=M.id+1)}),U.map(M=>({...Qn(M.locator),...M}))}}catch{}return[Qn()]});d.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(k.filter(j=>j.kind!=="file")))},[k]),d.useEffect(()=>{p.current=k},[k]);const[R,G]=d.useState(!1),[B,Y]=d.useState(null),[ne,ce]=d.useState(null),[$e,ge]=d.useState(!0),[D,L]=d.useState(!0),[Q,K]=d.useState(!0);d.useEffect(()=>{co().then(j=>{ce(j),ge(j.cookie_ext_enabled??!0),L(j.modal_closer_enabled??!0)}).catch(()=>ce({}))},[]);const ee=B!==null?B:(ne==null?void 0:ne.ublock_enabled)??!0,[De,te]=d.useState(!1);d.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(j=>sessionStorage.removeItem(j)),o.forEach(j=>{j.jobUid&&!y.current.has(j.jobUid)&&je(j.id,j.jobUid,j.locator,j.archiveId,null)})},[]),d.useEffect(()=>{const j=u.current;if(!j)return;const U=()=>{if(g.current.forEach(M=>clearTimeout(M)),g.current.clear(),!f.current){const M=v.current;p.current.forEach(A=>{var W;A.kind==="file"&&(A.uploadStatus==="uploading"?((W=m.current.get(A.id))==null||W(),m.current.delete(A.id)):A.uploadStatus==="done"&&A.uploadLocator&&xi(M,A.uploadLocator).catch(()=>{}))})}f.current=!1,n()};return j.addEventListener("close",U),()=>j.removeEventListener("close",U)},[n]),d.useEffect(()=>{const j=u.current;j&&(e?(c.current||P([Qn()]),c.current=!1,j.open||j.showModal()):(g.current.forEach(U=>clearTimeout(U)),g.current.clear(),j.open&&j.close()))},[e]),d.useEffect(()=>()=>{y.current.forEach(j=>clearInterval(j)),g.current.forEach(j=>clearTimeout(j))},[]);function je(j,U,M,A,W=null){if(y.current.has(U))return;const V=setInterval(async()=>{var pe,ae,Ee,oe;try{const Je=await Zd(A,U);if(Je.status==="completed"){clearInterval(y.current.get(U)),y.current.delete(U),await Promise.resolve((pe=w.current)==null?void 0:pe.call(w)),(ae=T.current)==null||ae.call(T,j);try{const Se=Je.notes_json?JSON.parse(Je.notes_json):null;if(Se!=null&&Se.ublock_skipped||Se!=null&&Se.cookie_ext_skipped){const it=Se.ublock_skipped&&Se.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":Se.ublock_skipped?"Captured without ad-blocking. ARCHIVR_UBLOCK=true but ARCHIVR_UBLOCK_EXT is not set or the path is invalid.":"Captured without cookie-consent extension. ARCHIVR_COOKIE_EXT is not set or the path is invalid.";E.current(it,M,"warning"),se(W,"warning",M)}else W||E.current(null,M,"success"),se(W,"archived")}catch{W||E.current(null,M,"success"),se(W,"archived")}}else if(Je.status==="failed"){clearInterval(y.current.get(U)),y.current.delete(U),(Ee=T.current)==null||Ee.call(T,j);const Se=Je.error_text||"Capture failed.";E.current(Se,M),se(W,"failed",M)}}catch(Je){clearInterval(y.current.get(U)),y.current.delete(U),(oe=T.current)==null||oe.call(T,j);const Se=Je.message||"Network error";E.current(Se,M),se(W,"failed",M)}},500);y.current.set(U,V)}function se(j,U,M=null){if(!j)return;const A=h.current.get(j);if(!A||(U==="archived"||U==="warning"?(A.archived++,U==="warning"&&(A.warnings++,M&&A.warningLocators.push(M))):(A.failed++,M&&A.failedLocators.push(M)),A.archived+A.failed<A.total))return;h.current.delete(j);const{archived:W,warnings:V,failed:pe,failedLocators:ae,warningLocators:Ee}=A;let oe;if(W===0)oe=`${pe} failed`;else{const it=V>0?`${W} archived (${V} with warnings)`:`${W} archived`;oe=pe>0?`${it}, ${pe} failed`:it}const Je=W===0?"error":pe>0||V>0?"warning":"success",Se=[];ae.length>0&&Se.push(`Failed:
${ae.map(it=>` ${it}`).join(`
`)}`),Ee.length>0&&Se.push(`With warnings:
${Ee.map(it=>` ${it}`).join(`
`)}`);const Fn=Se.length>0?Se.join(`
`):null;E.current(Fn,null,Je,oe)}async function Pe(j,U,M,A={}){var ae,Ee;const W=v.current,V=((ae=crypto.randomUUID)==null?void 0:ae.call(crypto))??`job-${Date.now()}-${Math.random()}`,pe={ublock_enabled:ee,reader_mode:De,cookie_ext_enabled:$e,modal_closer_enabled:D,via_freedium:Q,...A};try{const oe=await Jh(W,j,U,pe);(Ee=b.current)==null||Ee.call(b,{id:V,jobUid:oe.job_uid,locator:j,archiveId:W}),je(V,oe.job_uid,j,W,M)}catch(oe){const Je=oe.message||"Submission failed.";E.current(Je,j),se(M,"failed",j),j.startsWith("file://")&&oe.status&&xi(W,j).catch(()=>{})}}function Mt(){var A,W;if(k.some(V=>V.kind==="file"&&V.uploadStatus==="uploading"))return;const j=k.filter(V=>V.kind==="file"?V.uploadStatus==="done"&&V.uploadLocator:V.locator.trim());if(j.length===0||j.some(V=>V.kind!=="file"&&Pu(V))||j.some(V=>V.kind!=="file"&&(V.probeState==="probing"||Tn(V.locator)&&V.playlistProbeState!=="done"))||j.some(V=>V.kind!=="file"&&Array.isArray(V.playlistItems)&&V.playlistItems.length===0))return;const U=j.length>1?((A=crypto.randomUUID)==null?void 0:A.call(crypto))??`batch-${Date.now()}`:null;U&&h.current.set(U,{total:j.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]});const M=j.map(V=>V.kind==="file"?{locator:V.uploadLocator,quality:"best",extraExtensions:{}}:{locator:V.locator.trim(),quality:V.playlistItems!==null?null:V.quality||"best",extraExtensions:V.playlistItems!==null?{per_item_quality:Object.fromEntries(V.playlistItems.map(pe=>[pe.id,pe.quality])),sync:V.syncEnabled}:{}});f.current=!0,P([Qn()]),(W=u.current)==null||W.close(),M.forEach(({locator:V,quality:pe,extraExtensions:ae})=>Pe(V,pe,U,ae))}function Oe(){P(j=>[...j,Qn()])}function Ft(j){var M;clearTimeout(g.current.get(j)),g.current.delete(j);const U=p.current.find(A=>A.id===j);(U==null?void 0:U.kind)==="file"&&(U.uploadStatus==="uploading"?((M=m.current.get(j))==null||M(),m.current.delete(j)):U.uploadStatus==="done"&&U.uploadLocator&&xi(v.current,U.uploadLocator).catch(()=>{})),P(A=>{const W=A.filter(V=>V.id!==j);return W.length===0?[Qn()]:W})}function Tt(j,U){if(clearTimeout(g.current.get(j)),P(M=>M.map(A=>A.id===j?{...A,locator:U,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best",playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1}:A)),ef(U)){const M=setTimeout(async()=>{g.current.delete(j),P(A=>A.map(W=>W.id===j?{...W,probeState:"probing"}:W));try{const A=await Gh(v.current,U.trim());P(W=>W.map(V=>{if(V.id!==j||V.locator!==U)return V;const pe=A.qualities??[],ae=A.has_audio??!1,Ee=pe.length===0&&ae?"audio":"best";return{...V,probeState:"done",probeQualities:pe,probeHasAudio:ae,quality:Ee}}))}catch{P(A=>A.map(W=>W.id===j?{...W,probeState:"idle",probeQualities:null}:W))}},600);g.current.set(j,M)}else if(Tn(U)){const M=setTimeout(async()=>{g.current.delete(j),P(A=>A.map(W=>W.id===j?{...W,playlistProbeState:"probing"}:W));try{const A=await Yh(v.current,U.trim());P(W=>W.map(V=>V.id!==j||V.locator!==U?V:{...V,playlistProbeState:"done",playlistInfo:A,playlistItems:A.items.map(pe=>({...pe,quality:null})),playlistQuality:null}))}catch{P(A=>A.map(W=>W.id===j?{...W,playlistProbeState:"error"}:W))}},800);g.current.set(j,M)}}function ht(j,U){P(M=>M.map(A=>A.id===j?{...A,quality:U}:A))}function mt(j,U){P(M=>M.map(A=>{if(A.id!==j)return A;const W=Im(U,A.playlistItems);return{...A,playlistQuality:U,playlistItems:W}}))}function Xe(j,U,M){P(A=>A.map(W=>W.id!==j?W:{...W,playlistItems:W.playlistItems.map(V=>V.id===U?{...V,quality:M}:V)}))}function Pt(j){P(U=>U.map(M=>M.id===j?{...M,playlistExpanded:!M.playlistExpanded}:M))}function O(j,U){P(M=>M.map(A=>A.id===j?{...A,syncEnabled:U}:A))}function X(j,U){P(M=>M.map(A=>A.id!==j?A:{...A,playlistItems:A.playlistItems.filter(W=>W.id!==U)}))}function ye(j){const U=Array.from(j);U.length!==0&&U.forEach(M=>{const A=zm(M.name);P(ae=>ae.length===1&&ae[0].kind!=="file"&&!ae[0].locator.trim()?[A]:[...ae,A]);const W=v.current,{promise:V,abort:pe}=bm(W,M,ae=>{P(Ee=>Ee.map(oe=>oe.id===A.id?{...oe,uploadProgress:ae}:oe))});m.current.set(A.id,pe),V.then(ae=>{m.current.delete(A.id),P(Ee=>Ee.map(oe=>oe.id===A.id?{...oe,uploadStatus:"done",uploadLocator:ae.locator,uploadProgress:100}:oe))}).catch(ae=>{m.current.delete(A.id),ae.message!=="Upload cancelled"&&P(Ee=>Ee.map(oe=>oe.id===A.id?{...oe,uploadStatus:"error",uploadError:ae.message}:oe))})})}function Le(j){j.preventDefault(),j.stopPropagation(),j.dataTransfer.types.includes("Files")&&_(!0)}function Yt(j){j.currentTarget.contains(j.relatedTarget)||_(!1)}function Ae(j){j.preventDefault(),j.stopPropagation(),_(!1),ye(j.dataTransfer.files)}function Bt(j){ye(j.target.files),j.target.value=""}const Mn=k.some(j=>j.kind==="file"&&j.uploadStatus==="uploading"),Lt=k.filter(j=>j.kind==="file"?j.uploadStatus==="done"&&j.uploadLocator:j.locator.trim()).length,We=k.some(j=>j.kind!=="file"&&Pu(j)),kn=k.some(j=>j.kind!=="file"&&Array.isArray(j.playlistItems)&&j.playlistItems.length===0),Rt=k.some(j=>j.kind!=="file"&&(j.probeState==="probing"||Tn(j.locator)&&j.playlistProbeState!=="done"));return s.jsx("dialog",{ref:u,className:`capture-dialog${S?" capture-dialog--dragover":""}`,onDragOver:Le,onDragLeave:Yt,onDrop:Ae,children:s.jsxs("div",{className:"capture-dialog-inner",children:[s.jsxs("div",{className:"capture-dialog-header",children:[s.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),s.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var j;return(j=u.current)==null?void 0:j.close()},"aria-label":"Close",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),s.jsx("div",{className:"capture-rows",children:k.map((j,U)=>j.kind==="file"?s.jsx(Om,{item:j,onRemove:()=>Ft(j.id)},j.id):s.jsx(Dm,{item:j,autoFocus:U===k.length-1,onLocatorChange:M=>Tt(j.id,M),onQualityChange:M=>ht(j.id,M),onRemove:()=>Ft(j.id),onSubmit:Mt,onPlaylistQualityChange:M=>mt(j.id,M),onPlaylistItemQualityChange:(M,A)=>Xe(j.id,M,A),onPlaylistToggle:()=>Pt(j.id),onSyncChange:M=>O(j.id,M),onPlaylistItemDelete:M=>X(j.id,M)},j.id))}),s.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:Bt,"aria-hidden":"true",tabIndex:-1}),s.jsxs("div",{className:"capture-add-row-group",children:[s.jsxs("button",{type:"button",className:"capture-add-row",onClick:Oe,children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),s.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add URL"]}),s.jsxs("button",{type:"button",className:"capture-add-row capture-add-file",onClick:()=>{var j;return(j=x.current)==null?void 0:j.click()},children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]}),"Upload file"]})]}),s.jsxs("div",{className:"capture-advanced",children:[s.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>G(j=>!j),"aria-expanded":R,children:[s.jsx("svg",{className:`capture-chevron${R?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),R&&s.jsxs("div",{className:"capture-advanced-panel",children:[s.jsxs("label",{className:"capture-ext-row",children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":ee,className:`ext-toggle ext-toggle--sm${ee?" ext-toggle--on":""}`,onClick:()=>Y(j=>j===null?!ee:!j),"aria-label":"Toggle uBlock for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),s.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(ne!=null&&ne.cookie_ext_available)&&s.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":$e,className:`ext-toggle ext-toggle--sm${$e?" ext-toggle--on":""}`,onClick:()=>ge(j=>!j),"aria-label":"Toggle cookie banner blocking for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),s.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":De,className:`ext-toggle ext-toggle--sm${De?" ext-toggle--on":""}`,onClick:()=>te(j=>!j),"aria-label":"Toggle reader mode for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Close modals and dialogs"}),s.jsx("span",{className:"capture-ext-desc",children:"Auto-dismiss cookie banners and overlays during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":D,className:`ext-toggle ext-toggle--sm${D?" ext-toggle--on":""}`,onClick:()=>L(j=>!j),"aria-label":"Toggle modal closer for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Freedium mirror"}),s.jsx("span",{className:"capture-ext-desc",children:"Route paywalled articles through a Freedium mirror (Medium, NYT, WaPo, etc.)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":Q,className:`ext-toggle ext-toggle--sm${Q?" ext-toggle--on":""}`,onClick:()=>K(j=>!j),"aria-label":"Toggle Freedium mirror for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),s.jsxs("div",{className:"capture-actions",children:[s.jsx("button",{type:"button",className:"capture-submit",onClick:Mt,disabled:Lt===0||We||Rt||kn||Mn,children:Lt>1?`Archive ${Lt}`:"Archive"}),s.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var j;return(j=u.current)==null?void 0:j.close()},children:"Cancel"})]})]})})}function Dm({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onSubmit:i,onPlaylistQualityChange:a,onPlaylistItemQualityChange:o,onPlaylistToggle:u,onSyncChange:c,onPlaylistItemDelete:y}){const g=d.useRef(null);d.useEffect(()=>{var x;t&&((x=g.current)==null||x.focus())},[t]);const h=(()=>{if(Tn(e.locator)){if(e.playlistProbeState==="probing")return s.jsx("span",{className:"capture-quality-probing","aria-label":"Probing playlist…",children:"…"});if(e.playlistProbeState==="done"){const x=[...new Set(e.playlistItems.flatMap(p=>p.qualities.map(f=>parseInt(f))))].sort((p,f)=>f-p),S=e.playlistItems.every(p=>p.has_audio),_=e.playlistItems.filter(p=>p.quality===null).length;return s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"capture-quality",value:e.playlistQuality??"",onChange:p=>a(p.target.value),"aria-label":"Playlist quality",children:[!e.playlistQuality&&s.jsx("option",{value:"",disabled:!0,children:"Select quality…"}),s.jsx("option",{value:"best",children:"Best quality"}),x.map(p=>s.jsxs("option",{value:`${p}p`,children:[p,"p"]},p)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]}),_>0&&s.jsxs("span",{className:"capture-conflict-badge",children:[_," need selection"]})]})}return e.playlistProbeState==="error"?s.jsx("span",{className:"capture-quality-hint capture-quality-hint--error",children:"Probe failed — edit URL to retry"}):null}if(!ef(e.locator))return null;if(e.probeState==="probing")return s.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const x=e.probeQualities??[],S=e.probeHasAudio??!1;return x.length===0&&!S?s.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):x.length===0&&S?s.jsx("select",{className:"capture-quality",value:"audio",onChange:_=>r(_.target.value),"aria-label":"Video quality",children:s.jsx("option",{value:"audio",children:"Audio only"})}):s.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:_=>r(_.target.value),"aria-label":"Video quality",children:[s.jsx("option",{value:"best",children:"Best quality"}),x.map(_=>s.jsx("option",{value:_,children:_},_)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]})}return null})(),v=Tn(e.locator)&&e.playlistProbeState==="done"?s.jsxs("label",{className:"capture-sync-row",children:[s.jsx("input",{type:"checkbox",checked:e.syncEnabled,onChange:x=>c(x.target.checked)}),s.jsx("span",{children:"Sync — skip already-archived videos"})]}):null;return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[Tn(e.locator)&&e.playlistProbeState==="done"?s.jsx("button",{type:"button",className:"capture-playlist-toggle capture-playlist-toggle--left",onClick:u,"aria-label":e.playlistExpanded?"Collapse video list":"Expand video list","aria-expanded":e.playlistExpanded,children:e.playlistExpanded?"▲":"▼"}):null,s.jsx("input",{ref:g,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:x=>n(x.target.value),onKeyDown:x=>{x.key==="Enter"&&i()},autoComplete:"off",spellCheck:!1}),h,s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&s.jsx("p",{className:"capture-row-error",children:e.error}),Tn(e.locator)&&e.playlistProbeState==="done"&&e.playlistExpanded?s.jsxs("div",{className:"capture-playlist-items",children:[e.playlistItems.map(x=>s.jsxs("div",{className:`capture-playlist-item${x.quality===null?" capture-playlist-item--conflict":""}`,children:[s.jsx("span",{className:"capture-playlist-item-title",children:x.title||x.url}),s.jsxs("select",{className:"capture-item-quality",value:x.quality??"",onChange:S=>o(x.id,S.target.value),"aria-label":`Quality for ${x.title||x.url}`,children:[x.quality===null&&s.jsx("option",{value:"",disabled:!0,children:"Choose…"}),s.jsx("option",{value:"best",children:"Best quality"}),x.qualities.map(S=>s.jsx("option",{value:S,children:S},S)),x.has_audio&&s.jsx("option",{value:"audio",children:"Audio only"})]}),x.quality===null&&s.jsx("span",{className:"capture-playlist-conflict-badge",children:"Choose quality"}),s.jsx("button",{type:"button",className:"capture-playlist-item-remove","aria-label":`Remove ${x.title||x.url}`,onClick:()=>y(x.id),children:"×"})]},x.id)),v]}):v]})}function Om({item:e,onRemove:t}){const n=e.uploadStatus==="uploading",r=e.uploadStatus==="done",l=e.uploadStatus==="error";return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[s.jsx("span",{className:"capture-file-icon","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14},children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]})}),s.jsx("span",{className:`capture-file-name${l?" capture-file-name--error":""}`,children:e.filename}),n&&s.jsxs("span",{className:"capture-file-progress-wrap","aria-label":`Uploading ${e.uploadProgress}%`,children:[s.jsx("span",{className:"capture-file-progress-bar",children:s.jsx("span",{className:"capture-file-progress-fill",style:{width:`${e.uploadProgress}%`}})}),s.jsxs("span",{className:"capture-file-progress-pct",children:[e.uploadProgress,"%"]})]}),r&&s.jsx("span",{className:"capture-file-badge capture-file-badge--done","aria-label":"Upload complete",children:s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:11,height:11},children:s.jsx("polyline",{points:"3 8.5 6.5 12 13 5"})})}),l&&s.jsx("span",{className:"capture-file-badge capture-file-badge--error",children:"!"}),s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:t,"aria-label":"Remove",disabled:n,children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),l&&s.jsx("p",{className:"capture-row-error",children:e.uploadError||"Upload failed"})]})}function Am(){return s.jsxs("div",{className:"skeleton-row",children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:s.jsx("span",{className:"skeleton-cell",style:{width:108,height:13}})}),s.jsxs("div",{className:"col-title",style:{gap:"0.42em",display:"flex",alignItems:"center"},children:[s.jsx("span",{className:"skeleton-cell",style:{width:14,height:14,borderRadius:"50%",flexShrink:0}}),s.jsx("span",{className:"skeleton-cell",style:{width:"58%",height:13}})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"skeleton-cell",style:{width:58,height:20,borderRadius:99}})}),s.jsx("div",{className:"col-size",children:s.jsx("span",{className:"skeleton-cell",style:{width:44,height:12}})}),s.jsx("div",{className:"col-url",children:s.jsx("span",{className:"skeleton-cell",style:{width:"65%",height:12}})})]})}function cl(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(r===0?0:1)} ${t[r]}`}function Mm(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&apos;/g,"'")}function ot(e){return Mm(e)??""}function po(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const Lu={youtube:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="#FF0000" d="M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.6 12 3.6 12 3.6s-7.5 0-9.4.5A3 3 0 0 0 .5 6.2C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.5 9.4.5 9.4.5s7.5 0 9.4-.5a3 3 0 0 0 2.1-2.1C24 15.9 24 12 24 12s0-3.9-.5-5.8z"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>',youtube_music:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF0000"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>',spotify:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#1DB954"/><path fill="#fff" d="M17.9 10.9c-3.2-1.9-8.5-2.1-11.6-1.1-.5.1-1-.2-1.1-.6-.1-.5.2-1 .6-1.1 3.5-1.1 9.4-.9 13 1.3.4.2.6.8.3 1.2-.2.5-.8.6-1.2.3zm-.1 2.9c-.2.4-.7.5-1.1.3-2.7-1.6-6.7-2.1-9.9-1.1-.4.1-.9-.1-1-.5-.1-.4.1-.9.5-1 3.6-1.1 8-.5 11.1 1.3.4.2.5.7.4 1zm-1.3 2.8c-.2.3-.6.4-.9.2-2.3-1.4-5.2-1.7-8.6-.9-.3.1-.7-.1-.8-.5-.1-.3.1-.7.4-.8 3.7-.9 7-.5 9.6 1 .4.2.5.6.3.9z"/></svg>',x:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2 2h3.3l-7.2 8.2L23 22h-6.6l-5.2-6.8L5 22H1.7l7.7-8.8L1 2h6.8l4.7 6.2zm-1.1 18h1.8L6.9 3.9H5z"/></svg>',instagram:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="ig" x1="0%" y1="100%" x2="100%" y2="0%"><stop offset="0%" stop-color="#f09433"/><stop offset="25%" stop-color="#e6683c"/><stop offset="50%" stop-color="#dc2743"/><stop offset="75%" stop-color="#cc2366"/><stop offset="100%" stop-color="#bc1888"/></linearGradient></defs><rect width="24" height="24" rx="5" fill="url(#ig)"/><rect x="2.5" y="2.5" width="19" height="19" rx="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="12" cy="12" r="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="17.5" cy="6.5" r="1" fill="#fff"/></svg>',facebook:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#1877F2"/><path fill="#fff" d="M16 8h-2c-.6 0-1 .4-1 1v2h3l-.4 3H13v8h-3v-8H8v-3h2V9a4 4 0 0 1 4-4h2v3z"/></svg>',tiktok:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19.6 5.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V8.4a8 8 0 0 0 4.8 1.6V6.7a4.8 4.8 0 0 1-0-.2l0 0 .1.9z" fill="#000"/><path d="M18.6 4.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V7.4a8 8 0 0 0 4.8 1.6V5.7" fill="none" stroke="#69C9D0" stroke-width="1.5"/></svg>',reddit:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF4500"/><path fill="#fff" d="M20 12a2 2 0 0 0-2-2 2 2 0 0 0-1.3.5c-1.3-.9-3-.9-4.6-.9l.8-3.7 2.6.5a1.4 1.4 0 1 0 1.4-1.3 1.4 1.4 0 0 0-1.3.8l-2.9-.5a.3.3 0 0 0-.4.3l-.9 4.1c-1.6 0-3.1.1-4.3.9A2 2 0 0 0 4 12a2 2 0 0 0 1 1.7 3.3 3.3 0 0 0 0 .5c0 2.6 3 4.8 6.8 4.8s6.8-2.1 6.8-4.8a3.3 3.3 0 0 0 0-.5A2 2 0 0 0 20 12zm-13.6 1a1.1 1.1 0 1 1 1.1 1.1A1.1 1.1 0 0 1 6.4 13zm6.2 3.1a3.5 3.5 0 0 1-2.3.7 3.5 3.5 0 0 1-2.3-.7.3.3 0 0 1 .4-.4 3 3 0 0 0 1.9.5 3 3 0 0 0 1.9-.5.3.3 0 0 1 .4.4zm-.3-2a1.1 1.1 0 1 1 1.1-1.1A1.1 1.1 0 0 1 12.3 14.1z"/></svg>',snapchat:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#FFFC00"/><path d="M12 3.5c-2.4 0-4.4 2-4.4 4.4v1.3l-.8.1c-.3 0-.5.2-.5.5s.3.5.6.6c.3.1.5.3.5.8 0 .3-.1.5-.3.7-.6.8-1.5 1.3-2.2 1.4-.1.7.7 1 1.7 1.2.1.6.3.8.8.8.6 0 1.1.4 2.7.4 1.5 0 2.1-.4 2.7-.4.5 0 .7-.2.8-.8 1-.2 1.8-.5 1.7-1.2-.7-.1-1.6-.6-2.2-1.4-.2-.2-.3-.4-.3-.7 0-.5.2-.7.5-.8.3-.1.6-.3.6-.6s-.2-.5-.5-.5l-.8-.1V7.9C16.4 5.5 14.4 3.5 12 3.5z"/></svg>',local:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="#666" stroke-width="1.5" stroke-linejoin="round" d="M4 4h7l2 2h7v14H4z"/></svg>',web:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#555" stroke-width="1.5"/><ellipse cx="12" cy="12" rx="4" ry="10" fill="none" stroke="#555" stroke-width="1.5"/><line x1="2" y1="9" x2="22" y2="9" stroke="#555" stroke-width="1.5"/><line x1="2" y1="15" x2="22" y2="15" stroke="#555" stroke-width="1.5"/></svg>',other:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#999" stroke-width="1.5"/><text x="12" y="16" text-anchor="middle" font-size="12" fill="#999">?</text></svg>'};function Ms(e){return Lu[e]??Lu.other}function tf(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Fm({entry:e,index:t,onRowClick:n,selectedUids:r}){const l=(r==null?void 0:r.size)===1&&r.has(e.entry_uid),i=(r==null?void 0:r.size)>=2&&r.has(e.entry_uid),a=["child-entry-row",t%2===0?"child-entry-row--light":"child-entry-row--dark",l&&"is-selected",i&&"is-multi-selected"].filter(Boolean).join(" ");return s.jsxs("div",{className:a,tabIndex:0,"data-entry-uid":e.entry_uid,onMouseDown:o=>{o.shiftKey&&o.preventDefault()},onClick:o=>n(e,o),onKeyDown:o=>{o.key==="Enter"&&n(e,o)},children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:po(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[s.jsx("span",{className:"source-icon",children:s.jsx("span",{dangerouslySetInnerHTML:{__html:Ms(e.source_kind)}})}),s.jsx("span",{className:"entry-title",children:ot(e.title)||ot(e.entry_uid)})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:ot(e.entity_kind)})}),s.jsx("div",{className:"col-size",children:s.jsx("span",{className:"size-total",children:cl(e.total_artifact_bytes)})}),s.jsx("div",{className:"url-cell col-url",children:ot(e.original_url)})]})}function Bm({entry:e,archiveId:t,rowIndex:n,isSelected:r,isMultiSelected:l,onRowClick:i,selectedUids:a,deletedUids:o,isPublicSession:u}){const[c,y]=d.useState(!1),[g,h]=d.useState(!1),[v,x]=d.useState(null),[S,_]=d.useState(!1),f=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!c?s.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>y(!0),style:{objectFit:"contain"}}):s.jsx("span",{dangerouslySetInnerHTML:{__html:Ms(e.source_kind)}}),m=r||l,w=e.child_count>0&&!u;function E(k){k.stopPropagation(),i(e,{ctrlKey:!0,metaKey:!1,shiftKey:!1,preventDefault(){}})}async function b(k){if(k.stopPropagation(),g){h(!1);return}if(h(!0),v===null&&!S){_(!0);try{const P=await Bh(t,e.entry_uid);x(P)}catch{x([])}finally{_(!1)}}}const T=["entry-row-outer",n%2===0?"entry-row-outer--light":"entry-row-outer--dark",r&&"is-selected",l&&"is-multi-selected"].filter(Boolean).join(" ");return s.jsxs("div",{className:T,"data-entry-uid":e.entry_uid,children:[s.jsxs("div",{className:"entry-row-main",tabIndex:0,onMouseDown:k=>{k.shiftKey&&k.preventDefault()},onClick:k=>i(e,k),onKeyDown:k=>{k.key==="Enter"&&i(e,k)},children:[s.jsx("div",{className:"col-check",children:s.jsx("button",{type:"button",className:`row-checkbox${m?" is-checked":""}`,"aria-pressed":m,"aria-label":m?"Deselect entry":"Select entry",onClick:E,onKeyDown:k=>k.stopPropagation()})}),s.jsx("div",{className:"col-added",children:po(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[w&&s.jsx("button",{type:"button",className:`entry-expand-btn${g?" is-expanded":""}`,"aria-label":g?"Collapse children":`Expand ${e.child_count} items`,"aria-expanded":g,onClick:b,onKeyDown:k=>k.stopPropagation()}),s.jsx("span",{className:"source-icon",children:f}),s.jsx("span",{className:"entry-title",children:ot(e.title)||ot(e.entry_uid)}),w&&s.jsx("span",{className:"child-count-badge","aria-hidden":"true",children:e.child_count})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:ot(e.entity_kind)})}),s.jsxs("div",{className:"col-size",children:[s.jsx("span",{className:"size-total",children:cl(e.total_artifact_bytes)}),e.cached_bytes>0&&e.cacheable_bytes>0&&s.jsxs("span",{className:"size-cached-pct",title:`${cl(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.cacheable_bytes*100),"% cached"]})]}),s.jsx("div",{className:"url-cell col-url",children:ot(e.original_url)})]}),g&&s.jsxs(s.Fragment,{children:[S&&s.jsx("div",{className:"child-entries-loading",children:"Loading…"}),s.jsx("div",{className:"child-entries","aria-label":`${e.child_count} child entries`,children:v&&v.filter(k=>!(o!=null&&o.has(k.entry_uid))).map((k,P)=>s.jsx(Fm,{entry:k,index:P,onRowClick:i,selectedUids:a},k.entry_uid))})]})]})}function Um({entries:e,selectedUids:t,onRowClick:n,archiveId:r,pendingCaptures:l=[],deletedUids:i,isPublicSession:a}){return s.jsx("section",{id:"archive-view",className:"view is-active",children:s.jsxs("div",{className:"entry-table",children:[s.jsxs("div",{className:"entry-header-row",children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:"Added"}),s.jsx("div",{className:"col-title",children:"Title"}),s.jsx("div",{className:"col-type",children:"Type"}),s.jsx("div",{className:"col-size",children:"Size"}),s.jsx("div",{className:"col-url",children:"Original URL"})]}),s.jsxs("div",{id:"entries-body",children:[l.filter(o=>o.archiveId===r).reverse().map(o=>s.jsx(Am,{},o.id)),e.map((o,u)=>s.jsx(Bm,{entry:o,rowIndex:u,archiveId:r,isSelected:t.size===1&&t.has(o.entry_uid),isMultiSelected:t.size>=2&&t.has(o.entry_uid),onRowClick:n,selectedUids:t,deletedUids:i,isPublicSession:a},o.entry_uid))]})]})})}function Hm(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 Wm({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return s.jsx("span",{className:`run-status ${t}`,children:n})}function Vm({runs:e}){const[t,n]=d.useState(null);function r(l){n(i=>i===l?null:l)}return s.jsx("section",{id:"runs-view",className:"view is-active",children:s.jsxs("table",{className:"entry-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Requested"}),s.jsx("th",{children:"Completed"}),s.jsx("th",{children:"Failed"})]})}),s.jsx("tbody",{children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const i=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[s.jsxs("tr",{className:i?"run-row run-row--failed":"run-row",onClick:i?()=>r(l.run_uid):void 0,title:i?a?"Click to hide error":"Click to view error":void 0,children:[s.jsx("td",{children:Hm(l.started_at)}),s.jsxs("td",{children:[s.jsx(Wm,{status:l.status}),i&&s.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),s.jsx("td",{children:l.requested_count??"—"}),s.jsx("td",{children:l.completed_count??"—"}),s.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),i&&a&&s.jsx("tr",{className:"run-error-row",children:s.jsx("td",{colSpan:5,children:s.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Qm=4;function qm({archives:e}){const{currentUser:t}=d.useContext(Fs)??{},n=t&&(t.role_bits&Qm)!==0,[r,l]=d.useState("users"),[i,a]=d.useState([]),[o,u]=d.useState([]),[c,y]=d.useState(!1),[g,h]=d.useState(null),[v,x]=d.useState(""),[S,_]=d.useState(""),[p,f]=d.useState(""),[m,w]=d.useState(null),[E,b]=d.useState(!1),[T,k]=d.useState(""),[P,R]=d.useState(""),[G,B]=d.useState(null),[Y,ne]=d.useState(!1),ce=d.useCallback(async()=>{if(n){y(!0),h(null);try{const[L,Q]=await Promise.all([cm(),pm()]);a(L),u(Q)}catch(L){h(L.message)}finally{y(!1)}}},[n]);d.useEffect(()=>{ce()},[ce]);async function $e(L){const Q=L.status==="active"?"disabled":"active";try{await fm(L.user_uid,Q),a(K=>K.map(ee=>ee.user_uid===L.user_uid?{...ee,status:Q}:ee))}catch(K){h(K.message)}}async function ge(L){if(L.preventDefault(),!v.trim()||!S){w("Username and password required");return}b(!0),w(null);try{await dm(v.trim(),S,p.trim()||void 0),x(""),_(""),f(""),await ce()}catch(Q){w(Q.message)}finally{b(!1)}}async function D(L){if(L.preventDefault(),!T.trim()||!P.trim()){B("Slug and name required");return}ne(!0),B(null);try{await hm(T.trim(),P.trim()),k(""),R(""),await ce()}catch(Q){B(Q.message)}finally{ne(!1)}}return n?s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsxs("div",{className:"view-tabs",children:[s.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),s.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),s.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),g&&s.jsx("div",{className:"form-msg form-msg--err",children:g}),r==="users"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Users"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Username"}),s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Roles"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:i.map(L=>s.jsxs("tr",{className:L.status==="disabled"?"admin-row-disabled":"",children:[s.jsx("td",{children:L.username}),s.jsx("td",{className:"muted",children:L.email||"—"}),s.jsx("td",{children:L.role_slugs.join(", ")||"—"}),s.jsx("td",{children:s.jsx("span",{className:`status-badge status-${L.status}`,children:L.status})}),s.jsx("td",{children:s.jsx("button",{className:"admin-action-btn",onClick:()=>$e(L),children:L.status==="active"?"Ban":"Unban"})})]},L.user_uid))})]}),s.jsx("h3",{children:"Create User"}),s.jsxs("form",{className:"admin-form",onSubmit:ge,children:[s.jsx("input",{className:"admin-input",placeholder:"Username",value:v,onChange:L=>x(L.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:S,onChange:L=>_(L.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:p,onChange:L=>f(L.target.value)}),m&&s.jsx("div",{className:"form-msg form-msg--err",children:m}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:E,children:E?"Creating…":"Create User"})]})]}),r==="roles"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Roles"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Slug"}),s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Level"}),s.jsx("th",{children:"Bit"}),s.jsx("th",{children:"Built-in"})]})}),s.jsx("tbody",{children:o.map(L=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:L.slug})}),s.jsx("td",{children:L.name}),s.jsx("td",{children:L.level}),s.jsx("td",{children:L.bit_position}),s.jsx("td",{children:L.is_builtin?"✓":""})]},L.role_uid))})]}),s.jsx("h3",{children:"Create Custom Role"}),s.jsxs("form",{className:"admin-form",onSubmit:D,children:[s.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:T,onChange:L=>k(L.target.value),required:!0}),s.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:P,onChange:L=>R(L.target.value),required:!0}),G&&s.jsx("div",{className:"form-msg form-msg--err",children:G}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:Y,children:Y?"Creating…":"Create Role"})]})]}),r==="archives"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(L=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:L.label}),s.jsx("div",{className:"muted",children:L.archive_path})]},L.id))})]})]}):s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(L=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:L.label}),s.jsx("div",{className:"muted",children:L.archive_path})]},L.id))})]})}function nf({node:e,onPick:t}){var n;return s.jsxs("li",{children:[s.jsx("button",{className:"tag-picker-node-btn",title:e.tag.full_path,onClick:()=>t(e.tag),children:e.tag.slug}),((n=e.children)==null?void 0:n.length)>0&&s.jsx("div",{className:"tag-children",children:s.jsx("ul",{className:"tag-tree-list",children:e.children.map(r=>s.jsx(nf,{node:r,onPick:t},r.tag.tag_uid))})})]})}function Ru({title:e,tagNodes:t,excludeUid:n,onPick:r,onCancel:l}){d.useEffect(()=>{function o(u){u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),l())}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[l]);function i(o){return o.filter(u=>u.tag.tag_uid!==n).map(u=>({...u,children:i(u.children)}))}const a=n?i(t):t;return s.jsx("div",{className:"tag-picker-backdrop",onClick:o=>{o.target===o.currentTarget&&l()},children:s.jsxs("div",{className:"tag-picker-modal",role:"dialog","aria-modal":"true",children:[s.jsxs("div",{className:"tag-picker-header",children:[s.jsx("span",{className:"tag-picker-title",children:e}),s.jsx("button",{className:"tag-picker-close",onClick:l,title:"Cancel","aria-label":"Cancel",children:"×"})]}),s.jsxs("div",{className:"tag-picker-body",children:[s.jsx("button",{className:"tag-picker-root-btn",onClick:()=>r(null),title:"Place at root level (no parent)",children:"↑ Root tag (no parent)"}),a.length>0?s.jsx("ul",{className:"tag-tree-list tag-picker-tree",children:a.map(o=>s.jsx(nf,{node:o,onPick:r},o.tag.tag_uid))}):s.jsx("p",{className:"tag-picker-empty",children:"No other tags available."})]})]})})}function rf({parentPath:e,archiveId:t,onDone:n,onCancel:r}){const[l,i]=d.useState(""),a=d.useRef(!1);async function o(){const u=l.trim();if(!u){r();return}const c=e?`${e}/${u}`:`/${u}`;try{await Kh(t,c),n()}catch(y){alert(y.message||"Create failed"),r()}}return s.jsx("input",{className:"tag-rename-input",autoFocus:!0,placeholder:"tag name",value:l,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&u.currentTarget.blur(),u.key==="Escape"&&(a.current=!0,u.currentTarget.blur())},onBlur:()=>{a.current?(a.current=!1,r()):o()}})}function lf({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:c,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:h,onCreateCancel:v}){var G;const x=n===e.tag.full_path,[S,_]=d.useState(!1),[p,f]=d.useState(""),m=d.useRef(!1);function w(){if(S)return;if(c){y(e);return}const B=x?null:e.tag.full_path;r(B),l("archive")}function E(B){B.stopPropagation(),!c&&(f(e.tag.slug),_(!0))}async function b(){const B=p.trim();if(!B||B===e.tag.slug){_(!1);return}try{const Y=await Qh(t,e.tag.tag_uid,B);i(e.tag.full_path,Y.full_path),o()}catch{}finally{_(!1)}}async function T(B){var ne;B.stopPropagation();const Y=((ne=e.children)==null?void 0:ne.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(Y))try{await qh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const k={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:c,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:h,onCreateCancel:v},P=g===e.tag.tag_uid,R=((G=e.children)==null?void 0:G.length)>0;return s.jsxs("li",{children:[s.jsxs("div",{className:`tag-node-row${c?" tag-node-row--move-select":""}`,children:[S?s.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:p,onChange:B=>f(B.target.value),onKeyDown:B=>{B.key==="Enter"&&B.currentTarget.blur(),B.key==="Escape"&&(m.current=!0,B.currentTarget.blur())},onBlur:()=>{m.current?(m.current=!1,_(!1)):b()}}):s.jsxs("button",{className:`tag-node-btn${x?" is-active":""}${c?" tag-node-btn--move-select":""}`,title:c?`Select "${e.tag.full_path}" to move`:e.tag.full_path,onClick:w,onDoubleClick:c?void 0:E,children:[s.jsx("span",{className:"tag-node-label",children:u?e.tag.name:e.tag.slug}),s.jsx("span",{className:"tag-node-count",children:e.children.length===0?`(${e.entry_count})`:`(${e.entry_count}) (${e.subtree_count} Total)`}),!c&&s.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",title:"Rename tag",onClick:B=>{B.stopPropagation(),E(B)},children:s.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&&!c&&s.jsx("button",{className:"remove tag-node-delete",title:`Delete "${e.tag.full_path}"`,onClick:T,"aria-label":`Delete "${e.tag.full_path}"`,children:"×"})]}),(R||P)&&s.jsx("div",{className:"tag-children",children:s.jsxs("ul",{className:"tag-tree-list",children:[e.children.map(B=>s.jsx(lf,{node:B,...k},B.tag.tag_uid)),P&&s.jsx("li",{children:s.jsx(rf,{parentPath:e.tag.full_path,archiveId:t,onDone:h,onCancel:v})})]})})]})}function Km({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){const[c,y]=d.useState(null),[g,h]=d.useState(null);function v(){y("select-source"),h(null)}function x(){y(null),h(null)}d.useEffect(()=>{if(c!=="select-source")return;function Y(ne){ne.key==="Escape"&&(ne.preventDefault(),ne.stopPropagation(),x())}return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[c]);function S(Y){h(Y),y("select-dest")}async function _(Y){const ne=g.tag.full_path,ce=g.tag.tag_uid,$e=(Y==null?void 0:Y.tag_uid)??null;x();try{const ge=await Xh(e,ce,$e);i(ne,ge.full_path),o()}catch(ge){alert(ge.message||"Move failed")}}const[p,f]=d.useState(null),[m,w]=d.useState(void 0);function E(){f("select-parent"),w(void 0)}function b(){f(null),w(void 0)}function T(Y){w(Y??null),f("input")}function k(){f(null),w(void 0),o()}const P=c==="select-source",R=p==="input"?m?m.tag_uid:"__root__":void 0,G={archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:P,onMoveSourceSelect:S,pendingCreateParentUid:R,onCreateDone:k,onCreateCancel:b},B=R==="__root__";return s.jsxs("section",{id:"tags-view",className:"view is-active",children:[s.jsxs("div",{className:"tag-tree",children:[s.jsx("div",{className:"tag-tree-header",children:P?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title tag-tree-title--move",children:"Select a tag to move"}),s.jsx("button",{className:"tag-tree-action-btn tag-tree-action-btn--cancel",onClick:x,children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&s.jsxs("span",{className:"tag-tree-active",title:n,children:["Filtering: ",n]}),s.jsxs("div",{className:"tag-tree-actions",children:[s.jsx("button",{className:"tag-tree-action-btn",onClick:E,title:"Create a new tag",disabled:!!p||!!c,children:"+ New"}),s.jsx("button",{className:"tag-tree-action-btn",onClick:v,title:"Move a tag to a different parent",disabled:!!p||!!c||t.length===0,children:"Move"})]})]})}),t.length===0&&!B?s.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):s.jsxs("ul",{className:"tag-tree-list",children:[t.map(Y=>s.jsx(lf,{node:Y,...G},Y.tag.tag_uid)),B&&s.jsx("li",{children:s.jsx(rf,{parentPath:null,archiveId:e,onDone:k,onCancel:b})})]})]}),p==="select-parent"&&s.jsx(Ru,{title:"Create tag under…",tagNodes:t,excludeUid:null,onPick:T,onCancel:b}),c==="select-dest"&&g&&s.jsx(Ru,{title:`Move "${g.tag.slug}" under…`,tagNodes:t,excludeUid:g.tag.tag_uid,onPick:_,onCancel:x})]})}const Or=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],Xm=e=>{var t;return((t=Or.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function Jm({archiveId:e}){const[t,n]=d.useState([]),[r,l]=d.useState(!1),[i,a]=d.useState(null),[o,u]=d.useState(null),[c,y]=d.useState(null),[g,h]=d.useState(!1),[v,x]=d.useState(null),[S,_]=d.useState(""),[p,f]=d.useState(""),[m,w]=d.useState(2),[E,b]=d.useState(!1),[T,k]=d.useState(!0),[P,R]=d.useState(null),[G,B]=d.useState(""),[Y,ne]=d.useState(2),[ce,$e]=d.useState(!1),[ge,D]=d.useState(null),[L,Q]=d.useState(!1),[K,ee]=d.useState(""),De=d.useRef(null),te=t.find(O=>O.collection_uid===o)??null,je=(te==null?void 0:te.slug)==="_default_",se=d.useCallback(async()=>{if(e){l(!0),a(null);try{const O=await fo(e);n(O)}catch(O){a(O.message)}finally{l(!1)}}},[e]),Pe=d.useCallback(async O=>{if(!O){y(null);return}h(!0),x(null);try{const X=await gm(e,O);y(X)}catch(X){x(X.message)}finally{h(!1)}},[e]);d.useEffect(()=>{se()},[se]),d.useEffect(()=>{Pe(o)},[o,Pe]),d.useEffect(()=>{L&&De.current&&De.current.focus()},[L]),d.useEffect(()=>{c!=null&&ne(c.default_visibility_bits)},[c]);async function Mt(O){O.preventDefault();const X=S.trim(),ye=p.trim();if(!(!X||!ye)){b(!0),R(null);try{const Le=await mm(e,X,ye,m,T);_(""),f(""),w(2),k(!0),await se(),u(Le.collection_uid)}catch(Le){R(Le.message)}finally{b(!1)}}}async function Oe(){const O=K.trim();if(!O||!te){Q(!1);return}try{await vi(e,te.collection_uid,{name:O}),await se(),y(X=>X&&{...X,name:O})}catch(X){a(X.message)}finally{Q(!1)}}async function Ft(O){if(te)try{await vi(e,te.collection_uid,{default_visibility_bits:O}),await se(),y(X=>X&&{...X,default_visibility_bits:O})}catch(X){a(X.message)}}async function Tt(O){if(te)try{await vi(e,te.collection_uid,{requires_auth:O}),await se(),y(X=>X&&{...X,requires_auth:O})}catch(X){a(X.message)}}async function ht(){if(te&&window.confirm(`Delete collection "${te.name}"? Entries will not be deleted.`))try{await xm(e,te.collection_uid),u(null),y(null),await se()}catch(O){a(O.message)}}async function mt(O){O.preventDefault();const X=G.trim();if(!(!X||!te)){$e(!0),D(null);try{await ma(e,te.collection_uid,X,Y),B(""),await Pe(te.collection_uid)}catch(ye){D(ye.message)}finally{$e(!1)}}}async function Xe(O){if(te)try{await ym(e,te.collection_uid,O),await Pe(te.collection_uid)}catch(X){x(X.message)}}async function Pt(O,X){if(te)try{await vm(e,te.collection_uid,O,X),y(ye=>ye&&{...ye,entries:ye.entries.map(Le=>Le.entry_uid===O?{...Le,collection_visibility_bits:X}:Le)})}catch(ye){x(ye.message)}}return e?s.jsxs("div",{className:"collections-view",children:[s.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&s.jsx("div",{className:"muted",children:"Loading…"}),i&&s.jsxs("div",{className:"collections-error",children:[i," ",s.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),s.jsxs("div",{className:"collections-layout",children:[s.jsxs("div",{className:"collections-sidebar",children:[t.map(O=>s.jsxs("button",{className:`coll-sidebar-row${o===O.collection_uid?" is-active":""}`,onClick:()=>u(O.collection_uid),children:[s.jsx("span",{className:"coll-row-name",children:O.name}),s.jsx("span",{className:"coll-row-meta",children:Xm(O.default_visibility_bits)})]},O.collection_uid)),t.length===0&&!r&&s.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),te?s.jsxs("div",{className:"coll-detail",children:[s.jsxs("div",{className:"coll-detail-header",children:[L?s.jsx("input",{ref:De,className:"coll-rename-input",value:K,onChange:O=>ee(O.target.value),onBlur:Oe,onKeyDown:O=>{O.key==="Enter"&&Oe(),O.key==="Escape"&&Q(!1)}}):s.jsxs("h3",{className:`coll-detail-name${je?"":" coll-detail-name--editable"}`,title:je?void 0:"Click to rename",onClick:()=>{je||(ee(te.name),Q(!0))},children:[(c==null?void 0:c.name)??te.name,!je&&s.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!je&&s.jsx("button",{className:"coll-delete-btn",onClick:ht,title:"Delete collection",children:"Delete"})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Entries' default visibility"}),s.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??te.default_visibility_bits,onChange:O=>Ft(Number(O.target.value)),children:Or.map(O=>s.jsx("option",{value:O.value,children:O.label},O.value))})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Collection access"}),s.jsxs("label",{className:"coll-auth-label",children:[s.jsx("input",{type:"checkbox",checked:!!((c==null?void 0:c.requires_auth)??te.requires_auth),onChange:O=>Tt(O.target.checked)})," Require authentication to view"]})]}),s.jsxs("div",{className:"coll-entries-section",children:[s.jsx("div",{className:"coll-section-heading",children:"Entries"}),g&&s.jsx("div",{className:"muted",children:"Loading…"}),v&&s.jsx("div",{className:"collections-error",children:v}),!g&&c&&(c.entries.length===0?s.jsx("div",{className:"muted",children:"No entries in this collection."}):s.jsx("ul",{className:"coll-entries-list",children:c.entries.map(O=>s.jsxs("li",{className:"coll-entry-row",children:[s.jsxs("div",{className:"coll-entry-info",children:[s.jsx("span",{className:"coll-entry-title",children:O.title||O.entry_uid}),s.jsx("span",{className:"coll-entry-kind muted",children:O.source_kind})]}),s.jsxs("div",{className:"coll-entry-actions",children:[s.jsx("select",{className:"coll-entry-vis-select",value:O.collection_visibility_bits,onChange:X=>Pt(O.entry_uid,Number(X.target.value)),children:Or.map(X=>s.jsx("option",{value:X.value,children:X.label},X.value))}),!je&&s.jsx("button",{className:"coll-entry-remove",onClick:()=>Xe(O.entry_uid),title:"Remove from collection",children:"×"})]})]},O.entry_uid))}))]}),!je&&s.jsxs("form",{className:"coll-add-entry-form",onSubmit:mt,children:[s.jsx("div",{className:"coll-section-heading",children:"Add entry"}),s.jsxs("div",{className:"coll-add-entry-row",children:[s.jsx("input",{className:"coll-add-entry-input",type:"text",value:G,onChange:O=>B(O.target.value),placeholder:"entry_uid",required:!0}),s.jsx("select",{className:"coll-vis-select",value:Y,onChange:O=>ne(Number(O.target.value)),children:Or.map(O=>s.jsx("option",{value:O.value,children:O.label},O.value))}),s.jsx("button",{className:"coll-add-btn",type:"submit",disabled:ce,children:ce?"…":"Add"})]}),ge&&s.jsx("div",{className:"collections-error",style:{marginTop:4},children:ge})]})]}):s.jsx("div",{className:"coll-detail coll-detail--empty",children:s.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),s.jsxs("details",{className:"coll-create-details",children:[s.jsx("summary",{children:"+ Create collection"}),s.jsxs("form",{className:"coll-create-form",onSubmit:Mt,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),s.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:S,onChange:O=>{_(O.target.value),p||f(O.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),s.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:p,onChange:O=>f(O.target.value),placeholder:"my-collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Entries' default visibility"}),s.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:m,onChange:O=>w(Number(O.target.value)),children:Or.map(O=>s.jsx("option",{value:O.value,children:O.label},O.value))})]}),s.jsx("div",{className:"form-field",children:s.jsxs("label",{className:"form-label",children:[s.jsx("input",{type:"checkbox",checked:T,onChange:O=>k(O.target.checked)})," Require authentication to view"]})}),P&&s.jsx("div",{className:"collections-error",children:P}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:E,children:E?"Creating…":"Create collection"})]})]})]}):s.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const Gm=4;function Ym({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=d.useContext(Fs)??{},i=r&&(r.role_bits&Gm)!==0,a=["profile","tokens",...i?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return s.jsxs("section",{className:"admin-view",children:[s.jsx("h1",{children:"Settings"}),s.jsx("div",{className:"view-tabs",children:a.map(u=>s.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&s.jsx(Zm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&s.jsx(eg,{}),e==="instance"&&i&&s.jsx(tg,{}),e==="cookies"&&i&&s.jsx(rg,{}),e==="extensions"&&i&&s.jsx(lg,{}),e==="storage"&&i&&s.jsx(ng,{archiveId:n})]})}function Zm({currentUser:e,setCurrentUser:t}){const[n,r]=d.useState((e==null?void 0:e.display_name)??""),[l,i]=d.useState(!1),[a,o]=d.useState(null),[u,c]=d.useState(""),[y,g]=d.useState(""),[h,v]=d.useState(""),[x,S]=d.useState(!1),[_,p]=d.useState(null);async function f(w){w.preventDefault(),i(!0),o(null);try{await lm(n),t(E=>({...E,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(E){o({ok:!1,text:E.message})}finally{i(!1)}}async function m(w){if(w.preventDefault(),y!==h){p({ok:!1,text:"Passwords do not match."});return}S(!0),p(null);try{await im(u,y),c(""),g(""),v(""),p({ok:!0,text:"Password changed."})}catch(E){p({ok:!1,text:E.message})}finally{S(!1)}}return s.jsxs("div",{style:{maxWidth:440},children:[s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Name"}),s.jsxs("form",{onSubmit:f,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),s.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:w=>r(w.target.value)})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Preferences"}),s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async w=>{const E=w.target.checked;try{await sm({humanize_slugs:E}),t(b=>({...b,humanize_slugs:E}))}catch{}}}),s.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),s.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Change Password"}),s.jsxs("form",{onSubmit:m,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),s.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:w=>c(w.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),s.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:y,onChange:w=>g(w.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),s.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:h,onChange:w=>v(w.target.value),required:!0})]}),_&&s.jsx("div",{className:`form-msg form-msg--${_.ok?"ok":"err"}`,children:_.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function eg(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState(""),[u,c]=d.useState(!1),[y,g]=d.useState(null),h=d.useCallback(async()=>{r(!0),i(null);try{t(await am())}catch(S){i(S.message)}finally{r(!1)}},[]);d.useEffect(()=>{h()},[h]);async function v(S){if(S.preventDefault(),!!a.trim()){c(!0);try{const _=await om(a.trim());g(_),o(""),h()}catch(_){i(_.message)}finally{c(!1)}}}async function x(S){try{await um(S),t(_=>_.filter(p=>p.token_uid!==S))}catch(_){i(_.message)}}return s.jsx("div",{style:{maxWidth:600},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"API Tokens"}),y&&s.jsxs("div",{className:"token-banner",children:[s.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",s.jsx("code",{children:y.raw_token}),s.jsx("button",{className:"token-dismiss",onClick:()=>g(null),children:"Dismiss"})]}),s.jsxs("form",{className:"token-create-row",onSubmit:v,children:[s.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:S=>o(S.target.value),required:!0}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&s.jsx("div",{className:"form-msg form-msg--err",children:l}),n?s.jsx("div",{className:"muted",children:"Loading…"}):s.jsxs("div",{children:[e.length===0&&s.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(S=>s.jsxs("div",{className:"token-row",children:[s.jsxs("div",{className:"token-row-info",children:[s.jsx("strong",{children:S.name}),s.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)}`]})]}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(S.token_uid),children:"Revoke"})]},S.token_uid))]})]})})}function tg(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState(!1),[u,c]=d.useState(null);d.useEffect(()=>{(async()=>{try{t(await co())}catch(g){i(g.message)}finally{r(!1)}})()},[]);async function y(g){g.preventDefault(),o(!0),c(null);try{await Xl(e),c({ok:!0,text:"Saved."})}catch(h){c({ok:!1,text:h.message})}finally{o(!1)}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):e?s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Instance Settings"}),s.jsxs("form",{onSubmit:y,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([g,h])=>s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:!!e[g],onChange:v=>t(x=>({...x,[g]:v.target.checked}))}),h]},g)),s.jsxs("div",{className:"form-field",style:{marginTop:4},children:[s.jsx("label",{className:"form-label",children:"Default entry visibility"}),s.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:g=>t(h=>({...h,default_entry_visibility:Number(g.target.value)})),children:[s.jsx("option",{value:0,children:"Private"}),s.jsx("option",{value:2,children:"Unlisted"}),s.jsx("option",{value:3,children:"Public"})]})]}),u&&s.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function wi(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n===0?0:1)} ${t[n]}`}function ng({archiveId:e}){const[t,n]=d.useState("idle"),[r,l]=d.useState(null),[i,a]=d.useState(null),[o,u]=d.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function y(){n("scanning"),u(null),l(null);try{const v=await wm(e);l(v),n("scanned")}catch(v){u(v.message),n("error")}}async function g(){n("deleting"),u(null);try{const v=await km(e);a(v),n("done")}catch(v){u(v.message),n("error")}}const h=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Orphan Cleanup"}),s.jsxs("p",{className:"muted",style:{marginBottom:16},children:["Scan for blob files and database records that are no longer referenced by any archive entry and safely delete them."," ",s.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&s.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&s.jsx("button",{className:"btn-ghost",onClick:y,children:"Scan for orphaned blobs"}),t==="scanning"&&s.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!h&&s.jsxs("div",{children:[s.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",s.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",s.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",s.jsx("strong",{children:wi(r.total_bytes)})," recoverable."]}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("button",{className:"btn-danger",onClick:g,children:["Delete (",wi(r.total_bytes),")"]}),s.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&s.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&i&&s.jsxs("div",{children:[s.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",s.jsx("strong",{children:wi(i.freed_bytes)})," ","— removed ",i.deleted_files," file",i.deleted_files!==1?"s":""," ","and ",i.deleted_blob_rows," DB record",i.deleted_blob_rows!==1?"s":"","."]}),i.errors&&i.errors.length>0&&s.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[i.errors.length," file",i.errors.length!==1?"s":""," could not be deleted."]}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&s.jsxs("div",{children:[s.jsx("div",{className:"form-msg form-msg--err",children:o}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function rg(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(null),[a,o]=d.useState("global"),[u,c]=d.useState(""),[y,g]=d.useState("{}"),[h,v]=d.useState(null),[x,S]=d.useState(!1),[_,p]=d.useState({});d.useEffect(()=>{f()},[]);async function f(){r(!0),i(null);try{t(await Nm())}catch(k){i(k.message)}finally{r(!1)}}async function m(k){k.preventDefault();try{JSON.parse(y)}catch{v({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}S(!0),v(null);try{await _m(a==="global"?null:u.trim(),a,y),c(""),g("{}"),o("global"),v({ok:!0,text:"Rule added."}),await f()}catch(P){v({ok:!1,text:P.message})}finally{S(!1)}}async function w(k){try{await Em(k),await f()}catch(P){i(P.message)}}function E(k){p(P=>({...P,[k.rule_uid]:{cookiesInput:k.cookies_json,saving:!1,msg:null}}))}function b(k){p(P=>{const R={...P};return delete R[k],R})}async function T(k){const P=_[k.rule_uid];try{JSON.parse(P.cookiesInput)}catch{p(R=>({...R,[k.rule_uid]:{...R[k.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}p(R=>({...R,[k.rule_uid]:{...R[k.rule_uid],saving:!0,msg:null}}));try{await Cm(k.rule_uid,{cookies_json:P.cookiesInput}),b(k.rule_uid),await f()}catch(R){p(G=>({...G,[k.rule_uid]:{...G[k.rule_uid],saving:!1,msg:{ok:!1,text:R.message}}}))}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):s.jsx("div",{style:{maxWidth:560},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Cookie Rules"}),s.jsx("p",{className:"muted",style:{marginBottom:12},children:"Cookies are injected into every capture network request (yt-dlp, HTTP downloads, web-page snapshots). Global rules apply to all URLs; wildcard and regex rules apply only to matching URLs."}),e&&e.length>0?s.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Pattern"}),s.jsx("th",{children:"Cookies"}),s.jsx("th",{style:{width:100},children:"Actions"})]})}),s.jsx("tbody",{children:e.map(k=>{const P=_[k.rule_uid],R=k.url_pattern?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted",children:[k.pattern_kind,":"]})," ",s.jsx("code",{children:k.url_pattern})]}):s.jsx("span",{className:"muted",children:"global (all URLs)"});return s.jsxs("tr",{children:[s.jsx("td",{children:R}),s.jsx("td",{children:P?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:P.cookiesInput,onChange:G=>p(B=>({...B,[k.rule_uid]:{...B[k.rule_uid],cookiesInput:G.target.value}}))}),P.msg&&s.jsx("div",{className:`form-msg form-msg--${P.msg.ok?"ok":"err"}`,children:P.msg.text}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[s.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:P.saving,onClick:()=>T(k),children:P.saving?"Saving…":"Save"}),s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>b(k.rule_uid),children:"Cancel"})]})]}):s.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:k.cookies_json})}),s.jsx("td",{children:!P&&s.jsxs("div",{style:{display:"flex",gap:6},children:[s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>E(k),children:"Edit"}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>w(k.rule_uid),children:"Del"})]})})]},k.rule_uid)})})]}):s.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),s.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),s.jsxs("form",{onSubmit:m,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Pattern type"}),s.jsxs("select",{className:"field-input",value:a,onChange:k=>o(k.target.value),children:[s.jsx("option",{value:"global",children:"Global (all URLs)"}),s.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),s.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),s.jsx("input",{className:"field-input",type:"text",value:u,onChange:k=>c(k.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:y,onChange:k=>g(k.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),h&&s.jsx("div",{className:`form-msg form-msg--${h.ok?"ok":"err"}`,children:h.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Adding…":"Add Rule"})]})]})})}function lg(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[l,i]=d.useState(!1),[a,o]=d.useState(null);d.useEffect(()=>{(async()=>{try{t(await co())}catch(_){o({ok:!1,text:_.message})}finally{r(!1)}})()},[]);async function u(_){i(!0),o(null);try{await Xl({ublock_enabled:_}),t(p=>({...p,ublock_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function c(_){i(!0),o(null);try{await Xl({cookie_ext_enabled:_}),t(p=>({...p,cookie_ext_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function y(_){i(!0),o(null);try{await Xl({modal_closer_enabled:_}),t(p=>({...p,modal_closer_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}if(n)return s.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,h=(e==null?void 0:e.ublock_enabled)??!0,v=(e==null?void 0:e.cookie_ext_available)??!1,x=(e==null?void 0:e.cookie_ext_enabled)??!0,S=(e==null?void 0:e.modal_closer_enabled)??!0;return s.jsx("div",{children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Extensions"}),s.jsx("p",{className:"form-hint",style:{marginBottom:20},children:"Extensions run inside the browser during WebPage captures and can block ads, accept cookie banners, and more. Changes take effect on the next capture."}),s.jsxs("div",{className:"ext-grid",children:[s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":h,className:`ext-toggle${h?" ext-toggle--on":""}`,onClick:()=>u(!h),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),s.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!v&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":x,className:`ext-toggle${x?" ext-toggle--on":""}`,onClick:()=>c(!x),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"Modal & Dialog Closer"}),s.jsx("span",{className:"ext-card-desc",children:"Auto-dismiss cookie banners, consent overlays, and other modal dialogs before a WebPage capture is taken. Implemented as an injected browser script; no external extension required."})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle${S?" ext-toggle--on":""}`,onClick:()=>y(!S),disabled:l,"aria-label":"Toggle Modal and Dialog Closer",children:s.jsx("span",{className:"ext-toggle-knob"})})]})})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const zu={0:"Private",1:"Public",2:"Users only",3:"Public"},Jl=[{value:"anthropic_http",label:"Anthropic API"},{value:"openai_compatible",label:"OpenAI-compatible API"},{value:"claude_cli",label:"Claude CLI"},{value:"codex_cli",label:"Codex CLI"}],sg=Object.fromEntries(Jl.map(e=>[e.value,e.label])),Iu="archivr:summary:provider",ig=1500;function ag(e){if(!e)return null;try{const t=JSON.parse(e);if(t&&typeof t=="object")return{tldr:typeof t.tldr=="string"?t.tldr:"",summary:typeof t.summary=="string"?t.summary:"",tags:Array.isArray(t.tags)?t.tags.filter(n=>typeof n=="string"):[]}}catch{}return{tldr:"",summary:e,tags:[]}}const og=()=>s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function ug({archiveId:e,selectedEntry:t,selectedUids:n,selectedEntries:r,detail:l,onTagFilterSet:i,tagNodes:a,onTagsRefresh:o,onEntryTitleChange:u,onEntryDeleted:c,onBulkDeleted:y,humanizeTags:g,onDetailRefresh:h,onOpenPreview:v,onPlay:x,isPublicSession:S}){var z,$,q;const[_,p]=d.useState([]),[f,m]=d.useState(""),[w,E]=d.useState([]),[b,T]=d.useState(""),k=d.useRef(0),P=d.useRef(!1),[R,G]=d.useState(!1),[B,Y]=d.useState(""),[ne,ce]=d.useState("idle"),[$e,ge]=d.useState(""),D=d.useRef(null),[L,Q]=d.useState(!1);d.useEffect(()=>{Q(!1)},[(z=l==null?void 0:l.summary)==null?void 0:z.entry_uid]);const[K,ee]=d.useState(null),[De,te]=d.useState(""),[je,se]=d.useState(!1),[Pe,Mt]=d.useState(()=>{try{return sessionStorage.getItem(Iu)||Jl[0].value}catch{return Jl[0].value}}),Oe=d.useRef(null),Ft=(n==null?void 0:n.size)>=2,[Tt,ht]=d.useState(""),[mt,Xe]=d.useState("idle"),[Pt,O]=d.useState(""),[X,ye]=d.useState([]),[Le,Yt]=d.useState(""),[Ae,Bt]=d.useState("idle"),[Mn,Lt]=d.useState(""),[We,kn]=d.useState("idle"),[Rt,j]=d.useState(""),[U,M]=d.useState("idle"),[A,W]=d.useState("");d.useEffect(()=>{const N=++k.current;if(D.current&&(clearInterval(D.current),D.current=null),ce("idle"),ge(""),!t||!e){p([]),E([]);return}if(S){p([]),E([]);return}G(!1),Y(""),P.current=!1,p([]),Promise.all([$l(e,t.entry_uid),Tu(e,t.entry_uid)]).then(([F,J])=>{N===k.current&&(p(F),E(J))}).catch(()=>{})},[t,e,S]),d.useEffect(()=>()=>{clearInterval(D.current)},[]),d.useEffect(()=>{clearInterval(Oe.current),Oe.current=null,ee((l==null?void 0:l.latest_summary)??null),te(""),se(!1)},[($=l==null?void 0:l.summary)==null?void 0:$.entry_uid]);const V=K==null?void 0:K.status;d.useEffect(()=>{var F;if(clearInterval(Oe.current),Oe.current=null,V!=="pending"&&V!=="running"||!e||!((F=l==null?void 0:l.summary)!=null&&F.entry_uid))return;const N=l.summary.entry_uid;return Oe.current=setInterval(async()=>{var J;try{const de=await Mh(e,N);ee(de.summary??null);const ie=(J=de.summary)==null?void 0:J.status;ie!=="pending"&&ie!=="running"&&(clearInterval(Oe.current),Oe.current=null,se(!1),ie==="completed"&&(h==null||h()))}catch{}},ig),()=>{clearInterval(Oe.current),Oe.current=null}},[V,e,(q=l==null?void 0:l.summary)==null?void 0:q.entry_uid]),d.useEffect(()=>()=>clearInterval(Oe.current),[]);async function pe(N=!1){var F;if(!(!e||!((F=l==null?void 0:l.summary)!=null&&F.entry_uid)||je)){se(!0),te("");try{const J=await Fh(e,l.summary.entry_uid,{provider:Pe,force:N});J.status==="completed"?(ee(J),se(!1),h==null||h()):ee({...J??{},status:"pending"})}catch(J){te(J.message||"Summary request failed"),se(!1)}}}function ae(N){Mt(N);try{sessionStorage.setItem(Iu,N)}catch{}}d.useEffect(()=>{if(!e){ye([]);return}fo(e).then(ye).catch(()=>ye([]))},[e]),d.useEffect(()=>{ht(""),Xe("idle"),O(""),Yt(""),Bt("idle"),Lt(""),kn("idle"),j(""),M("idle"),W("")},[n]);async function Ee(){const N=n.size;if(!window.confirm(`Delete ${N} entr${N===1?"y":"ies"}? This cannot be undone.`))return;kn("running");const F=new Set;for(const J of n)try{await bu(e,J),F.add(J)}catch{}kn("idle"),y==null||y(F)}async function oe(){const N=Tt.trim();if(N){Xe("running"),O("");try{for(const F of n)await Eu(e,F,N);ht(""),Xe("done"),o==null||o(),setTimeout(()=>Xe("idle"),1800)}catch(F){O(F.message),Xe("error")}}}async function Je(){if(!Le)return;Bt("running"),Lt("");const N=[],F=X.find(J=>J.collection_uid===Le);for(const J of n)try{await ma(e,Le,J,(F==null?void 0:F.default_visibility_bits)??2)}catch{N.push(J)}N.length>0?(Lt(`Failed for ${N.length} entr${N.length===1?"y":"ies"}.`),Bt("error")):(Bt("done"),setTimeout(()=>Bt("idle"),1800))}async function Se(){if(!Rt||!t)return;M("running"),W("");const N=X.find(F=>F.collection_uid===Rt);try{await ma(e,Rt,t.entry_uid,(N==null?void 0:N.default_visibility_bits)??2),M("done"),j("");const F=await Tu(e,t.entry_uid);E(F),setTimeout(()=>M("idle"),1800)}catch(F){W(F.message),M("error")}}async function Fn(){const N=B.trim()||null;try{await Wh(e,t.entry_uid,N),u==null||u(t.entry_uid,N)}catch{}finally{G(!1)}}async function it(){const N=f.trim();if(!(!N||!t))try{await Eu(e,t.entry_uid,N),m(""),T("");const F=await $l(e,t.entry_uid);p(F),o()}catch(F){T(F.message)}}async function Bs(N){try{await Vh(e,t.entry_uid,N);const F=await $l(e,t.entry_uid);p(F),o()}catch{}}async function Us(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await bu(e,t.entry_uid),c==null||c(t.entry_uid)}catch{}}async function Hs(){if(!t||!e||ne==="running")return;const N=k.current,F=t.entry_uid;ce("running"),ge("");try{const{job_uid:J}=await jm(e,F);if(k.current!==N)return;D.current=setInterval(async()=>{try{const de=await Zd(e,J);if(de.status==="completed"){if(clearInterval(D.current),D.current=null,k.current!==N)return;ce("done");const ie=await $l(e,F);if(k.current!==N)return;p(ie),h==null||h()}else if(de.status==="failed"){if(clearInterval(D.current),D.current=null,k.current!==N)return;ce("error"),ge(de.error_text||"Re-archive failed.")}}catch{if(clearInterval(D.current),D.current=null,k.current!==N)return;ce("error"),ge("Network error while polling.")}},500)}catch(J){if(k.current!==N)return;ce("error"),ge(J.message||"Failed to start re-archive.")}}const Bn=l?[["Added",po(l.summary.archived_at)],["Source",l.summary.source_kind],["Type",l.summary.entity_kind],["Visibility",zu[l.summary.visibility]??l.summary.visibility],["Root",l.structured_root_relpath]]:[],jr=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),jn=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),Sn=l?l.artifacts.findIndex(N=>N.artifact_role==="primary_media"):-1,Un=Sn>=0?l.artifacts[Sn]:null,gl=Un?Un.relpath.split(".").pop().toLowerCase():"",yl=Un&&jr.has(gl),Ws=Sn>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${Sn}`:null,C=l&&!yl&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread"||Un&&jn.has(gl));return s.jsxs("aside",{className:"context-rail",children:[s.jsx("div",{className:"rail-eyebrow",children:"Context"}),Ft?S?s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}):s.jsxs("div",{className:"bulk-panel",children:[s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}),s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Assign tag"}),Pt&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:Pt}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:Tt,onChange:N=>ht(N.target.value),onKeyDown:N=>{N.key==="Enter"&&oe()}}),s.jsx("button",{className:"tag-add-btn",onClick:oe,disabled:mt==="running"||!Tt.trim(),children:mt==="running"?"…":mt==="done"?"✓":"Add"})]})]}),X.length>0&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Add to collection"}),s.jsxs("div",{className:"bulk-coll-row",children:[s.jsxs("select",{className:"bulk-coll-select",value:Le,onChange:N=>Yt(N.target.value),children:[s.jsx("option",{value:"",children:"Pick a collection…"}),X.filter(N=>N.slug!=="_default_").map(N=>s.jsx("option",{value:N.collection_uid,children:N.name},N.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:Je,disabled:!Le||Ae==="running",children:Ae==="running"?"…":Ae==="done"?"✓":Ae==="error"?"!":"Add"})]}),Mn&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"6px 0 0"},children:Mn})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:Ee,disabled:We==="running",children:We==="running"?"Deleting…":`Delete ${n.size} entr${n.size===1?"y":"ies"}`})})]}):t?l?s.jsxs(s.Fragment,{children:[S?s.jsx("h2",{className:"rail-title",children:ot(l.summary.title)||ot(l.summary.entry_uid)}):R?s.jsx("input",{className:"rail-title-input",autoFocus:!0,value:B,onChange:N=>Y(N.target.value),onKeyDown:N=>{N.key==="Enter"&&N.currentTarget.blur(),N.key==="Escape"&&(P.current=!0,N.currentTarget.blur())},onBlur:()=>{P.current?G(!1):Fn(),P.current=!1}}):s.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{Y(l.summary.title??""),G(!0)},children:[ot(l.summary.title)||ot(l.summary.entry_uid),s.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:s.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),l.summary.original_url&&s.jsxs("a",{className:"url-tile",href:l.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[s.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Ms(l.summary.source_kind)}}),s.jsx("span",{className:"u-text",children:l.summary.original_url}),s.jsx("span",{className:"ext",children:s.jsx(og,{})})]}),yl&&x&&s.jsx("button",{className:"rail-preview-btn",onClick:()=>x(Ws,t),children:"▶ Play"}),C&&v&&s.jsx("button",{className:"rail-preview-btn",onClick:v,children:"Preview"}),(()=>{const N=(K==null?void 0:K.status)==="completed"?ag(K.summary_text):null,F=(K==null?void 0:K.status)==="pending"||(K==null?void 0:K.status)==="running";return S&&!N?null:s.jsxs("div",{className:"rail-section rail-summary",children:[s.jsx("div",{className:"rail-section-heading",children:"Summary"}),N&&s.jsxs("div",{className:"rail-summary-body",children:[N.tldr&&s.jsx("p",{className:"rail-summary-tldr",children:N.tldr}),N.summary&&s.jsx("p",{className:"rail-summary-text",children:N.summary}),N.tags.length>0&&s.jsx("div",{className:"rail-summary-tags",children:N.tags.map(J=>s.jsx("span",{className:"rail-summary-tag",children:J},J))}),s.jsxs("p",{className:"rail-summary-provider",children:[sg[K.provider_kind]||K.provider_kind,K.provider_model?` · ${K.provider_model}`:""]})]}),F&&s.jsxs("p",{className:"rail-summary-status",children:[s.jsx("span",{className:"rail-summary-spinner","aria-hidden":"true"}),"Generating…"]}),(K==null?void 0:K.status)==="failed"&&K.error_text&&!S&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:K.error_text}),De&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:De}),!S&&!F&&s.jsxs("div",{className:"rail-summary-controls",children:[s.jsx("select",{className:"rail-summary-select",value:Pe,onChange:J=>ae(J.target.value),"aria-label":"Summary provider",children:Jl.map(J=>s.jsx("option",{value:J.value,children:J.label},J.value))}),s.jsx("button",{className:"rail-rearchive-btn",onClick:()=>pe(!!N),disabled:je,children:je?"…":N?"Regenerate":"Generate"})]})]})})(),s.jsx("div",{className:"meta-list",children:Bn.filter(([,N])=>N!=null&&N!=="").map(([N,F])=>s.jsxs("div",{className:"meta-item",children:[s.jsx("span",{className:"meta-k",children:N}),s.jsx("span",{className:`meta-v${N==="Root"?" mono":""}`,children:ot(F)})]},N))}),l.artifacts.length>0&&(()=>{const N=l.artifacts.map((be,Wn)=>({...be,_idx:Wn})),F=N.filter(be=>be.artifact_role==="font"),J=N.filter(be=>be.artifact_role!=="font"),de=F.reduce((be,Wn)=>be+(Wn.byte_size||0),0),ie=l.summary.entry_uid,Hn=be=>s.jsx("li",{children:s.jsxs("a",{href:`/api/archives/${e}/entries/${ie}/artifacts/${be._idx}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[s.jsx("span",{className:"artifact-name",children:be.artifact_role==="font"?be.relpath.split("/").pop():be.artifact_role.replace(/_/g," ")}),s.jsx("span",{className:"artifact-size",children:be.byte_size!=null?cl(be.byte_size):"—"})]})},be._idx);return s.jsxs("div",{className:"rail-section",children:[s.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",s.jsx("span",{className:"num",children:l.artifacts.length})]}),s.jsxs("ul",{className:"artifact-list",children:[J.map(Hn),F.length>0&&s.jsxs("li",{className:"artifact-group",children:[s.jsxs("button",{type:"button",className:"artifact-group-header artifact-link","aria-expanded":L,onClick:()=>Q(be=>!be),children:[s.jsxs("span",{className:"artifact-name",children:[s.jsx("span",{"aria-hidden":"true",className:`artifact-group-chevron${L?" open":""}`,children:"›"}),` fonts (${F.length})`]}),s.jsx("span",{className:"artifact-size",children:cl(de)})]}),L&&s.jsx("ul",{className:"artifact-list artifact-group-body",children:F.map(Hn)})]})]})]})})()]}):s.jsx("p",{className:"tags-empty",children:"Loading\\u2026"}):s.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&!Ft&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Tags"}),_.length===0?s.jsx("p",{className:"tags-empty",children:"No tags yet."}):s.jsx("div",{className:"tags-wrap",children:_.map(N=>s.jsxs("span",{className:"tag-pill",title:N.full_path,children:[g?tf(N.full_path):N.full_path,s.jsx("button",{className:"remove",title:`Remove tag ${N.full_path}`,onClick:()=>Bs(N.tag_uid),children:"×"})]},N.tag_uid))}),b&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:b}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:f,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&it()}}),s.jsx("button",{className:"tag-add-btn",onClick:it,children:"Add"})]})]}),(w.length>0||X.filter(N=>N.slug!=="_default_").length>0)&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Collections"}),w.map(N=>s.jsxs("div",{className:"coll-row",children:[s.jsx("span",{className:"coll-name",children:N.name}),s.jsx("span",{className:"vis-badge",children:zu[N.visibility_bits]??`bits:${N.visibility_bits}`})]},N.collection_uid)),X.filter(N=>N.slug!=="_default_").length>0&&s.jsxs("div",{className:"bulk-coll-row",style:{marginTop:8},children:[s.jsxs("select",{className:"bulk-coll-select",value:Rt,onChange:N=>j(N.target.value),children:[s.jsx("option",{value:"",children:"Add to collection…"}),X.filter(N=>N.slug!=="_default_").map(N=>s.jsx("option",{value:N.collection_uid,children:N.name},N.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:Se,disabled:!Rt||U==="running",children:U==="running"?"…":U==="done"?"✓":U==="error"?"!":"Add"})]}),A&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"4px 0 0"},children:A})]}),l&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread")&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Actions"}),s.jsx("button",{className:"rail-rearchive-btn",onClick:Hs,disabled:ne==="running",children:ne==="running"?"Re-archiving…":"Re-archive"}),ne==="done"&&s.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),ne==="error"&&s.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:$e})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:Us,children:"Delete entry"})})]})]})}const cg=/\/api\/archives\/([^/]+)\/entries\/([^/]+)\/artifacts\/(\d+)/;function dg(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M5 17H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h18a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"}),s.jsx("polygon",{points:"12 15 17 21 7 21 12 15"})]})}function fg({src:e,contentType:t="video/mp4"}){const n=d.useRef(null),[r,l]=d.useState(null),[i,a]=d.useState(!1),[o,u]=d.useState(!1);d.useEffect(()=>{if(!e){l(null);return}const g=e.match(cg);if(!g){l(e);return}let h=!1;return l(null),Sm(g[1],g[2],parseInt(g[3],10)).then(({url:v})=>{h||l(v)}).catch(()=>{h||l(e)}),()=>{h=!0}},[e]),d.useEffect(()=>{n.current&&n.current.load()},[r]),d.useEffect(()=>{u(typeof HTMLVideoElement<"u"&&"webkitShowPlaybackTargetPicker"in HTMLVideoElement.prototype)},[]),d.useEffect(()=>{var h;const g=v=>{if(v)try{cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a(!0)}catch{}};if((h=window.cast)!=null&&h.framework)g(!0);else if(window.__onGCastApiAvailable=g,!document.querySelector('script[src*="cast_sender"]')){const v=document.createElement("script");v.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(v)}},[]),d.useEffect(()=>{if(!i||!r)return;const g=cast.framework.CastContext.getInstance(),{CastContextEventType:h,SessionState:v}=cast.framework,x=_=>{if(!_)return;const p=new chrome.cast.media.MediaInfo(window.location.origin+r,t);_.loadMedia(new chrome.cast.media.LoadRequest(p)).catch(()=>{})};x(g.getCurrentSession());const S=_=>{(_.sessionState===v.SESSION_STARTED||_.sessionState===v.SESSION_RESUMED)&&x(g.getCurrentSession())};return g.addEventListener(h.SESSION_STATE_CHANGED,S),()=>g.removeEventListener(h.SESSION_STATE_CHANGED,S)},[i,r,t]);const c=()=>{var g,h;(h=(g=n.current)==null?void 0:g.webkitShowPlaybackTargetPicker)==null||h.call(g)},y=i||o;return s.jsx("div",{className:"preview-video-wrap",style:{position:"relative"},children:e?s.jsxs(s.Fragment,{children:[r?s.jsxs("video",{ref:n,controls:!0,autoPlay:!1,playsInline:!0,"x-webkit-airplay":"allow",style:{width:"100%",maxHeight:"100%",display:"block"},children:[s.jsx("source",{src:r}),"Your browser does not support the video element."]}):s.jsx("div",{className:"video-tv-loading","aria-label":"Loading video…"}),y&&r&&s.jsxs("div",{className:"video-tv-controls",children:[o&&s.jsx("button",{className:"video-tv-btn",title:"AirPlay to device","aria-label":"AirPlay to device",onClick:c,children:s.jsx(dg,{})}),i&&s.jsx("google-cast-launcher",{className:"video-tv-btn",title:"Cast to TV"})]})]}):s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function $u({src:e,type:t,title:n,originalUrl:r}){const l=r||e,i=n||null;return s.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[s.jsxs("div",{className:"preview-iframe-toolbar",style:{display:"flex",flexDirection:"column",gap:"2px",padding:"6px 12px",borderBottom:"1px solid var(--line-soft)",background:"var(--paper-2)",flexShrink:0},children:[i&&s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),s.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{fontSize:"0.78rem",color:"var(--accent)",textDecoration:"none",whiteSpace:"nowrap",fontFamily:"var(--sans)",flexShrink:0},children:t==="pdf"?"Open PDF ↗":"Open in new tab ↗"})]})]}),s.jsx("iframe",{src:e,sandbox:"allow-same-origin allow-popups",allow:"autoplay 'none'",referrerPolicy:"no-referrer",style:{flex:1,border:"none",width:"100%",minHeight:0},title:i||(t==="pdf"?"PDF preview":"Page preview")})]})}function pg({src:e,alt:t}){return s.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:s.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:s.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function sf(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function Du(e){return!e||!e.includes("&")?e:e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&apos;/g,"'")}const Z={card:{background:"var(--paper)",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},threadOuter:{border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},tweetRow:{display:"flex",gap:"10px",padding:"10px 12px"},tweetRowThread:{display:"flex",gap:"10px",padding:"10px 12px 0"},leftCol:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:"36px"},rightCol:{flex:1,minWidth:0,paddingBottom:"8px"},avatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},avatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},threadLine:{flex:1,width:"2px",background:"var(--line-soft, var(--line))",margin:"4px 0",minHeight:"12px",borderRadius:"1px"},authorRow:{display:"flex",alignItems:"baseline",gap:"4px",flexWrap:"wrap",marginBottom:"4px",lineHeight:"1.3"},authorName:{fontWeight:"700",fontSize:"14px",color:"var(--ink)"},authorHandle:{fontSize:"13px",color:"var(--muted)"},datePart:{fontSize:"13px",color:"var(--muted)"},tweetText:{fontSize:"14px",lineHeight:"1.5",color:"var(--ink)",whiteSpace:"pre-line",marginBottom:"8px",wordBreak:"break-word"},stats:{display:"flex",gap:"12px",fontSize:"13px",color:"var(--muted)"},link:{color:"var(--accent)",textDecoration:"none"},loading:{padding:"24px 16px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},error:{padding:"24px 16px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},mediaGrid:{marginBottom:"8px",borderRadius:"10px",overflow:"hidden",border:"1px solid var(--line)"},mediaImg:{display:"block",width:"100%",objectFit:"cover",maxHeight:"260px"},mediaVideo:{display:"block",width:"100%",maxHeight:"260px",background:"#000"},article:{maxWidth:"560px",margin:"0 auto",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"280px"},aMeta:{padding:"10px 14px 0"},aTweetTitle:{fontSize:"20px",fontWeight:"800",letterSpacing:"-0.3px",color:"var(--ink)",lineHeight:"1.3",marginBottom:"8px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},aAvatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},aAuthorName:{fontSize:"14px",fontWeight:"700",color:"var(--ink)",lineHeight:"1.3"},aAuthorSub:{fontSize:"13px",color:"var(--muted)",lineHeight:"1.3"},aDivider:{border:"none",borderTop:"1px solid var(--line)",margin:"0"},aBody:{padding:"4px 14px 16px"},bH1:{fontSize:"22px",fontWeight:"800",letterSpacing:"-0.4px",color:"var(--ink)",lineHeight:"1.25",margin:"16px 0 6px"},bH2:{fontSize:"18px",fontWeight:"700",letterSpacing:"-0.2px",color:"var(--ink)",lineHeight:"1.3",margin:"14px 0 4px"},bP:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.65",marginBottom:"12px",marginTop:"0"},bSpacer:{height:"4px",display:"block"},bQuote:{borderLeft:"3px solid var(--line)",padding:"2px 12px",margin:"12px 0",color:"var(--muted)",fontSize:"15px",lineHeight:"1.6"},bHr:{border:"none",borderTop:"1px solid var(--line)",margin:"14px 0"},bImg:{width:"100%",display:"block",borderRadius:"8px",margin:"12px 0"},bUl:{margin:"8px 0 12px",paddingLeft:"24px"},bOl:{margin:"8px 0 12px",paddingLeft:"24px"},bLi:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.6",marginBottom:"4px"},bTweet:{display:"flex",alignItems:"center",gap:"10px",border:"1px solid var(--line)",borderRadius:"10px",padding:"10px 14px",margin:"12px 0",color:"var(--muted)",fontSize:"14px",textDecoration:"none"},bMdPre:{borderRadius:"8px",margin:"10px 0",overflow:"auto",background:"var(--paper-3, var(--field))",padding:"12px 14px"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"12px",lineHeight:"1.6",color:"var(--ink)",background:"transparent",display:"block"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:"var(--paper-3, var(--field))",padding:"1px 5px",borderRadius:"4px",color:"var(--ink)"},qtBadge:{fontSize:"11px",color:"var(--muted)",display:"inline-flex",alignItems:"center",gap:"2px",marginLeft:"4px",letterSpacing:"0.03em",flexShrink:0},lightboxBackdrop:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},lightboxContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",maxWidth:"90vw",maxHeight:"90vh"},lightboxToolbar:{display:"flex",alignItems:"center",gap:"10px",alignSelf:"flex-end"},lightboxImg:{maxWidth:"88vw",maxHeight:"80vh",objectFit:"contain",borderRadius:"6px",display:"block"},lightboxNav:{display:"flex",gap:"12px",alignItems:"center"},lightboxNavBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"20px",cursor:"pointer",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"16px",cursor:"pointer",borderRadius:"50%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxLink:{color:"rgba(255,255,255,0.7)",textDecoration:"none",fontSize:"14px"},lightboxCounter:{color:"rgba(255,255,255,0.6)",fontSize:"13px"}},Re={bg:"#000000",border:"#2f3336",text:"#e7e9ea",dim:"#71767b",accent:"#1d9bf0",codeBg:"#16181c"},ki={article:{background:Re.bg,color:Re.text,minHeight:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'},articleInner:{maxWidth:"598px",margin:"0 auto",paddingBottom:"80px"},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"420px"},aMeta:{padding:"20px 16px 0"},aTweetTitle:{fontSize:"34px",fontWeight:"800",letterSpacing:"-0.5px",color:Re.text,lineHeight:"44px",marginBottom:"16px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},aAvatar:{width:"40px",height:"40px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"40px",height:"40px",borderRadius:"50%",background:Re.border,flexShrink:0},aAuthorName:{fontSize:"15px",fontWeight:"700",color:Re.text,lineHeight:"1.3"},aAuthorSub:{fontSize:"15px",color:Re.dim,lineHeight:"1.3"},aDivider:{border:"none",borderTop:`1px solid ${Re.border}`,margin:"0"},aBody:{padding:"4px 16px 0"},bH1:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:Re.text,lineHeight:"36px",margin:"24px 0 10px"},bH2:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:Re.text,lineHeight:"36px",margin:"24px 0 10px"},bP:{fontSize:"17px",color:Re.text,lineHeight:"1.5",marginBottom:"16px",marginTop:"0"},bSpacer:{height:"6px",display:"block"},bQuote:{borderLeft:`3px solid ${Re.border}`,padding:"2px 14px",margin:"14px 0",color:Re.dim,fontSize:"17px",lineHeight:"1.5"},bHr:{border:"none",borderTop:`1px solid ${Re.border}`,margin:"28px 0"},bImg:{width:"100%",display:"block",borderRadius:"12px",margin:"16px 0"},bUl:{margin:"10px 0 16px",paddingLeft:"28px"},bOl:{margin:"10px 0 16px",paddingLeft:"28px"},bLi:{fontSize:"17px",color:Re.text,lineHeight:"1.5",marginBottom:"6px"},bTweet:{display:"flex",alignItems:"center",gap:"12px",border:`1px solid ${Re.border}`,borderRadius:"12px",padding:"14px 16px",margin:"14px 0",color:Re.dim,fontSize:"15px",textDecoration:"none"},bMdPre:{borderRadius:"12px",margin:"12px 0",overflow:"auto",background:"#1e2029"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"13px",lineHeight:"1.65",padding:"18px 20px",display:"block",color:Re.text,background:"transparent"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:Re.codeBg,padding:"2px 6px",borderRadius:"4px",color:"#e6edf3"},link:{color:Re.accent,textDecoration:"none"}};function hg(e,t,n){const r={};return n&&n.forEach((l,i)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${i}`)}),r}function dr(e,t,n){return e&&n[e]?n[e]:t||null}function af(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:s.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"})})}function ho(e,t,...n){var r;if(e.fromIndex!=null&&e.toIndex!=null)return{s:e.fromIndex,e:e.toIndex};if(((r=e.indices)==null?void 0:r.length)===2)return{s:e.indices[0],e:e.indices[1]};if(t)for(const l of n){if(!l)continue;const i=t.indexOf(l);if(i!==-1)return{s:i,e:i+l.length}}return null}function of(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=ho(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function uf(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=ho(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Ou=/https?:\/\/[^\s<>"'\])]+/g,mg=/[.,;:!?)()]+$/;function js(e,t){const n=[];let r=0,l;for(Ou.lastIndex=0;(l=Ou.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let i=l[0].replace(mg,"");n.push(s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:t,children:i},l.index));const a=l[0].slice(i.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(r<e.length&&n.push(e.slice(r)),n)}function gg(e,t,n=[]){if(!e)return null;const r=[...(t.urls||[]).map(o=>of(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>uf(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return js(Du(e),Z.link);const l=new Set([0,e.length]);for(const o of r)o.s>=0&&o.s<=e.length&&l.add(o.s),o.e>=0&&o.e<=e.length&&l.add(o.e);for(const[o,u]of n)o>=0&&o<=e.length&&l.add(o),u>=0&&u<=e.length&&l.add(u);const i=(o,u)=>n.some(([c,y])=>c<=o&&y>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(i(o,c))return null;const y=e.slice(o,c),g=r.filter(x=>x.s<=o&&x.e>=c),h=g.find(x=>x.kind==="url");if(h)return s.jsx("a",{href:h.href,target:"_blank",rel:"noopener noreferrer",style:Z.link,children:h.display||y},u);const v=g.find(x=>x.kind==="mention");return v?s.jsx("a",{href:`https://x.com/${v.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:Z.link,children:y},u):s.jsx("span",{children:js(Du(y),Z.link)},u)}).filter(o=>o!==null)}function yg(e,t,n,r,l=Z){if(!e)return null;t=t||[],n=n||[],r=r||[];const i=[];for(const u of t)u.length>0&&i.push({s:u.offset,e:u.offset+u.length,kind:"style",style:u.style});for(const u of n){const c=of(u,e);c&&i.push(c)}for(const u of r){const c=uf(u,e);c&&i.push(c)}if(i.length===0)return js(e,l.link);const a=new Set([0,e.length]);for(const u of i)u.s>=0&&u.s<=e.length&&a.add(u.s),u.e>=0&&u.e<=e.length&&a.add(u.e);const o=[...a].sort((u,c)=>u-c);return o.slice(0,-1).map((u,c)=>{const y=o[c+1],g=i.filter(_=>_.s<=u&&_.e>=y),h=e.slice(u,y);let v;if(h.includes(`
`)){const _=h.split(`
`);v=_.flatMap((p,f)=>f<_.length-1?[p,s.jsx("br",{},f)]:[p])}else v=h;g.some(_=>_.kind==="style"&&_.style==="Code")&&(v=s.jsx("code",{style:l.iCode,children:v})),g.some(_=>_.kind==="style"&&_.style==="Bold")&&(v=s.jsx("strong",{children:v})),g.some(_=>_.kind==="style"&&_.style==="Italic")&&(v=s.jsx("em",{children:v})),g.some(_=>_.kind==="style"&&_.style==="Underline")&&(v=s.jsx("u",{children:v})),g.some(_=>_.kind==="style"&&_.style==="Strikethrough")&&(v=s.jsx("s",{children:v}));const x=g.find(_=>_.kind==="url");if(x){const _=/^https?:\/\/t\.co\//i.test(v);v=s.jsx("a",{href:x.href,target:"_blank",rel:"noopener noreferrer",style:l.link,children:_?x.display:v})}const S=g.find(_=>_.kind==="mention");return S&&(v=s.jsx("a",{href:`https://x.com/${S.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:l.link,children:v})),s.jsx("span",{children:typeof v=="string"?js(v,l.link):v},c)})}function vg(e,t,n){const r=(n==null?void 0:n.st)||Z,l=e.resolved_entities||[];return l.length===0?null:l.map((i,a)=>{var o;switch(i.type){case"divider":return s.jsx("hr",{style:r.bHr},a);case"media":{const u=dr(i.local_path,i.url,t);return u?s.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:c=>{var y;!c.metaKey&&!c.ctrlKey&&(c.preventDefault(),(y=n==null?void 0:n.onImgClick)==null||y.call(n,u))},children:s.jsx("img",{src:u,style:r.bImg,loading:"lazy",alt:""})},a):null}case"tweet":return i.tweet_id?s.jsxs("a",{href:`https://x.com/i/status/${i.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:r.bTweet,children:[s.jsx(af,{}),"View post on X"]},a):null;case"link":return i.url?s.jsx("p",{style:r.bP,children:s.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",style:r.link,children:i.url})},a):null;case"markdown":{const u=i.markdown??((o=i.data)==null?void 0:o.markdown)??"";return s.jsx("pre",{style:r.bMdPre,children:s.jsx("code",{style:r.bMdCode,children:u})},a)}case"emoji":return i.url?s.jsx("img",{src:i.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},a):null;default:return null}})}function ji(e,t,n,r){const l=(r==null?void 0:r.st)||Z,i=e.type||"",a=e.text||"",o=e.inline_style_ranges||[],u=e.data||{},c=yg(a,o,u.urls||[],u.mentions||[],l);switch(i){case"header-one":return s.jsx("h1",{style:l.bH1,children:c},t);case"header-two":{const y=a.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return y?s.jsxs("a",{href:`https://x.com/i/status/${y[1]}`,target:"_blank",rel:"noopener noreferrer",style:l.bTweet,children:[s.jsx(af,{}),"View post on X"]},t):s.jsx("h2",{style:l.bH2,children:c},t)}case"unstyled":return a.trim()?s.jsx("p",{style:l.bP,children:c},t):s.jsx("span",{style:l.bSpacer},t);case"blockquote":return s.jsx("blockquote",{style:l.bQuote,children:c},t);case"unordered-list-item":case"ordered-list-item":return s.jsx("li",{style:l.bLi,children:c},t);case"atomic":return s.jsx("span",{children:vg(e,n,r)},t);default:return a?s.jsx("p",{style:l.bP,children:c},t):null}}function xg(e,t,n){const r=(n==null?void 0:n.st)||Z,l=[];let i=0;for(;i<e.length;){const a=e[i];if(a.type==="unordered-list-item"){const o=i,u=[];for(;i<e.length&&e[i].type==="unordered-list-item";)u.push(ji(e[i],i,t,n)),i++;l.push(s.jsx("ul",{style:r.bUl,children:u},`ul-${o}`))}else if(a.type==="ordered-list-item"){const o=i,u=[];for(;i<e.length&&e[i].type==="ordered-list-item";)u.push(ji(e[i],i,t,n)),i++;l.push(s.jsx("ol",{style:r.bOl,children:u},`ol-${o}`))}else l.push(ji(a,i,t,n)),i++}return l}function wg({article:e,tweetAuthor:t,artifactMap:n,fullPage:r,onXArticle:l}){const[i,a]=d.useState(null);d.useEffect(()=>{r&&(l==null||l(!0))},[r,l]);const o=r?ki:Z,u=e.cover_media||{},c=e.author||t||{},y=e.first_published_at_secs?sf(e.first_published_at_secs):"",h=[c.screen_name?`@${c.screen_name}`:"",y].filter(Boolean).join(" · "),v=dr(u.local_path,u.url,n),x=dr(c.avatar_local_path,c.avatar_url,n),S=s.jsxs(s.Fragment,{children:[i&&s.jsx(cf,{items:[{src:i,alt:""}],startIndex:0,onClose:()=>a(null)}),v&&s.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:_=>{!_.metaKey&&!_.ctrlKey&&(_.preventDefault(),a(v))},children:s.jsx("img",{src:v,style:o.aCover,alt:"Article cover"})}),s.jsxs("div",{style:o.aMeta,children:[e.title&&s.jsx("div",{style:o.aTweetTitle,children:e.title}),s.jsxs("div",{style:o.aAuthorRow,children:[x?s.jsx("img",{src:x,style:o.aAvatar,alt:c.name||""}):s.jsx("div",{style:o.aAvatarPh}),s.jsxs("div",{children:[s.jsx("div",{style:o.aAuthorName,children:c.name||c.screen_name||"Unknown"}),h&&s.jsx("div",{style:o.aAuthorSub,children:h})]})]})]}),s.jsx("hr",{style:o.aDivider}),s.jsx("div",{style:o.aBody,children:xg(e.blocks||[],n,{onImgClick:a,st:o})})]});return r?s.jsx("div",{style:ki.article,children:s.jsx("div",{style:ki.articleInner,children:S})}):s.jsx("div",{style:Z.article,children:S})}function kg({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return s.jsx("a",{href:e[0].src,target:"_blank",rel:"noopener noreferrer",style:{display:"block"},onClick:l=>{!l.metaKey&&!l.ctrlKey&&(l.preventDefault(),t(0))},children:s.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:Z.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,i)=>s.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&i===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(i))},children:s.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},i))})}function cf({items:e,startIndex:t,onClose:n}){const[r,l]=d.useState(t);d.useEffect(()=>{const a=o=>{(o.key==="Escape"||o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.stopPropagation(),o.preventDefault()),o.key==="Escape"&&n(),o.key==="ArrowRight"&&l(u=>Math.min(u+1,e.length-1)),o.key==="ArrowLeft"&&l(u=>Math.max(u-1,0))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,e.length]);const i=e[r];return s.jsx("div",{style:Z.lightboxBackdrop,onClick:n,children:s.jsxs("div",{style:Z.lightboxContent,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{style:Z.lightboxToolbar,children:[e.length>1&&s.jsxs("span",{style:Z.lightboxCounter,children:[r+1," / ",e.length]}),s.jsx("a",{href:i.src,target:"_blank",rel:"noopener noreferrer",style:Z.lightboxLink,title:"Open in new tab",children:"↗"}),s.jsx("button",{style:Z.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),s.jsx("img",{src:i.src,alt:i.alt||"",style:Z.lightboxImg}),e.length>1&&s.jsxs("div",{style:Z.lightboxNav,children:[s.jsx("button",{style:Z.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),s.jsx("button",{style:Z.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function Au({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var f,m;const[l,i]=d.useState(null),a=e.author||{},o=e.created_at_secs?sf(e.created_at_secs):"",u=e.entities||{},c=dr(a.avatar_local_path,a.avatar_url,r),y=t&&!n,g=e.is_quote_status===!0,h=t?Z.tweetRowThread:Z.tweetRow,v=e.full_text||"",x=((m=(f=e.extended_entities)==null?void 0:f.media)!=null&&m.length?e.extended_entities.media:u.media)||[],S=[],_=[];for(const w of x)if(w.type==="photo"){const E=dr(w.local_path,w.media_url_https,r);E&&S.push({kind:"photo",src:E,alt:w.alt_text||""})}else if(w.type==="video"||w.type==="animated_gif"){const E=w.local_path&&r[w.local_path]||(()=>{var T,k;return(k=(((T=w.video_info)==null?void 0:T.variants)||[]).filter(P=>P.content_type==="video/mp4").sort((P,R)=>(R.bitrate||0)-(P.bitrate||0))[0])==null?void 0:k.url})();E&&_.push({kind:w.type==="animated_gif"?"gif":"video",src:E})}const p=[];for(const w of x){if(!w.url||!(w.type==="photo"?S.some(T=>T.src===dr(w.local_path,w.media_url_https,r)):_.length>0))continue;const b=ho(w,v,w.url);b&&p.push([b.s,b.e])}return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx(cf,{items:S,startIndex:l,onClose:()=>i(null)}),s.jsxs("div",{style:h,children:[s.jsxs("div",{style:Z.leftCol,children:[c?s.jsx("img",{src:c,style:Z.avatar,alt:a.name||""}):s.jsx("div",{style:Z.avatarPh}),y&&s.jsx("div",{style:Z.threadLine})]}),s.jsxs("div",{style:Z.rightCol,children:[s.jsxs("div",{style:Z.authorRow,children:[s.jsx("span",{style:Z.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&s.jsxs("span",{style:Z.authorHandle,children:["@",a.screen_name]}),o&&s.jsxs("span",{style:Z.datePart,children:["· ",o]}),g&&s.jsx("span",{style:Z.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),s.jsx("div",{style:Z.tweetText,children:gg(v,u,p)}),S.length>0&&s.jsx("div",{style:Z.mediaGrid,children:s.jsx(kg,{photos:S,onOpen:w=>i(w)})}),_.map((w,E)=>s.jsx("div",{style:Z.mediaGrid,children:s.jsx("video",{src:w.src,style:Z.mediaVideo,controls:!0,loop:w.kind==="gif",muted:w.kind==="gif",autoPlay:w.kind==="gif"})},E)),(e.retweet_count>0||e.favorite_count>0)&&s.jsxs("div",{style:Z.stats,children:[e.favorite_count>0&&s.jsxs("span",{children:["❤️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&s.jsxs("span",{children:["🔁 ",e.retweet_count.toLocaleString()]})]})]})]})]})}function jg({archiveId:e,entryUid:t,artifacts:n,entityKind:r,fullPage:l,onXArticle:i}){const[a,o]=d.useState(!0),[u,c]=d.useState(null),[y,g]=d.useState([]);if(d.useEffect(()=>{if(o(!0),c(null),g([]),!n||!e||!t){o(!1);return}const x=n.map((_,p)=>({..._,index:p})).filter(_=>_.artifact_role==="raw_tweet_json");if(x.length===0){c("No tweet data found."),o(!1);return}let S=!1;return Uh(e,t,x.map(_=>_.index)).then(async _=>{if(S)return;const p=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,f=T=>{var P;const k=T.full_text||"";return(((P=T.entities)==null?void 0:P.urls)||[]).map(R=>{var G;if(R.fromIndex!=null&&R.toIndex!=null)return[R.fromIndex,R.toIndex];if(((G=R.indices)==null?void 0:G.length)===2)return[R.indices[0],R.indices[1]];if(R.url){const B=k.indexOf(R.url);if(B!==-1)return[B,B+R.url.length]}return null}).filter(Boolean)},m=(T,k,P)=>T.some(([R,G])=>R<=k&&G>=P),w=new Set;for(const T of _){const k=T.full_text||"",P=f(T);let R;for(p.lastIndex=0;(R=p.exec(k))!==null;)m(P,R.index,R.index+R[0].length)||w.add(R[0])}const E=w.size>0?await Hh([...w]).catch(()=>({})):{},b=_.map(T=>{var B;const k=T.full_text||"",P=f(T),R=[];let G;for(p.lastIndex=0;(G=p.exec(k))!==null;){const Y=G[0],ne=E[Y];ne&&ne!==Y&&!m(P,G.index,G.index+Y.length)&&R.push({url:Y,expanded_url:ne,display_url:(()=>{try{const ce=new URL(ne);return ce.hostname+(ce.pathname.length>1?"/…":"")}catch{return ne}})(),fromIndex:G.index,toIndex:G.index+Y.length})}return R.length===0?T:{...T,entities:{...T.entities||{},urls:[...((B=T.entities)==null?void 0:B.urls)||[],...R]}}});S||g(b)}).catch(_=>{S||c(_.message||"Failed to load tweet.")}).finally(()=>{S||o(!1)}),()=>{S=!0}},[e,t,n]),a)return s.jsx("div",{style:Z.loading,children:"Loading…"});if(u)return s.jsxs("div",{style:Z.error,children:["Error: ",u]});if(y.length===0)return null;const h=hg(e,t,n);if(r==="tweet_thread")return s.jsx("div",{style:Z.threadOuter,children:y.map((x,S)=>s.jsx(Au,{tweet:x,isInThread:!0,isLast:S===y.length-1,artifactMap:h},x.id||S))});const v=y[0];return v.is_article&&v.article?s.jsx(wg,{article:v.article,tweetAuthor:v.author,artifactMap:h,fullPage:l,onXArticle:i}):s.jsx("div",{style:Z.card,children:s.jsx(Au,{tweet:v,isInThread:!1,isLast:!0,artifactMap:h})})}const Sg=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),Ng=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),_g=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]),Cg={mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo",m4v:"video/mp4",ogv:"video/ogg"};function df({archiveId:e,entry:t,detail:n,fullPage:r,onXArticle:l}){if(!t)return s.jsx("div",{className:"preview-panel preview-panel--empty",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return s.jsx("div",{className:"preview-panel preview-panel--loading",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:i,artifacts:a}=n,o=i.entry_uid,u=i.entity_kind;if(u==="tweet"||u==="tweet_thread"){const v=s.jsx(jg,{archiveId:e,entryUid:o,artifacts:a,entityKind:u,fullPage:r,onXArticle:l});return r?v:s.jsx("div",{className:"preview-tweet-wrap",children:v})}const c=a.findIndex(v=>v.artifact_role==="primary_media");if(c===-1)return s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),a.length>0&&s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]});const y=a[c],g=`/api/archives/${e}/entries/${o}/artifacts/${c}`,h=y.relpath.split(".").pop().toLowerCase();return Sg.has(h)?s.jsx("div",{className:"preview-panel",children:s.jsx(fg,{src:g,contentType:Cg[h]||"video/mp4"})}):Ng.has(h)?s.jsxs("div",{className:"preview-panel preview-panel--audio",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",fontFamily:"var(--sans)"},children:[s.jsx("span",{style:{fontSize:"2rem"},children:"🎵"}),s.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:i.title||o}),s.jsx("audio",{src:g,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):h==="pdf"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx($u,{src:g,type:"pdf",title:i.title,originalUrl:i.original_url})}):h==="html"||h==="htm"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx($u,{src:g,type:"page",title:i.title,originalUrl:i.original_url})}):_g.has(h)?s.jsx("div",{className:"preview-panel",style:{height:"100%"},children:s.jsx(pg,{src:g,alt:i.title||"Image"})}):s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((v,x)=>s.jsxs("li",{children:[v.artifact_role,": ",v.relpath]},x))})]})}function Eg({archiveId:e,entry:t,detail:n,onClose:r}){var l,i;return d.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:s.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((i=n==null?void 0:n.summary)==null?void 0:i.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"preview-modal-header",children:[s.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),s.jsx("a",{className:"preview-modal-newtab",href:`/preview/${e}/${t==null?void 0:t.entry_uid}`,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",children:"↗"}),s.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"×"})]}),s.jsx("div",{className:"preview-modal-body",children:s.jsx(df,{archiveId:e,entry:t,detail:n})})]})})}function Mu(e){if(!isFinite(e)||isNaN(e))return"--:--";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,"0")}`}function bg({entry:e,src:t,archiveId:n,onClose:r}){const l=d.useRef(null),[i,a]=d.useState(!1),[o,u]=d.useState(0),[c,y]=d.useState(NaN),[g,h]=d.useState(1);d.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),y(NaN),a(!1))},[t]),d.useEffect(()=>{l.current&&(l.current.volume=g)},[g]);function v(){const f=l.current;f&&(i?f.pause():f.play().catch(()=>{}))}function x(f){const m=l.current;if(!m||!isFinite(c))return;const w=Number(f.target.value);m.currentTime=w,u(w)}function S(f){h(Number(f.target.value))}const _=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",p=(e==null?void 0:e.source_kind)||"other";return s.jsxs(s.Fragment,{children:[s.jsx("audio",{ref:l,src:t||void 0,preload:"auto",onPlay:()=>a(!0),onPause:()=>a(!1),onEnded:()=>a(!1),onTimeUpdate:()=>{var f;return u(((f=l.current)==null?void 0:f.currentTime)??0)},onLoadedMetadata:()=>{var f;return y(((f=l.current)==null?void 0:f.duration)??NaN)},onDurationChange:()=>{var f;return y(((f=l.current)==null?void 0:f.duration)??NaN)},style:{display:"none"}}),s.jsxs("div",{className:"audio-bar",style:{position:"fixed",bottom:0,left:0,right:0,zIndex:100,background:"var(--paper-3)",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",gap:"16px",padding:"0 16px",height:"56px",fontFamily:"var(--sans)"},children:[s.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[s.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:Ms(p)}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:_,children:_})]}),s.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[s.jsx("button",{onClick:v,"aria-label":i?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:i?"⏸":"▶"}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Mu(o)}),s.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:x,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Mu(c)})]}),s.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[s.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"🔊"}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:g,onChange:S,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),s.jsx("button",{onClick:r,"aria-label":"Close audio player",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--muted)",fontSize:"1rem",lineHeight:1,marginLeft:"4px"},children:"✕"})]})]})]})}function Tg({archiveId:e,entryUid:t}){var h,v;const[n,r]=d.useState(null),[l,i]=d.useState(!0),[a,o]=d.useState(null),[u,c]=d.useState(!1);d.useEffect(()=>{if(!u)return;const x=document.documentElement,S=document.body,_=x.style.colorScheme,p=S.style.background;return x.style.colorScheme="dark",S.style.background="#000",()=>{x.style.colorScheme=_,S.style.background=p}},[u]),d.useEffect(()=>{c(!1),Dr(e,t).then(x=>{r(x),i(!1)}).catch(x=>{o((x==null?void 0:x.message)||"Failed to load entry"),i(!1)})},[e,t]);const y=((h=n==null?void 0:n.summary)==null?void 0:h.title)||t,g=(v=n==null?void 0:n.summary)==null?void 0:v.original_url;return s.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:u?"#000":"var(--paper)",fontFamily:"var(--sans)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:u?"8px 12px":"10px 16px",borderBottom:u?"none":"1px solid var(--line)",flexShrink:0,position:u?"sticky":"relative",top:0,zIndex:20,background:u?"rgba(0,0,0,0.82)":"var(--paper-2)",backdropFilter:u?"blur(12px)":"none",WebkitBackdropFilter:u?"blur(12px)":"none"},children:[s.jsx("a",{href:"/",style:{color:u?"#1d9bf0":"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),s.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:u?"#e7e9ea":"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),g&&s.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:u?"#71767b":"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),s.jsxs("div",{style:u?{flex:1}:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&s.jsx(df,{archiveId:e,entry:n.summary,detail:n,fullPage:!0,onXArticle:c})]})]})}const Pg=7e3;function Lg({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?s.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>s.jsx(zg,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Rg(e){if(!e)return null;if(e.length<=52)return e;try{const{hostname:t,pathname:n,search:r}=new URL(e),l=n.split("/").filter(Boolean),i=(l[l.length-1]??"")+r,a=i?`${t}/…/${i}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function zg({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=d.useState(!1),i=e.type==="warning",a=e.type==="success";d.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Pg);return()=>clearTimeout(u)},[r,e.id,t]);const o=Rg(e.locator);return a?s.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✓"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsx("div",{className:"toast-btns",children:s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})})]})}):i?s.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&s.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&s.jsx("p",{className:"toast-warning-detail",children:e.text||"The page was captured but one or more browser extensions were unavailable (ad-blocking or cookie-consent). Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config."})]}):s.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&e.text&&s.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const Fs=d.createContext(null),Ig=["archive","tags","collections","runs","admin","settings"],$g=["profile","tokens","instance","cookies","extensions","storage"],Lr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})();function It(){const e=window.location.pathname.split("/").filter(Boolean),t=Ig.includes(e[0])?e[0]:"archive",n=t==="settings"&&$g.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",i=t==="archive"?r.get("tag")??null:null,a=t==="archive"?r.get("entry")??null:null,o=t==="archive"?r.get("collection")??null:null,u=o==="main"?null:o,c=r.get("archive")??null;return{view:t,settingsTab:n,q:l,tag:i,entry:a,collection:u,archive:c}}function Dg(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Og(){const[e,t]=d.useState("loading"),[n,r]=d.useState(null);d.useEffect(()=>{(async()=>{var $,q,N;if(await Zh()){t("setup");return}const z=await rm();if(!z){const{collection:F,archive:J}=It();try{const de=await _u(),ie=J?(($=de.find(Hn=>Hn.id===J))==null?void 0:$.id)??((q=de[0])==null?void 0:q.id):(N=de[0])==null?void 0:N.id;if(ie){await Cu(ie,F),i(de),o(ie),c(F),t("authenticated");return}}catch{}t("login");return}r(z),t("authenticated")})()},[]),d.useEffect(()=>{const C=()=>{n&&(r(null),t("login"))};return window.addEventListener("auth:expired",C),()=>window.removeEventListener("auth:expired",C)},[n]),d.useEffect(()=>{const C=()=>{const{view:z,settingsTab:$,q,tag:N,entry:F,collection:J}=It();P(z),G($),Y(q),T(N),p(F),m(null),E(F?new Set([F]):new Set),c(J)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[]);const[l,i]=d.useState([]),[a,o]=d.useState(null),[u,c]=d.useState(()=>It().collection),[y,g]=d.useState([]),[h,v]=d.useState([]),[x,S]=d.useState(()=>new Set),[_,p]=d.useState(()=>It().entry),[f,m]=d.useState(null),[w,E]=d.useState(()=>{const C=It().entry;return C?new Set([C]):new Set}),[b,T]=d.useState(()=>It().tag),[k,P]=d.useState(()=>It().view),[R,G]=d.useState(()=>It().settingsTab),[B,Y]=d.useState(()=>It().q),[ne,ce]=d.useState(""),[$e,ge]=d.useState(!1),[D,L]=d.useState([]),[Q,K]=d.useState([]),[ee,De]=d.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[te,je]=d.useState([]),se=d.useRef(0),[Pe,Mt]=d.useState(()=>{try{const C=JSON.parse(sessionStorage.getItem("pendingCaptures")||"[]");if(Array.isArray(C))return C}catch{}return[]});d.useEffect(()=>{sessionStorage.setItem("pendingCaptures",JSON.stringify(Pe))},[Pe]);const[Oe,Ft]=d.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[Tt,ht]=d.useState(null),mt=d.useRef(0),Xe=d.useRef(null),Pt=d.useRef(!1),O=d.useRef(!0),X=d.useRef(null),ye=d.useRef(0),Le=d.useRef(new Map),Yt=(n==null?void 0:n.humanize_slugs)??!1;d.useEffect(()=>{const C=++mt.current;ht(null),!(!f||!a)&&Dr(a,f.entry_uid).then(z=>{C===mt.current&&ht(z)}).catch(()=>{})},[f,a]),d.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",ee)},[ee]);const Ae=d.useCallback(async(C,z,$,q)=>{if(C){ge(!0);try{let N;z||$?N=await Ah(C,z,$,q):N=await Cu(C,q),v(N),E(F=>{if(F.size<2)return F;const J=new Set(N.map(ie=>ie.entry_uid)),de=new Set([...F].filter(ie=>J.has(ie)));return de.size===F.size?F:de}),ce(N.length===0?"No results":`${N.length} result${N.length===1?"":"s"}`)}catch{v([]),ce("Search failed. Try again.")}finally{ge(!1)}}},[]);d.useEffect(()=>{e==="authenticated"&&(a||_u().then(C=>{if(i(C),C.length>0){const{archive:z}=It(),$=z?C.find(q=>q.id===z):null;o(($==null?void 0:$.id)??C[0].id)}}))},[e,a]),d.useEffect(()=>{if(!a)return;const C=!n;if(O.current){O.current=!1;const $=[];C||($.push(yi(a).then(L)),$.push(Dl(a).then(K))),$.length&&Promise.all($);return}T(null),m(null),p(null),E(new Set),c(null);const z=[Ae(a,"",null,null)];C||(z.push(yi(a).then(L)),z.push(Dl(a).then(K))),Promise.all(z)},[a,n]),d.useEffect(()=>{if(a===null)return;const C=setTimeout(()=>{Ae(a,B,b,u)},300);return()=>clearTimeout(C)},[B,a,u]),d.useEffect(()=>{a!==null&&(b!==null&&P("archive"),Ae(a,B,b,u))},[b,a,u]);const Bt=d.useCallback(C=>{o(C),c(null);const z=new URLSearchParams(window.location.search);z.set("archive",C),z.delete("collection");const $=z.toString();history.replaceState(null,"",window.location.pathname+($?"?"+$:""))},[]);d.useEffect(()=>{if(!a){g([]);return}fo(a).then(g).catch(()=>g([]))},[a]);const Mn=d.useCallback(C=>{if(!n){const q=C?y.find(N=>N.collection_uid===C):y.find(N=>N.slug==="_default_");if(q!=null&&q.requires_auth){t("login");return}}c(C),m(null),p(null),E(new Set),Ae(a,B,b,C);const z=new URLSearchParams(window.location.search);C?(z.set("collection",C),z.set("archive",a)):(z.delete("collection"),a&&z.set("archive",a));const $=z.toString();history.replaceState(null,"",window.location.pathname+($?"?"+$:""))},[a,B,b,n,y,Ae]),Lt=d.useCallback(C=>{P(C),C==="tags"&&a&&Dl(a).then(K)},[a]);d.useEffect(()=>{if(Lr)return;const C=Dg(k,R);window.location.pathname!==C&&history.pushState(null,"",C+window.location.search)},[k,R]);const We=d.useCallback(C=>{p(C?C.entry_uid:null),m(C)},[]),kn=d.useCallback((C,z)=>{if(Le.current.set(C.entry_uid,C),++ye.current,z.shiftKey&&X.current!==null){z.preventDefault();const $=[...document.querySelectorAll("#entries-body [data-entry-uid]")],q=$.findIndex(ie=>ie.dataset.entryUid===X.current),N=$.findIndex(ie=>ie.dataset.entryUid===C.entry_uid);if(q===-1||N===-1){X.current=C.entry_uid,E(new Set([C.entry_uid])),We(C);return}const F=Math.min(q,N),J=Math.max(q,N),de=new Set($.slice(F,J+1).map(ie=>ie.dataset.entryUid));E(de),de.size===1&&We(C)}else if(z.ctrlKey||z.metaKey){X.current=C.entry_uid;const $=new Set(w);if($.has(C.entry_uid)?$.delete(C.entry_uid):$.add(C.entry_uid),E($),$.size===0)We(null);else if($.size===1){const[q]=$,N=Le.current.get(q)??h.find(F=>F.entry_uid===q)??null;if(N)We(N);else{const F=++ye.current;Dr(a,q).then(J=>{F===ye.current&&(J!=null&&J.summary)&&We(J.summary)}).catch(()=>{})}}else We(null)}else X.current=C.entry_uid,E(new Set([C.entry_uid])),We(C)},[h,w,We,a]),Rt=d.useCallback(C=>{T(C)},[]),j=d.useCallback(()=>{T(null)},[]),U=d.useCallback(()=>{a&&Dl(a).then(K)},[a]),M=d.useCallback((C,z)=>{b===C?T(z):b!=null&&b.startsWith(C+"/")&&T(z+b.slice(C.length))},[b]),A=d.useCallback(C=>{(b===C||b!=null&&b.startsWith(C+"/"))&&T(null)},[b]),W=d.useCallback((C,z)=>{v($=>$.map(q=>q.entry_uid===C?{...q,title:z}:q)),m($=>$&&$.entry_uid===C?{...$,title:z}:$),ht($=>$&&$.summary.entry_uid===C?{...$,summary:{...$.summary,title:z}}:$)},[]),V=d.useCallback(()=>{if(!a||!f)return;const C=++mt.current;Dr(a,f.entry_uid).then(z=>{C===mt.current&&ht(z)}).catch(()=>{})},[a,f]),pe=d.useCallback(C=>{const z=h.some($=>$.entry_uid===C);S($=>{const q=new Set($);return q.add(C),q}),v($=>$.filter(q=>q.entry_uid!==C)),m($=>($==null?void 0:$.entry_uid)===C?null:$),p($=>$===C?null:$),E($=>{const q=new Set($);return q.delete(C),q}),z||Ae(a,B,b,u)},[h,a,B,b,u,Ae]),ae=d.useCallback(C=>{const z=new Set(h.map(q=>q.entry_uid)),$=[...C].some(q=>!z.has(q));S(q=>{const N=new Set(q);return C.forEach(F=>N.add(F)),N}),v(q=>q.filter(N=>!C.has(N.entry_uid))),E(new Set),m(null),p(null),$&&Ae(a,B,b,u)},[h,a,B,b,u,Ae]);d.useEffect(()=>{if(w.size>=2)p(null),m(null);else if(w.size===1){const[C]=w;p(C)}else p(null),m(null)},[w]);const Ee=d.useMemo(()=>h.filter(C=>w.has(C.entry_uid)),[h,w]);d.useEffect(()=>{if(!_||f)return;const C=h.find(z=>z.entry_uid===_);C&&m(C)},[h,_,f]),d.useEffect(()=>{if(Lr)return;const C=new URLSearchParams(window.location.search).get("archive"),z=new URLSearchParams;B&&z.set("q",B),k==="archive"&&b&&z.set("tag",b),k==="archive"&&_&&z.set("entry",_),k==="archive"&&u?(z.set("collection",u),a&&z.set("archive",a)):C&&a&&z.set("archive",a);const $=z.toString(),q=window.location.pathname+($?"?"+$:"");window.location.pathname+window.location.search!==q&&history.replaceState(null,"",q)},[B,b,_,u,a,k]),d.useEffect(()=>{const C=z=>{var F,J,de,ie;const $=z.key==="/"&&!z.metaKey&&!z.ctrlKey&&!z.altKey,q=(z.metaKey||z.ctrlKey)&&z.key==="k";if(!$&&!q)return;const N=(F=document.activeElement)==null?void 0:F.tagName;$&&(N==="INPUT"||N==="TEXTAREA"||N==="SELECT")||$&&((J=document.activeElement)!=null&&J.isContentEditable)||(z.preventDefault(),k==="archive"?((de=Xe.current)==null||de.focus(),(ie=Xe.current)==null||ie.select()):(Pt.current=!0,P("archive")))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[k]),d.useEffect(()=>{const C=z=>{var Wn,mo;if(z.metaKey||z.ctrlKey||z.altKey||z.key!=="j"&&z.key!=="k")return;const $=(Wn=document.activeElement)==null?void 0:Wn.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT"||(mo=document.activeElement)!=null&&mo.isContentEditable)return;const q=[...document.querySelectorAll("#entries-body [data-entry-uid]")];if(q.length===0)return;const[N]=w.size===1?w:[null],F=N?q.findIndex(Zt=>Zt.dataset.entryUid===N):-1,J=z.key==="j"?Math.min(F+1,q.length-1):Math.max(F-1,0);if(J===F&&F!==-1)return;const de=q[J<0?0:J],ie=de.dataset.entryUid;X.current=ie;const Hn=++ye.current;E(new Set([ie]));const be=Le.current.get(ie)??h.find(Zt=>Zt.entry_uid===ie)??null;be?We(be):Dr(a,ie).then(Zt=>{Hn===ye.current&&(Zt!=null&&Zt.summary)&&We(Zt.summary)}).catch(()=>{}),de.scrollIntoView({block:"nearest"}),z.preventDefault()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[w,h,We,a]),d.useEffect(()=>{k==="archive"&&Pt.current&&(Pt.current=!1,requestAnimationFrame(()=>{var C,z;(C=Xe.current)==null||C.focus(),(z=Xe.current)==null||z.select()}))},[k]);const oe=d.useCallback(()=>{De(!0)},[]),Je=d.useCallback(()=>{De(!1)},[]),Se=d.useCallback(()=>{if(a)return Promise.allSettled([Ae(a,B,b,u),yi(a).then(L)])},[a,B,b,u,Ae]),Fn=d.useCallback((C,z,$="error",q=null)=>{if($==="warning"&&Oe&&z)return;const N=++se.current;je(F=>[...F,{id:N,text:C,locator:z,type:$,headline:q}])},[Oe]),it=d.useCallback(C=>{je(z=>z.filter($=>$.id!==C))},[]),Bs=d.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),Ft(!0),je(C=>C.filter(z=>!(z.type==="warning"&&z.locator)))},[]),Us=d.useCallback(C=>{Mt(z=>[...z,C])},[]),Hs=d.useCallback(C=>{Mt(z=>z.filter($=>$.id!==C))},[]),[Bn,jr]=d.useState(null),[jn,Sn]=d.useState(null),Un=d.useCallback(()=>{f&&jr(f.entry_uid)},[f]),gl=d.useCallback(()=>jr(null),[]),yl=d.useCallback((C,z)=>{Sn({src:C,entry:z})},[]),Ws=d.useCallback(()=>Sn(null),[]);return d.useEffect(()=>{jr(null)},[f]),d.useEffect(()=>{const C=z=>{var q,N,F;if(z.key!=="Escape"||ee||Bn)return;const $=(q=document.activeElement)==null?void 0:q.tagName;$==="INPUT"||$==="TEXTAREA"||$==="SELECT"||w.size>0&&(z.preventDefault(),E(new Set),(F=(N=document.activeElement)==null?void 0:N.blur)==null||F.call(N))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[ee,Bn,w]),d.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!jn),()=>document.body.classList.remove("has-audio-bar")),[jn]),Lr?s.jsx(Tg,{archiveId:Lr.archiveId,entryUid:Lr.entryUid}):e==="loading"?s.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?s.jsx(Lm,{onComplete:()=>t("login")}):e==="login"?s.jsx(Pm,{onLogin:C=>{r(C),t("authenticated")}}):s.jsx(Fs.Provider,{value:{currentUser:n,setCurrentUser:r},children:s.jsxs(s.Fragment,{children:[s.jsx(Rm,{archives:l,archiveId:a,onArchiveChange:Bt,view:k,onViewChange:Lt,onCaptureClick:oe,collections:y,selectedCollectionUid:u,onCollectionChange:Mn,isPublicSession:!n,onSignInClick:()=>t("login")}),s.jsxs("main",{className:"app-shell",children:[s.jsxs("div",{className:"workspace",children:[k==="archive"&&s.jsxs("div",{className:"toolbar",children:[s.jsxs("div",{className:"search-field",children:[s.jsx("span",{className:"ico","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),s.jsx("input",{ref:Xe,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":$e,placeholder:"Search titles, URLs, types, tags…",value:B,onChange:C=>Y(C.target.value)}),s.jsx("span",{className:"kbd",children:"⌘K"})]}),s.jsxs("span",{className:"result-count",children:[ne&&s.jsxs(s.Fragment,{children:[s.jsx("b",{children:ne.split(" ")[0]})," ",ne.split(" ").slice(1).join(" ")]}),b&&s.jsxs("button",{className:"tag-filter-badge",onClick:j,children:["× ",Yt?tf(b):b]})]})]}),k==="archive"&&s.jsx(Um,{entries:h,selectedUids:w,onRowClick:kn,archiveId:a,pendingCaptures:Pe,deletedUids:x,isPublicSession:!n}),k==="runs"&&s.jsx(Vm,{runs:D}),k==="admin"&&s.jsx(qm,{archives:l}),k==="tags"&&s.jsx(Km,{archiveId:a,tagNodes:Q,tagFilter:b,onTagFilterSet:Rt,onViewChange:Lt,onTagRenamed:M,onTagDeleted:A,onTagsRefresh:U,humanizeTags:Yt}),k==="collections"&&s.jsx(Jm,{archiveId:a}),k==="settings"&&s.jsx(Ym,{tab:R,onTabChange:G,archiveId:a})]}),s.jsx(ug,{archiveId:a,selectedEntry:f,selectedUids:w,selectedEntries:Ee,detail:Tt,onTagFilterSet:Rt,tagNodes:Q,onTagsRefresh:U,onEntryTitleChange:W,onEntryDeleted:pe,onBulkDeleted:ae,humanizeTags:Yt,onDetailRefresh:V,onOpenPreview:Un,onPlay:yl,isPublicSession:!n})]}),Bn&&f&&f.entry_uid===Bn&&s.jsx(Eg,{archiveId:a,entry:f,detail:Tt,onClose:gl}),jn&&s.jsx(bg,{entry:jn.entry,src:jn.src,archiveId:a,onClose:Ws}),s.jsx($m,{open:ee,archiveId:a,onClose:Je,onCaptured:Se,onToast:Fn,activeJobs:Pe,onJobStarted:Us,onJobSettled:Hs}),s.jsx(Lg,{toasts:te,onDismiss:it,onIgnoreUblock:Bs})]})})}Yd(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(Og,{})}));