gemsmap 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cobragui/__init__.py +4 -0
- cobragui/errors.py +37 -0
- cobragui/main.py +331 -0
- cobragui/registry.py +68 -0
- cobragui/schemas.py +180 -0
- cobragui/services/__init__.py +0 -0
- cobragui/services/annotation_service.py +745 -0
- cobragui/services/bigg_service.py +498 -0
- cobragui/services/comparison_service.py +164 -0
- cobragui/services/edit_service.py +942 -0
- cobragui/services/export_service.py +118 -0
- cobragui/services/identity_service.py +429 -0
- cobragui/services/medium_service.py +117 -0
- cobragui/services/metanetx.py +209 -0
- cobragui/services/model_service.py +480 -0
- cobragui/services/search_service.py +97 -0
- cobragui/services/simulation_service.py +427 -0
- gemsmap/__init__.py +6 -0
- gemsmap/__main__.py +6 -0
- gemsmap/cli.py +172 -0
- gemsmap/server.py +32 -0
- gemsmap/web/assets/index-DzyjjcSI.js +79 -0
- gemsmap/web/assets/index-N-gkf6XD.css +1 -0
- gemsmap/web/brand/cobragui-logo.png +0 -0
- gemsmap/web/brand/mapbuilder-logo.png +0 -0
- gemsmap/web/brand/templates-logo.png +0 -0
- gemsmap/web/examples/fva_2conditions.csv +33 -0
- gemsmap/web/examples/pfba_4conditions.csv +33 -0
- gemsmap/web/examples/timecourse.csv +10 -0
- gemsmap/web/favicon.svg +33 -0
- gemsmap/web/index.html +17 -0
- gemsmap-0.3.0.dist-info/METADATA +82 -0
- gemsmap-0.3.0.dist-info/RECORD +36 -0
- gemsmap-0.3.0.dist-info/WHEEL +4 -0
- gemsmap-0.3.0.dist-info/entry_points.txt +2 -0
- gemsmap-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function i(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(s){if(s.ep)return;s.ep=!0;const o=i(s);fetch(s.href,o)}})();function Zg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qg={exports:{}},cc={},Jg={exports:{}},Me={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var il=Symbol.for("react.element"),W_=Symbol.for("react.portal"),Y_=Symbol.for("react.fragment"),Z_=Symbol.for("react.strict_mode"),Q_=Symbol.for("react.profiler"),J_=Symbol.for("react.provider"),ev=Symbol.for("react.context"),tv=Symbol.for("react.forward_ref"),nv=Symbol.for("react.suspense"),iv=Symbol.for("react.memo"),av=Symbol.for("react.lazy"),B0=Symbol.iterator;function sv(e){return e===null||typeof e!="object"?null:(e=B0&&e[B0]||e["@@iterator"],typeof e=="function"?e:null)}var eb={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tb=Object.assign,nb={};function Os(e,t,i){this.props=e,this.context=t,this.refs=nb,this.updater=i||eb}Os.prototype.isReactComponent={};Os.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")};Os.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ib(){}ib.prototype=Os.prototype;function Ou(e,t,i){this.props=e,this.context=t,this.refs=nb,this.updater=i||eb}var $u=Ou.prototype=new ib;$u.constructor=Ou;tb($u,Os.prototype);$u.isPureReactComponent=!0;var H0=Array.isArray,ab=Object.prototype.hasOwnProperty,Lu={current:null},sb={key:!0,ref:!0,__self:!0,__source:!0};function ob(e,t,i){var a,s={},o=null,l=null;if(t!=null)for(a in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(o=""+t.key),t)ab.call(t,a)&&!sb.hasOwnProperty(a)&&(s[a]=t[a]);var r=arguments.length-2;if(r===1)s.children=i;else if(1<r){for(var c=Array(r),d=0;d<r;d++)c[d]=arguments[d+2];s.children=c}if(e&&e.defaultProps)for(a in r=e.defaultProps,r)s[a]===void 0&&(s[a]=r[a]);return{$$typeof:il,type:e,key:o,ref:l,props:s,_owner:Lu.current}}function ov(e,t){return{$$typeof:il,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Tu(e){return typeof e=="object"&&e!==null&&e.$$typeof===il}function lv(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(i){return t[i]})}var O0=/\/+/g;function Qc(e,t){return typeof e=="object"&&e!==null&&e.key!=null?lv(""+e.key):t.toString(36)}function Zl(e,t,i,a,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case il:case W_:l=!0}}if(l)return l=e,s=s(l),e=a===""?"."+Qc(l,0):a,H0(s)?(i="",e!=null&&(i=e.replace(O0,"$&/")+"/"),Zl(s,t,i,"",function(d){return d})):s!=null&&(Tu(s)&&(s=ov(s,i+(!s.key||l&&l.key===s.key?"":(""+s.key).replace(O0,"$&/")+"/")+e)),t.push(s)),1;if(l=0,a=a===""?".":a+":",H0(e))for(var r=0;r<e.length;r++){o=e[r];var c=a+Qc(o,r);l+=Zl(o,t,i,c,s)}else if(c=sv(e),typeof c=="function")for(e=c.call(e),r=0;!(o=e.next()).done;)o=o.value,c=a+Qc(o,r++),l+=Zl(o,t,i,c,s);else if(o==="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 l}function _l(e,t,i){if(e==null)return e;var a=[],s=0;return Zl(e,a,"","",function(o){return t.call(i,o,s++)}),a}function rv(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(i){(e._status===0||e._status===-1)&&(e._status=1,e._result=i)},function(i){(e._status===0||e._status===-1)&&(e._status=2,e._result=i)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var zt={current:null},Ql={transition:null},cv={ReactCurrentDispatcher:zt,ReactCurrentBatchConfig:Ql,ReactCurrentOwner:Lu};function lb(){throw Error("act(...) is not supported in production builds of React.")}Me.Children={map:_l,forEach:function(e,t,i){_l(e,function(){t.apply(this,arguments)},i)},count:function(e){var t=0;return _l(e,function(){t++}),t},toArray:function(e){return _l(e,function(t){return t})||[]},only:function(e){if(!Tu(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Me.Component=Os;Me.Fragment=Y_;Me.Profiler=Q_;Me.PureComponent=Ou;Me.StrictMode=Z_;Me.Suspense=nv;Me.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=cv;Me.act=lb;Me.cloneElement=function(e,t,i){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var a=tb({},e.props),s=e.key,o=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,l=Lu.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var r=e.type.defaultProps;for(c in t)ab.call(t,c)&&!sb.hasOwnProperty(c)&&(a[c]=t[c]===void 0&&r!==void 0?r[c]:t[c])}var c=arguments.length-2;if(c===1)a.children=i;else if(1<c){r=Array(c);for(var d=0;d<c;d++)r[d]=arguments[d+2];a.children=r}return{$$typeof:il,type:e.type,key:s,ref:o,props:a,_owner:l}};Me.createContext=function(e){return e={$$typeof:ev,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:J_,_context:e},e.Consumer=e};Me.createElement=ob;Me.createFactory=function(e){var t=ob.bind(null,e);return t.type=e,t};Me.createRef=function(){return{current:null}};Me.forwardRef=function(e){return{$$typeof:tv,render:e}};Me.isValidElement=Tu;Me.lazy=function(e){return{$$typeof:av,_payload:{_status:-1,_result:e},_init:rv}};Me.memo=function(e,t){return{$$typeof:iv,type:e,compare:t===void 0?null:t}};Me.startTransition=function(e){var t=Ql.transition;Ql.transition={};try{e()}finally{Ql.transition=t}};Me.unstable_act=lb;Me.useCallback=function(e,t){return zt.current.useCallback(e,t)};Me.useContext=function(e){return zt.current.useContext(e)};Me.useDebugValue=function(){};Me.useDeferredValue=function(e){return zt.current.useDeferredValue(e)};Me.useEffect=function(e,t){return zt.current.useEffect(e,t)};Me.useId=function(){return zt.current.useId()};Me.useImperativeHandle=function(e,t,i){return zt.current.useImperativeHandle(e,t,i)};Me.useInsertionEffect=function(e,t){return zt.current.useInsertionEffect(e,t)};Me.useLayoutEffect=function(e,t){return zt.current.useLayoutEffect(e,t)};Me.useMemo=function(e,t){return zt.current.useMemo(e,t)};Me.useReducer=function(e,t,i){return zt.current.useReducer(e,t,i)};Me.useRef=function(e){return zt.current.useRef(e)};Me.useState=function(e){return zt.current.useState(e)};Me.useSyncExternalStore=function(e,t,i){return zt.current.useSyncExternalStore(e,t,i)};Me.useTransition=function(){return zt.current.useTransition()};Me.version="18.3.1";Jg.exports=Me;var E=Jg.exports;const dv=Zg(E);/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var mv=E,uv=Symbol.for("react.element"),pv=Symbol.for("react.fragment"),hv=Object.prototype.hasOwnProperty,fv=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,gv={key:!0,ref:!0,__self:!0,__source:!0};function rb(e,t,i){var a,s={},o=null,l=null;i!==void 0&&(o=""+i),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(l=t.ref);for(a in t)hv.call(t,a)&&!gv.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps,t)s[a]===void 0&&(s[a]=t[a]);return{$$typeof:uv,type:e,key:o,ref:l,props:s,_owner:fv.current}}cc.Fragment=pv;cc.jsx=rb;cc.jsxs=rb;Qg.exports=cc;var n=Qg.exports;const yr="metmap",em="gemsmap";function bv(){try{const e=[];for(let t=0;t<localStorage.length;t++){const i=localStorage.key(t);i!=null&&i.startsWith(yr)&&e.push(i)}for(const t of e){const i=em+t.slice(yr.length),a=localStorage.getItem(t);if(!(a==null||localStorage.getItem(i)!=null)){localStorage.removeItem(t);try{localStorage.setItem(i,a)}catch{localStorage.setItem(t,a)}}}}catch{}}function $0(e){return new Promise(t=>{try{const i=indexedDB.open(e);i.onupgradeneeded=()=>{var a;return(a=i.transaction)==null?void 0:a.abort()},i.onsuccess=()=>t(i.result),i.onerror=()=>t(null),i.onblocked=()=>t(null)}catch{t(null)}})}const yv=e=>new Promise((t,i)=>{e.oncomplete=()=>t(),e.onerror=e.onabort=()=>i(e.error)}),L0=e=>new Promise((t,i)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>i(e.error)});async function xv(e,t){const i=await $0(t);if(i){i.close();return}const a=await $0(e);if(!a)return;const s=Array.from(a.objectStoreNames).map(c=>{const d=a.transaction(c,"readonly").objectStore(c);return{name:c,keyPath:d.keyPath,autoIncrement:d.autoIncrement,keys:L0(d.getAllKeys()),values:L0(d.getAll())}}),o=await Promise.all(s.map(async c=>({...c,keys:await c.keys,values:await c.values}))),l=a.version;a.close();const r=await new Promise((c,d)=>{const f=indexedDB.open(t,l);f.onupgradeneeded=()=>{for(const u of o)f.result.createObjectStore(u.name,{keyPath:u.keyPath,autoIncrement:u.autoIncrement})},f.onsuccess=()=>c(f.result),f.onerror=()=>d(f.error)});try{if(o.length){const c=r.transaction(o.map(d=>d.name),"readwrite");for(const d of o){const f=c.objectStore(d.name);d.values.forEach((u,p)=>{d.keyPath==null?f.put(u,d.keys[p]):f.put(u)})}await yv(c)}r.close()}catch(c){throw r.close(),indexedDB.deleteDatabase(t),c}}async function _v(){if(!(typeof indexedDB>"u"))for(const[e,t]of[[yr,em],[`${yr}-lab`,`${em}-lab`]])try{await xv(e,t)}catch(i){console.warn(`[GEMsMAP] could not move browser database "${e}"`,i)}}bv();const Fu=_v();var cb={exports:{}},fn={},db={exports:{}},mb={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(L,D){var F=L.length;L.push(D);e:for(;0<F;){var U=F-1>>>1,z=L[U];if(0<s(z,D))L[U]=D,L[F]=z,F=U;else break e}}function i(L){return L.length===0?null:L[0]}function a(L){if(L.length===0)return null;var D=L[0],F=L.pop();if(F!==D){L[0]=F;e:for(var U=0,z=L.length,O=z>>>1;U<O;){var Z=2*(U+1)-1,oe=L[Z],he=Z+1,J=L[he];if(0>s(oe,F))he<z&&0>s(J,oe)?(L[U]=J,L[he]=F,U=he):(L[U]=oe,L[Z]=F,U=Z);else if(he<z&&0>s(J,F))L[U]=J,L[he]=F,U=he;else break e}}return D}function s(L,D){var F=L.sortIndex-D.sortIndex;return F!==0?F:L.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,r=l.now();e.unstable_now=function(){return l.now()-r}}var c=[],d=[],f=1,u=null,p=3,m=!1,h=!1,g=!1,y=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(L){for(var D=i(d);D!==null;){if(D.callback===null)a(d);else if(D.startTime<=L)a(d),D.sortIndex=D.expirationTime,t(c,D);else break;D=i(d)}}function v(L){if(g=!1,x(L),!h)if(i(c)!==null)h=!0,I(j);else{var D=i(d);D!==null&&K(v,D.startTime-L)}}function j(L,D){h=!1,g&&(g=!1,b(w),w=-1),m=!0;var F=p;try{for(x(D),u=i(c);u!==null&&(!(u.expirationTime>D)||L&&!H());){var U=u.callback;if(typeof U=="function"){u.callback=null,p=u.priorityLevel;var z=U(u.expirationTime<=D);D=e.unstable_now(),typeof z=="function"?u.callback=z:u===i(c)&&a(c),x(D)}else a(c);u=i(c)}if(u!==null)var O=!0;else{var Z=i(d);Z!==null&&K(v,Z.startTime-D),O=!1}return O}finally{u=null,p=F,m=!1}}var N=!1,C=null,w=-1,k=5,P=-1;function H(){return!(e.unstable_now()-P<k)}function G(){if(C!==null){var L=e.unstable_now();P=L;var D=!0;try{D=C(!0,L)}finally{D?M():(N=!1,C=null)}}else N=!1}var M;if(typeof _=="function")M=function(){_(G)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,X=A.port2;A.port1.onmessage=G,M=function(){X.postMessage(null)}}else M=function(){y(G,0)};function I(L){C=L,N||(N=!0,M())}function K(L,D){w=y(function(){L(e.unstable_now())},D)}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(L){L.callback=null},e.unstable_continueExecution=function(){h||m||(h=!0,I(j))},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):k=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return i(c)},e.unstable_next=function(L){switch(p){case 1:case 2:case 3:var D=3;break;default:D=p}var F=p;p=D;try{return L()}finally{p=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,D){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var F=p;p=L;try{return D()}finally{p=F}},e.unstable_scheduleCallback=function(L,D,F){var U=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?U+F:U):F=U,L){case 1:var z=-1;break;case 2:z=250;break;case 5:z=1073741823;break;case 4:z=1e4;break;default:z=5e3}return z=F+z,L={id:f++,callback:D,priorityLevel:L,startTime:F,expirationTime:z,sortIndex:-1},F>U?(L.sortIndex=F,t(d,L),i(c)===null&&L===i(d)&&(g?(b(w),w=-1):g=!0,K(v,F-U))):(L.sortIndex=z,t(c,L),h||m||(h=!0,I(j))),L},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(L){var D=p;return function(){var F=p;p=D;try{return L.apply(this,arguments)}finally{p=F}}}})(mb);db.exports=mb;var vv=db.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var jv=E,hn=vv;function te(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i]);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 ub=new Set,Do={};function Va(e,t){Ms(e,t),Ms(e+"Capture",t)}function Ms(e,t){for(Do[e]=t,e=0;e<t.length;e++)ub.add(t[e])}var Ei=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),tm=Object.prototype.hasOwnProperty,Nv=/^[: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]*$/,T0={},F0={};function wv(e){return tm.call(F0,e)?!0:tm.call(T0,e)?!1:Nv.test(e)?F0[e]=!0:(T0[e]=!0,!1)}function Cv(e,t,i,a){if(i!==null&&i.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return a?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function kv(e,t,i,a){if(t===null||typeof t>"u"||Cv(e,t,i,a))return!0;if(a)return!1;if(i!==null)switch(i.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 Ut(e,t,i,a,s,o,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=a,this.attributeNamespace=s,this.mustUseProperty=i,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=l}var wt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){wt[e]=new Ut(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];wt[t]=new Ut(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){wt[e]=new Ut(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){wt[e]=new Ut(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){wt[e]=new Ut(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){wt[e]=new Ut(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){wt[e]=new Ut(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){wt[e]=new Ut(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){wt[e]=new Ut(e,5,!1,e.toLowerCase(),null,!1,!1)});var Xu=/[\-:]([a-z])/g;function Ku(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(Xu,Ku);wt[t]=new Ut(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(Xu,Ku);wt[t]=new Ut(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(Xu,Ku);wt[t]=new Ut(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){wt[e]=new Ut(e,1,!1,e.toLowerCase(),null,!1,!1)});wt.xlinkHref=new Ut("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){wt[e]=new Ut(e,1,!1,e.toLowerCase(),null,!0,!0)});function zu(e,t,i,a){var s=wt.hasOwnProperty(t)?wt[t]:null;(s!==null?s.type!==0:a||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(kv(t,i,s,a)&&(i=null),a||s===null?wv(t)&&(i===null?e.removeAttribute(t):e.setAttribute(t,""+i)):s.mustUseProperty?e[s.propertyName]=i===null?s.type===3?!1:"":i:(t=s.attributeName,a=s.attributeNamespace,i===null?e.removeAttribute(t):(s=s.type,i=s===3||s===4&&i===!0?"":""+i,a?e.setAttributeNS(a,t,i):e.setAttribute(t,i))))}var Bi=jv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,vl=Symbol.for("react.element"),ss=Symbol.for("react.portal"),os=Symbol.for("react.fragment"),Uu=Symbol.for("react.strict_mode"),nm=Symbol.for("react.profiler"),pb=Symbol.for("react.provider"),hb=Symbol.for("react.context"),qu=Symbol.for("react.forward_ref"),im=Symbol.for("react.suspense"),am=Symbol.for("react.suspense_list"),Vu=Symbol.for("react.memo"),Ti=Symbol.for("react.lazy"),fb=Symbol.for("react.offscreen"),X0=Symbol.iterator;function zs(e){return e===null||typeof e!="object"?null:(e=X0&&e[X0]||e["@@iterator"],typeof e=="function"?e:null)}var it=Object.assign,Jc;function to(e){if(Jc===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Jc=t&&t[1]||""}return`
|
|
34
|
+
`+Jc+e}var ed=!1;function td(e,t){if(!e||ed)return"";ed=!0;var i=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(d){var a=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){a=d}e.call(t.prototype)}else{try{throw Error()}catch(d){a=d}e()}}catch(d){if(d&&a&&typeof d.stack=="string"){for(var s=d.stack.split(`
|
|
35
|
+
`),o=a.stack.split(`
|
|
36
|
+
`),l=s.length-1,r=o.length-1;1<=l&&0<=r&&s[l]!==o[r];)r--;for(;1<=l&&0<=r;l--,r--)if(s[l]!==o[r]){if(l!==1||r!==1)do if(l--,r--,0>r||s[l]!==o[r]){var c=`
|
|
37
|
+
`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=r);break}}}finally{ed=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?to(e):""}function Mv(e){switch(e.tag){case 5:return to(e.type);case 16:return to("Lazy");case 13:return to("Suspense");case 19:return to("SuspenseList");case 0:case 2:case 15:return e=td(e.type,!1),e;case 11:return e=td(e.type.render,!1),e;case 1:return e=td(e.type,!0),e;default:return""}}function sm(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 os:return"Fragment";case ss:return"Portal";case nm:return"Profiler";case Uu:return"StrictMode";case im:return"Suspense";case am:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case hb:return(e.displayName||"Context")+".Consumer";case pb:return(e._context.displayName||"Context")+".Provider";case qu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Vu:return t=e.displayName||null,t!==null?t:sm(e.type)||"Memo";case Ti:t=e._payload,e=e._init;try{return sm(e(t))}catch{}}return null}function Ev(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 sm(t);case 8:return t===Uu?"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 ma(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gb(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Gv(e){var t=gb(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),a=""+e[t];if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var s=i.get,o=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){a=""+l,o.call(this,l)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return a},setValue:function(l){a=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function jl(e){e._valueTracker||(e._valueTracker=Gv(e))}function bb(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),a="";return e&&(a=gb(e)?e.checked?"true":"false":e.value),e=a,e!==i?(t.setValue(e),!0):!1}function xr(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 om(e,t){var i=t.checked;return it({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function K0(e,t){var i=t.defaultValue==null?"":t.defaultValue,a=t.checked!=null?t.checked:t.defaultChecked;i=ma(t.value!=null?t.value:i),e._wrapperState={initialChecked:a,initialValue:i,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function yb(e,t){t=t.checked,t!=null&&zu(e,"checked",t,!1)}function lm(e,t){yb(e,t);var i=ma(t.value),a=t.type;if(i!=null)a==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(a==="submit"||a==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?rm(e,t.type,i):t.hasOwnProperty("defaultValue")&&rm(e,t.type,ma(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function z0(e,t,i){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var a=t.type;if(!(a!=="submit"&&a!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,i||t===e.value||(e.value=t),e.defaultValue=t}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function rm(e,t,i){(t!=="number"||xr(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var no=Array.isArray;function ys(e,t,i,a){if(e=e.options,t){t={};for(var s=0;s<i.length;s++)t["$"+i[s]]=!0;for(i=0;i<e.length;i++)s=t.hasOwnProperty("$"+e[i].value),e[i].selected!==s&&(e[i].selected=s),s&&a&&(e[i].defaultSelected=!0)}else{for(i=""+ma(i),t=null,s=0;s<e.length;s++){if(e[s].value===i){e[s].selected=!0,a&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function cm(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(te(91));return it({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function U0(e,t){var i=t.value;if(i==null){if(i=t.children,t=t.defaultValue,i!=null){if(t!=null)throw Error(te(92));if(no(i)){if(1<i.length)throw Error(te(93));i=i[0]}t=i}t==null&&(t=""),i=t}e._wrapperState={initialValue:ma(i)}}function xb(e,t){var i=ma(t.value),a=ma(t.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),t.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),a!=null&&(e.defaultValue=""+a)}function q0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function _b(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 dm(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?_b(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Nl,vb=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,i,a,s){MSApp.execUnsafeLocalFunction(function(){return e(t,i,a,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Nl=Nl||document.createElement("div"),Nl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Nl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Po(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var lo={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},Sv=["Webkit","ms","Moz","O"];Object.keys(lo).forEach(function(e){Sv.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),lo[t]=lo[e]})});function jb(e,t,i){return t==null||typeof t=="boolean"||t===""?"":i||typeof t!="number"||t===0||lo.hasOwnProperty(e)&&lo[e]?(""+t).trim():t+"px"}function Nb(e,t){e=e.style;for(var i in t)if(t.hasOwnProperty(i)){var a=i.indexOf("--")===0,s=jb(i,t[i],a);i==="float"&&(i="cssFloat"),a?e.setProperty(i,s):e[i]=s}}var Av=it({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 mm(e,t){if(t){if(Av[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(te(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(te(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(te(61))}if(t.style!=null&&typeof t.style!="object")throw Error(te(62))}}function um(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 pm=null;function Wu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var hm=null,xs=null,_s=null;function V0(e){if(e=ol(e)){if(typeof hm!="function")throw Error(te(280));var t=e.stateNode;t&&(t=hc(t),hm(e.stateNode,e.type,t))}}function wb(e){xs?_s?_s.push(e):_s=[e]:xs=e}function Cb(){if(xs){var e=xs,t=_s;if(_s=xs=null,V0(e),t)for(e=0;e<t.length;e++)V0(t[e])}}function kb(e,t){return e(t)}function Mb(){}var nd=!1;function Eb(e,t,i){if(nd)return e(t,i);nd=!0;try{return kb(e,t,i)}finally{nd=!1,(xs!==null||_s!==null)&&(Mb(),Cb())}}function Ro(e,t){var i=e.stateNode;if(i===null)return null;var a=hc(i);if(a===null)return null;i=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(te(231,t,typeof i));return i}var fm=!1;if(Ei)try{var Us={};Object.defineProperty(Us,"passive",{get:function(){fm=!0}}),window.addEventListener("test",Us,Us),window.removeEventListener("test",Us,Us)}catch{fm=!1}function Dv(e,t,i,a,s,o,l,r,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(i,d)}catch(f){this.onError(f)}}var ro=!1,_r=null,vr=!1,gm=null,Pv={onError:function(e){ro=!0,_r=e}};function Rv(e,t,i,a,s,o,l,r,c){ro=!1,_r=null,Dv.apply(Pv,arguments)}function Iv(e,t,i,a,s,o,l,r,c){if(Rv.apply(this,arguments),ro){if(ro){var d=_r;ro=!1,_r=null}else throw Error(te(198));vr||(vr=!0,gm=d)}}function Wa(e){var t=e,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function Gb(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 W0(e){if(Wa(e)!==e)throw Error(te(188))}function Bv(e){var t=e.alternate;if(!t){if(t=Wa(e),t===null)throw Error(te(188));return t!==e?null:e}for(var i=e,a=t;;){var s=i.return;if(s===null)break;var o=s.alternate;if(o===null){if(a=s.return,a!==null){i=a;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===i)return W0(s),e;if(o===a)return W0(s),t;o=o.sibling}throw Error(te(188))}if(i.return!==a.return)i=s,a=o;else{for(var l=!1,r=s.child;r;){if(r===i){l=!0,i=s,a=o;break}if(r===a){l=!0,a=s,i=o;break}r=r.sibling}if(!l){for(r=o.child;r;){if(r===i){l=!0,i=o,a=s;break}if(r===a){l=!0,a=o,i=s;break}r=r.sibling}if(!l)throw Error(te(189))}}if(i.alternate!==a)throw Error(te(190))}if(i.tag!==3)throw Error(te(188));return i.stateNode.current===i?e:t}function Sb(e){return e=Bv(e),e!==null?Ab(e):null}function Ab(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Ab(e);if(t!==null)return t;e=e.sibling}return null}var Db=hn.unstable_scheduleCallback,Y0=hn.unstable_cancelCallback,Hv=hn.unstable_shouldYield,Ov=hn.unstable_requestPaint,lt=hn.unstable_now,$v=hn.unstable_getCurrentPriorityLevel,Yu=hn.unstable_ImmediatePriority,Pb=hn.unstable_UserBlockingPriority,jr=hn.unstable_NormalPriority,Lv=hn.unstable_LowPriority,Rb=hn.unstable_IdlePriority,dc=null,ni=null;function Tv(e){if(ni&&typeof ni.onCommitFiberRoot=="function")try{ni.onCommitFiberRoot(dc,e,void 0,(e.current.flags&128)===128)}catch{}}var Bn=Math.clz32?Math.clz32:Kv,Fv=Math.log,Xv=Math.LN2;function Kv(e){return e>>>=0,e===0?32:31-(Fv(e)/Xv|0)|0}var wl=64,Cl=4194304;function io(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 Nr(e,t){var i=e.pendingLanes;if(i===0)return 0;var a=0,s=e.suspendedLanes,o=e.pingedLanes,l=i&268435455;if(l!==0){var r=l&~s;r!==0?a=io(r):(o&=l,o!==0&&(a=io(o)))}else l=i&~s,l!==0?a=io(l):o!==0&&(a=io(o));if(a===0)return 0;if(t!==0&&t!==a&&!(t&s)&&(s=a&-a,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(a&4&&(a|=i&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=a;0<t;)i=31-Bn(t),s=1<<i,a|=e[i],t&=~s;return a}function zv(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 Uv(e,t){for(var i=e.suspendedLanes,a=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var l=31-Bn(o),r=1<<l,c=s[l];c===-1?(!(r&i)||r&a)&&(s[l]=zv(r,t)):c<=t&&(e.expiredLanes|=r),o&=~r}}function bm(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ib(){var e=wl;return wl<<=1,!(wl&4194240)&&(wl=64),e}function id(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function al(e,t,i){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bn(t),e[t]=i}function qv(e,t){var i=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var a=e.eventTimes;for(e=e.expirationTimes;0<i;){var s=31-Bn(i),o=1<<s;t[s]=0,a[s]=-1,e[s]=-1,i&=~o}}function Zu(e,t){var i=e.entangledLanes|=t;for(e=e.entanglements;i;){var a=31-Bn(i),s=1<<a;s&t|e[a]&t&&(e[a]|=t),i&=~s}}var Le=0;function Bb(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Hb,Qu,Ob,$b,Lb,ym=!1,kl=[],Zi=null,Qi=null,Ji=null,Io=new Map,Bo=new Map,Xi=[],Vv="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 Z0(e,t){switch(e){case"focusin":case"focusout":Zi=null;break;case"dragenter":case"dragleave":Qi=null;break;case"mouseover":case"mouseout":Ji=null;break;case"pointerover":case"pointerout":Io.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bo.delete(t.pointerId)}}function qs(e,t,i,a,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:i,eventSystemFlags:a,nativeEvent:o,targetContainers:[s]},t!==null&&(t=ol(t),t!==null&&Qu(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function Wv(e,t,i,a,s){switch(t){case"focusin":return Zi=qs(Zi,e,t,i,a,s),!0;case"dragenter":return Qi=qs(Qi,e,t,i,a,s),!0;case"mouseover":return Ji=qs(Ji,e,t,i,a,s),!0;case"pointerover":var o=s.pointerId;return Io.set(o,qs(Io.get(o)||null,e,t,i,a,s)),!0;case"gotpointercapture":return o=s.pointerId,Bo.set(o,qs(Bo.get(o)||null,e,t,i,a,s)),!0}return!1}function Tb(e){var t=ka(e.target);if(t!==null){var i=Wa(t);if(i!==null){if(t=i.tag,t===13){if(t=Gb(i),t!==null){e.blockedOn=t,Lb(e.priority,function(){Ob(i)});return}}else if(t===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Jl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var i=xm(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var a=new i.constructor(i.type,i);pm=a,i.target.dispatchEvent(a),pm=null}else return t=ol(i),t!==null&&Qu(t),e.blockedOn=i,!1;t.shift()}return!0}function Q0(e,t,i){Jl(e)&&i.delete(t)}function Yv(){ym=!1,Zi!==null&&Jl(Zi)&&(Zi=null),Qi!==null&&Jl(Qi)&&(Qi=null),Ji!==null&&Jl(Ji)&&(Ji=null),Io.forEach(Q0),Bo.forEach(Q0)}function Vs(e,t){e.blockedOn===t&&(e.blockedOn=null,ym||(ym=!0,hn.unstable_scheduleCallback(hn.unstable_NormalPriority,Yv)))}function Ho(e){function t(s){return Vs(s,e)}if(0<kl.length){Vs(kl[0],e);for(var i=1;i<kl.length;i++){var a=kl[i];a.blockedOn===e&&(a.blockedOn=null)}}for(Zi!==null&&Vs(Zi,e),Qi!==null&&Vs(Qi,e),Ji!==null&&Vs(Ji,e),Io.forEach(t),Bo.forEach(t),i=0;i<Xi.length;i++)a=Xi[i],a.blockedOn===e&&(a.blockedOn=null);for(;0<Xi.length&&(i=Xi[0],i.blockedOn===null);)Tb(i),i.blockedOn===null&&Xi.shift()}var vs=Bi.ReactCurrentBatchConfig,wr=!0;function Zv(e,t,i,a){var s=Le,o=vs.transition;vs.transition=null;try{Le=1,Ju(e,t,i,a)}finally{Le=s,vs.transition=o}}function Qv(e,t,i,a){var s=Le,o=vs.transition;vs.transition=null;try{Le=4,Ju(e,t,i,a)}finally{Le=s,vs.transition=o}}function Ju(e,t,i,a){if(wr){var s=xm(e,t,i,a);if(s===null)pd(e,t,a,Cr,i),Z0(e,a);else if(Wv(s,e,t,i,a))a.stopPropagation();else if(Z0(e,a),t&4&&-1<Vv.indexOf(e)){for(;s!==null;){var o=ol(s);if(o!==null&&Hb(o),o=xm(e,t,i,a),o===null&&pd(e,t,a,Cr,i),o===s)break;s=o}s!==null&&a.stopPropagation()}else pd(e,t,a,null,i)}}var Cr=null;function xm(e,t,i,a){if(Cr=null,e=Wu(a),e=ka(e),e!==null)if(t=Wa(e),t===null)e=null;else if(i=t.tag,i===13){if(e=Gb(t),e!==null)return e;e=null}else if(i===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Cr=e,null}function Fb(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($v()){case Yu:return 1;case Pb:return 4;case jr:case Lv:return 16;case Rb:return 536870912;default:return 16}default:return 16}}var zi=null,ep=null,er=null;function Xb(){if(er)return er;var e,t=ep,i=t.length,a,s="value"in zi?zi.value:zi.textContent,o=s.length;for(e=0;e<i&&t[e]===s[e];e++);var l=i-e;for(a=1;a<=l&&t[i-a]===s[o-a];a++);return er=s.slice(e,1<a?1-a:void 0)}function tr(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 Ml(){return!0}function J0(){return!1}function gn(e){function t(i,a,s,o,l){this._reactName=i,this._targetInst=s,this.type=a,this.nativeEvent=o,this.target=l,this.currentTarget=null;for(var r in e)e.hasOwnProperty(r)&&(i=e[r],this[r]=i?i(o):o[r]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Ml:J0,this.isPropagationStopped=J0,this}return it(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Ml)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Ml)},persist:function(){},isPersistent:Ml}),t}var $s={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tp=gn($s),sl=it({},$s,{view:0,detail:0}),Jv=gn(sl),ad,sd,Ws,mc=it({},sl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:np,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!==Ws&&(Ws&&e.type==="mousemove"?(ad=e.screenX-Ws.screenX,sd=e.screenY-Ws.screenY):sd=ad=0,Ws=e),ad)},movementY:function(e){return"movementY"in e?e.movementY:sd}}),eh=gn(mc),e2=it({},mc,{dataTransfer:0}),t2=gn(e2),n2=it({},sl,{relatedTarget:0}),od=gn(n2),i2=it({},$s,{animationName:0,elapsedTime:0,pseudoElement:0}),a2=gn(i2),s2=it({},$s,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),o2=gn(s2),l2=it({},$s,{data:0}),th=gn(l2),r2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},c2={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"},d2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function m2(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=d2[e])?!!t[e]:!1}function np(){return m2}var u2=it({},sl,{key:function(e){if(e.key){var t=r2[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=tr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?c2[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:np,charCode:function(e){return e.type==="keypress"?tr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?tr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),p2=gn(u2),h2=it({},mc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),nh=gn(h2),f2=it({},sl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:np}),g2=gn(f2),b2=it({},$s,{propertyName:0,elapsedTime:0,pseudoElement:0}),y2=gn(b2),x2=it({},mc,{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}),_2=gn(x2),v2=[9,13,27,32],ip=Ei&&"CompositionEvent"in window,co=null;Ei&&"documentMode"in document&&(co=document.documentMode);var j2=Ei&&"TextEvent"in window&&!co,Kb=Ei&&(!ip||co&&8<co&&11>=co),ih=" ",ah=!1;function zb(e,t){switch(e){case"keyup":return v2.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ub(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ls=!1;function N2(e,t){switch(e){case"compositionend":return Ub(t);case"keypress":return t.which!==32?null:(ah=!0,ih);case"textInput":return e=t.data,e===ih&&ah?null:e;default:return null}}function w2(e,t){if(ls)return e==="compositionend"||!ip&&zb(e,t)?(e=Xb(),er=ep=zi=null,ls=!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 Kb&&t.locale!=="ko"?null:t.data;default:return null}}var C2={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 sh(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!C2[e.type]:t==="textarea"}function qb(e,t,i,a){wb(a),t=kr(t,"onChange"),0<t.length&&(i=new tp("onChange","change",null,i,a),e.push({event:i,listeners:t}))}var mo=null,Oo=null;function k2(e){ay(e,0)}function uc(e){var t=ds(e);if(bb(t))return e}function M2(e,t){if(e==="change")return t}var Vb=!1;if(Ei){var ld;if(Ei){var rd="oninput"in document;if(!rd){var oh=document.createElement("div");oh.setAttribute("oninput","return;"),rd=typeof oh.oninput=="function"}ld=rd}else ld=!1;Vb=ld&&(!document.documentMode||9<document.documentMode)}function lh(){mo&&(mo.detachEvent("onpropertychange",Wb),Oo=mo=null)}function Wb(e){if(e.propertyName==="value"&&uc(Oo)){var t=[];qb(t,Oo,e,Wu(e)),Eb(k2,t)}}function E2(e,t,i){e==="focusin"?(lh(),mo=t,Oo=i,mo.attachEvent("onpropertychange",Wb)):e==="focusout"&&lh()}function G2(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return uc(Oo)}function S2(e,t){if(e==="click")return uc(t)}function A2(e,t){if(e==="input"||e==="change")return uc(t)}function D2(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Tn=typeof Object.is=="function"?Object.is:D2;function $o(e,t){if(Tn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(a=0;a<i.length;a++){var s=i[a];if(!tm.call(t,s)||!Tn(e[s],t[s]))return!1}return!0}function rh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ch(e,t){var i=rh(e);e=0;for(var a;i;){if(i.nodeType===3){if(a=e+i.textContent.length,e<=t&&a>=t)return{node:i,offset:t-e};e=a}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=rh(i)}}function Yb(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yb(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zb(){for(var e=window,t=xr();t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=xr(e.document)}return t}function ap(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 P2(e){var t=Zb(),i=e.focusedElem,a=e.selectionRange;if(t!==i&&i&&i.ownerDocument&&Yb(i.ownerDocument.documentElement,i)){if(a!==null&&ap(i)){if(t=a.start,e=a.end,e===void 0&&(e=t),"selectionStart"in i)i.selectionStart=t,i.selectionEnd=Math.min(e,i.value.length);else if(e=(t=i.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=i.textContent.length,o=Math.min(a.start,s);a=a.end===void 0?o:Math.min(a.end,s),!e.extend&&o>a&&(s=a,a=o,o=s),s=ch(i,o);var l=ch(i,a);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>a?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=i;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<t.length;i++)e=t[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var R2=Ei&&"documentMode"in document&&11>=document.documentMode,rs=null,_m=null,uo=null,vm=!1;function dh(e,t,i){var a=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;vm||rs==null||rs!==xr(a)||(a=rs,"selectionStart"in a&&ap(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),uo&&$o(uo,a)||(uo=a,a=kr(_m,"onSelect"),0<a.length&&(t=new tp("onSelect","select",null,t,i),e.push({event:t,listeners:a}),t.target=rs)))}function El(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var cs={animationend:El("Animation","AnimationEnd"),animationiteration:El("Animation","AnimationIteration"),animationstart:El("Animation","AnimationStart"),transitionend:El("Transition","TransitionEnd")},cd={},Qb={};Ei&&(Qb=document.createElement("div").style,"AnimationEvent"in window||(delete cs.animationend.animation,delete cs.animationiteration.animation,delete cs.animationstart.animation),"TransitionEvent"in window||delete cs.transitionend.transition);function pc(e){if(cd[e])return cd[e];if(!cs[e])return e;var t=cs[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in Qb)return cd[e]=t[i];return e}var Jb=pc("animationend"),ey=pc("animationiteration"),ty=pc("animationstart"),ny=pc("transitionend"),iy=new Map,mh="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 pa(e,t){iy.set(e,t),Va(t,[e])}for(var dd=0;dd<mh.length;dd++){var md=mh[dd],I2=md.toLowerCase(),B2=md[0].toUpperCase()+md.slice(1);pa(I2,"on"+B2)}pa(Jb,"onAnimationEnd");pa(ey,"onAnimationIteration");pa(ty,"onAnimationStart");pa("dblclick","onDoubleClick");pa("focusin","onFocus");pa("focusout","onBlur");pa(ny,"onTransitionEnd");Ms("onMouseEnter",["mouseout","mouseover"]);Ms("onMouseLeave",["mouseout","mouseover"]);Ms("onPointerEnter",["pointerout","pointerover"]);Ms("onPointerLeave",["pointerout","pointerover"]);Va("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Va("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Va("onBeforeInput",["compositionend","keypress","textInput","paste"]);Va("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Va("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Va("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ao="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(" "),H2=new Set("cancel close invalid load scroll toggle".split(" ").concat(ao));function uh(e,t,i){var a=e.type||"unknown-event";e.currentTarget=i,Iv(a,t,void 0,e),e.currentTarget=null}function ay(e,t){t=(t&4)!==0;for(var i=0;i<e.length;i++){var a=e[i],s=a.event;a=a.listeners;e:{var o=void 0;if(t)for(var l=a.length-1;0<=l;l--){var r=a[l],c=r.instance,d=r.currentTarget;if(r=r.listener,c!==o&&s.isPropagationStopped())break e;uh(s,r,d),o=c}else for(l=0;l<a.length;l++){if(r=a[l],c=r.instance,d=r.currentTarget,r=r.listener,c!==o&&s.isPropagationStopped())break e;uh(s,r,d),o=c}}}if(vr)throw e=gm,vr=!1,gm=null,e}function We(e,t){var i=t[km];i===void 0&&(i=t[km]=new Set);var a=e+"__bubble";i.has(a)||(sy(t,e,2,!1),i.add(a))}function ud(e,t,i){var a=0;t&&(a|=4),sy(i,e,a,t)}var Gl="_reactListening"+Math.random().toString(36).slice(2);function Lo(e){if(!e[Gl]){e[Gl]=!0,ub.forEach(function(i){i!=="selectionchange"&&(H2.has(i)||ud(i,!1,e),ud(i,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Gl]||(t[Gl]=!0,ud("selectionchange",!1,t))}}function sy(e,t,i,a){switch(Fb(t)){case 1:var s=Zv;break;case 4:s=Qv;break;default:s=Ju}i=s.bind(null,t,i,e),s=void 0,!fm||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),a?s!==void 0?e.addEventListener(t,i,{capture:!0,passive:s}):e.addEventListener(t,i,!0):s!==void 0?e.addEventListener(t,i,{passive:s}):e.addEventListener(t,i,!1)}function pd(e,t,i,a,s){var o=a;if(!(t&1)&&!(t&2)&&a!==null)e:for(;;){if(a===null)return;var l=a.tag;if(l===3||l===4){var r=a.stateNode.containerInfo;if(r===s||r.nodeType===8&&r.parentNode===s)break;if(l===4)for(l=a.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;l=l.return}for(;r!==null;){if(l=ka(r),l===null)return;if(c=l.tag,c===5||c===6){a=o=l;continue e}r=r.parentNode}}a=a.return}Eb(function(){var d=o,f=Wu(i),u=[];e:{var p=iy.get(e);if(p!==void 0){var m=tp,h=e;switch(e){case"keypress":if(tr(i)===0)break e;case"keydown":case"keyup":m=p2;break;case"focusin":h="focus",m=od;break;case"focusout":h="blur",m=od;break;case"beforeblur":case"afterblur":m=od;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=eh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=t2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=g2;break;case Jb:case ey:case ty:m=a2;break;case ny:m=y2;break;case"scroll":m=Jv;break;case"wheel":m=_2;break;case"copy":case"cut":case"paste":m=o2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=nh}var g=(t&4)!==0,y=!g&&e==="scroll",b=g?p!==null?p+"Capture":null:p;g=[];for(var _=d,x;_!==null;){x=_;var v=x.stateNode;if(x.tag===5&&v!==null&&(x=v,b!==null&&(v=Ro(_,b),v!=null&&g.push(To(_,v,x)))),y)break;_=_.return}0<g.length&&(p=new m(p,h,null,i,f),u.push({event:p,listeners:g}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&i!==pm&&(h=i.relatedTarget||i.fromElement)&&(ka(h)||h[Gi]))break e;if((m||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,m?(h=i.relatedTarget||i.toElement,m=d,h=h?ka(h):null,h!==null&&(y=Wa(h),h!==y||h.tag!==5&&h.tag!==6)&&(h=null)):(m=null,h=d),m!==h)){if(g=eh,v="onMouseLeave",b="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(g=nh,v="onPointerLeave",b="onPointerEnter",_="pointer"),y=m==null?p:ds(m),x=h==null?p:ds(h),p=new g(v,_+"leave",m,i,f),p.target=y,p.relatedTarget=x,v=null,ka(f)===d&&(g=new g(b,_+"enter",h,i,f),g.target=x,g.relatedTarget=y,v=g),y=v,m&&h)t:{for(g=m,b=h,_=0,x=g;x;x=Za(x))_++;for(x=0,v=b;v;v=Za(v))x++;for(;0<_-x;)g=Za(g),_--;for(;0<x-_;)b=Za(b),x--;for(;_--;){if(g===b||b!==null&&g===b.alternate)break t;g=Za(g),b=Za(b)}g=null}else g=null;m!==null&&ph(u,p,m,g,!1),h!==null&&y!==null&&ph(u,y,h,g,!0)}}e:{if(p=d?ds(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var j=M2;else if(sh(p))if(Vb)j=A2;else{j=G2;var N=E2}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(j=S2);if(j&&(j=j(e,d))){qb(u,j,i,f);break e}N&&N(e,p,d),e==="focusout"&&(N=p._wrapperState)&&N.controlled&&p.type==="number"&&rm(p,"number",p.value)}switch(N=d?ds(d):window,e){case"focusin":(sh(N)||N.contentEditable==="true")&&(rs=N,_m=d,uo=null);break;case"focusout":uo=_m=rs=null;break;case"mousedown":vm=!0;break;case"contextmenu":case"mouseup":case"dragend":vm=!1,dh(u,i,f);break;case"selectionchange":if(R2)break;case"keydown":case"keyup":dh(u,i,f)}var C;if(ip)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else ls?zb(e,i)&&(w="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(w="onCompositionStart");w&&(Kb&&i.locale!=="ko"&&(ls||w!=="onCompositionStart"?w==="onCompositionEnd"&&ls&&(C=Xb()):(zi=f,ep="value"in zi?zi.value:zi.textContent,ls=!0)),N=kr(d,w),0<N.length&&(w=new th(w,e,null,i,f),u.push({event:w,listeners:N}),C?w.data=C:(C=Ub(i),C!==null&&(w.data=C)))),(C=j2?N2(e,i):w2(e,i))&&(d=kr(d,"onBeforeInput"),0<d.length&&(f=new th("onBeforeInput","beforeinput",null,i,f),u.push({event:f,listeners:d}),f.data=C))}ay(u,t)})}function To(e,t,i){return{instance:e,listener:t,currentTarget:i}}function kr(e,t){for(var i=t+"Capture",a=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Ro(e,i),o!=null&&a.unshift(To(e,o,s)),o=Ro(e,t),o!=null&&a.push(To(e,o,s))),e=e.return}return a}function Za(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function ph(e,t,i,a,s){for(var o=t._reactName,l=[];i!==null&&i!==a;){var r=i,c=r.alternate,d=r.stateNode;if(c!==null&&c===a)break;r.tag===5&&d!==null&&(r=d,s?(c=Ro(i,o),c!=null&&l.unshift(To(i,c,r))):s||(c=Ro(i,o),c!=null&&l.push(To(i,c,r)))),i=i.return}l.length!==0&&e.push({event:t,listeners:l})}var O2=/\r\n?/g,$2=/\u0000|\uFFFD/g;function hh(e){return(typeof e=="string"?e:""+e).replace(O2,`
|
|
38
|
+
`).replace($2,"")}function Sl(e,t,i){if(t=hh(t),hh(e)!==t&&i)throw Error(te(425))}function Mr(){}var jm=null,Nm=null;function wm(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 Cm=typeof setTimeout=="function"?setTimeout:void 0,L2=typeof clearTimeout=="function"?clearTimeout:void 0,fh=typeof Promise=="function"?Promise:void 0,T2=typeof queueMicrotask=="function"?queueMicrotask:typeof fh<"u"?function(e){return fh.resolve(null).then(e).catch(F2)}:Cm;function F2(e){setTimeout(function(){throw e})}function hd(e,t){var i=t,a=0;do{var s=i.nextSibling;if(e.removeChild(i),s&&s.nodeType===8)if(i=s.data,i==="/$"){if(a===0){e.removeChild(s),Ho(t);return}a--}else i!=="$"&&i!=="$?"&&i!=="$!"||a++;i=s}while(i);Ho(t)}function ea(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 gh(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(t===0)return e;t--}else i==="/$"&&t++}e=e.previousSibling}return null}var Ls=Math.random().toString(36).slice(2),Jn="__reactFiber$"+Ls,Fo="__reactProps$"+Ls,Gi="__reactContainer$"+Ls,km="__reactEvents$"+Ls,X2="__reactListeners$"+Ls,K2="__reactHandles$"+Ls;function ka(e){var t=e[Jn];if(t)return t;for(var i=e.parentNode;i;){if(t=i[Gi]||i[Jn]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=gh(e);e!==null;){if(i=e[Jn])return i;e=gh(e)}return t}e=i,i=e.parentNode}return null}function ol(e){return e=e[Jn]||e[Gi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ds(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(te(33))}function hc(e){return e[Fo]||null}var Mm=[],ms=-1;function ha(e){return{current:e}}function Ye(e){0>ms||(e.current=Mm[ms],Mm[ms]=null,ms--)}function Ue(e,t){ms++,Mm[ms]=e.current,e.current=t}var ua={},Pt=ha(ua),en=ha(!1),Ba=ua;function Es(e,t){var i=e.type.contextTypes;if(!i)return ua;var a=e.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===t)return a.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in i)s[o]=t[o];return a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function tn(e){return e=e.childContextTypes,e!=null}function Er(){Ye(en),Ye(Pt)}function bh(e,t,i){if(Pt.current!==ua)throw Error(te(168));Ue(Pt,t),Ue(en,i)}function oy(e,t,i){var a=e.stateNode;if(t=t.childContextTypes,typeof a.getChildContext!="function")return i;a=a.getChildContext();for(var s in a)if(!(s in t))throw Error(te(108,Ev(e)||"Unknown",s));return it({},i,a)}function Gr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ua,Ba=Pt.current,Ue(Pt,e),Ue(en,en.current),!0}function yh(e,t,i){var a=e.stateNode;if(!a)throw Error(te(169));i?(e=oy(e,t,Ba),a.__reactInternalMemoizedMergedChildContext=e,Ye(en),Ye(Pt),Ue(Pt,e)):Ye(en),Ue(en,i)}var gi=null,fc=!1,fd=!1;function ly(e){gi===null?gi=[e]:gi.push(e)}function z2(e){fc=!0,ly(e)}function fa(){if(!fd&&gi!==null){fd=!0;var e=0,t=Le;try{var i=gi;for(Le=1;e<i.length;e++){var a=i[e];do a=a(!0);while(a!==null)}gi=null,fc=!1}catch(s){throw gi!==null&&(gi=gi.slice(e+1)),Db(Yu,fa),s}finally{Le=t,fd=!1}}return null}var us=[],ps=0,Sr=null,Ar=0,yn=[],xn=0,Ha=null,xi=1,_i="";function ja(e,t){us[ps++]=Ar,us[ps++]=Sr,Sr=e,Ar=t}function ry(e,t,i){yn[xn++]=xi,yn[xn++]=_i,yn[xn++]=Ha,Ha=e;var a=xi;e=_i;var s=32-Bn(a)-1;a&=~(1<<s),i+=1;var o=32-Bn(t)+s;if(30<o){var l=s-s%5;o=(a&(1<<l)-1).toString(32),a>>=l,s-=l,xi=1<<32-Bn(t)+s|i<<s|a,_i=o+e}else xi=1<<o|i<<s|a,_i=e}function sp(e){e.return!==null&&(ja(e,1),ry(e,1,0))}function op(e){for(;e===Sr;)Sr=us[--ps],us[ps]=null,Ar=us[--ps],us[ps]=null;for(;e===Ha;)Ha=yn[--xn],yn[xn]=null,_i=yn[--xn],yn[xn]=null,xi=yn[--xn],yn[xn]=null}var un=null,cn=null,Qe=!1,Pn=null;function cy(e,t){var i=_n(5,null,null,0);i.elementType="DELETED",i.stateNode=t,i.return=e,t=e.deletions,t===null?(e.deletions=[i],e.flags|=16):t.push(i)}function xh(e,t){switch(e.tag){case 5:var i=e.type;return t=t.nodeType!==1||i.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,un=e,cn=ea(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,un=e,cn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(i=Ha!==null?{id:xi,overflow:_i}:null,e.memoizedState={dehydrated:t,treeContext:i,retryLane:1073741824},i=_n(18,null,null,0),i.stateNode=t,i.return=e,e.child=i,un=e,cn=null,!0):!1;default:return!1}}function Em(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Gm(e){if(Qe){var t=cn;if(t){var i=t;if(!xh(e,t)){if(Em(e))throw Error(te(418));t=ea(i.nextSibling);var a=un;t&&xh(e,t)?cy(a,i):(e.flags=e.flags&-4097|2,Qe=!1,un=e)}}else{if(Em(e))throw Error(te(418));e.flags=e.flags&-4097|2,Qe=!1,un=e}}}function _h(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;un=e}function Al(e){if(e!==un)return!1;if(!Qe)return _h(e),Qe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!wm(e.type,e.memoizedProps)),t&&(t=cn)){if(Em(e))throw dy(),Error(te(418));for(;t;)cy(e,t),t=ea(t.nextSibling)}if(_h(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(te(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(t===0){cn=ea(e.nextSibling);break e}t--}else i!=="$"&&i!=="$!"&&i!=="$?"||t++}e=e.nextSibling}cn=null}}else cn=un?ea(e.stateNode.nextSibling):null;return!0}function dy(){for(var e=cn;e;)e=ea(e.nextSibling)}function Gs(){cn=un=null,Qe=!1}function lp(e){Pn===null?Pn=[e]:Pn.push(e)}var U2=Bi.ReactCurrentBatchConfig;function Ys(e,t,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(te(309));var a=i.stateNode}if(!a)throw Error(te(147,e));var s=a,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(l){var r=s.refs;l===null?delete r[o]:r[o]=l},t._stringRef=o,t)}if(typeof e!="string")throw Error(te(284));if(!i._owner)throw Error(te(290,e))}return e}function Dl(e,t){throw e=Object.prototype.toString.call(t),Error(te(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function vh(e){var t=e._init;return t(e._payload)}function my(e){function t(b,_){if(e){var x=b.deletions;x===null?(b.deletions=[_],b.flags|=16):x.push(_)}}function i(b,_){if(!e)return null;for(;_!==null;)t(b,_),_=_.sibling;return null}function a(b,_){for(b=new Map;_!==null;)_.key!==null?b.set(_.key,_):b.set(_.index,_),_=_.sibling;return b}function s(b,_){return b=aa(b,_),b.index=0,b.sibling=null,b}function o(b,_,x){return b.index=x,e?(x=b.alternate,x!==null?(x=x.index,x<_?(b.flags|=2,_):x):(b.flags|=2,_)):(b.flags|=1048576,_)}function l(b){return e&&b.alternate===null&&(b.flags|=2),b}function r(b,_,x,v){return _===null||_.tag!==6?(_=jd(x,b.mode,v),_.return=b,_):(_=s(_,x),_.return=b,_)}function c(b,_,x,v){var j=x.type;return j===os?f(b,_,x.props.children,v,x.key):_!==null&&(_.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ti&&vh(j)===_.type)?(v=s(_,x.props),v.ref=Ys(b,_,x),v.return=b,v):(v=rr(x.type,x.key,x.props,null,b.mode,v),v.ref=Ys(b,_,x),v.return=b,v)}function d(b,_,x,v){return _===null||_.tag!==4||_.stateNode.containerInfo!==x.containerInfo||_.stateNode.implementation!==x.implementation?(_=Nd(x,b.mode,v),_.return=b,_):(_=s(_,x.children||[]),_.return=b,_)}function f(b,_,x,v,j){return _===null||_.tag!==7?(_=Ra(x,b.mode,v,j),_.return=b,_):(_=s(_,x),_.return=b,_)}function u(b,_,x){if(typeof _=="string"&&_!==""||typeof _=="number")return _=jd(""+_,b.mode,x),_.return=b,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case vl:return x=rr(_.type,_.key,_.props,null,b.mode,x),x.ref=Ys(b,null,_),x.return=b,x;case ss:return _=Nd(_,b.mode,x),_.return=b,_;case Ti:var v=_._init;return u(b,v(_._payload),x)}if(no(_)||zs(_))return _=Ra(_,b.mode,x,null),_.return=b,_;Dl(b,_)}return null}function p(b,_,x,v){var j=_!==null?_.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return j!==null?null:r(b,_,""+x,v);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case vl:return x.key===j?c(b,_,x,v):null;case ss:return x.key===j?d(b,_,x,v):null;case Ti:return j=x._init,p(b,_,j(x._payload),v)}if(no(x)||zs(x))return j!==null?null:f(b,_,x,v,null);Dl(b,x)}return null}function m(b,_,x,v,j){if(typeof v=="string"&&v!==""||typeof v=="number")return b=b.get(x)||null,r(_,b,""+v,j);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case vl:return b=b.get(v.key===null?x:v.key)||null,c(_,b,v,j);case ss:return b=b.get(v.key===null?x:v.key)||null,d(_,b,v,j);case Ti:var N=v._init;return m(b,_,x,N(v._payload),j)}if(no(v)||zs(v))return b=b.get(x)||null,f(_,b,v,j,null);Dl(_,v)}return null}function h(b,_,x,v){for(var j=null,N=null,C=_,w=_=0,k=null;C!==null&&w<x.length;w++){C.index>w?(k=C,C=null):k=C.sibling;var P=p(b,C,x[w],v);if(P===null){C===null&&(C=k);break}e&&C&&P.alternate===null&&t(b,C),_=o(P,_,w),N===null?j=P:N.sibling=P,N=P,C=k}if(w===x.length)return i(b,C),Qe&&ja(b,w),j;if(C===null){for(;w<x.length;w++)C=u(b,x[w],v),C!==null&&(_=o(C,_,w),N===null?j=C:N.sibling=C,N=C);return Qe&&ja(b,w),j}for(C=a(b,C);w<x.length;w++)k=m(C,b,w,x[w],v),k!==null&&(e&&k.alternate!==null&&C.delete(k.key===null?w:k.key),_=o(k,_,w),N===null?j=k:N.sibling=k,N=k);return e&&C.forEach(function(H){return t(b,H)}),Qe&&ja(b,w),j}function g(b,_,x,v){var j=zs(x);if(typeof j!="function")throw Error(te(150));if(x=j.call(x),x==null)throw Error(te(151));for(var N=j=null,C=_,w=_=0,k=null,P=x.next();C!==null&&!P.done;w++,P=x.next()){C.index>w?(k=C,C=null):k=C.sibling;var H=p(b,C,P.value,v);if(H===null){C===null&&(C=k);break}e&&C&&H.alternate===null&&t(b,C),_=o(H,_,w),N===null?j=H:N.sibling=H,N=H,C=k}if(P.done)return i(b,C),Qe&&ja(b,w),j;if(C===null){for(;!P.done;w++,P=x.next())P=u(b,P.value,v),P!==null&&(_=o(P,_,w),N===null?j=P:N.sibling=P,N=P);return Qe&&ja(b,w),j}for(C=a(b,C);!P.done;w++,P=x.next())P=m(C,b,w,P.value,v),P!==null&&(e&&P.alternate!==null&&C.delete(P.key===null?w:P.key),_=o(P,_,w),N===null?j=P:N.sibling=P,N=P);return e&&C.forEach(function(G){return t(b,G)}),Qe&&ja(b,w),j}function y(b,_,x,v){if(typeof x=="object"&&x!==null&&x.type===os&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case vl:e:{for(var j=x.key,N=_;N!==null;){if(N.key===j){if(j=x.type,j===os){if(N.tag===7){i(b,N.sibling),_=s(N,x.props.children),_.return=b,b=_;break e}}else if(N.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ti&&vh(j)===N.type){i(b,N.sibling),_=s(N,x.props),_.ref=Ys(b,N,x),_.return=b,b=_;break e}i(b,N);break}else t(b,N);N=N.sibling}x.type===os?(_=Ra(x.props.children,b.mode,v,x.key),_.return=b,b=_):(v=rr(x.type,x.key,x.props,null,b.mode,v),v.ref=Ys(b,_,x),v.return=b,b=v)}return l(b);case ss:e:{for(N=x.key;_!==null;){if(_.key===N)if(_.tag===4&&_.stateNode.containerInfo===x.containerInfo&&_.stateNode.implementation===x.implementation){i(b,_.sibling),_=s(_,x.children||[]),_.return=b,b=_;break e}else{i(b,_);break}else t(b,_);_=_.sibling}_=Nd(x,b.mode,v),_.return=b,b=_}return l(b);case Ti:return N=x._init,y(b,_,N(x._payload),v)}if(no(x))return h(b,_,x,v);if(zs(x))return g(b,_,x,v);Dl(b,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,_!==null&&_.tag===6?(i(b,_.sibling),_=s(_,x),_.return=b,b=_):(i(b,_),_=jd(x,b.mode,v),_.return=b,b=_),l(b)):i(b,_)}return y}var Ss=my(!0),uy=my(!1),Dr=ha(null),Pr=null,hs=null,rp=null;function cp(){rp=hs=Pr=null}function dp(e){var t=Dr.current;Ye(Dr),e._currentValue=t}function Sm(e,t,i){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===i)break;e=e.return}}function js(e,t){Pr=e,rp=hs=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jt=!0),e.firstContext=null)}function Cn(e){var t=e._currentValue;if(rp!==e)if(e={context:e,memoizedValue:t,next:null},hs===null){if(Pr===null)throw Error(te(308));hs=e,Pr.dependencies={lanes:0,firstContext:e}}else hs=hs.next=e;return t}var Ma=null;function mp(e){Ma===null?Ma=[e]:Ma.push(e)}function py(e,t,i,a){var s=t.interleaved;return s===null?(i.next=i,mp(t)):(i.next=s.next,s.next=i),t.interleaved=i,Si(e,a)}function Si(e,t){e.lanes|=t;var i=e.alternate;for(i!==null&&(i.lanes|=t),i=e,e=e.return;e!==null;)e.childLanes|=t,i=e.alternate,i!==null&&(i.childLanes|=t),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Fi=!1;function up(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function hy(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 Ni(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ta(e,t,i){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,Ie&2){var s=a.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),a.pending=t,Si(e,i)}return s=a.interleaved,s===null?(t.next=t,mp(a)):(t.next=s.next,s.next=t),a.interleaved=t,Si(e,i)}function nr(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194240)!==0)){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Zu(e,i)}}function jh(e,t){var i=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,i===a)){var s=null,o=null;if(i=i.firstBaseUpdate,i!==null){do{var l={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};o===null?s=o=l:o=o.next=l,i=i.next}while(i!==null);o===null?s=o=t:o=o.next=t}else s=o=t;i={baseState:a.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:a.shared,effects:a.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}function Rr(e,t,i,a){var s=e.updateQueue;Fi=!1;var o=s.firstBaseUpdate,l=s.lastBaseUpdate,r=s.shared.pending;if(r!==null){s.shared.pending=null;var c=r,d=c.next;c.next=null,l===null?o=d:l.next=d,l=c;var f=e.alternate;f!==null&&(f=f.updateQueue,r=f.lastBaseUpdate,r!==l&&(r===null?f.firstBaseUpdate=d:r.next=d,f.lastBaseUpdate=c))}if(o!==null){var u=s.baseState;l=0,f=d=c=null,r=o;do{var p=r.lane,m=r.eventTime;if((a&p)===p){f!==null&&(f=f.next={eventTime:m,lane:0,tag:r.tag,payload:r.payload,callback:r.callback,next:null});e:{var h=e,g=r;switch(p=t,m=i,g.tag){case 1:if(h=g.payload,typeof h=="function"){u=h.call(m,u,p);break e}u=h;break e;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h=="function"?h.call(m,u,p):h,p==null)break e;u=it({},u,p);break e;case 2:Fi=!0}}r.callback!==null&&r.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[r]:p.push(r))}else m={eventTime:m,lane:p,tag:r.tag,payload:r.payload,callback:r.callback,next:null},f===null?(d=f=m,c=u):f=f.next=m,l|=p;if(r=r.next,r===null){if(r=s.shared.pending,r===null)break;p=r,r=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(f===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);$a|=l,e.lanes=l,e.memoizedState=u}}function Nh(e,t,i){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var a=e[t],s=a.callback;if(s!==null){if(a.callback=null,a=i,typeof s!="function")throw Error(te(191,s));s.call(a)}}}var ll={},ii=ha(ll),Xo=ha(ll),Ko=ha(ll);function Ea(e){if(e===ll)throw Error(te(174));return e}function pp(e,t){switch(Ue(Ko,t),Ue(Xo,e),Ue(ii,ll),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:dm(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=dm(t,e)}Ye(ii),Ue(ii,t)}function As(){Ye(ii),Ye(Xo),Ye(Ko)}function fy(e){Ea(Ko.current);var t=Ea(ii.current),i=dm(t,e.type);t!==i&&(Ue(Xo,e),Ue(ii,i))}function hp(e){Xo.current===e&&(Ye(ii),Ye(Xo))}var et=ha(0);function Ir(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.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 gd=[];function fp(){for(var e=0;e<gd.length;e++)gd[e]._workInProgressVersionPrimary=null;gd.length=0}var ir=Bi.ReactCurrentDispatcher,bd=Bi.ReactCurrentBatchConfig,Oa=0,nt=null,pt=null,gt=null,Br=!1,po=!1,zo=0,q2=0;function Et(){throw Error(te(321))}function gp(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!Tn(e[i],t[i]))return!1;return!0}function bp(e,t,i,a,s,o){if(Oa=o,nt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ir.current=e===null||e.memoizedState===null?Z2:Q2,e=i(a,s),po){o=0;do{if(po=!1,zo=0,25<=o)throw Error(te(301));o+=1,gt=pt=null,t.updateQueue=null,ir.current=J2,e=i(a,s)}while(po)}if(ir.current=Hr,t=pt!==null&&pt.next!==null,Oa=0,gt=pt=nt=null,Br=!1,t)throw Error(te(300));return e}function yp(){var e=zo!==0;return zo=0,e}function Yn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?nt.memoizedState=gt=e:gt=gt.next=e,gt}function kn(){if(pt===null){var e=nt.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var t=gt===null?nt.memoizedState:gt.next;if(t!==null)gt=t,pt=e;else{if(e===null)throw Error(te(310));pt=e,e={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},gt===null?nt.memoizedState=gt=e:gt=gt.next=e}return gt}function Uo(e,t){return typeof t=="function"?t(e):t}function yd(e){var t=kn(),i=t.queue;if(i===null)throw Error(te(311));i.lastRenderedReducer=e;var a=pt,s=a.baseQueue,o=i.pending;if(o!==null){if(s!==null){var l=s.next;s.next=o.next,o.next=l}a.baseQueue=s=o,i.pending=null}if(s!==null){o=s.next,a=a.baseState;var r=l=null,c=null,d=o;do{var f=d.lane;if((Oa&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),a=d.hasEagerState?d.eagerState:e(a,d.action);else{var u={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(r=c=u,l=a):c=c.next=u,nt.lanes|=f,$a|=f}d=d.next}while(d!==null&&d!==o);c===null?l=a:c.next=r,Tn(a,t.memoizedState)||(Jt=!0),t.memoizedState=a,t.baseState=l,t.baseQueue=c,i.lastRenderedState=a}if(e=i.interleaved,e!==null){s=e;do o=s.lane,nt.lanes|=o,$a|=o,s=s.next;while(s!==e)}else s===null&&(i.lanes=0);return[t.memoizedState,i.dispatch]}function xd(e){var t=kn(),i=t.queue;if(i===null)throw Error(te(311));i.lastRenderedReducer=e;var a=i.dispatch,s=i.pending,o=t.memoizedState;if(s!==null){i.pending=null;var l=s=s.next;do o=e(o,l.action),l=l.next;while(l!==s);Tn(o,t.memoizedState)||(Jt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),i.lastRenderedState=o}return[o,a]}function gy(){}function by(e,t){var i=nt,a=kn(),s=t(),o=!Tn(a.memoizedState,s);if(o&&(a.memoizedState=s,Jt=!0),a=a.queue,xp(_y.bind(null,i,a,e),[e]),a.getSnapshot!==t||o||gt!==null&>.memoizedState.tag&1){if(i.flags|=2048,qo(9,xy.bind(null,i,a,s,t),void 0,null),xt===null)throw Error(te(349));Oa&30||yy(i,t,s)}return s}function yy(e,t,i){e.flags|=16384,e={getSnapshot:t,value:i},t=nt.updateQueue,t===null?(t={lastEffect:null,stores:null},nt.updateQueue=t,t.stores=[e]):(i=t.stores,i===null?t.stores=[e]:i.push(e))}function xy(e,t,i,a){t.value=i,t.getSnapshot=a,vy(t)&&jy(e)}function _y(e,t,i){return i(function(){vy(t)&&jy(e)})}function vy(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!Tn(e,i)}catch{return!0}}function jy(e){var t=Si(e,1);t!==null&&Hn(t,e,1,-1)}function wh(e){var t=Yn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:e},t.queue=e,e=e.dispatch=Y2.bind(null,nt,e),[t.memoizedState,e]}function qo(e,t,i,a){return e={tag:e,create:t,destroy:i,deps:a,next:null},t=nt.updateQueue,t===null?(t={lastEffect:null,stores:null},nt.updateQueue=t,t.lastEffect=e.next=e):(i=t.lastEffect,i===null?t.lastEffect=e.next=e:(a=i.next,i.next=e,e.next=a,t.lastEffect=e)),e}function Ny(){return kn().memoizedState}function ar(e,t,i,a){var s=Yn();nt.flags|=e,s.memoizedState=qo(1|t,i,void 0,a===void 0?null:a)}function gc(e,t,i,a){var s=kn();a=a===void 0?null:a;var o=void 0;if(pt!==null){var l=pt.memoizedState;if(o=l.destroy,a!==null&&gp(a,l.deps)){s.memoizedState=qo(t,i,o,a);return}}nt.flags|=e,s.memoizedState=qo(1|t,i,o,a)}function Ch(e,t){return ar(8390656,8,e,t)}function xp(e,t){return gc(2048,8,e,t)}function wy(e,t){return gc(4,2,e,t)}function Cy(e,t){return gc(4,4,e,t)}function ky(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 My(e,t,i){return i=i!=null?i.concat([e]):null,gc(4,4,ky.bind(null,t,e),i)}function _p(){}function Ey(e,t){var i=kn();t=t===void 0?null:t;var a=i.memoizedState;return a!==null&&t!==null&&gp(t,a[1])?a[0]:(i.memoizedState=[e,t],e)}function Gy(e,t){var i=kn();t=t===void 0?null:t;var a=i.memoizedState;return a!==null&&t!==null&&gp(t,a[1])?a[0]:(e=e(),i.memoizedState=[e,t],e)}function Sy(e,t,i){return Oa&21?(Tn(i,t)||(i=Ib(),nt.lanes|=i,$a|=i,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jt=!0),e.memoizedState=i)}function V2(e,t){var i=Le;Le=i!==0&&4>i?i:4,e(!0);var a=bd.transition;bd.transition={};try{e(!1),t()}finally{Le=i,bd.transition=a}}function Ay(){return kn().memoizedState}function W2(e,t,i){var a=ia(e);if(i={lane:a,action:i,hasEagerState:!1,eagerState:null,next:null},Dy(e))Py(t,i);else if(i=py(e,t,i,a),i!==null){var s=Tt();Hn(i,e,a,s),Ry(i,t,a)}}function Y2(e,t,i){var a=ia(e),s={lane:a,action:i,hasEagerState:!1,eagerState:null,next:null};if(Dy(e))Py(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var l=t.lastRenderedState,r=o(l,i);if(s.hasEagerState=!0,s.eagerState=r,Tn(r,l)){var c=t.interleaved;c===null?(s.next=s,mp(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}i=py(e,t,s,a),i!==null&&(s=Tt(),Hn(i,e,a,s),Ry(i,t,a))}}function Dy(e){var t=e.alternate;return e===nt||t!==null&&t===nt}function Py(e,t){po=Br=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Ry(e,t,i){if(i&4194240){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Zu(e,i)}}var Hr={readContext:Cn,useCallback:Et,useContext:Et,useEffect:Et,useImperativeHandle:Et,useInsertionEffect:Et,useLayoutEffect:Et,useMemo:Et,useReducer:Et,useRef:Et,useState:Et,useDebugValue:Et,useDeferredValue:Et,useTransition:Et,useMutableSource:Et,useSyncExternalStore:Et,useId:Et,unstable_isNewReconciler:!1},Z2={readContext:Cn,useCallback:function(e,t){return Yn().memoizedState=[e,t===void 0?null:t],e},useContext:Cn,useEffect:Ch,useImperativeHandle:function(e,t,i){return i=i!=null?i.concat([e]):null,ar(4194308,4,ky.bind(null,t,e),i)},useLayoutEffect:function(e,t){return ar(4194308,4,e,t)},useInsertionEffect:function(e,t){return ar(4,2,e,t)},useMemo:function(e,t){var i=Yn();return t=t===void 0?null:t,e=e(),i.memoizedState=[e,t],e},useReducer:function(e,t,i){var a=Yn();return t=i!==void 0?i(t):t,a.memoizedState=a.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},a.queue=e,e=e.dispatch=W2.bind(null,nt,e),[a.memoizedState,e]},useRef:function(e){var t=Yn();return e={current:e},t.memoizedState=e},useState:wh,useDebugValue:_p,useDeferredValue:function(e){return Yn().memoizedState=e},useTransition:function(){var e=wh(!1),t=e[0];return e=V2.bind(null,e[1]),Yn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,i){var a=nt,s=Yn();if(Qe){if(i===void 0)throw Error(te(407));i=i()}else{if(i=t(),xt===null)throw Error(te(349));Oa&30||yy(a,t,i)}s.memoizedState=i;var o={value:i,getSnapshot:t};return s.queue=o,Ch(_y.bind(null,a,o,e),[e]),a.flags|=2048,qo(9,xy.bind(null,a,o,i,t),void 0,null),i},useId:function(){var e=Yn(),t=xt.identifierPrefix;if(Qe){var i=_i,a=xi;i=(a&~(1<<32-Bn(a)-1)).toString(32)+i,t=":"+t+"R"+i,i=zo++,0<i&&(t+="H"+i.toString(32)),t+=":"}else i=q2++,t=":"+t+"r"+i.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Q2={readContext:Cn,useCallback:Ey,useContext:Cn,useEffect:xp,useImperativeHandle:My,useInsertionEffect:wy,useLayoutEffect:Cy,useMemo:Gy,useReducer:yd,useRef:Ny,useState:function(){return yd(Uo)},useDebugValue:_p,useDeferredValue:function(e){var t=kn();return Sy(t,pt.memoizedState,e)},useTransition:function(){var e=yd(Uo)[0],t=kn().memoizedState;return[e,t]},useMutableSource:gy,useSyncExternalStore:by,useId:Ay,unstable_isNewReconciler:!1},J2={readContext:Cn,useCallback:Ey,useContext:Cn,useEffect:xp,useImperativeHandle:My,useInsertionEffect:wy,useLayoutEffect:Cy,useMemo:Gy,useReducer:xd,useRef:Ny,useState:function(){return xd(Uo)},useDebugValue:_p,useDeferredValue:function(e){var t=kn();return pt===null?t.memoizedState=e:Sy(t,pt.memoizedState,e)},useTransition:function(){var e=xd(Uo)[0],t=kn().memoizedState;return[e,t]},useMutableSource:gy,useSyncExternalStore:by,useId:Ay,unstable_isNewReconciler:!1};function An(e,t){if(e&&e.defaultProps){t=it({},t),e=e.defaultProps;for(var i in e)t[i]===void 0&&(t[i]=e[i]);return t}return t}function Am(e,t,i,a){t=e.memoizedState,i=i(a,t),i=i==null?t:it({},t,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var bc={isMounted:function(e){return(e=e._reactInternals)?Wa(e)===e:!1},enqueueSetState:function(e,t,i){e=e._reactInternals;var a=Tt(),s=ia(e),o=Ni(a,s);o.payload=t,i!=null&&(o.callback=i),t=ta(e,o,s),t!==null&&(Hn(t,e,s,a),nr(t,e,s))},enqueueReplaceState:function(e,t,i){e=e._reactInternals;var a=Tt(),s=ia(e),o=Ni(a,s);o.tag=1,o.payload=t,i!=null&&(o.callback=i),t=ta(e,o,s),t!==null&&(Hn(t,e,s,a),nr(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var i=Tt(),a=ia(e),s=Ni(i,a);s.tag=2,t!=null&&(s.callback=t),t=ta(e,s,a),t!==null&&(Hn(t,e,a,i),nr(t,e,a))}};function kh(e,t,i,a,s,o,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,o,l):t.prototype&&t.prototype.isPureReactComponent?!$o(i,a)||!$o(s,o):!0}function Iy(e,t,i){var a=!1,s=ua,o=t.contextType;return typeof o=="object"&&o!==null?o=Cn(o):(s=tn(t)?Ba:Pt.current,a=t.contextTypes,o=(a=a!=null)?Es(e,s):ua),t=new t(i,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=bc,e.stateNode=t,t._reactInternals=e,a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Mh(e,t,i,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(i,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(i,a),t.state!==e&&bc.enqueueReplaceState(t,t.state,null)}function Dm(e,t,i,a){var s=e.stateNode;s.props=i,s.state=e.memoizedState,s.refs={},up(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Cn(o):(o=tn(t)?Ba:Pt.current,s.context=Es(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Am(e,t,o,i),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&bc.enqueueReplaceState(s,s.state,null),Rr(e,i,s,a),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Ds(e,t){try{var i="",a=t;do i+=Mv(a),a=a.return;while(a);var s=i}catch(o){s=`
|
|
39
|
+
Error generating stack: `+o.message+`
|
|
40
|
+
`+o.stack}return{value:e,source:t,stack:s,digest:null}}function _d(e,t,i){return{value:e,source:null,stack:i??null,digest:t??null}}function Pm(e,t){try{console.error(t.value)}catch(i){setTimeout(function(){throw i})}}var ej=typeof WeakMap=="function"?WeakMap:Map;function By(e,t,i){i=Ni(-1,i),i.tag=3,i.payload={element:null};var a=t.value;return i.callback=function(){$r||($r=!0,Xm=a),Pm(e,t)},i}function Hy(e,t,i){i=Ni(-1,i),i.tag=3;var a=e.type.getDerivedStateFromError;if(typeof a=="function"){var s=t.value;i.payload=function(){return a(s)},i.callback=function(){Pm(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(i.callback=function(){Pm(e,t),typeof a!="function"&&(na===null?na=new Set([this]):na.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),i}function Eh(e,t,i){var a=e.pingCache;if(a===null){a=e.pingCache=new ej;var s=new Set;a.set(t,s)}else s=a.get(t),s===void 0&&(s=new Set,a.set(t,s));s.has(i)||(s.add(i),e=hj.bind(null,e,t,i),t.then(e,e))}function Gh(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 Sh(e,t,i,a,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(t=Ni(-1,1),t.tag=2,ta(i,t,1))),i.lanes|=1),e)}var tj=Bi.ReactCurrentOwner,Jt=!1;function Ht(e,t,i,a){t.child=e===null?uy(t,null,i,a):Ss(t,e.child,i,a)}function Ah(e,t,i,a,s){i=i.render;var o=t.ref;return js(t,s),a=bp(e,t,i,a,o,s),i=yp(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Ai(e,t,s)):(Qe&&i&&sp(t),t.flags|=1,Ht(e,t,a,s),t.child)}function Dh(e,t,i,a,s){if(e===null){var o=i.type;return typeof o=="function"&&!Ep(o)&&o.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(t.tag=15,t.type=o,Oy(e,t,o,a,s)):(e=rr(i.type,null,a,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var l=o.memoizedProps;if(i=i.compare,i=i!==null?i:$o,i(l,a)&&e.ref===t.ref)return Ai(e,t,s)}return t.flags|=1,e=aa(o,a),e.ref=t.ref,e.return=t,t.child=e}function Oy(e,t,i,a,s){if(e!==null){var o=e.memoizedProps;if($o(o,a)&&e.ref===t.ref)if(Jt=!1,t.pendingProps=a=o,(e.lanes&s)!==0)e.flags&131072&&(Jt=!0);else return t.lanes=e.lanes,Ai(e,t,s)}return Rm(e,t,i,a,s)}function $y(e,t,i){var a=t.pendingProps,s=a.children,o=e!==null?e.memoizedState:null;if(a.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ue(gs,ln),ln|=i;else{if(!(i&1073741824))return e=o!==null?o.baseLanes|i:i,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ue(gs,ln),ln|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},a=o!==null?o.baseLanes:i,Ue(gs,ln),ln|=a}else o!==null?(a=o.baseLanes|i,t.memoizedState=null):a=i,Ue(gs,ln),ln|=a;return Ht(e,t,s,i),t.child}function Ly(e,t){var i=t.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(t.flags|=512,t.flags|=2097152)}function Rm(e,t,i,a,s){var o=tn(i)?Ba:Pt.current;return o=Es(t,o),js(t,s),i=bp(e,t,i,a,o,s),a=yp(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Ai(e,t,s)):(Qe&&a&&sp(t),t.flags|=1,Ht(e,t,i,s),t.child)}function Ph(e,t,i,a,s){if(tn(i)){var o=!0;Gr(t)}else o=!1;if(js(t,s),t.stateNode===null)sr(e,t),Iy(t,i,a),Dm(t,i,a,s),a=!0;else if(e===null){var l=t.stateNode,r=t.memoizedProps;l.props=r;var c=l.context,d=i.contextType;typeof d=="object"&&d!==null?d=Cn(d):(d=tn(i)?Ba:Pt.current,d=Es(t,d));var f=i.getDerivedStateFromProps,u=typeof f=="function"||typeof l.getSnapshotBeforeUpdate=="function";u||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(r!==a||c!==d)&&Mh(t,l,a,d),Fi=!1;var p=t.memoizedState;l.state=p,Rr(t,a,l,s),c=t.memoizedState,r!==a||p!==c||en.current||Fi?(typeof f=="function"&&(Am(t,i,f,a),c=t.memoizedState),(r=Fi||kh(t,i,r,a,p,c,d))?(u||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=c),l.props=a,l.state=c,l.context=d,a=r):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{l=t.stateNode,hy(e,t),r=t.memoizedProps,d=t.type===t.elementType?r:An(t.type,r),l.props=d,u=t.pendingProps,p=l.context,c=i.contextType,typeof c=="object"&&c!==null?c=Cn(c):(c=tn(i)?Ba:Pt.current,c=Es(t,c));var m=i.getDerivedStateFromProps;(f=typeof m=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(r!==u||p!==c)&&Mh(t,l,a,c),Fi=!1,p=t.memoizedState,l.state=p,Rr(t,a,l,s);var h=t.memoizedState;r!==u||p!==h||en.current||Fi?(typeof m=="function"&&(Am(t,i,m,a),h=t.memoizedState),(d=Fi||kh(t,i,d,a,p,h,c)||!1)?(f||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(a,h,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(a,h,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||r===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||r===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=h),l.props=a,l.state=h,l.context=c,a=d):(typeof l.componentDidUpdate!="function"||r===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||r===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),a=!1)}return Im(e,t,i,a,o,s)}function Im(e,t,i,a,s,o){Ly(e,t);var l=(t.flags&128)!==0;if(!a&&!l)return s&&yh(t,i,!1),Ai(e,t,o);a=t.stateNode,tj.current=t;var r=l&&typeof i.getDerivedStateFromError!="function"?null:a.render();return t.flags|=1,e!==null&&l?(t.child=Ss(t,e.child,null,o),t.child=Ss(t,null,r,o)):Ht(e,t,r,o),t.memoizedState=a.state,s&&yh(t,i,!0),t.child}function Ty(e){var t=e.stateNode;t.pendingContext?bh(e,t.pendingContext,t.pendingContext!==t.context):t.context&&bh(e,t.context,!1),pp(e,t.containerInfo)}function Rh(e,t,i,a,s){return Gs(),lp(s),t.flags|=256,Ht(e,t,i,a),t.child}var Bm={dehydrated:null,treeContext:null,retryLane:0};function Hm(e){return{baseLanes:e,cachePool:null,transitions:null}}function Fy(e,t,i){var a=t.pendingProps,s=et.current,o=!1,l=(t.flags&128)!==0,r;if((r=l)||(r=e!==null&&e.memoizedState===null?!1:(s&2)!==0),r?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),Ue(et,s&1),e===null)return Gm(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):(l=a.children,e=a.fallback,o?(a=t.mode,o=t.child,l={mode:"hidden",children:l},!(a&1)&&o!==null?(o.childLanes=0,o.pendingProps=l):o=_c(l,a,0,null),e=Ra(e,a,i,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Hm(i),t.memoizedState=Bm,e):vp(t,l));if(s=e.memoizedState,s!==null&&(r=s.dehydrated,r!==null))return nj(e,t,l,a,r,s,i);if(o){o=a.fallback,l=t.mode,s=e.child,r=s.sibling;var c={mode:"hidden",children:a.children};return!(l&1)&&t.child!==s?(a=t.child,a.childLanes=0,a.pendingProps=c,t.deletions=null):(a=aa(s,c),a.subtreeFlags=s.subtreeFlags&14680064),r!==null?o=aa(r,o):(o=Ra(o,l,i,null),o.flags|=2),o.return=t,a.return=t,a.sibling=o,t.child=a,a=o,o=t.child,l=e.child.memoizedState,l=l===null?Hm(i):{baseLanes:l.baseLanes|i,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~i,t.memoizedState=Bm,a}return o=e.child,e=o.sibling,a=aa(o,{mode:"visible",children:a.children}),!(t.mode&1)&&(a.lanes=i),a.return=t,a.sibling=null,e!==null&&(i=t.deletions,i===null?(t.deletions=[e],t.flags|=16):i.push(e)),t.child=a,t.memoizedState=null,a}function vp(e,t){return t=_c({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Pl(e,t,i,a){return a!==null&&lp(a),Ss(t,e.child,null,i),e=vp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function nj(e,t,i,a,s,o,l){if(i)return t.flags&256?(t.flags&=-257,a=_d(Error(te(422))),Pl(e,t,l,a)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=a.fallback,s=t.mode,a=_c({mode:"visible",children:a.children},s,0,null),o=Ra(o,s,l,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,t.mode&1&&Ss(t,e.child,null,l),t.child.memoizedState=Hm(l),t.memoizedState=Bm,o);if(!(t.mode&1))return Pl(e,t,l,null);if(s.data==="$!"){if(a=s.nextSibling&&s.nextSibling.dataset,a)var r=a.dgst;return a=r,o=Error(te(419)),a=_d(o,a,void 0),Pl(e,t,l,a)}if(r=(l&e.childLanes)!==0,Jt||r){if(a=xt,a!==null){switch(l&-l){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(a.suspendedLanes|l)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,Si(e,s),Hn(a,e,s,-1))}return Mp(),a=_d(Error(te(421))),Pl(e,t,l,a)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=fj.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,cn=ea(s.nextSibling),un=t,Qe=!0,Pn=null,e!==null&&(yn[xn++]=xi,yn[xn++]=_i,yn[xn++]=Ha,xi=e.id,_i=e.overflow,Ha=t),t=vp(t,a.children),t.flags|=4096,t)}function Ih(e,t,i){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Sm(e.return,t,i)}function vd(e,t,i,a,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:i,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=a,o.tail=i,o.tailMode=s)}function Xy(e,t,i){var a=t.pendingProps,s=a.revealOrder,o=a.tail;if(Ht(e,t,a.children,i),a=et.current,a&2)a=a&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ih(e,i,t);else if(e.tag===19)Ih(e,i,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}a&=1}if(Ue(et,a),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(i=t.child,s=null;i!==null;)e=i.alternate,e!==null&&Ir(e)===null&&(s=i),i=i.sibling;i=s,i===null?(s=t.child,t.child=null):(s=i.sibling,i.sibling=null),vd(t,!1,s,i,o);break;case"backwards":for(i=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Ir(e)===null){t.child=s;break}e=s.sibling,s.sibling=i,i=s,s=e}vd(t,!0,i,null,o);break;case"together":vd(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function sr(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ai(e,t,i){if(e!==null&&(t.dependencies=e.dependencies),$a|=t.lanes,!(i&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(te(153));if(t.child!==null){for(e=t.child,i=aa(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=aa(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}function ij(e,t,i){switch(t.tag){case 3:Ty(t),Gs();break;case 5:fy(t);break;case 1:tn(t.type)&&Gr(t);break;case 4:pp(t,t.stateNode.containerInfo);break;case 10:var a=t.type._context,s=t.memoizedProps.value;Ue(Dr,a._currentValue),a._currentValue=s;break;case 13:if(a=t.memoizedState,a!==null)return a.dehydrated!==null?(Ue(et,et.current&1),t.flags|=128,null):i&t.child.childLanes?Fy(e,t,i):(Ue(et,et.current&1),e=Ai(e,t,i),e!==null?e.sibling:null);Ue(et,et.current&1);break;case 19:if(a=(i&t.childLanes)!==0,e.flags&128){if(a)return Xy(e,t,i);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),Ue(et,et.current),a)break;return null;case 22:case 23:return t.lanes=0,$y(e,t,i)}return Ai(e,t,i)}var Ky,Om,zy,Uy;Ky=function(e,t){for(var i=t.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}};Om=function(){};zy=function(e,t,i,a){var s=e.memoizedProps;if(s!==a){e=t.stateNode,Ea(ii.current);var o=null;switch(i){case"input":s=om(e,s),a=om(e,a),o=[];break;case"select":s=it({},s,{value:void 0}),a=it({},a,{value:void 0}),o=[];break;case"textarea":s=cm(e,s),a=cm(e,a),o=[];break;default:typeof s.onClick!="function"&&typeof a.onClick=="function"&&(e.onclick=Mr)}mm(i,a);var l;i=null;for(d in s)if(!a.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var r=s[d];for(l in r)r.hasOwnProperty(l)&&(i||(i={}),i[l]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Do.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in a){var c=a[d];if(r=s!=null?s[d]:void 0,a.hasOwnProperty(d)&&c!==r&&(c!=null||r!=null))if(d==="style")if(r){for(l in r)!r.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(i||(i={}),i[l]="");for(l in c)c.hasOwnProperty(l)&&r[l]!==c[l]&&(i||(i={}),i[l]=c[l])}else i||(o||(o=[]),o.push(d,i)),i=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,r=r?r.__html:void 0,c!=null&&r!==c&&(o=o||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Do.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&We("scroll",e),o||r===c||(o=[])):(o=o||[]).push(d,c))}i&&(o=o||[]).push("style",i);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};Uy=function(e,t,i,a){i!==a&&(t.flags|=4)};function Zs(e,t){if(!Qe)switch(e.tailMode){case"hidden":t=e.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var a=null;i!==null;)i.alternate!==null&&(a=i),i=i.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Gt(e){var t=e.alternate!==null&&e.alternate.child===e.child,i=0,a=0;if(t)for(var s=e.child;s!==null;)i|=s.lanes|s.childLanes,a|=s.subtreeFlags&14680064,a|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)i|=s.lanes|s.childLanes,a|=s.subtreeFlags,a|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=a,e.childLanes=i,t}function aj(e,t,i){var a=t.pendingProps;switch(op(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(t),null;case 1:return tn(t.type)&&Er(),Gt(t),null;case 3:return a=t.stateNode,As(),Ye(en),Ye(Pt),fp(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Al(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pn!==null&&(Um(Pn),Pn=null))),Om(e,t),Gt(t),null;case 5:hp(t);var s=Ea(Ko.current);if(i=t.type,e!==null&&t.stateNode!=null)zy(e,t,i,a,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!a){if(t.stateNode===null)throw Error(te(166));return Gt(t),null}if(e=Ea(ii.current),Al(t)){a=t.stateNode,i=t.type;var o=t.memoizedProps;switch(a[Jn]=t,a[Fo]=o,e=(t.mode&1)!==0,i){case"dialog":We("cancel",a),We("close",a);break;case"iframe":case"object":case"embed":We("load",a);break;case"video":case"audio":for(s=0;s<ao.length;s++)We(ao[s],a);break;case"source":We("error",a);break;case"img":case"image":case"link":We("error",a),We("load",a);break;case"details":We("toggle",a);break;case"input":K0(a,o),We("invalid",a);break;case"select":a._wrapperState={wasMultiple:!!o.multiple},We("invalid",a);break;case"textarea":U0(a,o),We("invalid",a)}mm(i,o),s=null;for(var l in o)if(o.hasOwnProperty(l)){var r=o[l];l==="children"?typeof r=="string"?a.textContent!==r&&(o.suppressHydrationWarning!==!0&&Sl(a.textContent,r,e),s=["children",r]):typeof r=="number"&&a.textContent!==""+r&&(o.suppressHydrationWarning!==!0&&Sl(a.textContent,r,e),s=["children",""+r]):Do.hasOwnProperty(l)&&r!=null&&l==="onScroll"&&We("scroll",a)}switch(i){case"input":jl(a),z0(a,o,!0);break;case"textarea":jl(a),q0(a);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(a.onclick=Mr)}a=s,t.updateQueue=a,a!==null&&(t.flags|=4)}else{l=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=_b(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof a.is=="string"?e=l.createElement(i,{is:a.is}):(e=l.createElement(i),i==="select"&&(l=e,a.multiple?l.multiple=!0:a.size&&(l.size=a.size))):e=l.createElementNS(e,i),e[Jn]=t,e[Fo]=a,Ky(e,t,!1,!1),t.stateNode=e;e:{switch(l=um(i,a),i){case"dialog":We("cancel",e),We("close",e),s=a;break;case"iframe":case"object":case"embed":We("load",e),s=a;break;case"video":case"audio":for(s=0;s<ao.length;s++)We(ao[s],e);s=a;break;case"source":We("error",e),s=a;break;case"img":case"image":case"link":We("error",e),We("load",e),s=a;break;case"details":We("toggle",e),s=a;break;case"input":K0(e,a),s=om(e,a),We("invalid",e);break;case"option":s=a;break;case"select":e._wrapperState={wasMultiple:!!a.multiple},s=it({},a,{value:void 0}),We("invalid",e);break;case"textarea":U0(e,a),s=cm(e,a),We("invalid",e);break;default:s=a}mm(i,s),r=s;for(o in r)if(r.hasOwnProperty(o)){var c=r[o];o==="style"?Nb(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&vb(e,c)):o==="children"?typeof c=="string"?(i!=="textarea"||c!=="")&&Po(e,c):typeof c=="number"&&Po(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Do.hasOwnProperty(o)?c!=null&&o==="onScroll"&&We("scroll",e):c!=null&&zu(e,o,c,l))}switch(i){case"input":jl(e),z0(e,a,!1);break;case"textarea":jl(e),q0(e);break;case"option":a.value!=null&&e.setAttribute("value",""+ma(a.value));break;case"select":e.multiple=!!a.multiple,o=a.value,o!=null?ys(e,!!a.multiple,o,!1):a.defaultValue!=null&&ys(e,!!a.multiple,a.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Mr)}switch(i){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}}a&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Gt(t),null;case 6:if(e&&t.stateNode!=null)Uy(e,t,e.memoizedProps,a);else{if(typeof a!="string"&&t.stateNode===null)throw Error(te(166));if(i=Ea(Ko.current),Ea(ii.current),Al(t)){if(a=t.stateNode,i=t.memoizedProps,a[Jn]=t,(o=a.nodeValue!==i)&&(e=un,e!==null))switch(e.tag){case 3:Sl(a.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Sl(a.nodeValue,i,(e.mode&1)!==0)}o&&(t.flags|=4)}else a=(i.nodeType===9?i:i.ownerDocument).createTextNode(a),a[Jn]=t,t.stateNode=a}return Gt(t),null;case 13:if(Ye(et),a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Qe&&cn!==null&&t.mode&1&&!(t.flags&128))dy(),Gs(),t.flags|=98560,o=!1;else if(o=Al(t),a!==null&&a.dehydrated!==null){if(e===null){if(!o)throw Error(te(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(te(317));o[Jn]=t}else Gs(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Gt(t),o=!1}else Pn!==null&&(Um(Pn),Pn=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=i,t):(a=a!==null,a!==(e!==null&&e.memoizedState!==null)&&a&&(t.child.flags|=8192,t.mode&1&&(e===null||et.current&1?ht===0&&(ht=3):Mp())),t.updateQueue!==null&&(t.flags|=4),Gt(t),null);case 4:return As(),Om(e,t),e===null&&Lo(t.stateNode.containerInfo),Gt(t),null;case 10:return dp(t.type._context),Gt(t),null;case 17:return tn(t.type)&&Er(),Gt(t),null;case 19:if(Ye(et),o=t.memoizedState,o===null)return Gt(t),null;if(a=(t.flags&128)!==0,l=o.rendering,l===null)if(a)Zs(o,!1);else{if(ht!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=Ir(e),l!==null){for(t.flags|=128,Zs(o,!1),a=l.updateQueue,a!==null&&(t.updateQueue=a,t.flags|=4),t.subtreeFlags=0,a=i,i=t.child;i!==null;)o=i,e=a,o.flags&=14680066,l=o.alternate,l===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=l.childLanes,o.lanes=l.lanes,o.child=l.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=l.memoizedProps,o.memoizedState=l.memoizedState,o.updateQueue=l.updateQueue,o.type=l.type,e=l.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return Ue(et,et.current&1|2),t.child}e=e.sibling}o.tail!==null&<()>Ps&&(t.flags|=128,a=!0,Zs(o,!1),t.lanes=4194304)}else{if(!a)if(e=Ir(l),e!==null){if(t.flags|=128,a=!0,i=e.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),Zs(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Qe)return Gt(t),null}else 2*lt()-o.renderingStartTime>Ps&&i!==1073741824&&(t.flags|=128,a=!0,Zs(o,!1),t.lanes=4194304);o.isBackwards?(l.sibling=t.child,t.child=l):(i=o.last,i!==null?i.sibling=l:t.child=l,o.last=l)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=lt(),t.sibling=null,i=et.current,Ue(et,a?i&1|2:i&1),t):(Gt(t),null);case 22:case 23:return kp(),a=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==a&&(t.flags|=8192),a&&t.mode&1?ln&1073741824&&(Gt(t),t.subtreeFlags&6&&(t.flags|=8192)):Gt(t),null;case 24:return null;case 25:return null}throw Error(te(156,t.tag))}function sj(e,t){switch(op(t),t.tag){case 1:return tn(t.type)&&Er(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return As(),Ye(en),Ye(Pt),fp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hp(t),null;case 13:if(Ye(et),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(te(340));Gs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ye(et),null;case 4:return As(),null;case 10:return dp(t.type._context),null;case 22:case 23:return kp(),null;case 24:return null;default:return null}}var Rl=!1,At=!1,oj=typeof WeakSet=="function"?WeakSet:Set,de=null;function fs(e,t){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(a){st(e,t,a)}else i.current=null}function $m(e,t,i){try{i()}catch(a){st(e,t,a)}}var Bh=!1;function lj(e,t){if(jm=wr,e=Zb(),ap(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var a=i.getSelection&&i.getSelection();if(a&&a.rangeCount!==0){i=a.anchorNode;var s=a.anchorOffset,o=a.focusNode;a=a.focusOffset;try{i.nodeType,o.nodeType}catch{i=null;break e}var l=0,r=-1,c=-1,d=0,f=0,u=e,p=null;t:for(;;){for(var m;u!==i||s!==0&&u.nodeType!==3||(r=l+s),u!==o||a!==0&&u.nodeType!==3||(c=l+a),u.nodeType===3&&(l+=u.nodeValue.length),(m=u.firstChild)!==null;)p=u,u=m;for(;;){if(u===e)break t;if(p===i&&++d===s&&(r=l),p===o&&++f===a&&(c=l),(m=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=m}i=r===-1||c===-1?null:{start:r,end:c}}else i=null}i=i||{start:0,end:0}}else i=null;for(Nm={focusedElem:e,selectionRange:i},wr=!1,de=t;de!==null;)if(t=de,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,de=e;else for(;de!==null;){t=de;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,y=h.memoizedState,b=t.stateNode,_=b.getSnapshotBeforeUpdate(t.elementType===t.type?g:An(t.type,g),y);b.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(te(163))}}catch(v){st(t,t.return,v)}if(e=t.sibling,e!==null){e.return=t.return,de=e;break}de=t.return}return h=Bh,Bh=!1,h}function ho(e,t,i){var a=t.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var s=a=a.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&$m(t,i,o)}s=s.next}while(s!==a)}}function yc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var a=i.create;i.destroy=a()}i=i.next}while(i!==t)}}function Lm(e){var t=e.ref;if(t!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof t=="function"?t(e):t.current=e}}function qy(e){var t=e.alternate;t!==null&&(e.alternate=null,qy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jn],delete t[Fo],delete t[km],delete t[X2],delete t[K2])),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 Vy(e){return e.tag===5||e.tag===3||e.tag===4}function Hh(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Vy(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 Tm(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?i.nodeType===8?i.parentNode.insertBefore(e,t):i.insertBefore(e,t):(i.nodeType===8?(t=i.parentNode,t.insertBefore(e,i)):(t=i,t.appendChild(e)),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=Mr));else if(a!==4&&(e=e.child,e!==null))for(Tm(e,t,i),e=e.sibling;e!==null;)Tm(e,t,i),e=e.sibling}function Fm(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(a!==4&&(e=e.child,e!==null))for(Fm(e,t,i),e=e.sibling;e!==null;)Fm(e,t,i),e=e.sibling}var _t=null,Dn=!1;function Hi(e,t,i){for(i=i.child;i!==null;)Wy(e,t,i),i=i.sibling}function Wy(e,t,i){if(ni&&typeof ni.onCommitFiberUnmount=="function")try{ni.onCommitFiberUnmount(dc,i)}catch{}switch(i.tag){case 5:At||fs(i,t);case 6:var a=_t,s=Dn;_t=null,Hi(e,t,i),_t=a,Dn=s,_t!==null&&(Dn?(e=_t,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):_t.removeChild(i.stateNode));break;case 18:_t!==null&&(Dn?(e=_t,i=i.stateNode,e.nodeType===8?hd(e.parentNode,i):e.nodeType===1&&hd(e,i),Ho(e)):hd(_t,i.stateNode));break;case 4:a=_t,s=Dn,_t=i.stateNode.containerInfo,Dn=!0,Hi(e,t,i),_t=a,Dn=s;break;case 0:case 11:case 14:case 15:if(!At&&(a=i.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){s=a=a.next;do{var o=s,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&$m(i,t,l),s=s.next}while(s!==a)}Hi(e,t,i);break;case 1:if(!At&&(fs(i,t),a=i.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=i.memoizedProps,a.state=i.memoizedState,a.componentWillUnmount()}catch(r){st(i,t,r)}Hi(e,t,i);break;case 21:Hi(e,t,i);break;case 22:i.mode&1?(At=(a=At)||i.memoizedState!==null,Hi(e,t,i),At=a):Hi(e,t,i);break;default:Hi(e,t,i)}}function Oh(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new oj),t.forEach(function(a){var s=gj.bind(null,e,a);i.has(a)||(i.add(a),a.then(s,s))})}}function Gn(e,t){var i=t.deletions;if(i!==null)for(var a=0;a<i.length;a++){var s=i[a];try{var o=e,l=t,r=l;e:for(;r!==null;){switch(r.tag){case 5:_t=r.stateNode,Dn=!1;break e;case 3:_t=r.stateNode.containerInfo,Dn=!0;break e;case 4:_t=r.stateNode.containerInfo,Dn=!0;break e}r=r.return}if(_t===null)throw Error(te(160));Wy(o,l,s),_t=null,Dn=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){st(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Yy(t,e),t=t.sibling}function Yy(e,t){var i=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Gn(t,e),qn(e),a&4){try{ho(3,e,e.return),yc(3,e)}catch(g){st(e,e.return,g)}try{ho(5,e,e.return)}catch(g){st(e,e.return,g)}}break;case 1:Gn(t,e),qn(e),a&512&&i!==null&&fs(i,i.return);break;case 5:if(Gn(t,e),qn(e),a&512&&i!==null&&fs(i,i.return),e.flags&32){var s=e.stateNode;try{Po(s,"")}catch(g){st(e,e.return,g)}}if(a&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,l=i!==null?i.memoizedProps:o,r=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{r==="input"&&o.type==="radio"&&o.name!=null&&yb(s,o),um(r,l);var d=um(r,o);for(l=0;l<c.length;l+=2){var f=c[l],u=c[l+1];f==="style"?Nb(s,u):f==="dangerouslySetInnerHTML"?vb(s,u):f==="children"?Po(s,u):zu(s,f,u,d)}switch(r){case"input":lm(s,o);break;case"textarea":xb(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m!=null?ys(s,!!o.multiple,m,!1):p!==!!o.multiple&&(o.defaultValue!=null?ys(s,!!o.multiple,o.defaultValue,!0):ys(s,!!o.multiple,o.multiple?[]:"",!1))}s[Fo]=o}catch(g){st(e,e.return,g)}}break;case 6:if(Gn(t,e),qn(e),a&4){if(e.stateNode===null)throw Error(te(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(g){st(e,e.return,g)}}break;case 3:if(Gn(t,e),qn(e),a&4&&i!==null&&i.memoizedState.isDehydrated)try{Ho(t.containerInfo)}catch(g){st(e,e.return,g)}break;case 4:Gn(t,e),qn(e);break;case 13:Gn(t,e),qn(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(wp=lt())),a&4&&Oh(e);break;case 22:if(f=i!==null&&i.memoizedState!==null,e.mode&1?(At=(d=At)||f,Gn(t,e),At=d):Gn(t,e),qn(e),a&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(de=e,f=e.child;f!==null;){for(u=de=f;de!==null;){switch(p=de,m=p.child,p.tag){case 0:case 11:case 14:case 15:ho(4,p,p.return);break;case 1:fs(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount=="function"){a=p,i=p.return;try{t=a,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(g){st(a,i,g)}}break;case 5:fs(p,p.return);break;case 22:if(p.memoizedState!==null){Lh(u);continue}}m!==null?(m.return=p,de=m):Lh(u)}f=f.sibling}e:for(f=null,u=e;;){if(u.tag===5){if(f===null){f=u;try{s=u.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(r=u.stateNode,c=u.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,r.style.display=jb("display",l))}catch(g){st(e,e.return,g)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=d?"":u.memoizedProps}catch(g){st(e,e.return,g)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===e)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===e)break e;for(;u.sibling===null;){if(u.return===null||u.return===e)break e;f===u&&(f=null),u=u.return}f===u&&(f=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Gn(t,e),qn(e),a&4&&Oh(e);break;case 21:break;default:Gn(t,e),qn(e)}}function qn(e){var t=e.flags;if(t&2){try{e:{for(var i=e.return;i!==null;){if(Vy(i)){var a=i;break e}i=i.return}throw Error(te(160))}switch(a.tag){case 5:var s=a.stateNode;a.flags&32&&(Po(s,""),a.flags&=-33);var o=Hh(e);Fm(e,o,s);break;case 3:case 4:var l=a.stateNode.containerInfo,r=Hh(e);Tm(e,r,l);break;default:throw Error(te(161))}}catch(c){st(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function rj(e,t,i){de=e,Zy(e)}function Zy(e,t,i){for(var a=(e.mode&1)!==0;de!==null;){var s=de,o=s.child;if(s.tag===22&&a){var l=s.memoizedState!==null||Rl;if(!l){var r=s.alternate,c=r!==null&&r.memoizedState!==null||At;r=Rl;var d=At;if(Rl=l,(At=c)&&!d)for(de=s;de!==null;)l=de,c=l.child,l.tag===22&&l.memoizedState!==null?Th(s):c!==null?(c.return=l,de=c):Th(s);for(;o!==null;)de=o,Zy(o),o=o.sibling;de=s,Rl=r,At=d}$h(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,de=o):$h(e)}}function $h(e){for(;de!==null;){var t=de;if(t.flags&8772){var i=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:At||yc(5,t);break;case 1:var a=t.stateNode;if(t.flags&4&&!At)if(i===null)a.componentDidMount();else{var s=t.elementType===t.type?i.memoizedProps:An(t.type,i.memoizedProps);a.componentDidUpdate(s,i.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Nh(t,o,a);break;case 3:var l=t.updateQueue;if(l!==null){if(i=null,t.child!==null)switch(t.child.tag){case 5:i=t.child.stateNode;break;case 1:i=t.child.stateNode}Nh(t,l,i)}break;case 5:var r=t.stateNode;if(i===null&&t.flags&4){i=r;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&i.focus();break;case"img":c.src&&(i.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var u=f.dehydrated;u!==null&&Ho(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(te(163))}At||t.flags&512&&Lm(t)}catch(p){st(t,t.return,p)}}if(t===e){de=null;break}if(i=t.sibling,i!==null){i.return=t.return,de=i;break}de=t.return}}function Lh(e){for(;de!==null;){var t=de;if(t===e){de=null;break}var i=t.sibling;if(i!==null){i.return=t.return,de=i;break}de=t.return}}function Th(e){for(;de!==null;){var t=de;try{switch(t.tag){case 0:case 11:case 15:var i=t.return;try{yc(4,t)}catch(c){st(t,i,c)}break;case 1:var a=t.stateNode;if(typeof a.componentDidMount=="function"){var s=t.return;try{a.componentDidMount()}catch(c){st(t,s,c)}}var o=t.return;try{Lm(t)}catch(c){st(t,o,c)}break;case 5:var l=t.return;try{Lm(t)}catch(c){st(t,l,c)}}}catch(c){st(t,t.return,c)}if(t===e){de=null;break}var r=t.sibling;if(r!==null){r.return=t.return,de=r;break}de=t.return}}var cj=Math.ceil,Or=Bi.ReactCurrentDispatcher,jp=Bi.ReactCurrentOwner,Nn=Bi.ReactCurrentBatchConfig,Ie=0,xt=null,dt=null,Nt=0,ln=0,gs=ha(0),ht=0,Vo=null,$a=0,xc=0,Np=0,fo=null,Yt=null,wp=0,Ps=1/0,hi=null,$r=!1,Xm=null,na=null,Il=!1,Ui=null,Lr=0,go=0,Km=null,or=-1,lr=0;function Tt(){return Ie&6?lt():or!==-1?or:or=lt()}function ia(e){return e.mode&1?Ie&2&&Nt!==0?Nt&-Nt:U2.transition!==null?(lr===0&&(lr=Ib()),lr):(e=Le,e!==0||(e=window.event,e=e===void 0?16:Fb(e.type)),e):1}function Hn(e,t,i,a){if(50<go)throw go=0,Km=null,Error(te(185));al(e,i,a),(!(Ie&2)||e!==xt)&&(e===xt&&(!(Ie&2)&&(xc|=i),ht===4&&Ki(e,Nt)),nn(e,a),i===1&&Ie===0&&!(t.mode&1)&&(Ps=lt()+500,fc&&fa()))}function nn(e,t){var i=e.callbackNode;Uv(e,t);var a=Nr(e,e===xt?Nt:0);if(a===0)i!==null&&Y0(i),e.callbackNode=null,e.callbackPriority=0;else if(t=a&-a,e.callbackPriority!==t){if(i!=null&&Y0(i),t===1)e.tag===0?z2(Fh.bind(null,e)):ly(Fh.bind(null,e)),T2(function(){!(Ie&6)&&fa()}),i=null;else{switch(Bb(a)){case 1:i=Yu;break;case 4:i=Pb;break;case 16:i=jr;break;case 536870912:i=Rb;break;default:i=jr}i=s1(i,Qy.bind(null,e))}e.callbackPriority=t,e.callbackNode=i}}function Qy(e,t){if(or=-1,lr=0,Ie&6)throw Error(te(327));var i=e.callbackNode;if(Ns()&&e.callbackNode!==i)return null;var a=Nr(e,e===xt?Nt:0);if(a===0)return null;if(a&30||a&e.expiredLanes||t)t=Tr(e,a);else{t=a;var s=Ie;Ie|=2;var o=e1();(xt!==e||Nt!==t)&&(hi=null,Ps=lt()+500,Pa(e,t));do try{uj();break}catch(r){Jy(e,r)}while(!0);cp(),Or.current=o,Ie=s,dt!==null?t=0:(xt=null,Nt=0,t=ht)}if(t!==0){if(t===2&&(s=bm(e),s!==0&&(a=s,t=zm(e,s))),t===1)throw i=Vo,Pa(e,0),Ki(e,a),nn(e,lt()),i;if(t===6)Ki(e,a);else{if(s=e.current.alternate,!(a&30)&&!dj(s)&&(t=Tr(e,a),t===2&&(o=bm(e),o!==0&&(a=o,t=zm(e,o))),t===1))throw i=Vo,Pa(e,0),Ki(e,a),nn(e,lt()),i;switch(e.finishedWork=s,e.finishedLanes=a,t){case 0:case 1:throw Error(te(345));case 2:Na(e,Yt,hi);break;case 3:if(Ki(e,a),(a&130023424)===a&&(t=wp+500-lt(),10<t)){if(Nr(e,0)!==0)break;if(s=e.suspendedLanes,(s&a)!==a){Tt(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Cm(Na.bind(null,e,Yt,hi),t);break}Na(e,Yt,hi);break;case 4:if(Ki(e,a),(a&4194240)===a)break;for(t=e.eventTimes,s=-1;0<a;){var l=31-Bn(a);o=1<<l,l=t[l],l>s&&(s=l),a&=~o}if(a=s,a=lt()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*cj(a/1960))-a,10<a){e.timeoutHandle=Cm(Na.bind(null,e,Yt,hi),a);break}Na(e,Yt,hi);break;case 5:Na(e,Yt,hi);break;default:throw Error(te(329))}}}return nn(e,lt()),e.callbackNode===i?Qy.bind(null,e):null}function zm(e,t){var i=fo;return e.current.memoizedState.isDehydrated&&(Pa(e,t).flags|=256),e=Tr(e,t),e!==2&&(t=Yt,Yt=i,t!==null&&Um(t)),e}function Um(e){Yt===null?Yt=e:Yt.push.apply(Yt,e)}function dj(e){for(var t=e;;){if(t.flags&16384){var i=t.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var a=0;a<i.length;a++){var s=i[a],o=s.getSnapshot;s=s.value;try{if(!Tn(o(),s))return!1}catch{return!1}}}if(i=t.child,t.subtreeFlags&16384&&i!==null)i.return=t,t=i;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 Ki(e,t){for(t&=~Np,t&=~xc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var i=31-Bn(t),a=1<<i;e[i]=-1,t&=~a}}function Fh(e){if(Ie&6)throw Error(te(327));Ns();var t=Nr(e,0);if(!(t&1))return nn(e,lt()),null;var i=Tr(e,t);if(e.tag!==0&&i===2){var a=bm(e);a!==0&&(t=a,i=zm(e,a))}if(i===1)throw i=Vo,Pa(e,0),Ki(e,t),nn(e,lt()),i;if(i===6)throw Error(te(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Na(e,Yt,hi),nn(e,lt()),null}function Cp(e,t){var i=Ie;Ie|=1;try{return e(t)}finally{Ie=i,Ie===0&&(Ps=lt()+500,fc&&fa())}}function La(e){Ui!==null&&Ui.tag===0&&!(Ie&6)&&Ns();var t=Ie;Ie|=1;var i=Nn.transition,a=Le;try{if(Nn.transition=null,Le=1,e)return e()}finally{Le=a,Nn.transition=i,Ie=t,!(Ie&6)&&fa()}}function kp(){ln=gs.current,Ye(gs)}function Pa(e,t){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,L2(i)),dt!==null)for(i=dt.return;i!==null;){var a=i;switch(op(a),a.tag){case 1:a=a.type.childContextTypes,a!=null&&Er();break;case 3:As(),Ye(en),Ye(Pt),fp();break;case 5:hp(a);break;case 4:As();break;case 13:Ye(et);break;case 19:Ye(et);break;case 10:dp(a.type._context);break;case 22:case 23:kp()}i=i.return}if(xt=e,dt=e=aa(e.current,null),Nt=ln=t,ht=0,Vo=null,Np=xc=$a=0,Yt=fo=null,Ma!==null){for(t=0;t<Ma.length;t++)if(i=Ma[t],a=i.interleaved,a!==null){i.interleaved=null;var s=a.next,o=i.pending;if(o!==null){var l=o.next;o.next=s,a.next=l}i.pending=a}Ma=null}return e}function Jy(e,t){do{var i=dt;try{if(cp(),ir.current=Hr,Br){for(var a=nt.memoizedState;a!==null;){var s=a.queue;s!==null&&(s.pending=null),a=a.next}Br=!1}if(Oa=0,gt=pt=nt=null,po=!1,zo=0,jp.current=null,i===null||i.return===null){ht=1,Vo=t,dt=null;break}e:{var o=e,l=i.return,r=i,c=t;if(t=Nt,r.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=r,u=f.tag;if(!(f.mode&1)&&(u===0||u===11||u===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var m=Gh(l);if(m!==null){m.flags&=-257,Sh(m,l,r,o,t),m.mode&1&&Eh(o,d,t),t=m,c=d;var h=t.updateQueue;if(h===null){var g=new Set;g.add(c),t.updateQueue=g}else h.add(c);break e}else{if(!(t&1)){Eh(o,d,t),Mp();break e}c=Error(te(426))}}else if(Qe&&r.mode&1){var y=Gh(l);if(y!==null){!(y.flags&65536)&&(y.flags|=256),Sh(y,l,r,o,t),lp(Ds(c,r));break e}}o=c=Ds(c,r),ht!==4&&(ht=2),fo===null?fo=[o]:fo.push(o),o=l;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var b=By(o,c,t);jh(o,b);break e;case 1:r=c;var _=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof _.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(na===null||!na.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var v=Hy(o,r,t);jh(o,v);break e}}o=o.return}while(o!==null)}n1(i)}catch(j){t=j,dt===i&&i!==null&&(dt=i=i.return);continue}break}while(!0)}function e1(){var e=Or.current;return Or.current=Hr,e===null?Hr:e}function Mp(){(ht===0||ht===3||ht===2)&&(ht=4),xt===null||!($a&268435455)&&!(xc&268435455)||Ki(xt,Nt)}function Tr(e,t){var i=Ie;Ie|=2;var a=e1();(xt!==e||Nt!==t)&&(hi=null,Pa(e,t));do try{mj();break}catch(s){Jy(e,s)}while(!0);if(cp(),Ie=i,Or.current=a,dt!==null)throw Error(te(261));return xt=null,Nt=0,ht}function mj(){for(;dt!==null;)t1(dt)}function uj(){for(;dt!==null&&!Hv();)t1(dt)}function t1(e){var t=a1(e.alternate,e,ln);e.memoizedProps=e.pendingProps,t===null?n1(e):dt=t,jp.current=null}function n1(e){var t=e;do{var i=t.alternate;if(e=t.return,t.flags&32768){if(i=sj(i,t),i!==null){i.flags&=32767,dt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ht=6,dt=null;return}}else if(i=aj(i,t,ln),i!==null){dt=i;return}if(t=t.sibling,t!==null){dt=t;return}dt=t=e}while(t!==null);ht===0&&(ht=5)}function Na(e,t,i){var a=Le,s=Nn.transition;try{Nn.transition=null,Le=1,pj(e,t,i,a)}finally{Nn.transition=s,Le=a}return null}function pj(e,t,i,a){do Ns();while(Ui!==null);if(Ie&6)throw Error(te(327));i=e.finishedWork;var s=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(te(177));e.callbackNode=null,e.callbackPriority=0;var o=i.lanes|i.childLanes;if(qv(e,o),e===xt&&(dt=xt=null,Nt=0),!(i.subtreeFlags&2064)&&!(i.flags&2064)||Il||(Il=!0,s1(jr,function(){return Ns(),null})),o=(i.flags&15990)!==0,i.subtreeFlags&15990||o){o=Nn.transition,Nn.transition=null;var l=Le;Le=1;var r=Ie;Ie|=4,jp.current=null,lj(e,i),Yy(i,e),P2(Nm),wr=!!jm,Nm=jm=null,e.current=i,rj(i),Ov(),Ie=r,Le=l,Nn.transition=o}else e.current=i;if(Il&&(Il=!1,Ui=e,Lr=s),o=e.pendingLanes,o===0&&(na=null),Tv(i.stateNode),nn(e,lt()),t!==null)for(a=e.onRecoverableError,i=0;i<t.length;i++)s=t[i],a(s.value,{componentStack:s.stack,digest:s.digest});if($r)throw $r=!1,e=Xm,Xm=null,e;return Lr&1&&e.tag!==0&&Ns(),o=e.pendingLanes,o&1?e===Km?go++:(go=0,Km=e):go=0,fa(),null}function Ns(){if(Ui!==null){var e=Bb(Lr),t=Nn.transition,i=Le;try{if(Nn.transition=null,Le=16>e?16:e,Ui===null)var a=!1;else{if(e=Ui,Ui=null,Lr=0,Ie&6)throw Error(te(331));var s=Ie;for(Ie|=4,de=e.current;de!==null;){var o=de,l=o.child;if(de.flags&16){var r=o.deletions;if(r!==null){for(var c=0;c<r.length;c++){var d=r[c];for(de=d;de!==null;){var f=de;switch(f.tag){case 0:case 11:case 15:ho(8,f,o)}var u=f.child;if(u!==null)u.return=f,de=u;else for(;de!==null;){f=de;var p=f.sibling,m=f.return;if(qy(f),f===d){de=null;break}if(p!==null){p.return=m,de=p;break}de=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(g!==null)}}de=o}}if(o.subtreeFlags&2064&&l!==null)l.return=o,de=l;else e:for(;de!==null;){if(o=de,o.flags&2048)switch(o.tag){case 0:case 11:case 15:ho(9,o,o.return)}var b=o.sibling;if(b!==null){b.return=o.return,de=b;break e}de=o.return}}var _=e.current;for(de=_;de!==null;){l=de;var x=l.child;if(l.subtreeFlags&2064&&x!==null)x.return=l,de=x;else e:for(l=_;de!==null;){if(r=de,r.flags&2048)try{switch(r.tag){case 0:case 11:case 15:yc(9,r)}}catch(j){st(r,r.return,j)}if(r===l){de=null;break e}var v=r.sibling;if(v!==null){v.return=r.return,de=v;break e}de=r.return}}if(Ie=s,fa(),ni&&typeof ni.onPostCommitFiberRoot=="function")try{ni.onPostCommitFiberRoot(dc,e)}catch{}a=!0}return a}finally{Le=i,Nn.transition=t}}return!1}function Xh(e,t,i){t=Ds(i,t),t=By(e,t,1),e=ta(e,t,1),t=Tt(),e!==null&&(al(e,1,t),nn(e,t))}function st(e,t,i){if(e.tag===3)Xh(e,e,i);else for(;t!==null;){if(t.tag===3){Xh(t,e,i);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(na===null||!na.has(a))){e=Ds(i,e),e=Hy(t,e,1),t=ta(t,e,1),e=Tt(),t!==null&&(al(t,1,e),nn(t,e));break}}t=t.return}}function hj(e,t,i){var a=e.pingCache;a!==null&&a.delete(t),t=Tt(),e.pingedLanes|=e.suspendedLanes&i,xt===e&&(Nt&i)===i&&(ht===4||ht===3&&(Nt&130023424)===Nt&&500>lt()-wp?Pa(e,0):Np|=i),nn(e,t)}function i1(e,t){t===0&&(e.mode&1?(t=Cl,Cl<<=1,!(Cl&130023424)&&(Cl=4194304)):t=1);var i=Tt();e=Si(e,t),e!==null&&(al(e,t,i),nn(e,i))}function fj(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),i1(e,i)}function gj(e,t){var i=0;switch(e.tag){case 13:var a=e.stateNode,s=e.memoizedState;s!==null&&(i=s.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(te(314))}a!==null&&a.delete(t),i1(e,i)}var a1;a1=function(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps||en.current)Jt=!0;else{if(!(e.lanes&i)&&!(t.flags&128))return Jt=!1,ij(e,t,i);Jt=!!(e.flags&131072)}else Jt=!1,Qe&&t.flags&1048576&&ry(t,Ar,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;sr(e,t),e=t.pendingProps;var s=Es(t,Pt.current);js(t,i),s=bp(null,t,a,e,s,i);var o=yp();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,tn(a)?(o=!0,Gr(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,up(t),s.updater=bc,t.stateNode=s,s._reactInternals=t,Dm(t,a,e,i),t=Im(null,t,a,!0,o,i)):(t.tag=0,Qe&&o&&sp(t),Ht(null,t,s,i),t=t.child),t;case 16:a=t.elementType;e:{switch(sr(e,t),e=t.pendingProps,s=a._init,a=s(a._payload),t.type=a,s=t.tag=yj(a),e=An(a,e),s){case 0:t=Rm(null,t,a,e,i);break e;case 1:t=Ph(null,t,a,e,i);break e;case 11:t=Ah(null,t,a,e,i);break e;case 14:t=Dh(null,t,a,An(a.type,e),i);break e}throw Error(te(306,a,""))}return t;case 0:return a=t.type,s=t.pendingProps,s=t.elementType===a?s:An(a,s),Rm(e,t,a,s,i);case 1:return a=t.type,s=t.pendingProps,s=t.elementType===a?s:An(a,s),Ph(e,t,a,s,i);case 3:e:{if(Ty(t),e===null)throw Error(te(387));a=t.pendingProps,o=t.memoizedState,s=o.element,hy(e,t),Rr(t,a,null,i);var l=t.memoizedState;if(a=l.element,o.isDehydrated)if(o={element:a,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=Ds(Error(te(423)),t),t=Rh(e,t,a,i,s);break e}else if(a!==s){s=Ds(Error(te(424)),t),t=Rh(e,t,a,i,s);break e}else for(cn=ea(t.stateNode.containerInfo.firstChild),un=t,Qe=!0,Pn=null,i=uy(t,null,a,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Gs(),a===s){t=Ai(e,t,i);break e}Ht(e,t,a,i)}t=t.child}return t;case 5:return fy(t),e===null&&Gm(t),a=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,l=s.children,wm(a,s)?l=null:o!==null&&wm(a,o)&&(t.flags|=32),Ly(e,t),Ht(e,t,l,i),t.child;case 6:return e===null&&Gm(t),null;case 13:return Fy(e,t,i);case 4:return pp(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=Ss(t,null,a,i):Ht(e,t,a,i),t.child;case 11:return a=t.type,s=t.pendingProps,s=t.elementType===a?s:An(a,s),Ah(e,t,a,s,i);case 7:return Ht(e,t,t.pendingProps,i),t.child;case 8:return Ht(e,t,t.pendingProps.children,i),t.child;case 12:return Ht(e,t,t.pendingProps.children,i),t.child;case 10:e:{if(a=t.type._context,s=t.pendingProps,o=t.memoizedProps,l=s.value,Ue(Dr,a._currentValue),a._currentValue=l,o!==null)if(Tn(o.value,l)){if(o.children===s.children&&!en.current){t=Ai(e,t,i);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var r=o.dependencies;if(r!==null){l=o.child;for(var c=r.firstContext;c!==null;){if(c.context===a){if(o.tag===1){c=Ni(-1,i&-i),c.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}o.lanes|=i,c=o.alternate,c!==null&&(c.lanes|=i),Sm(o.return,i,t),r.lanes|=i;break}c=c.next}}else if(o.tag===10)l=o.type===t.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(te(341));l.lanes|=i,r=l.alternate,r!==null&&(r.lanes|=i),Sm(l,i,t),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===t){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}Ht(e,t,s.children,i),t=t.child}return t;case 9:return s=t.type,a=t.pendingProps.children,js(t,i),s=Cn(s),a=a(s),t.flags|=1,Ht(e,t,a,i),t.child;case 14:return a=t.type,s=An(a,t.pendingProps),s=An(a.type,s),Dh(e,t,a,s,i);case 15:return Oy(e,t,t.type,t.pendingProps,i);case 17:return a=t.type,s=t.pendingProps,s=t.elementType===a?s:An(a,s),sr(e,t),t.tag=1,tn(a)?(e=!0,Gr(t)):e=!1,js(t,i),Iy(t,a,s),Dm(t,a,s,i),Im(null,t,a,!0,e,i);case 19:return Xy(e,t,i);case 22:return $y(e,t,i)}throw Error(te(156,t.tag))};function s1(e,t){return Db(e,t)}function bj(e,t,i,a){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(e,t,i,a){return new bj(e,t,i,a)}function Ep(e){return e=e.prototype,!(!e||!e.isReactComponent)}function yj(e){if(typeof e=="function")return Ep(e)?1:0;if(e!=null){if(e=e.$$typeof,e===qu)return 11;if(e===Vu)return 14}return 2}function aa(e,t){var i=e.alternate;return i===null?(i=_n(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function rr(e,t,i,a,s,o){var l=2;if(a=e,typeof e=="function")Ep(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case os:return Ra(i.children,s,o,t);case Uu:l=8,s|=8;break;case nm:return e=_n(12,i,t,s|2),e.elementType=nm,e.lanes=o,e;case im:return e=_n(13,i,t,s),e.elementType=im,e.lanes=o,e;case am:return e=_n(19,i,t,s),e.elementType=am,e.lanes=o,e;case fb:return _c(i,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pb:l=10;break e;case hb:l=9;break e;case qu:l=11;break e;case Vu:l=14;break e;case Ti:l=16,a=null;break e}throw Error(te(130,e==null?e:typeof e,""))}return t=_n(l,i,t,s),t.elementType=e,t.type=a,t.lanes=o,t}function Ra(e,t,i,a){return e=_n(7,e,a,t),e.lanes=i,e}function _c(e,t,i,a){return e=_n(22,e,a,t),e.elementType=fb,e.lanes=i,e.stateNode={isHidden:!1},e}function jd(e,t,i){return e=_n(6,e,null,t),e.lanes=i,e}function Nd(e,t,i){return t=_n(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function xj(e,t,i,a,s){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=id(0),this.expirationTimes=id(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=id(0),this.identifierPrefix=a,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Gp(e,t,i,a,s,o,l,r,c){return e=new xj(e,t,i,r,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=_n(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:a,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},up(o),e}function _j(e,t,i){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ss,key:a==null?null:""+a,children:e,containerInfo:t,implementation:i}}function o1(e){if(!e)return ua;e=e._reactInternals;e:{if(Wa(e)!==e||e.tag!==1)throw Error(te(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(tn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(te(171))}if(e.tag===1){var i=e.type;if(tn(i))return oy(e,i,t)}return t}function l1(e,t,i,a,s,o,l,r,c){return e=Gp(i,a,!0,e,s,o,l,r,c),e.context=o1(null),i=e.current,a=Tt(),s=ia(i),o=Ni(a,s),o.callback=t??null,ta(i,o,s),e.current.lanes=s,al(e,s,a),nn(e,a),e}function vc(e,t,i,a){var s=t.current,o=Tt(),l=ia(s);return i=o1(i),t.context===null?t.context=i:t.pendingContext=i,t=Ni(o,l),t.payload={element:e},a=a===void 0?null:a,a!==null&&(t.callback=a),e=ta(s,t,l),e!==null&&(Hn(e,s,l,o),nr(e,s,l)),l}function Fr(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 Kh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<t?i:t}}function Sp(e,t){Kh(e,t),(e=e.alternate)&&Kh(e,t)}function vj(){return null}var r1=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ap(e){this._internalRoot=e}jc.prototype.render=Ap.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(te(409));vc(e,t,null,null)};jc.prototype.unmount=Ap.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;La(function(){vc(null,e,null,null)}),t[Gi]=null}};function jc(e){this._internalRoot=e}jc.prototype.unstable_scheduleHydration=function(e){if(e){var t=$b();e={blockedOn:null,target:e,priority:t};for(var i=0;i<Xi.length&&t!==0&&t<Xi[i].priority;i++);Xi.splice(i,0,e),i===0&&Tb(e)}};function Dp(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Nc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function zh(){}function jj(e,t,i,a,s){if(s){if(typeof a=="function"){var o=a;a=function(){var d=Fr(l);o.call(d)}}var l=l1(t,a,e,0,null,!1,!1,"",zh);return e._reactRootContainer=l,e[Gi]=l.current,Lo(e.nodeType===8?e.parentNode:e),La(),l}for(;s=e.lastChild;)e.removeChild(s);if(typeof a=="function"){var r=a;a=function(){var d=Fr(c);r.call(d)}}var c=Gp(e,0,!1,null,null,!1,!1,"",zh);return e._reactRootContainer=c,e[Gi]=c.current,Lo(e.nodeType===8?e.parentNode:e),La(function(){vc(t,c,i,a)}),c}function wc(e,t,i,a,s){var o=i._reactRootContainer;if(o){var l=o;if(typeof s=="function"){var r=s;s=function(){var c=Fr(l);r.call(c)}}vc(t,l,e,s)}else l=jj(i,t,e,s,a);return Fr(l)}Hb=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var i=io(t.pendingLanes);i!==0&&(Zu(t,i|1),nn(t,lt()),!(Ie&6)&&(Ps=lt()+500,fa()))}break;case 13:La(function(){var a=Si(e,1);if(a!==null){var s=Tt();Hn(a,e,1,s)}}),Sp(e,1)}};Qu=function(e){if(e.tag===13){var t=Si(e,134217728);if(t!==null){var i=Tt();Hn(t,e,134217728,i)}Sp(e,134217728)}};Ob=function(e){if(e.tag===13){var t=ia(e),i=Si(e,t);if(i!==null){var a=Tt();Hn(i,e,t,a)}Sp(e,t)}};$b=function(){return Le};Lb=function(e,t){var i=Le;try{return Le=e,t()}finally{Le=i}};hm=function(e,t,i){switch(t){case"input":if(lm(e,i),t=i.name,i.type==="radio"&&t!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<i.length;t++){var a=i[t];if(a!==e&&a.form===e.form){var s=hc(a);if(!s)throw Error(te(90));bb(a),lm(a,s)}}}break;case"textarea":xb(e,i);break;case"select":t=i.value,t!=null&&ys(e,!!i.multiple,t,!1)}};kb=Cp;Mb=La;var Nj={usingClientEntryPoint:!1,Events:[ol,ds,hc,wb,Cb,Cp]},Qs={findFiberByHostInstance:ka,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},wj={bundleType:Qs.bundleType,version:Qs.version,rendererPackageName:Qs.rendererPackageName,rendererConfig:Qs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Bi.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Sb(e),e===null?null:e.stateNode},findFiberByHostInstance:Qs.findFiberByHostInstance||vj,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 Bl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bl.isDisabled&&Bl.supportsFiber)try{dc=Bl.inject(wj),ni=Bl}catch{}}fn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nj;fn.createPortal=function(e,t){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dp(t))throw Error(te(200));return _j(e,t,null,i)};fn.createRoot=function(e,t){if(!Dp(e))throw Error(te(299));var i=!1,a="",s=r1;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Gp(e,1,!1,null,null,i,!1,a,s),e[Gi]=t.current,Lo(e.nodeType===8?e.parentNode:e),new Ap(t)};fn.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(te(188)):(e=Object.keys(e).join(","),Error(te(268,e)));return e=Sb(t),e=e===null?null:e.stateNode,e};fn.flushSync=function(e){return La(e)};fn.hydrate=function(e,t,i){if(!Nc(t))throw Error(te(200));return wc(null,e,t,!0,i)};fn.hydrateRoot=function(e,t,i){if(!Dp(e))throw Error(te(405));var a=i!=null&&i.hydratedSources||null,s=!1,o="",l=r1;if(i!=null&&(i.unstable_strictMode===!0&&(s=!0),i.identifierPrefix!==void 0&&(o=i.identifierPrefix),i.onRecoverableError!==void 0&&(l=i.onRecoverableError)),t=l1(t,null,e,1,i??null,s,!1,o,l),e[Gi]=t.current,Lo(e),a)for(e=0;e<a.length;e++)i=a[e],s=i._getVersion,s=s(i._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[i,s]:t.mutableSourceEagerHydrationData.push(i,s);return new jc(t)};fn.render=function(e,t,i){if(!Nc(t))throw Error(te(200));return wc(null,e,t,!1,i)};fn.unmountComponentAtNode=function(e){if(!Nc(e))throw Error(te(40));return e._reactRootContainer?(La(function(){wc(null,null,e,!1,function(){e._reactRootContainer=null,e[Gi]=null})}),!0):!1};fn.unstable_batchedUpdates=Cp;fn.unstable_renderSubtreeIntoContainer=function(e,t,i,a){if(!Nc(i))throw Error(te(200));if(e==null||e._reactInternals===void 0)throw Error(te(38));return wc(e,t,i,!1,a)};fn.version="18.3.1-next-f1338f8080-20240426";function c1(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(c1)}catch(e){console.error(e)}}c1(),cb.exports=fn;var Pp=cb.exports,Rp,Uh=Pp;Rp=Uh.createRoot,Uh.hydrateRoot;const Cj="gemsmap",wd="kv";function Ip(e,t){return Fu.then(()=>new Promise(i=>{try{if(typeof indexedDB>"u")return i(void 0);const a=indexedDB.open(Cj,1);a.onupgradeneeded=()=>a.result.createObjectStore(wd),a.onerror=()=>i(void 0),a.onsuccess=()=>{try{const s=t(a.result.transaction(wd,e).objectStore(wd));s.onsuccess=()=>i(s.result),s.onerror=()=>i(void 0)}catch{i(void 0)}}}catch{i(void 0)}}))}const Cc=e=>Ip("readonly",t=>t.get(e)),Xr=(e,t)=>Ip("readwrite",i=>i.put(t,e)),Bp=e=>Ip("readwrite",t=>t.delete(e)),Hp="gemsmap",Wo=".gemsmap",kj="metmap",qm=".metmap",Op=e=>e===Hp||e===kj,d1=e=>e.includes('"format"')&&/"(gemsmap|metmap)"/.test(e);let cr=null;const m1=e=>{cr=e},ke=e=>(cr==null?void 0:cr(e))??`${e}_${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`,$p=()=>({nodes:{},reactions:{},plots:{},texts:{},groups:{},legend:{x:420,y:40,visible:!0,auto:!0}});function Kr(e){if(!e.legend.auto)return{x:e.legend.x,y:e.legend.y};const t=Object.values(e.nodes);return t.length?{x:Math.max(...t.map(i=>i.x))+150,y:Math.min(...t.map(i=>i.y))}:{x:e.legend.x,y:e.legend.y}}const u1=()=>({preset:"nature",metaboliteLabel:"id",reactionLabel:"id",showFluxValues:!1,currency:"hide",nodeRadius:7,baseEdgeWidth:1.4,fontSize:10}),Mj=()=>({showGrid:!0,snap:!0,gridSize:10,smartGuides:!0}),Ej=()=>({playing:!1,loop:"loop",stepSeconds:1.2,particles:!1});function Yo(){return{format:Hp,version:1,name:"Untitled figure",model:null,datasets:[],conditions:[],doc:$p(),mappings:[],view:{activeCondition:"",compare:"absolute",reference:""},savedViews:[],style:u1(),canvas:Mj(),animation:Ej()}}function wa(e,t){const i=[],a=[],s=t?t.map(r=>e.nodes[r]).filter(Boolean):Object.values(e.nodes);for(const r of s)i.push(r.x-20,r.x+50),a.push(r.y-16,r.y+16);if(!t){for(const r of Object.values(e.texts))i.push(r.x,r.x+r.text.length*r.size*.55),a.push(r.y-r.size,r.y+4);for(const r of Object.values(e.plots)){const c=Ta(e,r.anchor);c&&(i.push(c.x+r.dx,c.x+r.dx+r.w),a.push(c.y+r.dy,c.y+r.dy+r.h))}}if(!i.length)return null;const o=Math.min(...i),l=Math.min(...a);return{x:o,y:l,w:Math.max(...i)-o,h:Math.max(...a)-l}}function Ta(e,t){if(t.kind==="node"){const c=e.nodes[t.id];return c?{x:c.x,y:c.y}:null}const i=e.reactions[t.id];if(!i)return null;const a=[...i.sources,...i.targets].map(c=>e.nodes[c]).filter(Boolean);if(!a.length)return null;const s=i.sources.map(c=>e.nodes[c]).filter(Boolean),o=i.targets.map(c=>e.nodes[c]).filter(Boolean);if(!s.length||!o.length)return{x:a[0].x,y:a[0].y};const l={x:s.reduce((c,d)=>c+d.x,0)/s.length,y:s.reduce((c,d)=>c+d.y,0)/s.length},r={x:o.reduce((c,d)=>c+d.x,0)/o.length,y:o.reduce((c,d)=>c+d.y,0)/o.length};return{x:(l.x+r.x)/2,y:(l.y+r.y)/2}}const Gj={},qh=e=>{let t;const i=new Set,a=(f,u)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const m=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),i.forEach(h=>h(t,m))}},s=()=>t,c={setState:a,getState:s,getInitialState:()=>d,subscribe:f=>(i.add(f),()=>i.delete(f)),destroy:()=>{(Gj?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},d=t=e(a,s,c);return c},Sj=e=>e?qh(e):qh;var p1={exports:{}},h1={},f1={exports:{}},g1={};/**
|
|
41
|
+
* @license React
|
|
42
|
+
* use-sync-external-store-shim.production.js
|
|
43
|
+
*
|
|
44
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
45
|
+
*
|
|
46
|
+
* This source code is licensed under the MIT license found in the
|
|
47
|
+
* LICENSE file in the root directory of this source tree.
|
|
48
|
+
*/var Rs=E;function Aj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dj=typeof Object.is=="function"?Object.is:Aj,Pj=Rs.useState,Rj=Rs.useEffect,Ij=Rs.useLayoutEffect,Bj=Rs.useDebugValue;function Hj(e,t){var i=t(),a=Pj({inst:{value:i,getSnapshot:t}}),s=a[0].inst,o=a[1];return Ij(function(){s.value=i,s.getSnapshot=t,Cd(s)&&o({inst:s})},[e,i,t]),Rj(function(){return Cd(s)&&o({inst:s}),e(function(){Cd(s)&&o({inst:s})})},[e]),Bj(i),i}function Cd(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!Dj(e,i)}catch{return!0}}function Oj(e,t){return t()}var $j=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Oj:Hj;g1.useSyncExternalStore=Rs.useSyncExternalStore!==void 0?Rs.useSyncExternalStore:$j;f1.exports=g1;var Lj=f1.exports;/**
|
|
49
|
+
* @license React
|
|
50
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
51
|
+
*
|
|
52
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the MIT license found in the
|
|
55
|
+
* LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/var kc=E,Tj=Lj;function Fj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xj=typeof Object.is=="function"?Object.is:Fj,Kj=Tj.useSyncExternalStore,zj=kc.useRef,Uj=kc.useEffect,qj=kc.useMemo,Vj=kc.useDebugValue;h1.useSyncExternalStoreWithSelector=function(e,t,i,a,s){var o=zj(null);if(o.current===null){var l={hasValue:!1,value:null};o.current=l}else l=o.current;o=qj(function(){function c(m){if(!d){if(d=!0,f=m,m=a(m),s!==void 0&&l.hasValue){var h=l.value;if(s(h,m))return u=h}return u=m}if(h=u,Xj(f,m))return h;var g=a(m);return s!==void 0&&s(h,g)?(f=m,h):(f=m,u=g)}var d=!1,f,u,p=i===void 0?null:i;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,i,a,s]);var r=Kj(e,o[0],o[1]);return Uj(function(){l.hasValue=!0,l.value=r},[r]),Vj(r),r};p1.exports=h1;var Wj=p1.exports;const Yj=Zg(Wj),b1={},{useDebugValue:Zj}=dv,{useSyncExternalStoreWithSelector:Qj}=Yj;let Vh=!1;const Jj=e=>e;function eN(e,t=Jj,i){(b1?"production":void 0)!=="production"&&i&&!Vh&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Vh=!0);const a=Qj(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,i);return Zj(a),a}const Wh=e=>{(b1?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Sj(e):e,i=(a,s)=>eN(t,a,s);return Object.assign(i,t),i},Ts=e=>e?Wh(e):Wh,tN=/^(.+?)(_REV)?_EXP_\d+$/,nN=/^(.+?)_REV$/;function Mc(e){const t=tN.exec(e);if(t)return{id:t[1],sign:t[2]?-1:1};const i=nN.exec(e);return i?{id:i[1],sign:-1}:null}const Yh=new WeakMap;function iN(e){let t=Yh.get(e);if(t)return t;t=new Map;for(const i of Object.keys(e)){const a=Mc(i);if(!a)continue;let s=t.get(a.id);s||(s=e[a.id]!==void 0?[{id:a.id,sign:1}]:[],t.set(a.id,s)),s.push({id:i,sign:a.sign})}return Yh.set(e,t),t}function Lp(e,t){return e?iN(e).get(t)??(e[t]!==void 0?[{id:t,sign:1}]:[]):[]}function Ec(e,t,i){var o;let a=0,s=!1;for(const l of Lp(e.values,t)){const r=(o=e.values[l.id])==null?void 0:o[i];r!=null&&(a+=l.sign*r,s=!0)}return s?a:null}function Vm(e,t,i){var l,r;const a=Lp(e.samples,t);if(a.length<=1)return a.length?((r=(l=e.samples)==null?void 0:l[a[0].id])==null?void 0:r[i])??[]:[];const s=a.map(c=>{var d;return{s:c.sign,a:((d=e.samples[c.id])==null?void 0:d[i])??[]}}).filter(c=>c.a.length);if(!s.length)return[];const o=Math.min(...s.map(c=>c.a.length));return Array.from({length:o},(c,d)=>s.reduce((f,u)=>f+u.s*u.a[d],0))}function Wm(e,t,i){var l;let a=0,s=0,o=!1;for(const r of Lp(e.ranges,t)){const c=(l=e.ranges[r.id])==null?void 0:l[i];c&&(o=!0,r.sign>0?(a+=c[0],s+=c[1]):(a-=c[1],s-=c[0]))}return o?[a,s]:null}const aN=new Set(["h","h2o","atp","adp","amp","gtp","gdp","utp","udp","ctp","cdp","itp","idp","nad","nadh","nadp","nadph","fad","fadh2","pi","ppi","co2","o2","nh4","coa","q8","q8h2","mqn8","mql8","hco3","h2o2","na1","k","fe2","fe3","so4","h2s","ficytc","focytc"]),sN=[/^h\+?$/i,/^proton$/i,/^water$/i,/^h2o$/i,/^atp$/i,/^adp$/i,/^amp$/i,/^nad\+?$/i,/^nadh$/i,/^nadp\+?$/i,/^nadph$/i,/^phosphate$/i,/^orthophosphate$/i,/^diphosphate$/i,/^co2$/i,/^carbon dioxide$/i,/^o2$/i,/^oxygen$/i,/^coenzyme a$/i,/^ammonium$/i,/^ubiquinone/i,/^ubiquinol/i];function bt(e){let t=e.replace(/^M_/,"").replace(/^R_/,"");return t=t.replace(/\[[a-z0-9]+\]$/i,""),t=t.replace(new RegExp("(?<!_)_[a-z][a-z0-9]?$"),""),t}const Zh=new WeakMap;function Fa(e,t){if(!e)return!1;{let i=Zh.get(e);return i===void 0&&(i=oN(e),Zh.set(e,i)),i}}function oN(e,t){if(/^(prot_|pmet_)/.test(e.id))return!0;const i=bt(e.id).toLowerCase();return aN.has(i)||t!=null&&t.has(i)?!0:sN.some(a=>a.test(e.name.trim()))}function ws(e,t){const i=[],a=[],s=[],o=[];for(const[l,r]of Object.entries(e.stoichiometry)){const c=Fa(t[l]);r<0?(c?s:i).push(l):r>0&&(c?o:a).push(l)}return{substrates:i.length?i:s,products:a.length?a:o,cofactorsIn:i.length?s:[],cofactorsOut:a.length?o:[]}}function zr(e,t,i=!1){const a=s=>Object.entries(e.stoichiometry).filter(([,o])=>o*s>0).map(([o,l])=>{var d;const r=Math.abs(l),c=i?((d=t[o])==null?void 0:d.name)??o:o;return(r!==1?`${+r.toFixed(3)} `:"")+c}).join(" + ");return`${a(-1)||"∅"} ${e.reversible?"⇌":"→"} ${a(1)||"∅"}`}function y1(e){const t=e.replace(/\r/g,"").split(`
|
|
57
|
+
`).filter(a=>a.trim()&&!a.startsWith("#"));if(!t.length)return[];const i=t[0].includes(" ")?" ":t[0].split(";").length>t[0].split(",").length?";":",";return t.map(a=>{const s=[];let o="",l=!1;for(let r=0;r<a.length;r++){const c=a[r];c==='"'?l&&a[r+1]==='"'?(o+='"',r++):l=!l:c===i&&!l?(s.push(o.trim()),o=""):o+=c}return s.push(o.trim()),s})}const xa=e=>{if(e==null||e===""||/^(na|nan|null|none|-)$/i.test(e))return null;const t=Number(e);return Number.isFinite(t)?t:null};function Ym(e,t){if(!e)return l=>l;const i=t==="reaction"?e.reactions:e.metabolites,a=new Map,s=new Map,o=new Map;for(const[l,r]of Object.entries(i)){a.set(l.toLowerCase(),l);const c=bt(l).toLowerCase();(!s.has(c)||/_c$/.test(l))&&s.set(c,l),o.set(r.name.toLowerCase(),l)}return l=>{if(i[l])return l;const r=l.replace(/^[RM]_/,"");if(i[r])return r;const c=Mc(r);if(c&&t==="reaction"&&(i[c.id]||a.has(c.id.toLowerCase())))return r;const d=r.toLowerCase();return a.get(d)??s.get(bt(r).toLowerCase())??o.get(d)??null}}function lN(e,t,i){const a=y1(e);if(a.length<2)throw new Error("The file needs a header row and at least one data row.");const[s,...o]=a,l=s[0].toLowerCase();let r=/met|compound|species/.test(l)?"metabolite":"reaction";if(t&&!/met|compound|species|rxn|reaction/.test(l)){const p=Ym(t,"reaction"),m=Ym(t,"metabolite"),h=o.slice(0,200),g=h.filter(b=>p(b[0])!=null).length;r=h.filter(b=>m(b[0])!=null).length>g?"metabolite":"reaction"}if(s.length===3&&o.length>0&&xa(o[0][1])==null&&xa(o[0][2])!=null||i==="samples"){const p=[],m=new Map;for(const h of o){const g=xa(h[2]);if(g==null)continue;let y=p.indexOf(h[1]);y<0&&(p.push(h[1]),y=p.length-1),m.has(h[0])||m.set(h[0],[]);const b=m.get(h[0]);for(;b.length<=y;)b.push([]);b[y].push(g)}return{kind:"samples",target:r,columns:p,rows:[...m].map(([h,g])=>{for(;g.length<p.length;)g.push([]);return{raw:h,samples:g,values:g.map(y=>y.length?y.reduce((b,_)=>b+_,0)/y.length:null)}})}}const d=s.slice(1).map(p=>p.match(/^(.*?)[\s_.-]*(min|max|lower|upper|lb|ub)$/i));if(d.length>=2&&d.every(Boolean)){const p=[],m=[],h=[];return d.forEach((g,y)=>{const b=g[1]||"FVA";let _=p.indexOf(b);_<0&&(p.push(b),_=p.length-1),/min|lower|lb/i.test(g[2])?m[_]=y+1:h[_]=y+1}),{kind:"fva",target:"reaction",columns:p,rows:o.map(g=>{const y=p.map((b,_)=>{const x=xa(g[m[_]]),v=xa(g[h[_]]);return x==null||v==null?null:[Math.min(x,v),Math.max(x,v)]});return{raw:g[0],ranges:y,values:y.map(b=>b?(b[0]+b[1])/2:null)}})}}const f=s.map((p,m)=>m).slice(1).filter(p=>o.filter(m=>xa(m[p])!=null).length>=o.length*.5);return{kind:r==="metabolite"?"metabolite":"flux",target:r,columns:f.map(p=>s[p]),rows:o.map(p=>({raw:p[0],values:f.map(m=>xa(p[m]))}))}}function rN(e,t,i,a,s={}){const o=Ym(i,t.target),l={id:"ds_"+Math.random().toString(36).slice(2,9),name:e,kind:t.kind,target:t.target,visible:!0,columns:t.columns.map(a),values:{},unmatched:[],idMap:{...s},unit:t.kind==="flux"||t.kind==="fva"||t.kind==="samples"?"mmol gDW⁻¹ h⁻¹":void 0};t.kind==="fva"&&(l.ranges={}),t.kind==="samples"&&(l.samples={});for(const c of t.rows){const d=s[c.raw]??o(c.raw);if(!d){l.unmatched.push(c.raw);continue}d!==c.raw&&(l.idMap[c.raw]=d),l.values[d]=c.values,c.ranges&&(l.ranges[d]=c.ranges),c.samples&&(l.samples[d]=c.samples)}const r=t.rows.length;return l.matchedFraction=r?(r-l.unmatched.length)/r:1,l._raw=t,l}function cN(e,t,i){const a=e._raw,s=a==null?void 0:a.rows.find(r=>r.raw===t);if(!s)return e;const o={...e,values:{...e.values,[i]:s.values},idMap:{...e.idMap,[t]:i},unmatched:e.unmatched.filter(r=>r!==t)};s.ranges&&(o.ranges={...e.ranges,[i]:s.ranges}),s.samples&&(o.samples={...e.samples,[i]:s.samples});const l=a.rows.length;return o.matchedFraction=(l-o.unmatched.length)/l,o._raw=a,o}function dN(e,t,i){const a=new Set(e.map(m=>m.id)),s=t.filter(([m,h])=>a.has(m)&&a.has(h)&&m!==h),o=new Map(e.map(m=>[m.id,m])),l=new Map(e.map(m=>[m.id,0])),r=new Map(e.map(m=>[m.id,[]]));for(const[m,h]of s)r.get(m).push(h),l.set(h,l.get(h)+1);const c=[],d=new Set(a),f=(m,h)=>o.get(m)[i]-o.get(h)[i];for(;d.size;){let m=[...d].filter(g=>l.get(g)===0).sort(f);m.length||(m=[[...d].sort((g,y)=>l.get(g)-l.get(y)||f(g,y))[0]]);const h=m[0];d.delete(h),c.push(h);for(const g of r.get(h))l.set(g,l.get(g)-1)}const u=new Map(c.map((m,h)=>[m,h])),p=new Map(c.map(m=>[m,0]));for(const m of c)for(const h of r.get(m))u.get(h)>u.get(m)&&p.set(h,Math.max(p.get(h),p.get(m)+1));return{depth:p,order:c}}function kd(e,t,i,a,s=1){const o=a==="vertical"?"y":"x",l=a==="vertical"?"x":"y",{depth:r,order:c}=dN(e,t,o),d=new Map(e.map(_=>[_.id,_])),f=new Map;for(const _ of c){const x=r.get(_);f.has(x)||f.set(x,[]),f.get(x).push(_)}const u=new Map;for(const[_,x]of t)u.has(_)||u.set(_,[]),u.get(_).push(x);const p=Math.min(...e.map(_=>_[o])),h=d.get(c[0])[l],g={};let y;const b=Math.max(...f.keys());for(let _=0;_<=b;_++){const x=f.get(_)??[];if(!x.length)continue;const v=x.find(k=>{var P;return y&&((P=u.get(y))==null?void 0:P.includes(k))})??x[0],j=x.filter(k=>k!==v).sort((k,P)=>d.get(k)[l]-d.get(P)[l]),N=(k,P)=>{const H={x:0,y:0};H[o]=p+_*i.spacing,H[l]=h+P*i.spacing*s,g[k]=H};N(v,0);let C=0,w=0;for(const k of j)d.get(k)[l]<h?N(k,-++C):N(k,++w);y=v}return g}function mN(e,t){const i=new Set(e.map(u=>u.id)),a=new Map;for(const[u,p]of t)i.has(u)&&i.has(p)&&(a.has(u)||a.set(u,[]),a.get(u).push(p));const s=e.reduce((u,p)=>u+p.x,0)/e.length,o=e.reduce((u,p)=>u+p.y,0)/e.length,l=u=>Math.atan2(u.y-o,u.x-s),r=new Map(e.map(u=>[u.id,u])),d=[[...e].sort((u,p)=>u.y-p.y)[0].id],f=new Set(d);for(;d.length<e.length;){const u=d[d.length-1],p=(a.get(u)??[]).find(g=>!f.has(g));if(p){d.push(p),f.add(p);continue}const m=l(r.get(u)),h=e.filter(g=>!f.has(g.id)).sort((g,y)=>(l(g)-m+4*Math.PI)%(2*Math.PI)-(l(y)-m+4*Math.PI)%(2*Math.PI));d.push(h[0].id),f.add(h[0].id)}return d}function Zm(e,t,i,a){if(t.length<2)return{};const s=t.reduce((l,r)=>l+r.x,0)/t.length,o=t.reduce((l,r)=>l+r.y,0)/t.length;switch(e){case"vertical":return kd(t,i,a,"vertical");case"horizontal":return kd(t,i,a,"horizontal");case"hierarchical":return kd(t,i,{...a,spacing:a.spacing*1.1},"vertical",1.4);case"circle":{const l=mN(t,i),r=a.radius??Math.max(50,a.spacing*l.length/(2*Math.PI)),c=(a.startAngle??-90)*Math.PI/180,d=a.clockwise===!1?-1:1,f={};return l.forEach((u,p)=>{const m=c+d*(2*Math.PI*p/l.length);f[u]={x:s+r*Math.cos(m),y:o+r*Math.sin(m)}}),f}case"grid":{const l=a.columns??Math.ceil(Math.sqrt(t.length)),r=[...t].sort((u,p)=>Math.abs(u.y-p.y)>a.spacing/2?u.y-p.y:u.x-p.x),c=Math.min(...t.map(u=>u.x)),d=Math.min(...t.map(u=>u.y)),f={};return r.forEach((u,p)=>f[u.id]={x:c+p%l*a.spacing,y:d+Math.floor(p/l)*a.spacing}),f}case"organic":return uN(t,i,a.spacing)}}function uN(e,t,i){const a=e.map(u=>({id:u.id,x:u.x,y:u.y,vx:0,vy:0})),s=new Map(a.map((u,p)=>[u.id,p])),o=t.filter(([u,p])=>s.has(u)&&s.has(p)).map(([u,p])=>[s.get(u),s.get(p)]),l=e.reduce((u,p)=>u+p.x,0)/e.length,r=e.reduce((u,p)=>u+p.y,0)/e.length;for(let u=0;u<300;u++){const p=1-u/300;for(let m=0;m<a.length;m++)for(let h=m+1;h<a.length;h++){const g=a[m].x-a[h].x||.01,y=a[m].y-a[h].y||.01,b=g*g+y*y,_=i*i/b;a[m].vx+=g*_*.05,a[m].vy+=y*_*.05,a[h].vx-=g*_*.05,a[h].vy-=y*_*.05}for(const[m,h]of o){const g=a[h].x-a[m].x,y=a[h].y-a[m].y,b=Math.hypot(g,y)||1,_=(b-i)/b*.1;a[m].vx+=g*_,a[m].vy+=y*_,a[h].vx-=g*_,a[h].vy-=y*_}for(const m of a){const h=Math.hypot(m.vx,m.vy),g=i*.5*p+.5;h>g&&(m.vx*=g/h,m.vy*=g/h),m.x+=m.vx,m.y+=m.vy,m.vx*=.5,m.vy*=.5}}const c=a.reduce((u,p)=>u+p.x,0)/a.length,d=a.reduce((u,p)=>u+p.y,0)/a.length,f={};for(const u of a)f[u.id]={x:u.x-c+l,y:u.y-d+r};return f}function pN(e,t){const i=t.map(r=>r.x),a=t.map(r=>r.y),s=e==="left"?Math.min(...i):e==="right"?Math.max(...i):e==="top"?Math.min(...a):e==="bottom"?Math.max(...a):e==="centerX"?(Math.min(...i)+Math.max(...i))/2:(Math.min(...a)+Math.max(...a))/2,o={},l=e==="top"||e==="bottom"||e==="centerY";for(const r of t)o[r.id]=l?{x:r.x,y:s}:{x:s,y:r.y};return o}function hN(e,t,i){const a=[...t].sort((r,c)=>r[e]-c[e]),s=a[0][e],o=i??(a[a.length-1][e]-s)/Math.max(1,a.length-1),l={};return a.forEach((r,c)=>l[r.id]=e==="x"?{x:s+c*o,y:r.y}:{x:r.x,y:s+c*o}),l}function fN(e,t,i,a){if(e.length<2)return{pos:{},detected:"nothing"};const s=e.reduce((m,h)=>m+h.x,0)/e.length,o=e.reduce((m,h)=>m+h.y,0)/e.length,l=e.reduce((m,h)=>m+(h.x-s)**2,0)/e.length,r=e.reduce((m,h)=>m+(h.y-o)**2,0)/e.length,c=e.map(m=>Math.hypot(m.x-s,m.y-o)),d=c.reduce((m,h)=>m+h,0)/c.length,f=Math.sqrt(c.reduce((m,h)=>m+(h-d)**2,0)/c.length)/(d||1),u=m=>Math.round(m/a)*a;if(e.length>=4&&f<.22&&l>0&&r>0&&Math.min(l,r)/Math.max(l,r)>.4)return{pos:Zm("circle",e,t,{spacing:i,radius:Math.round(d/(a/2))*(a/2)}),detected:"ring"};if(l>3*r||r>3*l){const m=l>r?"x":"y",h=m==="x"?"y":"x",g=[...e].sort((j,N)=>j[m]-N[m]),y=u([...e].map(j=>j[h]).sort((j,N)=>j-N)[Math.floor(e.length/2)]),b=g[g.length-1][m]-g[0][m],_=Math.max(a,Math.round(b/(g.length-1)/a)*a),x=u(g[0][m]),v={};return g.forEach((j,N)=>{const C={x:0,y:0};C[m]=x+N*_,C[h]=y,v[j.id]=C}),{pos:v,detected:m==="x"?"row":"column"}}const p={};for(const m of e)p[m.id]={x:u(m.x),y:u(m.y)};return{pos:p,detected:"grid"}}const Qh=new WeakMap;function Gc(e){var i,a;let t=Qh.get(e);if(t)return t;t=new Map;for(const s of Object.values(e.reactions)){const o=Mc(s.id);if(!(o&&((a=(i=e.reactions[o.id])==null?void 0:i.meta)!=null&&a.virtual)))for(const l of Object.keys(s.stoichiometry)){const r=t.get(l);r?r.push(s.id):t.set(l,[s.id])}}return Qh.set(e,t),t}const Jh=new WeakMap;function Xa(e,t,i,a=!1){let s=Jh.get(e);s||(s=new Map,Jh.set(e,s));const o=`${i}|${a?1:0}|${t}`,l=s.get(o);if(l)return l;const r=gN(e,t,i,a);return s.set(o,r),r}function gN(e,t,i,a){const s=[];for(const o of Gc(e).get(t)??[]){const l=e.reactions[o],r=l.stoichiometry[t],{substrates:c,products:d}=a?bN(l):ws(l,e.metabolites),f=i==="down"?r<0&&l.upperBound>0:r>0&&l.upperBound>0,u=l.lowerBound<0&&(i==="down"?r>0:r<0);if(f){const p=i==="down"?d:c;for(const m of p)m!==t&&s.push({reactionId:o,from:i==="down"?t:m,to:i==="down"?m:t,reversed:!1})}if(u){const p=i==="down"?c:d;for(const m of p)m!==t&&s.push({reactionId:o,from:i==="down"?t:m,to:i==="down"?m:t,reversed:!0})}}return s.filter(o=>a||!Fa(e.metabolites[i==="down"?o.to:o.from]))}function bN(e){const t=[],i=[];for(const[a,s]of Object.entries(e.stoichiometry))(s<0?t:i).push(a);return{substrates:t,products:i}}function yN(e,t,i,a,s=8){const o=[],l=new Set([t]);let r=[t];for(let c=0;c<a;c++){const d=[];for(const f of r){const u=Xa(e,f,i).slice(0,s);for(const p of u){o.push(p);const m=i==="down"?p.to:p.from;l.has(m)||(l.add(m),d.push(m))}}r=d}return o}function xN(e,t,i,a={}){var c;const s=new Map,o=new Set([t]);let l=[t];const r=a.maxDepth??25;for(let d=0;d<r&&l.length;d++){const f=[];for(const u of l)for(const p of Xa(e,u,"down",a.allowCurrency))if(!o.has(p.to)&&!(a.compartment&&((c=e.metabolites[p.to])==null?void 0:c.compartment)!==a.compartment&&p.to!==i)){if(o.add(p.to),s.set(p.to,p),p.to===i){const m=[];let h=i;for(;h!==t;){const g=s.get(h);m.unshift(g),h=g.from}return m}f.push(p.to)}l=f}return null}function Tp(e,t,i,a=[],s={}){const o=[];for(const f of Gc(e).get(t)??[]){const u=e.reactions[f],p=u.stoichiometry[t],m=u.stoichiometry[i];p==null||m==null||Math.sign(p)===Math.sign(m)||o.push({reactionIds:[f],reversed:p>0})}const l=new Set(a.map(f=>f.toLowerCase())),r=new Set(s.ec??[]),c=f=>{var m;const u=e.reactions[f.reactionIds[0]],p=new Set(Object.keys(u.stoichiometry).map(h=>{var g;return(g=e.metabolites[h])==null?void 0:g.compartment}));return(l.has(bt(f.reactionIds[0]).toLowerCase())?-10:0)+((m=u.ec)!=null&&m.some(h=>r.has(h))?-5:0)+(p.size>1?3:0)+(f.reversed?1:0)+Object.keys(u.stoichiometry).length*.01};if(o.length)return o.sort((f,u)=>c(f)-c(u));const d=[];for(const f of Xa(e,t,"down"))for(const u of Xa(e,f.to,"down"))u.to===i&&u.reactionId!==f.reactionId&&d.push({reactionIds:[f.reactionId,u.reactionId],reversed:f.reversed});return d}function _N(e,t,i,a={}){const s=a.allow??(()=>!0),o=a.maxExtra??2,l=a.limit??25,r=a.maxDepth??14;let c=a.budget??15e4;const d=new Map([[i,0]]);let f=[i];for(let v=1;v<=r&&f.length;v++){const j=[];for(const N of f)for(const C of Xa(e,N,"up",a.allowCurrency))s(C)&&(d.has(C.from)||(d.set(C.from,v),j.push(C.from)));f=j}const u=d.get(t);if(u==null||t===i)return{routes:[],shortest:null,truncated:!1};const p=u+o,m=[],h=new Set,g=[],y=new Set([t]),b=new Set;let _=!1;const x=v=>{if(m.length>=l*4){_=!0;return}if(--c<=0){_=!0;return}const j=Xa(e,v,"down",a.allowCurrency).filter(N=>s(N)&&d.has(N.to)&&g.length+1+d.get(N.to)<=p&&!y.has(N.to)&&!b.has(N.reactionId)).sort((N,C)=>d.get(N.to)-d.get(C.to));for(const N of j){if(g.push(N),N.to===i){const C=g.map(w=>w.reactionId).join(">");h.has(C)||(h.add(C),m.push({steps:[...g],mets:[t,...g.map(w=>w.to)]}))}else y.add(N.to),b.add(N.reactionId),x(N.to),y.delete(N.to),b.delete(N.reactionId);if(g.pop(),_)return}};return x(t),m.sort((v,j)=>v.steps.length-j.steps.length),{routes:m.slice(0,l),shortest:u,truncated:_||m.length>l}}const vN=e=>/^(prot_|pmet_)/.test(e);function ef(e){const t=new Map;for(const a of Object.keys(e.reactions)){const s=Mc(a);if(!s||e.reactions[s.id])continue;const o=t.get(s.id)??[];o.push({id:a,sign:s.sign}),t.set(s.id,o)}if(!t.size)return e;const i={...e.reactions};for(const[a,s]of t){const o=s.filter(m=>m.sign>0).map(m=>e.reactions[m.id]),l=s.filter(m=>m.sign<0).map(m=>e.reactions[m.id]),r=o[0]??l[0],c=o[0]?1:-1,d={};for(const[m,h]of Object.entries(r.stoichiometry))vN(m)||(d[m]=c*h);const f=[...o,...l],u=Array.from(new Set(f.map(m=>m.gpr).filter(Boolean))),p=Array.from(new Set(f.flatMap(m=>m.ec??[])));i[a]={id:a,name:r.name.replace(/\s*\((?:reversible|reverse|isozyme)[^)]*\)\s*$/i,"")||a,stoichiometry:d,reversible:o.length>0&&l.length>0,lowerBound:o.length?-l.reduce((m,h)=>m+Math.max(0,h.upperBound),0):-r.upperBound,upperBound:o.reduce((m,h)=>m+Math.max(0,h.upperBound),0),subsystem:r.subsystem,gpr:u.length>1?u.map(m=>/\s(and|or)\s/.test(m)?`(${m})`:m).join(" or "):u[0],genes:Array.from(new Set(f.flatMap(m=>m.genes))),ec:p.length?p:void 0,meta:{...r.meta,virtual:!0,members:s}}}return{...e,reactions:i}}const tf=e=>{var t;return!!((t=e==null?void 0:e.meta)!=null&&t.virtual)};function jN(e){return Object.values(e.reactions).some(tf)?{...e,reactions:Object.fromEntries(Object.entries(e.reactions).filter(([,t])=>!tf(t)))}:e}const x1={c:"cytosol",e:"extracellular",p:"periplasm",m:"mitochondria",x:"peroxisome",r:"endoplasmic reticulum",g:"Golgi",n:"nucleus",l:"lysosome",v:"vacuole",h:"chloroplast"};function NN(e){return e?Array.from(new Set(e.replace(/[()]/g," ").split(/\s+/).filter(t=>t&&!/^(and|or)$/i.test(t)))):[]}function _1(e){var d,f;const t=JSON.parse(e);if(!Array.isArray(t.metabolites)||!Array.isArray(t.reactions))throw new Error('Not a COBRA JSON model: expected "metabolites" and "reactions" arrays.');const i=typeof t.id=="string"&&t.id?`__${t.id}__`:"",a=u=>u.split(i).join(""),s=i&&t.metabolites.some(u=>u.id.includes(i))&&new Set(t.metabolites.map(u=>a(u.id))).size===t.metabolites.length&&new Set(t.reactions.map(u=>a(u.id))).size===t.reactions.length?a:u=>u,o={};for(const u of t.metabolites){const p={...u,id:s(u.id)};o[p.id]={id:p.id,name:p.name||p.id,formula:p.formula||void 0,charge:typeof p.charge=="number"?p.charge:void 0,compartment:p.compartment||(((d=p.id.match(/_([a-z][a-z0-9]?)$/))==null?void 0:d[1])??"c"),annotation:p.annotation}}const l={};for(const u of t.reactions){const p={...u,id:s(u.id)},m=p.lower_bound??-1e3,h=p.upper_bound??1e3;l[p.id]={id:p.id,name:p.name||p.id,stoichiometry:Object.fromEntries(Object.entries(p.metabolites||{}).map(([g,y])=>[s(g),y])),reversible:m<0&&h>0,lowerBound:m,upperBound:h,subsystem:p.subsystem||void 0,gpr:p.gene_reaction_rule||void 0,genes:NN(p.gene_reaction_rule),ec:(f=p.annotation)!=null&&f["ec-code"]?[].concat(p.annotation["ec-code"]):void 0}}const r={};for(const u of t.genes||[])r[u.id]={id:u.id,name:u.name};const c={...t.compartments||{}};for(const u of Object.values(o))c[u.compartment]||(c[u.compartment]=x1[u.compartment]??u.compartment);return{id:t.id||"model",name:t.name||t.id||"Imported model",metabolites:o,reactions:l,genes:r,compartments:c,source:"cobra-json"}}function v1(e){const t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror").length)throw new Error("Invalid SBML/XML file.");const i=(p,m)=>Array.from(p.getElementsByTagName("*")).filter(h=>h.localName===m),a=i(t,"model")[0];if(!a)throw new Error("No <model> element found.");const s=p=>p.replace(/__(\d+)__/g,(m,h)=>String.fromCharCode(+h)),o=(p,m)=>s(p.startsWith(m)?p.slice(m.length):p),l=(p,m)=>p.getAttribute(m)??p.getAttribute("fbc:"+m)??void 0,r={};for(const p of i(a,"parameter")){const m=p.getAttribute("id");m&&(r[m]=Number(p.getAttribute("value")))}const c={};for(const p of i(a,"compartment")){const m=p.getAttribute("id");c[o(m,"C_")]=p.getAttribute("name")||x1[o(m,"C_")]||m}const d={};for(const p of i(a,"species")){const m=o(p.getAttribute("id"),"M_"),h=l(p,"charge");d[m]={id:m,name:p.getAttribute("name")||m,compartment:o(p.getAttribute("compartment")||"c","C_"),formula:l(p,"chemicalFormula"),charge:h!=null?Number(h):void 0,annotation:wN(p)}}const f={};for(const p of i(a,"reaction")){const m=o(p.getAttribute("id"),"R_"),h={};for(const[N,C]of[["listOfReactants",-1],["listOfProducts",1]]){const w=i(p,N)[0];if(w)for(const k of i(w,"speciesReference")){const P=o(k.getAttribute("species"),"M_");h[P]=(h[P]??0)+C*Number(k.getAttribute("stoichiometry")??1)}}const g=l(p,"lowerFluxBound"),y=l(p,"upperFluxBound"),b=p.getAttribute("reversible")!=="false",_=g&&g in r?r[g]:b?-1e3:0,x=y&&y in r?r[y]:1e3,v=i(p,"geneProductRef").map(N=>o(l(N,"geneProduct")||"","G_")),j=i(p,"geneProductAssociation")[0];f[m]={id:m,name:p.getAttribute("name")||m,stoichiometry:h,reversible:_<0&&x>0,lowerBound:_,upperBound:x,genes:Array.from(new Set(v)),gpr:j?Qm(j.firstElementChild):void 0,subsystem:void 0}}const u={};for(const p of i(a,"geneProduct")){const m=o(l(p,"id")||"","G_");u[m]={id:m,name:l(p,"label")||l(p,"name")}}for(const p of i(a,"group")){const m=p.getAttribute("groups:name")||p.getAttribute("name");for(const h of i(p,"member")){const g=o(h.getAttribute("groups:idRef")||h.getAttribute("idRef")||"","R_");f[g]&&m&&(f[g].subsystem=m)}}return{id:a.getAttribute("id")||"model",name:a.getAttribute("name")||a.getAttribute("id")||"SBML model",metabolites:d,reactions:f,genes:u,compartments:c,source:"sbml"}}function wN(e){const t={},i=Array.from(e.children).find(a=>a.localName==="annotation");if(i){for(const a of Array.from(i.getElementsByTagName("*")).filter(s=>s.localName==="li")){const o=(a.getAttribute("rdf:resource")??a.getAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#","resource")??"").match(/identifiers\.org\/+([^/:]+)[/:](.+)$/i);if(!o)continue;const l=o[1].toLowerCase();(t[l]??(t[l]=[])).push(decodeURIComponent(o[2]))}return Object.keys(t).length?t:void 0}}function Qm(e){if(!e)return"";const t=Array.from(e.children);if(e.localName==="geneProductRef")return(e.getAttribute("fbc:geneProduct")||e.getAttribute("geneProduct")||"").replace(/^G_/,"");const i=e.localName==="and"?" and ":" or ";return t.map(a=>a.children.length?`(${Qm(a)})`:Qm(a)).join(i)}function j1(e,t){const i=t.trimStart();return e.toLowerCase().endsWith(".xml")||e.toLowerCase().endsWith(".sbml")||i.startsWith("<")?v1(t):_1(t)}function CN(e){return JSON.stringify({id:e.id,name:e.name,compartments:e.compartments,version:"1",metabolites:Object.values(e.metabolites).map(t=>({id:t.id,name:t.name,compartment:t.compartment,formula:t.formula??"",charge:t.charge??0})),reactions:Object.values(e.reactions).filter(t=>{var i;return!((i=t.meta)!=null&&i.virtual)}).map(t=>({id:t.id,name:t.name,metabolites:t.stoichiometry,lower_bound:t.lowerBound,upper_bound:t.upperBound,gene_reaction_rule:t.gpr??"",subsystem:t.subsystem??""})),genes:Object.values(e.genes).map(t=>({id:t.id,name:t.name??""}))},null,1)}function Jm(e){const t=[],i=new Set,a=new Set,s=new Set,o=new Set,l=[],r=[];for(const f of Object.values(e.reactions)){const u=Object.entries(f.stoichiometry);u.length||l.push(f.id);for(const[p,m]of u)e.metabolites[p]||i.add(p),(!Number.isFinite(m)||m===0)&&r.push(f.id),o.add(p),(m>0||f.reversible)&&a.add(p),(m<0||f.reversible)&&s.add(p)}i.size&&t.push({level:"error",code:"missing-metabolite",message:`${i.size} metabolites referenced by reactions are not defined`,ids:[...i]}),r.length&&t.push({level:"error",code:"invalid-stoichiometry",message:`${r.length} reactions have zero/non-finite coefficients`,ids:r}),l.length&&t.push({level:"warning",code:"empty-reaction",message:`${l.length} reactions have no metabolites`,ids:l});const c=Object.keys(e.metabolites).filter(f=>o.has(f)&&(!a.has(f)||!s.has(f)));c.length&&t.push({level:"info",code:"dead-end",message:`${c.length} dead-end metabolites (only produced or only consumed)`,ids:c});const d=Object.keys(e.metabolites).filter(f=>!o.has(f));return d.length&&t.push({level:"info",code:"orphan-metabolite",message:`${d.length} metabolites are not used by any reaction`,ids:d}),t}const kN=Object.freeze(Object.defineProperty({__proto__:null,parseCobraJson:_1,parseModelFile:j1,parseSbml:v1,toCobraJson:CN,validateModel:Jm},Symbol.toStringTag,{value:"Module"})),Ce=e=>e,N1=[Ce({id:"D-glucose",name:"D-Glucose",short:"glc_D",formula:"C6H12O6",synonyms:["glucose","D-glucose","dextrose","D-glucopyranose","Glc"],xrefs:{"kegg.compound":["C00031"],chebi:["17634","4167"],"bigg.metabolite":["glc__D","glc_D"],"seed.compound":["cpd00027"],"metacyc.compound":["GLC","D-GLUCOSE"],hmdb:["HMDB0000122"]},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],xrefs:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}]}),Ce({id:"D-glucose-6-phosphate",name:"D-Glucose 6-phosphate",short:"g6p",formula:"C6H13O9P",synonyms:["glucose 6-phosphate","D-glucose 6-phosphate","glucose-6-phosphate","G6P","D-glucopyranose 6-phosphate","Robison ester"],xrefs:{"kegg.compound":["C00092"],chebi:["14314","4170","61548"],"bigg.metabolite":["g6p"],"seed.compound":["cpd00079"],"metacyc.compound":["GLC-6-P","D-GLUCOSE-6-PHOSPHATE"],hmdb:["HMDB0001401"]},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],xrefs:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}]}),Ce({id:"D-fructose-6-phosphate",name:"D-Fructose 6-phosphate",short:"f6p",formula:"C6H13O9P",synonyms:["fructose 6-phosphate","D-fructose 6-phosphate","fructose-6-phosphate","F6P","Neuberg ester"],xrefs:{"kegg.compound":["C00085"],chebi:["15946","61527"],"bigg.metabolite":["f6p"],"seed.compound":["cpd00072"],"metacyc.compound":["FRUCTOSE-6P"],hmdb:["HMDB0000124"]},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],xrefs:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}]}),Ce({id:"D-fructose-1,6-bisphosphate",name:"D-Fructose 1,6-bisphosphate",short:"fdp",formula:"C6H14O12P2",synonyms:["fructose 1,6-bisphosphate","D-fructose 1,6-bisphosphate","fructose 1,6-diphosphate","fructose-1,6-bisphosphate","FBP","F16BP","Harden-Young ester"],xrefs:{"kegg.compound":["C00354"],chebi:["49299","32966"],"bigg.metabolite":["fdp"],"seed.compound":["cpd00290"],"metacyc.compound":["FRUCTOSE-16-DIPHOSPHATE"],hmdb:["HMDB0001058"]},related:[{note:"ring form of D-fructose 1,6-bisphosphate",names:["beta-D-fructose 1,6-bisphosphate","beta-D-fructofuranose 1,6-bisphosphate"],xrefs:{"kegg.compound":["C05378"],chebi:["28013"],"bigg.metabolite":["fdp_B"]}}]}),Ce({id:"dihydroxyacetone-phosphate",name:"Dihydroxyacetone phosphate",short:"dhap",formula:"C3H7O6P",synonyms:["dihydroxyacetone phosphate","glycerone phosphate","DHAP","dihydroxy-acetone phosphate","glycerone-phosphate"],xrefs:{"kegg.compound":["C00111"],chebi:["16108","57642"],"bigg.metabolite":["dhap"],"seed.compound":["cpd00095"],"metacyc.compound":["DIHYDROXY-ACETONE-PHOSPHATE"],hmdb:["HMDB0001473"]}}),Ce({id:"D-glyceraldehyde-3-phosphate",name:"D-Glyceraldehyde 3-phosphate",short:"g3p",formula:"C3H7O6P",synonyms:["glyceraldehyde 3-phosphate","D-glyceraldehyde 3-phosphate","glyceraldehyde-3-phosphate","GAP","G3P","D-glyceraldehyde-3-phosphate"],xrefs:{"kegg.compound":["C00118"],chebi:["29052","59776"],"bigg.metabolite":["g3p"],"seed.compound":["cpd00102"],"metacyc.compound":["GAP"],hmdb:["HMDB0001112"]},related:[{note:"stereo-unspecified glyceraldehyde 3-phosphate",names:["glyceraldehyde 3-phosphate"],xrefs:{"kegg.compound":["C00661"]}}]}),Ce({id:"1,3-bisphosphoglycerate",name:"3-Phospho-D-glyceroyl phosphate",short:"13dpg",formula:"C3H8O10P2",synonyms:["3-phospho-D-glyceroyl phosphate","1,3-bisphospho-D-glycerate","1,3-bisphosphoglycerate","1,3-diphosphoglycerate","glycerate 1,3-bisphosphate","1,3-BPG","13BPG","3-phospho-D-glyceroyl-phosphate"],xrefs:{"kegg.compound":["C00236"],chebi:["16001","57604"],"bigg.metabolite":["13dpg"],"seed.compound":["cpd00203"],"metacyc.compound":["DPG"],hmdb:["HMDB0001270"]}}),Ce({id:"3-phospho-D-glycerate",name:"3-Phospho-D-glycerate",short:"3pg",formula:"C3H7O7P",synonyms:["3-phospho-D-glycerate","3-phosphoglycerate","glycerate 3-phosphate","3-phosphoglyceric acid","3PG","D-glycerate 3-phosphate"],xrefs:{"kegg.compound":["C00197"],chebi:["17794","58272"],"bigg.metabolite":["3pg"],"seed.compound":["cpd00169"],"metacyc.compound":["G3P"],hmdb:["HMDB0000807"]}}),Ce({id:"2-phospho-D-glycerate",name:"2-Phospho-D-glycerate",short:"2pg",formula:"C3H7O7P",synonyms:["2-phospho-D-glycerate","D-glycerate 2-phosphate","2-phosphoglycerate","glycerate 2-phosphate","2PG","2-phosphoglyceric acid"],xrefs:{"kegg.compound":["C00631"],chebi:["17835","58289"],"bigg.metabolite":["2pg"],"seed.compound":["cpd00482"],"metacyc.compound":["2-PG"]}}),Ce({id:"phosphoenolpyruvate",name:"Phosphoenolpyruvate",short:"pep",formula:"C3H5O6P",synonyms:["phosphoenolpyruvate","phosphoenolpyruvic acid","PEP","phospho-enol-pyruvate"],xrefs:{"kegg.compound":["C00074"],chebi:["18021","58702"],"bigg.metabolite":["pep"],"seed.compound":["cpd00061"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],hmdb:["HMDB0000263"]}}),Ce({id:"pyruvate",name:"Pyruvate",short:"pyr",formula:"C3H4O3",synonyms:["pyruvate","pyruvic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr"],xrefs:{"kegg.compound":["C00022"],chebi:["15361","32816"],"bigg.metabolite":["pyr"],"seed.compound":["cpd00020"],"metacyc.compound":["PYRUVATE"],hmdb:["HMDB0000243"]}}),Ce({id:"L-lactate",name:"L-Lactate",short:"lac_L",formula:"C3H6O3",synonyms:["L-lactate","(S)-lactate","L-lactic acid","(S)-lactic acid","L-lac"],xrefs:{"kegg.compound":["C00186"],chebi:["16651","422"],"bigg.metabolite":["lac__L","lac_L"],"seed.compound":["cpd00159"],"metacyc.compound":["L-LACTATE"],hmdb:["HMDB0000190"]}}),Ce({id:"D-lactate",name:"D-Lactate",short:"lac_D",formula:"C3H6O3",synonyms:["D-lactate","(R)-lactate","D-lactic acid","(R)-lactic acid","D-lac"],xrefs:{"kegg.compound":["C00256"],chebi:["16004","42111"],"bigg.metabolite":["lac__D","lac_D"],"seed.compound":["cpd00221"],"metacyc.compound":["D-LACTATE"],hmdb:["HMDB0001311"]}}),Ce({id:"acetyl-CoA",name:"Acetyl-CoA",short:"accoa",formula:"C23H38N7O17P3S",synonyms:["acetyl-CoA","acetyl coenzyme A","acetyl-coenzyme A","AcCoA"],xrefs:{"kegg.compound":["C00024"],chebi:["15351","57288"],"bigg.metabolite":["accoa"],"seed.compound":["cpd00022"],"metacyc.compound":["ACETYL-COA"],hmdb:["HMDB0001206"]}}),Ce({id:"citrate",name:"Citrate",short:"cit",formula:"C6H8O7",synonyms:["citrate","citric acid","2-hydroxypropane-1,2,3-tricarboxylate","Cit"],xrefs:{"kegg.compound":["C00158"],chebi:["16947","30769"],"bigg.metabolite":["cit"],"seed.compound":["cpd00137"],"metacyc.compound":["CIT"],hmdb:["HMDB0000094"]}}),Ce({id:"cis-aconitate",name:"cis-Aconitate",short:"acon_C",formula:"C6H6O6",synonyms:["cis-aconitate","cis-aconitic acid","aconitate"],xrefs:{"kegg.compound":["C00417"],chebi:["16383","32805"],"bigg.metabolite":["acon_C","acon__C"],"seed.compound":["cpd00331"],"metacyc.compound":["CIS-ACONITATE"],hmdb:["HMDB0000072"]}}),Ce({id:"isocitrate",name:"Isocitrate",short:"icit",formula:"C6H8O7",synonyms:["isocitrate","isocitric acid","D-threo-isocitrate","threo-Ds-isocitrate","(2R,3S)-isocitrate","D-isocitrate"],xrefs:{"kegg.compound":["C00311"],chebi:["16087","30887"],"bigg.metabolite":["icit"],"seed.compound":["cpd00260"],"metacyc.compound":["THREO-DS-ISO-CITRATE"],hmdb:["HMDB0000193"]}}),Ce({id:"2-oxoglutarate",name:"2-Oxoglutarate",short:"akg",formula:"C5H6O5",synonyms:["2-oxoglutarate","alpha-ketoglutarate","2-ketoglutarate","oxoglutarate","2-oxoglutaric acid","alpha-ketoglutaric acid","AKG","2-oxopentanedioate"],xrefs:{"kegg.compound":["C00026"],chebi:["16810","30915"],"bigg.metabolite":["akg"],"seed.compound":["cpd00024"],"metacyc.compound":["2-KETOGLUTARATE"],hmdb:["HMDB0000208"]}}),Ce({id:"succinyl-CoA",name:"Succinyl-CoA",short:"succoa",formula:"C25H40N7O19P3S",synonyms:["succinyl-CoA","succinyl coenzyme A","succinyl-coenzyme A","SucCoA"],xrefs:{"kegg.compound":["C00091"],chebi:["15380","57292"],"bigg.metabolite":["succoa"],"seed.compound":["cpd00078"],"metacyc.compound":["SUC-COA"],hmdb:["HMDB0001022"]}}),Ce({id:"succinate",name:"Succinate",short:"succ",formula:"C4H6O4",synonyms:["succinate","succinic acid","butanedioate","butanedioic acid","Succ"],xrefs:{"kegg.compound":["C00042"],chebi:["26806","30031","15741"],"bigg.metabolite":["succ"],"seed.compound":["cpd00036"],"metacyc.compound":["SUC"],hmdb:["HMDB0000254"]}}),Ce({id:"fumarate",name:"Fumarate",short:"fum",formula:"C4H4O4",synonyms:["fumarate","fumaric acid","trans-butenedioate","(E)-butenedioate","Fum"],xrefs:{"kegg.compound":["C00122"],chebi:["29806","18012"],"bigg.metabolite":["fum"],"seed.compound":["cpd00106"],"metacyc.compound":["FUM"],hmdb:["HMDB0000134"]}}),Ce({id:"L-malate",name:"L-Malate",short:"mal_L",formula:"C4H6O5",synonyms:["L-malate","(S)-malate","L-malic acid","(S)-malic acid","Mal"],xrefs:{"kegg.compound":["C00149"],chebi:["15589","30797"],"bigg.metabolite":["mal__L","mal_L"],"seed.compound":["cpd00130"],"metacyc.compound":["MAL"],hmdb:["HMDB0000156"]},related:[{note:"stereo-unspecified malate",names:["malate","malic acid"],xrefs:{"kegg.compound":["C00711"]}}]}),Ce({id:"oxaloacetate",name:"Oxaloacetate",short:"oaa",formula:"C4H4O5",synonyms:["oxaloacetate","oxaloacetic acid","oxalacetate","2-oxosuccinate","OAA"],xrefs:{"kegg.compound":["C00036"],chebi:["16452","30744"],"bigg.metabolite":["oaa"],"seed.compound":["cpd00032"],"metacyc.compound":["OXALACETIC_ACID"],hmdb:["HMDB0000223"]}}),Ce({id:"6-phosphogluconolactone",name:"6-Phospho-D-glucono-1,5-lactone",short:"6pgl",formula:"C6H11O9P",synonyms:["6-phospho-D-glucono-1,5-lactone","6-phosphogluconolactone","6-O-phosphono-D-glucono-1,5-lactone","D-glucono-1,5-lactone 6-phosphate","6-phosphoglucono-delta-lactone","6PGL"],xrefs:{"kegg.compound":["C01236"],chebi:["16938","57955"],"bigg.metabolite":["6pgl"],"seed.compound":["cpd00911"],"metacyc.compound":["D-6-P-GLUCONO-DELTA-LACTONE"],hmdb:["HMDB0001127"]}}),Ce({id:"6-phospho-D-gluconate",name:"6-Phospho-D-gluconate",short:"6pgc",formula:"C6H13O10P",synonyms:["6-phospho-D-gluconate","6-phosphogluconate","6-phosphogluconic acid","D-gluconate 6-phosphate","6PG"],xrefs:{"kegg.compound":["C00345"],chebi:["48928","58759"],"bigg.metabolite":["6pgc"],"seed.compound":["cpd00284"],"metacyc.compound":["CPD-2961"],hmdb:["HMDB0001316"]}}),Ce({id:"D-ribulose-5-phosphate",name:"D-Ribulose 5-phosphate",short:"ru5p_D",formula:"C5H11O8P",synonyms:["D-ribulose 5-phosphate","ribulose 5-phosphate","ribulose-5-phosphate","Ru5P"],xrefs:{"kegg.compound":["C00199"],chebi:["17363","58121"],"bigg.metabolite":["ru5p__D","ru5p_D"],"seed.compound":["cpd00171"],"metacyc.compound":["RIBULOSE-5P"],hmdb:["HMDB0000618"]}}),Ce({id:"D-ribose-5-phosphate",name:"D-Ribose 5-phosphate",short:"r5p",formula:"C5H11O8P",synonyms:["D-ribose 5-phosphate","ribose 5-phosphate","ribose-5-phosphate","R5P","alpha-D-ribose 5-phosphate"],xrefs:{"kegg.compound":["C00117"],chebi:["17797","78346"],"bigg.metabolite":["r5p"],"seed.compound":["cpd00101"],"metacyc.compound":["RIBOSE-5P"],hmdb:["HMDB0001548"]}}),Ce({id:"D-xylulose-5-phosphate",name:"D-Xylulose 5-phosphate",short:"xu5p_D",formula:"C5H11O8P",synonyms:["D-xylulose 5-phosphate","xylulose 5-phosphate","xylulose-5-phosphate","Xu5P"],xrefs:{"kegg.compound":["C00231"],chebi:["16332","57737"],"bigg.metabolite":["xu5p__D","xu5p_D"],"seed.compound":["cpd00198"],"metacyc.compound":["XYLULOSE-5-PHOSPHATE"],hmdb:["HMDB0000868"]}}),Ce({id:"ATP",name:"ATP",short:"atp",formula:"C10H16N5O13P3",synonyms:["ATP","adenosine 5'-triphosphate","adenosine triphosphate"],xrefs:{"kegg.compound":["C00002"],chebi:["15422","30616"],"bigg.metabolite":["atp"],"seed.compound":["cpd00002"],"metacyc.compound":["ATP"],hmdb:["HMDB0000538"]}}),Ce({id:"ADP",name:"ADP",short:"adp",formula:"C10H15N5O10P2",synonyms:["ADP","adenosine 5'-diphosphate","adenosine diphosphate"],xrefs:{"kegg.compound":["C00008"],chebi:["16761","456216"],"bigg.metabolite":["adp"],"seed.compound":["cpd00008"],"metacyc.compound":["ADP"],hmdb:["HMDB0001341"]}}),Ce({id:"NAD+",name:"NAD+",short:"nad",formula:"C21H28N7O14P2",synonyms:["NAD+","NAD","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],xrefs:{"kegg.compound":["C00003"],chebi:["15846","57540"],"bigg.metabolite":["nad"],"seed.compound":["cpd00003"],"metacyc.compound":["NAD"],hmdb:["HMDB0000902"]}}),Ce({id:"NADH",name:"NADH",short:"nadh",formula:"C21H29N7O14P2",synonyms:["NADH","reduced nicotinamide adenine dinucleotide"],xrefs:{"kegg.compound":["C00004"],chebi:["16908","57945"],"bigg.metabolite":["nadh"],"seed.compound":["cpd00004"],"metacyc.compound":["NADH"],hmdb:["HMDB0001487"]}}),Ce({id:"NADP+",name:"NADP+",short:"nadp",formula:"C21H29N7O17P3",synonyms:["NADP+","NADP","nicotinamide adenine dinucleotide phosphate"],xrefs:{"kegg.compound":["C00006"],chebi:["18009","58349"],"bigg.metabolite":["nadp"],"seed.compound":["cpd00006"],"metacyc.compound":["NADP"],hmdb:["HMDB0000217"]}}),Ce({id:"NADPH",name:"NADPH",short:"nadph",formula:"C21H30N7O17P3",synonyms:["NADPH","reduced nicotinamide adenine dinucleotide phosphate"],xrefs:{"kegg.compound":["C00005"],chebi:["16474","57783"],"bigg.metabolite":["nadph"],"seed.compound":["cpd00005"],"metacyc.compound":["NADPH"],hmdb:["HMDB0000221"]}}),Ce({id:"CoA",name:"Coenzyme A",short:"coa",formula:"C21H36N7O16P3S",synonyms:["CoA","coenzyme A","CoA-SH"],xrefs:{"kegg.compound":["C00010"],chebi:["15346","57287"],"bigg.metabolite":["coa"],"seed.compound":["cpd00010"],"metacyc.compound":["CO-A"],hmdb:["HMDB0001423"]}}),Ce({id:"CO2",name:"CO2",short:"co2",formula:"CO2",synonyms:["CO2","carbon dioxide"],xrefs:{"kegg.compound":["C00011"],chebi:["16526"],"bigg.metabolite":["co2"],"seed.compound":["cpd00011"],"metacyc.compound":["CARBON-DIOXIDE"],hmdb:["HMDB0001967"]}}),Ce({id:"H2O",name:"H2O",short:"h2o",formula:"H2O",synonyms:["H2O","water"],xrefs:{"kegg.compound":["C00001"],chebi:["15377"],"bigg.metabolite":["h2o"],"seed.compound":["cpd00001"],"metacyc.compound":["WATER"],hmdb:["HMDB0002111"]}}),Ce({id:"phosphate",name:"Orthophosphate",short:"pi",formula:"H3PO4",synonyms:["phosphate","orthophosphate","Pi","inorganic phosphate"],xrefs:{"kegg.compound":["C00009"],chebi:["18367","26078"],"bigg.metabolite":["pi"],"seed.compound":["cpd00009"],"metacyc.compound":["Pi"],hmdb:["HMDB0001429"]}}),Ce({id:"ubiquinone",name:"Ubiquinone",short:"q",synonyms:["ubiquinone","coenzyme Q","quinone"],xrefs:{"kegg.compound":["C00399"],chebi:["16389"]}}),Ce({id:"ubiquinol",name:"Ubiquinol",short:"qh2",synonyms:["ubiquinol","reduced coenzyme Q"],xrefs:{"kegg.compound":["C00390"],chebi:["17976"]}})],MN=new Map(N1.map(e=>[e.id,e])),Is=(e,t)=>{var i;return((i=e.entities)==null?void 0:i[t])??MN.get(t)},EN="gemsmap-template",GN="1.1.0",SN={id:"amino-acid-biosynthesis",name:"Amino acid biosynthesis (overview)",description:"Where the twenty amino acids come from: the central-carbon precursors (3-phosphoglycerate, PEP + erythrose-4P, pyruvate, oxaloacetate, 2-oxoglutarate, ribose-5P / PRPP) and the biosynthetic families built on them — serine, aromatic, pyruvate, aspartate, glutamate and histidine. Whole pathways are drawn as summary arrows (KEGG modules). After KEGG map01230; drawn by GEMsMAP.",pathway:"Biosynthesis of amino acids",section:"Central carbon",template_version:"0.1.0",scope:{level:"universal",taxa:[],note:"Families are universal; lysine is made from aspartate (DAP pathway, bacteria and plants) or from 2-oxoglutarate (AAA pathway, fungi). Animals lack several of these pathways (essential amino acids). Compartments are chosen by the person mapping onto a GEM."},authors:["Drafted with an LLM (Claude Opus 5.5)"],created:"2026-10-09T00:00:00Z",modified:"2026-10-09T18:54:29Z",license:"MIT (drawing and curation); identifiers and biology from KEGG, MetaNetX and BiGG",tags:["amino acids","overview","KEGG","map01230","central carbon","precursors"],citations:[{text:"Kanehisa M, Goto S. KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res 28:27-30 (2000)",doi:"10.1093/nar/28.1.27"}],layout_kind:"free",review_status:"ai-generated",source:{reference:"KEGG",pathway_id:"map01230",pathway_name:"Biosynthesis of amino acids",url:"https://www.genome.jp/pathway/map01230",generation_method:"KEGG flat files + KGML (structure only) → curated biological graph → identities reconciled with MetaNetX (backend client) and the BiGG tables → hand-designed layout",generated_by:"tools/kegg/kegg_template.py",retrieved:"2026-10-09"}},AN={compartments:[],entities:[{id:"tpl_ent_001",name:"D-Glucose",short:"Glucose",formula:"C6H12O6",charge:0,synonyms:["D-Glucopyranose","D-glucopyranose","D-glucose","Dextrose","Glc","Glucose","Grape sugar","dextrose","glucose"],identifiers:{"kegg.compound":["C00031"],chebi:["17634","4167","CHEBI:4167"],"metanetx.chemical":["MNXM1364061"],"bigg.metabolite":["glc_D","glc__D"],hmdb:["HMDB0000122","HMDB0304632"],"seed.compound":["cpd00027"],"metacyc.compound":["D-GLUCOSE","GLC"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00031; MetaNetX MNXM1364061; BiGG glc__D; GEMsMAP library 'D-glucose'"},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],identifiers:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}],library:"D-glucose",provenance:{source:"KEGG",id:"C00031",url:"https://www.kegg.jp/entry/C00031"}},{id:"tpl_ent_002",name:"3-Phospho-D-glycerate",short:"3-Phosphoglycerate",formula:"C3H4O7P",charge:-3,synonyms:["3-Phospho-(R)-glycerate","3-Phosphoglycerate","3-phospho-D-glycerate","3-phosphoglycerate","3-phosphoglyceric acid","3PG","D-Glycerate 3-phosphate","D-glycerate 3-phosphate","glycerate 3-phosphate"],identifiers:{"kegg.compound":["C00197","C00597"],chebi:["17794","58272","CHEBI:17050","CHEBI:17794","CHEBI:57998","CHEBI:58272","CHEBI:88005"],"metanetx.chemical":["MNXM727604"],"bigg.metabolite":["3pg"],hmdb:["HMDB0000807","HMDB0060180"],"metacyc.compound":["G3P"],"seed.compound":["cpd00169","cpd30741"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00197; MetaNetX MNXM727604; BiGG 3pg; GEMsMAP library '3-phospho-D-glycerate'"},library:"3-phospho-D-glycerate",provenance:{source:"KEGG",id:"C00197",url:"https://www.kegg.jp/entry/C00197"}},{id:"tpl_ent_003",name:"Phosphoenolpyruvate",short:"Phosphoenolpyruvate",formula:"C3H2O6P",charge:-3,synonyms:["PEP","Phosphoenolpyruvic acid","phospho-enol-pyruvate","phosphoenolpyruvate","phosphoenolpyruvic acid"],identifiers:{"kegg.compound":["C00074"],chebi:["18021","58702","CHEBI:18021","CHEBI:44897","CHEBI:58702"],"metanetx.chemical":["MNXM73"],"bigg.metabolite":["pep"],hmdb:["HMDB0000263"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],"seed.compound":["cpd00061"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00074; MetaNetX MNXM73; BiGG pep; GEMsMAP library 'phosphoenolpyruvate'"},library:"phosphoenolpyruvate",provenance:{source:"KEGG",id:"C00074",url:"https://www.kegg.jp/entry/C00074"}},{id:"tpl_ent_004",name:"Pyruvate",short:"Pyruvate",formula:"C3H3O3",charge:-1,synonyms:["2-Oxopropanoate","2-Oxopropanoic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr","Pyroracemic acid","Pyruvic acid","pyruvate","pyruvic acid"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816","CHEBI:15361","CHEBI:177913","CHEBI:32816"],"metanetx.chemical":["MNXM23"],"bigg.metabolite":["pyr"],hmdb:["HMDB0000243"],"metacyc.compound":["PYRUVATE"],"seed.compound":["cpd00020"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00022; MetaNetX MNXM23; BiGG pyr; GEMsMAP library 'pyruvate'"},library:"pyruvate",provenance:{source:"KEGG",id:"C00022",url:"https://www.kegg.jp/entry/C00022"}},{id:"tpl_ent_005",name:"Oxaloacetate",short:"Oxaloacetate",formula:"C4H2O5",charge:-2,synonyms:["2-Oxobutanedioic acid","2-Oxosuccinic acid","2-oxosuccinate","OAA","Oxalacetic acid","Oxaloacetic acid","keto-Oxaloacetate","oxalacetate","oxaloacetate","oxaloacetic acid"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744","CHEBI:16452","CHEBI:30744"],"metanetx.chemical":["MNXM46"],"bigg.metabolite":["oaa"],hmdb:["HMDB0000223"],"metacyc.compound":["OXALACETIC_ACID"],"seed.compound":["cpd00032"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00036; MetaNetX MNXM46; BiGG oaa; GEMsMAP library 'oxaloacetate'"},library:"oxaloacetate",provenance:{source:"KEGG",id:"C00036",url:"https://www.kegg.jp/entry/C00036"}},{id:"tpl_ent_006",name:"2-Oxoglutarate",short:"2-Oxoglutarate",formula:"C5H4O5",charge:-2,synonyms:["2-Ketoglutaric acid","2-ketoglutarate","2-oxoglutarate","2-oxoglutaric acid","Oxoglutaric acid","alpha-Ketoglutaric acid","alpha-ketoglutarate","alpha-ketoglutaric acid","oxoglutarate"],identifiers:{"kegg.compound":["C00026"],chebi:["16810","30915","CHEBI:16810","CHEBI:178058","CHEBI:178083","CHEBI:30915","CHEBI:30916"],"metanetx.chemical":["MNXM1368744"],"bigg.metabolite":["akg"],hmdb:["HMDB0000208","HMDB0002812","HMDB0062781"],"metacyc.compound":["2-KETOGLUTARATE"],"seed.compound":["cpd00024","cpd32228"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00026; MetaNetX MNXM1368744; BiGG akg; GEMsMAP library '2-oxoglutarate'"},library:"2-oxoglutarate",provenance:{source:"KEGG",id:"C00026",url:"https://www.kegg.jp/entry/C00026"}},{id:"tpl_ent_007",name:"D-Ribose 5-phosphate",short:"Ribose-5P",formula:"C5H11O8P",charge:0,synonyms:["D-ribose 5-phosphate","R5P","Ribose 5-phosphate","alpha-D-ribose 5-phosphate","ribose 5-phosphate","ribose-5-phosphate"],identifiers:{"kegg.compound":["C00117","C03736"],chebi:["17797","78346","CHEBI:140679","CHEBI:17797","CHEBI:18189","CHEBI:52742","CHEBI:78346"],"metanetx.chemical":["MNXM1363910"],"bigg.metabolite":["r5p"],hmdb:["HMDB0001548"],"metacyc.compound":["CPD-15317","CPD-15318","RIBOSE-5P"],"seed.compound":["cpd00101","cpd19028"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00117; MetaNetX MNXM1363910; BiGG r5p; GEMsMAP library 'D-ribose-5-phosphate'"},library:"D-ribose-5-phosphate",provenance:{source:"KEGG",id:"C00117",url:"https://www.kegg.jp/entry/C00117"}},{id:"tpl_ent_008",name:"5-Phospho-alpha-D-ribose 1-diphosphate",short:"PRPP",formula:"C5H8O14P3",charge:-5,synonyms:["5-Phosphoribosyl 1-pyrophosphate","5-Phosphoribosyl diphosphate","PRPP"],identifiers:{"kegg.compound":["C00119"],chebi:["CHEBI:17111","CHEBI:58017"],"metanetx.chemical":["MNXM1104453"],"bigg.metabolite":["prpp"],hmdb:["HMDB0000280"],"metacyc.compound":["PRPP"],"seed.compound":["cpd00103"]},identity:{status:"suggested",source:"ai",note:"KEGG C00119; MetaNetX MNXM1104453; BiGG prpp",confidence:"high"},provenance:{source:"KEGG",id:"C00119",url:"https://www.kegg.jp/entry/C00119"}},{id:"tpl_ent_009",name:"Chorismate",short:"Chorismate",formula:"C10H8O6",charge:-2,synonyms:["(3R,4R)-3-[(1-Carboxyethenyl)oxy]-4-hydroxycyclohexa-1,5-diene-1-carboxylate","Chorismic acid"],identifiers:{"kegg.compound":["C00251"],chebi:["CHEBI:17333","CHEBI:29748"],"metanetx.chemical":["MNXM337"],"bigg.metabolite":["chor"],hmdb:["HMDB0012199"],"metacyc.compound":["CHORISMATE"],"seed.compound":["cpd00216"]},identity:{status:"suggested",source:"ai",note:"KEGG C00251; MetaNetX MNXM337; BiGG chor",confidence:"high"},provenance:{source:"KEGG",id:"C00251",url:"https://www.kegg.jp/entry/C00251"}},{id:"tpl_ent_010",name:"3-Methyl-2-oxobutanoic acid",short:"2-Oxoisovalerate",formula:"C5H7O3",charge:-1,synonyms:["2-Ketovaline","2-Oxo-3-methylbutanoate","2-Oxoisopentanoate","2-Oxoisovalerate","3-Methyl-2-oxobutanoate","3-Methyl-2-oxobutyric acid","alpha-Ketovaline"],identifiers:{"kegg.compound":["C00141"],chebi:["CHEBI:11851","CHEBI:16530"],"metanetx.chemical":["MNXM732866"],"bigg.metabolite":["3mob"],hmdb:["HMDB0000019","HMDB0004260"],"metacyc.compound":["2-KETO-ISOVALERATE"],"seed.compound":["cpd00123"]},identity:{status:"suggested",source:"ai",note:"KEGG C00141; MetaNetX MNXM732866; BiGG 3mob",confidence:"high"},provenance:{source:"KEGG",id:"C00141",url:"https://www.kegg.jp/entry/C00141"}},{id:"tpl_ent_011",name:"L-Aspartate 4-semialdehyde",short:"Asp-semialdehyde",formula:"C4H7NO3",charge:0,synonyms:["Aspartate beta-semialdehyde","L-Aspartic 4-semialdehyde"],identifiers:{"kegg.compound":["C00441"],chebi:["CHEBI:13086","CHEBI:18051","CHEBI:537519"],"metanetx.chemical":["MNXM361"],"bigg.metabolite":["aspsa"],hmdb:["HMDB0012249"],"metacyc.compound":["L-ASPARTATE-SEMIALDEHYDE"],"seed.compound":["cpd00346"]},identity:{status:"suggested",source:"ai",note:"KEGG C00441; MetaNetX MNXM361; BiGG aspsa",confidence:"high"},provenance:{source:"KEGG",id:"C00441",url:"https://www.kegg.jp/entry/C00441"}},{id:"tpl_ent_012",name:"L-Homoserine",short:"Homoserine",formula:"C4H9NO3",charge:0,synonyms:["2-Amino-4-hydroxybutyric acid"],identifiers:{"kegg.compound":["C00263"],chebi:["CHEBI:15699","CHEBI:57476"],"metanetx.chemical":["MNXM353"],"bigg.metabolite":["hom__L"],hmdb:["HMDB0000719"],"metacyc.compound":["HOMO-SER"],"seed.compound":["cpd00227"]},identity:{status:"suggested",source:"ai",note:"KEGG C00263; MetaNetX MNXM353; BiGG hom__L",confidence:"high"},provenance:{source:"KEGG",id:"C00263",url:"https://www.kegg.jp/entry/C00263"}},{id:"tpl_ent_013",name:"L-Serine",short:"Ser",formula:"C3H7NO3",charge:0,synonyms:["L-2-Amino-3-hydroxypropionic acid","L-3-Hydroxy-alanine","Serine"],identifiers:{"kegg.compound":["C00065"],chebi:["CHEBI:17115","CHEBI:32836","CHEBI:32837","CHEBI:33384"],"metanetx.chemical":["MNXM737787"],"bigg.metabolite":["ser__L"],hmdb:["HMDB0000187","HMDB0000589","HMDB0062263"],"metacyc.compound":["SER"],"seed.compound":["cpd00054"]},identity:{status:"suggested",source:"ai",note:"KEGG C00065; MetaNetX MNXM737787; BiGG ser__L",confidence:"high"},provenance:{source:"KEGG",id:"C00065",url:"https://www.kegg.jp/entry/C00065"}},{id:"tpl_ent_014",name:"Glycine",short:"Gly",formula:"C2H5NO2",charge:0,synonyms:["Aminoacetic acid","Gly"],identifiers:{"kegg.compound":["C00037"],chebi:["CHEBI:132194","CHEBI:15428","CHEBI:191950","CHEBI:32507","CHEBI:32508","CHEBI:57305"],"metanetx.chemical":["MNXM29"],"bigg.metabolite":["gly"],hmdb:["HMDB0000123"],"metacyc.compound":["GLY","Phosphorylated-Amino-Acids"],"seed.compound":["cpd00033"]},identity:{status:"suggested",source:"ai",note:"KEGG C00037; MetaNetX MNXM29; BiGG gly",confidence:"high"},provenance:{source:"KEGG",id:"C00037",url:"https://www.kegg.jp/entry/C00037"}},{id:"tpl_ent_015",name:"L-Cysteine",short:"Cys",formula:"C3H7NO2S",charge:0,synonyms:["L-2-Amino-3-mercaptopropionic acid"],identifiers:{"kegg.compound":["C00097"],chebi:["CHEBI:17561","CHEBI:32442","CHEBI:32443","CHEBI:32445","CHEBI:35235"],"metanetx.chemical":["MNXM738068"],"bigg.metabolite":["cys__L"],hmdb:["HMDB0000574"],"metacyc.compound":["CYS"],"seed.compound":["cpd00084"]},identity:{status:"suggested",source:"ai",note:"KEGG C00097; MetaNetX MNXM738068; BiGG cys__L",confidence:"high"},provenance:{source:"KEGG",id:"C00097",url:"https://www.kegg.jp/entry/C00097"}},{id:"tpl_ent_016",name:"L-Phenylalanine",short:"Phe",formula:"C9H11NO2",charge:0,synonyms:["(S)-alpha-Amino-beta-phenylpropionic acid"],identifiers:{"kegg.compound":["C00079"],chebi:["CHEBI:17295","CHEBI:176650","CHEBI:192084","CHEBI:231580","CHEBI:32486","CHEBI:32487","CHEBI:58095"],"metanetx.chemical":["MNXM741664"],"bigg.metabolite":["phe__L"],hmdb:["HMDB0000159","HMDB0000612"],"metacyc.compound":["PHE"],"seed.compound":["cpd00066"]},identity:{status:"suggested",source:"ai",note:"KEGG C00079; MetaNetX MNXM741664; BiGG phe__L",confidence:"high"},provenance:{source:"KEGG",id:"C00079",url:"https://www.kegg.jp/entry/C00079"}},{id:"tpl_ent_017",name:"L-Tyrosine",short:"Tyr",formula:"C9H11NO3",charge:0,synonyms:["(S)-2-Amino-3-(p-hydroxyphenyl)propionic acid","(S)-3-(p-Hydroxyphenyl)alanine","Tyrosine"],identifiers:{"kegg.compound":["C00082","C01536"],chebi:["CHEBI:17895","CHEBI:18186","CHEBI:192085","CHEBI:231581","CHEBI:32760","CHEBI:32761","CHEBI:32762","CHEBI:32784","CHEBI:32785","CHEBI:32786","CHEBI:58315"],"metanetx.chemical":["MNXM76"],"bigg.metabolite":["tyr__L"],hmdb:["HMDB0000158","HMDB0000647","HMDB0250803"],"metacyc.compound":["TYR"],"seed.compound":["cpd00069","cpd30745"]},identity:{status:"suggested",source:"ai",note:"KEGG C00082; MetaNetX MNXM76; BiGG tyr__L",confidence:"high"},provenance:{source:"KEGG",id:"C00082",url:"https://www.kegg.jp/entry/C00082"}},{id:"tpl_ent_018",name:"L-Tryptophan",short:"Trp",formula:"C11H12N2O2",charge:0,synonyms:["(S)-alpha-Amino-beta-(3-indolyl)-propionic acid","Tryptophan"],identifiers:{"kegg.compound":["C00078","C00806"],chebi:["CHEBI:16828","CHEBI:231586","CHEBI:27897","CHEBI:32702","CHEBI:32704","CHEBI:32727","CHEBI:32728","CHEBI:57912","CHEBI:64554"],"metanetx.chemical":["MNXM741553"],"bigg.metabolite":["trp__L"],hmdb:["HMDB0000929","HMDB0030396"],"metacyc.compound":["TRP"],"seed.compound":["cpd00065","cpd19007"]},identity:{status:"suggested",source:"ai",note:"KEGG C00078; MetaNetX MNXM741553; BiGG trp__L",confidence:"high"},provenance:{source:"KEGG",id:"C00078",url:"https://www.kegg.jp/entry/C00078"}},{id:"tpl_ent_019",name:"L-Alanine",short:"Ala",formula:"C3H7NO2",charge:0,synonyms:["L-2-Aminopropionic acid","L-alpha-Alanine"],identifiers:{"kegg.compound":["C00041"],chebi:["CHEBI:16977","CHEBI:229589","CHEBI:32431","CHEBI:32432","CHEBI:57972","CHEBI:76050"],"metanetx.chemical":["MNXM1105732"],"bigg.metabolite":["ala__L"],hmdb:["HMDB0000161"],"metacyc.compound":["L-ALPHA-ALANINE"],"seed.compound":["cpd00035"]},identity:{status:"suggested",source:"ai",note:"KEGG C00041; MetaNetX MNXM1105732; BiGG ala__L",confidence:"high"},provenance:{source:"KEGG",id:"C00041",url:"https://www.kegg.jp/entry/C00041"}},{id:"tpl_ent_020",name:"L-Valine",short:"Val",formula:"C5H11NO2",charge:0,synonyms:["2-Amino-3-methylbutyric acid"],identifiers:{"kegg.compound":["C00183","C16436"],chebi:["CHEBI:16414","CHEBI:176648","CHEBI:192086","CHEBI:27266","CHEBI:32851","CHEBI:32852","CHEBI:32859","CHEBI:32860","CHEBI:57762","CHEBI:87977"],"metanetx.chemical":["MNXM199"],"bigg.metabolite":["val__L"],hmdb:["HMDB0000883","HMDB0034366","HMDB0250806"],"metacyc.compound":["VAL"],"seed.compound":["cpd00156","cpd15141"]},identity:{status:"suggested",source:"ai",note:"KEGG C00183; MetaNetX MNXM199; BiGG val__L",confidence:"high"},provenance:{source:"KEGG",id:"C00183",url:"https://www.kegg.jp/entry/C00183"}},{id:"tpl_ent_021",name:"L-Leucine",short:"Leu",formula:"C6H13NO2",charge:0,synonyms:["(2S)-alpha-2-Amino-4-methylvaleric acid","(2S)-alpha-Leucine","2-Amino-4-methylvaleric acid"],identifiers:{"kegg.compound":["C00123","C16439"],chebi:["CHEBI:15603","CHEBI:192087","CHEBI:231578","CHEBI:231579","CHEBI:231582","CHEBI:25017","CHEBI:32619","CHEBI:32620","CHEBI:32627","CHEBI:32628","CHEBI:57427"],"metanetx.chemical":["MNXM1106761"],"bigg.metabolite":["leu__L"],hmdb:["HMDB0000687"],"metacyc.compound":["LEU"],"seed.compound":["cpd00107","cpd15143"]},identity:{status:"suggested",source:"ai",note:"KEGG C00123; MetaNetX MNXM1106761; BiGG leu__L",confidence:"high"},provenance:{source:"KEGG",id:"C00123",url:"https://www.kegg.jp/entry/C00123"}},{id:"tpl_ent_022",name:"L-Aspartate",short:"Asp",formula:"C4H6NO4",charge:-1,synonyms:["2-Aminosuccinic acid","L-Asp","L-Aspartic acid"],identifiers:{"kegg.compound":["C00049"],chebi:["CHEBI:17053","CHEBI:176631","CHEBI:192076","CHEBI:29991","CHEBI:29993"],"metanetx.chemical":["MNXM1364497"],"bigg.metabolite":["asp__L"],hmdb:["HMDB0000191"],"metacyc.compound":["L-ASPARTATE"],"seed.compound":["cpd00041"]},identity:{status:"suggested",source:"ai",note:"KEGG C00049; MetaNetX MNXM1364497; BiGG asp__L",confidence:"high"},provenance:{source:"KEGG",id:"C00049",url:"https://www.kegg.jp/entry/C00049"}},{id:"tpl_ent_023",name:"L-Asparagine",short:"Asn",formula:"C4H8N2O3",charge:0,synonyms:["2-Aminosuccinamic acid"],identifiers:{"kegg.compound":["C00152"],chebi:["CHEBI:17196","CHEBI:32650","CHEBI:32651","CHEBI:58048"],"metanetx.chemical":["MNXM1107821"],"bigg.metabolite":["asn__L"],hmdb:["HMDB0000168"],"metacyc.compound":["ASN"],"seed.compound":["cpd00132"]},identity:{status:"suggested",source:"ai",note:"KEGG C00152; MetaNetX MNXM1107821; BiGG asn__L",confidence:"high"},provenance:{source:"KEGG",id:"C00152",url:"https://www.kegg.jp/entry/C00152"}},{id:"tpl_ent_024",name:"L-Lysine",short:"Lys",formula:"C6H15N2O2",charge:1,synonyms:["2,6-Diaminohexanoic acid","Lysine acid"],identifiers:{"kegg.compound":["C00047","C16440"],chebi:["CHEBI:132486","CHEBI:133538","CHEBI:18019","CHEBI:194466","CHEBI:25094","CHEBI:32550","CHEBI:32551","CHEBI:32552","CHEBI:32563","CHEBI:32564","CHEBI:32565"],"metanetx.chemical":["MNXM1364268"],"bigg.metabolite":["lys__L"],hmdb:["HMDB0000182","HMDB0062809"],"metacyc.compound":["LYS"],"seed.compound":["cpd00039","cpd19182"]},identity:{status:"suggested",source:"ai",note:"KEGG C00047; MetaNetX MNXM1364268; BiGG lys__L",confidence:"high"},provenance:{source:"KEGG",id:"C00047",url:"https://www.kegg.jp/entry/C00047"}},{id:"tpl_ent_025",name:"L-Threonine",short:"Thr",formula:"C4H9NO3",charge:0,synonyms:["2-Amino-3-hydroxybutyric acid"],identifiers:{"kegg.compound":["C00188"],chebi:["CHEBI:16857","CHEBI:26986","CHEBI:32820","CHEBI:32822","CHEBI:32832","CHEBI:32833","CHEBI:57926"],"metanetx.chemical":["MNXM142"],"bigg.metabolite":["thr__L"],hmdb:["HMDB0000167"],"metacyc.compound":["THR"],"seed.compound":["cpd00161"]},identity:{status:"suggested",source:"ai",note:"KEGG C00188; MetaNetX MNXM142; BiGG thr__L",confidence:"high"},provenance:{source:"KEGG",id:"C00188",url:"https://www.kegg.jp/entry/C00188"}},{id:"tpl_ent_026",name:"L-Methionine",short:"Met",formula:"C5H11NO2S",charge:0,synonyms:["L-2-Amino-4methylthiobutyric acid","Methionine"],identifiers:{"kegg.compound":["C00073"],chebi:["CHEBI:16643","CHEBI:192080","CHEBI:32631","CHEBI:32632","CHEBI:57844"],"metanetx.chemical":["MNXM738804"],"bigg.metabolite":["met__L"],hmdb:["HMDB0000696"],"metacyc.compound":["MET"],"seed.compound":["cpd00060"]},identity:{status:"suggested",source:"ai",note:"KEGG C00073; MetaNetX MNXM738804; BiGG met__L",confidence:"high"},provenance:{source:"KEGG",id:"C00073",url:"https://www.kegg.jp/entry/C00073"}},{id:"tpl_ent_027",name:"L-Isoleucine",short:"Ile",formula:"C6H13NO2",charge:0,synonyms:["2-Amino-3-methylvaleric acid"],identifiers:{"kegg.compound":["C00407","C16434"],chebi:["CHEBI:17191","CHEBI:32604","CHEBI:32605","CHEBI:38264","CHEBI:58045"],"metanetx.chemical":["MNXM728337"],"bigg.metabolite":["ile__L"],hmdb:["HMDB0000172","HMDB0033923"],"metacyc.compound":["ILE"],"seed.compound":["cpd00322","cpd15139"]},identity:{status:"suggested",source:"ai",note:"KEGG C00407; MetaNetX MNXM728337; BiGG ile__L",confidence:"high"},provenance:{source:"KEGG",id:"C00407",url:"https://www.kegg.jp/entry/C00407"}},{id:"tpl_ent_028",name:"L-Glutamate",short:"Glu",formula:"C5H8NO4",charge:-1,synonyms:["Glutamate","L-Glutamic acid","L-Glutaminic acid"],identifiers:{"kegg.compound":["C00025"],chebi:["CHEBI:16015","CHEBI:192079","CHEBI:29985","CHEBI:29988"],"metanetx.chemical":["MNXM741173"],"bigg.metabolite":["glu__L"],hmdb:["HMDB0000148"],"metacyc.compound":["GLT"],"seed.compound":["cpd00023"]},identity:{status:"suggested",source:"ai",note:"KEGG C00025; MetaNetX MNXM741173; BiGG glu__L",confidence:"high"},provenance:{source:"KEGG",id:"C00025",url:"https://www.kegg.jp/entry/C00025"}},{id:"tpl_ent_029",name:"L-Glutamine",short:"Gln",formula:"C5H10N2O3",charge:0,synonyms:["L-2-Aminoglutaramic acid"],identifiers:{"kegg.compound":["C00064","C00303"],chebi:["CHEBI:18050","CHEBI:28300","CHEBI:32665","CHEBI:32666","CHEBI:32678","CHEBI:32679","CHEBI:58359"],"metanetx.chemical":["MNXM37"],"bigg.metabolite":["gln__L"],hmdb:["HMDB0000641"],"metacyc.compound":["GLN"],"seed.compound":["cpd00053","cpd00253"]},identity:{status:"suggested",source:"ai",note:"KEGG C00064; MetaNetX MNXM37; BiGG gln__L",confidence:"high"},provenance:{source:"KEGG",id:"C00064",url:"https://www.kegg.jp/entry/C00064"}},{id:"tpl_ent_030",name:"L-Proline",short:"Pro",formula:"C5H9NO2",charge:0,synonyms:["2-Pyrrolidinecarboxylic acid"],identifiers:{"kegg.compound":["C00148","C16435"],chebi:["CHEBI:17203","CHEBI:172951","CHEBI:192088","CHEBI:26271","CHEBI:32862","CHEBI:32864","CHEBI:32871","CHEBI:32872","CHEBI:60039"],"metanetx.chemical":["MNXM114"],"bigg.metabolite":["pro__L"],hmdb:["HMDB0000162","HMDB0251528"],"metacyc.compound":["PRO"],"seed.compound":["cpd00129","cpd15140"]},identity:{status:"suggested",source:"ai",note:"KEGG C00148; MetaNetX MNXM114; BiGG pro__L",confidence:"high"},provenance:{source:"KEGG",id:"C00148",url:"https://www.kegg.jp/entry/C00148"}},{id:"tpl_ent_031",name:"L-Arginine",short:"Arg",formula:"C6H15N4O2",charge:1,synonyms:["(S)-2-Amino-5-guanidinovaleric acid","L-Arg"],identifiers:{"kegg.compound":["C00062"],chebi:["CHEBI:16467","CHEBI:32681","CHEBI:32682","CHEBI:32683"],"metanetx.chemical":["MNXM739527"],"bigg.metabolite":["arg__L"],hmdb:["HMDB0000517","HMDB0062762"],"metacyc.compound":["ARG"],"seed.compound":["cpd00051"]},identity:{status:"suggested",source:"ai",note:"KEGG C00062; MetaNetX MNXM739527; BiGG arg__L",confidence:"high"},provenance:{source:"KEGG",id:"C00062",url:"https://www.kegg.jp/entry/C00062"}},{id:"tpl_ent_032",name:"L-Histidine",short:"His",formula:"C6H9N3O2",charge:0,synonyms:["(S)-alpha-Amino-1H-imidazole-4-propionic acid"],identifiers:{"kegg.compound":["C00135","C00768"],chebi:["CHEBI:15971","CHEBI:27570","CHEBI:32510","CHEBI:32512","CHEBI:32513","CHEBI:32529","CHEBI:32531","CHEBI:32532","CHEBI:57595"],"metanetx.chemical":["MNXM1107769"],"bigg.metabolite":["his__L"],hmdb:["HMDB0000177","HMDB0003412","HMDB0250763"],"metacyc.compound":["HIS"],"seed.compound":["cpd00119","cpd00572"]},identity:{status:"suggested",source:"ai",note:"KEGG C00135; MetaNetX MNXM1107769; BiGG his__L",confidence:"high"},provenance:{source:"KEGG",id:"C00135",url:"https://www.kegg.jp/entry/C00135"}},{id:"tpl_ent_033",name:"ATP",short:"ATP",formula:"C10H12N5O13P3",charge:-4,synonyms:["Adenosine 5'-triphosphate","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616","CHEBI:15422","CHEBI:237958","CHEBI:30616","CHEBI:57299"],"metanetx.chemical":["MNXM3"],"bigg.metabolite":["atp"],hmdb:["HMDB0000538"],"metacyc.compound":["ATP"],"seed.compound":["cpd00002"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00002; MetaNetX MNXM3; BiGG atp; GEMsMAP library 'ATP'"},library:"ATP",provenance:{source:"KEGG",id:"C00002",url:"https://www.kegg.jp/entry/C00002"}},{id:"tpl_ent_034",name:"ADP",short:"ADP",formula:"C10H12N5O10P2",charge:-3,synonyms:["Adenosine 5'-diphosphate","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216","CHEBI:16761","CHEBI:456216","CHEBI:87518"],"metanetx.chemical":["MNXM40333"],"bigg.metabolite":["adp"],hmdb:["HMDB0001341"],"metacyc.compound":["ADP","ADP-GROUP"],"seed.compound":["cpd00008","cpd22244"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00008; MetaNetX MNXM40333; BiGG adp; GEMsMAP library 'ADP'"},library:"ADP",provenance:{source:"KEGG",id:"C00008",url:"https://www.kegg.jp/entry/C00008"}},{id:"tpl_ent_035",name:"AMP",short:"AMP",formula:"C10H12N5O7P",charge:-2,synonyms:["5'-AMP","5'-Adenosine monophosphate","5'-Adenylic acid","Adenosine 5'-monophosphate","Adenosine 5'-phosphate","Adenylate","Adenylic acid"],identifiers:{"kegg.compound":["C00020"],chebi:["CHEBI:16027","CHEBI:40721","CHEBI:456215"],"metanetx.chemical":["MNXM728294"],"bigg.metabolite":["amp"],hmdb:["HMDB0000045"],"metacyc.compound":["AMP","AMP-GROUP"],"seed.compound":["cpd00018"]},identity:{status:"suggested",source:"ai",note:"KEGG C00020; MetaNetX MNXM728294; BiGG amp",confidence:"high"},provenance:{source:"KEGG",id:"C00020",url:"https://www.kegg.jp/entry/C00020"}},{id:"tpl_ent_036",name:"Diphosphate",short:"PPᵢ",formula:"HO7P2",charge:-3,synonyms:["Diphosphoric acid","PPi","Pyrophosphate","Pyrophosphoric acid"],identifiers:{"kegg.compound":["C00013"],chebi:["CHEBI:18361","CHEBI:29888","CHEBI:33017","CHEBI:33019","CHEBI:45212"],"metanetx.chemical":["MNXM11"],"bigg.metabolite":["ppi"],hmdb:["HMDB0000250","HMDB0304340"],"metacyc.compound":["PPI","PYROPHOSPHATE-GROUP"],"seed.compound":["cpd00012","cpd27828"]},identity:{status:"suggested",source:"ai",note:"KEGG C00013; MetaNetX MNXM11; BiGG ppi",confidence:"high"},provenance:{source:"KEGG",id:"C00013",url:"https://www.kegg.jp/entry/C00013"}},{id:"tpl_ent_037",name:"Orthophosphate",short:"Pᵢ",formula:"HO4P",charge:-2,synonyms:["Orthophosphoric acid","Phosphate","Phosphoric acid","Pi","inorganic phosphate","orthophosphate","phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078","CHEBI:18367","CHEBI:26020","CHEBI:26078","CHEBI:35780","CHEBI:39745","CHEBI:43474"],"metanetx.chemical":["MNXM9"],"bigg.metabolite":["pi"],hmdb:["HMDB0000973","HMDB0001429","HMDB0002105","HMDB0002142","HMDB0005947"],"seed.compound":["cpd00009","cpd27787"],"metacyc.compound":["Pi"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00009; MetaNetX MNXM9; BiGG pi; GEMsMAP library 'phosphate'"},library:"phosphate",provenance:{source:"KEGG",id:"C00009",url:"https://www.kegg.jp/entry/C00009"}},{id:"tpl_ent_040",name:"NADP+",short:"NADP⁺",formula:"C21H25N7O17P3",charge:-3,synonyms:["NADP","Nicotinamide adenine dinucleotide phosphate","TPN","Triphosphopyridine nucleotide","beta-NADP+","beta-Nicotinamide adenine dinucleotide phosphate","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349","CHEBI:18009","CHEBI:25523","CHEBI:44409","CHEBI:58349"],"metanetx.chemical":["MNXM5"],"bigg.metabolite":["nadp"],hmdb:["HMDB0000217","HMDB0304435"],"metacyc.compound":["NADP"],"seed.compound":["cpd00006"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00006; MetaNetX MNXM5; BiGG nadp; GEMsMAP library 'NADP+'"},library:"NADP+",provenance:{source:"KEGG",id:"C00006",url:"https://www.kegg.jp/entry/C00006"}},{id:"tpl_ent_041",name:"NADPH",short:"NADPH",formula:"C21H26N7O17P3",charge:-4,synonyms:["Reduced nicotinamide adenine dinucleotide phosphate","TPNH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783","CHEBI:16474","CHEBI:57783"],"metanetx.chemical":["MNXM738702"],"bigg.metabolite":["nadph"],hmdb:["HMDB0000221","HMDB0000799","HMDB0006341"],"metacyc.compound":["NADPH"],"seed.compound":["cpd00005"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00005; MetaNetX MNXM738702; BiGG nadph; GEMsMAP library 'NADPH'"},library:"NADPH",provenance:{source:"KEGG",id:"C00005",url:"https://www.kegg.jp/entry/C00005"}},{id:"tpl_ent_042",name:"H2O",short:"H2O",formula:"H2O",charge:0,synonyms:["Water","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377","CHEBI:15377","CHEBI:29374","CHEBI:29375","CHEBI:33806","CHEBI:33811","CHEBI:33813","CHEBI:41981"],"metanetx.chemical":["WATER"],"bigg.metabolite":["h2o"],hmdb:["HMDB0002111"],"metacyc.compound":["WATER"],"seed.compound":["cpd00001"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00001; MetaNetX WATER; BiGG h2o; GEMsMAP library 'H2O'"},library:"H2O",provenance:{source:"KEGG",id:"C00001",url:"https://www.kegg.jp/entry/C00001"}},{id:"tpl_ent_043",name:"Ammonia",short:"NH₃",formula:"H4N",charge:1,synonyms:["NH3"],identifiers:{"kegg.compound":["C00014","C01342"],chebi:["CHEBI:135980","CHEBI:16134","CHEBI:28938"],"metanetx.chemical":["MNXM729302"],"bigg.metabolite":["nh4"],hmdb:["HMDB0000051","HMDB0041827"],"metacyc.compound":["AMMONIA","AMMONIUM"],"seed.compound":["cpd00013","cpd19013"]},identity:{status:"suggested",source:"ai",note:"KEGG C00014; MetaNetX MNXM729302; BiGG nh4",confidence:"high"},provenance:{source:"KEGG",id:"C00014",url:"https://www.kegg.jp/entry/C00014"}},{id:"tpl_ent_044",name:"HCO3-",short:"HCO₃⁻",formula:"CHO3",charge:-1,synonyms:["Acid carbonate","Bicarbonate","Hydrogen carbonate","Hydrogencarbonate"],identifiers:{"kegg.compound":["C00288","C01353"],chebi:["CHEBI:140315","CHEBI:17544","CHEBI:28976","CHEBI:41609"],"metanetx.chemical":["MNXM1094693"],"bigg.metabolite":["h2co3"],hmdb:["HMDB0000595","HMDB0003538","HMDB0031453"],"seed.compound":["cpd00242"]},identity:{status:"suggested",source:"ai",note:"KEGG C00288; MetaNetX MNXM1094693; BiGG h2co3",confidence:"high"},provenance:{source:"KEGG",id:"C00288",url:"https://www.kegg.jp/entry/C00288"}},{id:"tpl_ent_045",name:"Tetrahydrofolate",short:"THF",formula:"C19H21N7O6",charge:-2,synonyms:["(6S)-THFA","(6S)-Tetrahydrofolate","(6S)-Tetrahydrofolic acid","5,6,7,8-Tetrahydrofolate","THF","Tetrahydrofolic acid"],identifiers:{"kegg.compound":["C00101"],chebi:["CHEBI:15635","CHEBI:20506","CHEBI:57453","CHEBI:68437"],"metanetx.chemical":["MNXM1103936"],"bigg.metabolite":["thf"],hmdb:["HMDB0001846","HMDB0014264","HMDB0062806","HMDB0304496"],"metacyc.compound":["THF"],"seed.compound":["cpd00087"]},identity:{status:"suggested",source:"ai",note:"KEGG C00101; MetaNetX MNXM1103936; BiGG thf",confidence:"high"},provenance:{source:"KEGG",id:"C00101",url:"https://www.kegg.jp/entry/C00101"}},{id:"tpl_ent_046",name:"5,10-Methylenetetrahydrofolate",short:"CH₂-THF",formula:"C20H21N7O6",charge:-2,synonyms:["(6R)-5,10-Methylenetetrahydrofolate","5,10-Methylene-THF"],identifiers:{"kegg.compound":["C00143"],chebi:["CHEBI:15636","CHEBI:1989"],"metanetx.chemical":["MNXM1102150"],"bigg.metabolite":["mlthf"],hmdb:["HMDB0001533","HMDB0002365"],"metacyc.compound":["METHYLENE-THF"],"seed.compound":["cpd00125"]},identity:{status:"suggested",source:"ai",note:"KEGG C00143; MetaNetX MNXM1102150; BiGG mlthf",confidence:"high"},provenance:{source:"KEGG",id:"C00143",url:"https://www.kegg.jp/entry/C00143"}},{id:"tpl_ent_047",name:"D-Erythrose 4-phosphate",short:"Erythrose-4P",formula:"C4H7O7P",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00279"],chebi:["CHEBI:16897","CHEBI:48153"],"metanetx.chemical":["MNXM258"],"bigg.metabolite":["e4p"],hmdb:["HMDB0001321"],"metacyc.compound":["ERYTHROSE-4P"],"seed.compound":["cpd00236"]},identity:{status:"suggested",source:"ai",note:"KEGG C00279; MetaNetX MNXM258; BiGG e4p",confidence:"high"},provenance:{source:"KEGG",id:"C00279",url:"https://www.kegg.jp/entry/C00279"}},{id:"tpl_ent_048",name:"Acetyl-CoA",short:"Acetyl-CoA",formula:"C23H34N7O17P3S",charge:-4,synonyms:["AcCoA","Acetyl coenzyme A","acetyl coenzyme A","acetyl-CoA","acetyl-coenzyme A"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288","CHEBI:15351","CHEBI:57288"],"metanetx.chemical":["MNXM1104266"],"bigg.metabolite":["accoa"],hmdb:["HMDB0001206"],"metacyc.compound":["ACETYL-COA"],"seed.compound":["cpd00022"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00024; MetaNetX MNXM1104266; BiGG accoa; GEMsMAP library 'acetyl-CoA'"},library:"acetyl-CoA",provenance:{source:"KEGG",id:"C00024",url:"https://www.kegg.jp/entry/C00024"}}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:null,level:"required"},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:null,level:"required"},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:null,level:"required"},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:null,level:"required"},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:null,level:"required"},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:null,level:"required"},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:null,level:"required"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:null,level:"required"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:null,level:"recommended"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:null,level:"recommended"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:null,level:"recommended"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:null,level:"recommended"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:null,level:"required"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:null,level:"required"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:null,level:"required"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:null,level:"required"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:null,level:"required"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:null,level:"required"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:null,level:"required"},{id:"tpl_met_020",entity:"tpl_ent_020",compartment:null,level:"required"},{id:"tpl_met_021",entity:"tpl_ent_021",compartment:null,level:"required"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:null,level:"required"},{id:"tpl_met_023",entity:"tpl_ent_023",compartment:null,level:"required"},{id:"tpl_met_024",entity:"tpl_ent_024",compartment:null,level:"required"},{id:"tpl_met_025",entity:"tpl_ent_025",compartment:null,level:"required"},{id:"tpl_met_026",entity:"tpl_ent_026",compartment:null,level:"required"},{id:"tpl_met_027",entity:"tpl_ent_027",compartment:null,level:"required"},{id:"tpl_met_028",entity:"tpl_ent_028",compartment:null,level:"required"},{id:"tpl_met_029",entity:"tpl_ent_029",compartment:null,level:"required"},{id:"tpl_met_030",entity:"tpl_ent_030",compartment:null,level:"required"},{id:"tpl_met_031",entity:"tpl_ent_031",compartment:null,level:"required"},{id:"tpl_met_032",entity:"tpl_ent_032",compartment:null,level:"required"},{id:"tpl_met_033",entity:"tpl_ent_033",compartment:null,level:"optional"},{id:"tpl_met_034",entity:"tpl_ent_034",compartment:null,level:"optional"},{id:"tpl_met_035",entity:"tpl_ent_035",compartment:null,level:"optional"},{id:"tpl_met_036",entity:"tpl_ent_036",compartment:null,level:"optional"},{id:"tpl_met_037",entity:"tpl_ent_037",compartment:null,level:"optional"},{id:"tpl_met_040",entity:"tpl_ent_040",compartment:null,level:"optional"},{id:"tpl_met_041",entity:"tpl_ent_041",compartment:null,level:"optional"},{id:"tpl_met_042",entity:"tpl_ent_042",compartment:null,level:"optional"},{id:"tpl_met_043",entity:"tpl_ent_043",compartment:null,level:"optional"},{id:"tpl_met_044",entity:"tpl_ent_044",compartment:null,level:"optional"},{id:"tpl_met_045",entity:"tpl_ent_045",compartment:null,level:"optional"},{id:"tpl_met_046",entity:"tpl_ent_046",compartment:null,level:"optional"},{id:"tpl_met_047",entity:"tpl_ent_047",compartment:null,level:"optional"},{id:"tpl_met_048",entity:"tpl_ent_048",compartment:null,level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"Glycolysis",canonicalName:"glucose → 3-phosphoglycerate (upper glycolysis, GAPDH, PGK)",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00001 (Glycolysis (Embden-Meyerhof pathway), glucose => pyruvate)"},provenance:[{source:"KEGG",id:"M00001",url:"https://www.kegg.jp/entry/M00001"}],summary:!0},{id:"tpl_rxn_002",name:"PGAM · ENO",canonicalName:"3-phosphoglycerate → phosphoenolpyruvate",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG R01518 (D-phosphoglycerate 2,3-phosphomutase); KEGG R00658 (2-phospho-D-glycerate hydro-lyase (phosphoenolpyruvate-forming))"},provenance:[{source:"KEGG",id:"R01518",url:"https://www.kegg.jp/entry/R01518"},{source:"KEGG",id:"R00658",url:"https://www.kegg.jp/entry/R00658"}],summary:!0},{id:"tpl_rxn_003",name:"PK",canonicalName:"pyruvate kinase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_034",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.40"],identifiers:{"kegg.reaction":["R00200"],"metanetx.reaction":["MNXR103371"],"seed.reaction":["rxn00148","rxn20509","rxn35242"],"metacyc.reaction":["PEPDEPHOS-RXN"],rhea:["18157","18158","18159","18160"],"bigg.reaction":["PYK"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00200; MetaNetX MNXR103371; BiGG links PYK2 to this KEGG reaction but the participants differ — not used; KEGG ID confirmed in the built-in template ('PYK')"},provenance:[{source:"KEGG",id:"R00200",url:"https://www.kegg.jp/entry/R00200"}]},{id:"tpl_rxn_004",name:"SerA·C·B",canonicalName:"serine biosynthesis",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_013",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00020 (Serine biosynthesis, glycerate-3P => serine)"},provenance:[{source:"KEGG",id:"M00020",url:"https://www.kegg.jp/entry/M00020"}],summary:!0},{id:"tpl_rxn_005",name:"SHMT",canonicalName:"serine hydroxymethyltransferase",participants:[{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_045",coefficient:-1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!0},{metabolite:"tpl_met_046",coefficient:1,main:!1},{metabolite:"tpl_met_042",coefficient:1,main:!1}],reversible:!0,ec:["2.1.2.1"],identifiers:{"kegg.reaction":["R00945"],"metanetx.reaction":["MNXR188117"],"seed.reaction":["rxn00692","rxn19870","rxn27914","rxn30686","rxn33977","rxn38130"],rhea:["15481","15482","15483","15484"],"bigg.reaction":["GHMT2r"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00945; MetaNetX MNXR188117"},provenance:[{source:"KEGG",id:"R00945",url:"https://www.kegg.jp/entry/R00945"}]},{id:"tpl_rxn_006",name:"CysE·K",canonicalName:"cysteine biosynthesis (serine → O-acetylserine → cysteine)",participants:[{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_015",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00021 (Cysteine biosynthesis, serine => cysteine)"},provenance:[{source:"KEGG",id:"M00021",url:"https://www.kegg.jp/entry/M00021"}],summary:!0},{id:"tpl_rxn_007",name:"Shikimate pathway",canonicalName:"PEP + erythrose-4P → chorismate",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_047",coefficient:-1,main:!1},{metabolite:"tpl_met_009",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00022 (Shikimate pathway, phosphoenolpyruvate + erythrose-4P => chorismate)"},provenance:[{source:"KEGG",id:"M00022",url:"https://www.kegg.jp/entry/M00022"}],summary:!0},{id:"tpl_rxn_008",name:"Phe pathway",canonicalName:"chorismate → phenylalanine",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_016",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00024 (Phenylalanine biosynthesis, chorismate => phenylpyruvate => phenylalanine)"},provenance:[{source:"KEGG",id:"M00024",url:"https://www.kegg.jp/entry/M00024"}],summary:!0},{id:"tpl_rxn_009",name:"Tyr pathway",canonicalName:"chorismate → tyrosine",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_017",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00025 (Tyrosine biosynthesis, chorismate => HPP => tyrosine)"},provenance:[{source:"KEGG",id:"M00025",url:"https://www.kegg.jp/entry/M00025"}],summary:!0},{id:"tpl_rxn_010",name:"Trp pathway",canonicalName:"chorismate → tryptophan",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00023 (Tryptophan biosynthesis, chorismate => tryptophan)"},provenance:[{source:"KEGG",id:"M00023",url:"https://www.kegg.jp/entry/M00023"}],summary:!0},{id:"tpl_rxn_011",name:"ALT",canonicalName:"alanine aminotransferase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_019",coefficient:1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.2"],identifiers:{"kegg.reaction":["R00258"],"metanetx.reaction":["MNXR95698"],"seed.reaction":["rxn00191","rxn27697","rxn27698","rxn31211","rxn38028","rxn38029"],"metacyc.reaction":["ALANINE-AMINOTRANSFERASE-RXN","RXN-13698"],rhea:["19453","19454","19455","19456"],"bigg.reaction":["ALATA_L"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00258; MetaNetX MNXR95698"},provenance:[{source:"KEGG",id:"R00258",url:"https://www.kegg.jp/entry/R00258"}]},{id:"tpl_rxn_012",name:"IlvBN·C·D",canonicalName:"pyruvate → 2-oxoisovalerate (acetolactate synthase, KARI, DHAD)",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00019 (Valine/isoleucine biosynthesis, pyruvate => valine / 2-oxobutanoate => isoleucine)"},provenance:[{source:"KEGG",id:"M00019",url:"https://www.kegg.jp/entry/M00019"}],summary:!0},{id:"tpl_rxn_013",name:"BCAT",canonicalName:"branched-chain aminotransferase (valine)",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_020",coefficient:1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.6","2.6.1.42"],identifiers:{"kegg.reaction":["R01214"],"metanetx.reaction":["MNXR96230"],"seed.reaction":["rxn00903","rxn19242","rxn27739","rxn33935","rxn38055"],"metacyc.reaction":["BRANCHED-CHAINAMINOTRANSFERVAL-RXN"],rhea:["24813","24814","24815","24816"],"bigg.reaction":["VALTA"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01214; MetaNetX MNXR96230"},provenance:[{source:"KEGG",id:"R01214",url:"https://www.kegg.jp/entry/R01214"}]},{id:"tpl_rxn_014",name:"Leu pathway",canonicalName:"2-oxoisovalerate → leucine",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_021",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00432 (Leucine biosynthesis, 2-oxoisovalerate => 2-oxoisocaproate)"},provenance:[{source:"KEGG",id:"M00432",url:"https://www.kegg.jp/entry/M00432"}],summary:!0},{id:"tpl_rxn_015",name:"PC",canonicalName:"pyruvate carboxylase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_044",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1},{metabolite:"tpl_met_037",coefficient:1,main:!1}],reversible:!1,ec:["6.4.1.1"],identifiers:{"kegg.reaction":["R00344"],"metanetx.reaction":["MNXR102391"],"seed.reaction":["rxn00250","rxn28116"],"metacyc.reaction":["PYRUVATE-CARBOXYLASE-RXN"],rhea:["20844","20845","20846","20847"],"bigg.reaction":["PC"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00344; MetaNetX MNXR102391"},provenance:[{source:"KEGG",id:"R00344",url:"https://www.kegg.jp/entry/R00344"}]},{id:"tpl_rxn_016",name:"AST",canonicalName:"aspartate aminotransferase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_022",coefficient:1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.1"],identifiers:{"kegg.reaction":["R00355"],"metanetx.reaction":["MNXR192556"],"seed.reaction":["rxn00260","rxn27719","rxn27720","rxn30355"],"metacyc.reaction":["ASPAMINOTRANS-RXN","RXN-13697"],rhea:["21824","21825","21826","21827"],"bigg.reaction":["ASPTA"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00355; MetaNetX MNXR192556"},provenance:[{source:"KEGG",id:"R00355",url:"https://www.kegg.jp/entry/R00355"}]},{id:"tpl_rxn_017",name:"ASNS",canonicalName:"asparagine synthetase",participants:[{metabolite:"tpl_met_022",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_029",coefficient:-1,main:!1},{metabolite:"tpl_met_042",coefficient:-1,main:!1},{metabolite:"tpl_met_023",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1},{metabolite:"tpl_met_036",coefficient:1,main:!1},{metabolite:"tpl_met_028",coefficient:1,main:!1}],reversible:!1,ec:["6.3.5.4"],identifiers:{"kegg.reaction":["R00578"],"metanetx.reaction":["MNXR153021"],"seed.reaction":["rxn00416","rxn32227","rxn38046"],"metacyc.reaction":["ASNSYNB-RXN"],rhea:["12228","12229","12230","12231"],"bigg.reaction":["ASNS1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00578; MetaNetX MNXR153021"},provenance:[{source:"KEGG",id:"R00578",url:"https://www.kegg.jp/entry/R00578"}]},{id:"tpl_rxn_018",name:"AK · ASD",canonicalName:"aspartate → aspartate-semialdehyde (aspartokinase, ASA dehydrogenase)",participants:[{metabolite:"tpl_met_022",coefficient:-1,main:!0},{metabolite:"tpl_met_011",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG R00480 (ATP:L-aspartate 4-phosphotransferase); KEGG R02291 (L-aspartate-4-semialdehyde:NADP+ oxidoreductase (phosphorylating))"},provenance:[{source:"KEGG",id:"R00480",url:"https://www.kegg.jp/entry/R00480"},{source:"KEGG",id:"R02291",url:"https://www.kegg.jp/entry/R02291"}],summary:!0},{id:"tpl_rxn_019",name:"DAP pathway",canonicalName:"aspartate-semialdehyde → lysine (diaminopimelate pathway)",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00016 (Lysine biosynthesis, succinyl-DAP pathway, aspartate => lysine) — bacteria and plants; variants M00525, M00526, M00527"},provenance:[{source:"KEGG",id:"M00016",url:"https://www.kegg.jp/entry/M00016"}],summary:!0},{id:"tpl_rxn_020",name:"HSD",canonicalName:"homoserine dehydrogenase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_041",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["1.1.1.3"],identifiers:{"kegg.reaction":["R01775"],"metanetx.reaction":["MNXR100734"],"seed.reaction":["rxn01302","rxn27932"],rhea:["15761","15762","15763","15764"],"bigg.reaction":["HSDy"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01775; MetaNetX MNXR100734"},provenance:[{source:"KEGG",id:"R01775",url:"https://www.kegg.jp/entry/R01775"}]},{id:"tpl_rxn_021",name:"ThrB·C",canonicalName:"homoserine → threonine (homoserine kinase, threonine synthase)",participants:[{metabolite:"tpl_met_012",coefficient:-1,main:!0},{metabolite:"tpl_met_025",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00018 (Threonine biosynthesis, aspartate => homoserine => threonine)"},provenance:[{source:"KEGG",id:"M00018",url:"https://www.kegg.jp/entry/M00018"}],summary:!0},{id:"tpl_rxn_022",name:"Met pathway",canonicalName:"homoserine → methionine",participants:[{metabolite:"tpl_met_012",coefficient:-1,main:!0},{metabolite:"tpl_met_026",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00017 (Methionine biosynthesis, aspartate => homoserine => methionine)"},provenance:[{source:"KEGG",id:"M00017",url:"https://www.kegg.jp/entry/M00017"}],summary:!0},{id:"tpl_rxn_023",name:"Ile pathway",canonicalName:"threonine → 2-oxobutanoate → isoleucine",participants:[{metabolite:"tpl_met_025",coefficient:-1,main:!0},{metabolite:"tpl_met_027",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00570 (Isoleucine biosynthesis, threonine => 2-oxobutanoate => isoleucine)"},provenance:[{source:"KEGG",id:"M00570",url:"https://www.kegg.jp/entry/M00570"}],summary:!0},{id:"tpl_rxn_024",name:"TCA cycle",canonicalName:"oxaloacetate + acetyl-CoA → 2-oxoglutarate (CS, ACO, IDH)",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_048",coefficient:-1,main:!1},{metabolite:"tpl_met_006",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00010 (Citrate cycle, first carbon oxidation, oxaloacetate => 2-oxoglutarate)"},provenance:[{source:"KEGG",id:"M00010",url:"https://www.kegg.jp/entry/M00010"}],summary:!0},{id:"tpl_rxn_025",name:"GDH",canonicalName:"glutamate dehydrogenase",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_043",coefficient:-1,main:!1},{metabolite:"tpl_met_041",coefficient:-1,main:!1},{metabolite:"tpl_met_028",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1},{metabolite:"tpl_met_042",coefficient:1,main:!1}],reversible:null,ec:["1.4.1.3","1.4.1.4","1.4.1.13"],identifiers:{"kegg.reaction":["R00248"],"metanetx.reaction":["MNXR100086"],"seed.reaction":["rxn00184","rxn27887","rxn30023","rxn33943","rxn34794"],"metacyc.reaction":["GLUTDEHYD-RXN","RXN-20084"],rhea:["11612","11613","11614","11615"],"bigg.reaction":["GLUDy_1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00248; MetaNetX MNXR100086"},provenance:[{source:"KEGG",id:"R00248",url:"https://www.kegg.jp/entry/R00248"}]},{id:"tpl_rxn_026",name:"GS",canonicalName:"glutamine synthetase",participants:[{metabolite:"tpl_met_028",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_043",coefficient:-1,main:!1},{metabolite:"tpl_met_029",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1},{metabolite:"tpl_met_037",coefficient:1,main:!1}],reversible:!1,ec:["6.3.1.2"],identifiers:{"kegg.reaction":["R00253"],"metanetx.reaction":["MNXR100024"],"seed.reaction":["rxn00187","rxn19835","rxn19836","rxn30022","rxn33952","rxn33953","rxn34791","rxn34792"],"metacyc.reaction":["GLUTAMINESYN-RXN"],rhea:["16169","16170","16171","16172"],"bigg.reaction":["GLNS"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00253; MetaNetX MNXR100024"},provenance:[{source:"KEGG",id:"R00253",url:"https://www.kegg.jp/entry/R00253"}]},{id:"tpl_rxn_027",name:"ProB·A·C",canonicalName:"glutamate → proline",participants:[{metabolite:"tpl_met_028",coefficient:-1,main:!0},{metabolite:"tpl_met_030",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00015 (Proline biosynthesis, glutamate => proline)"},provenance:[{source:"KEGG",id:"M00015",url:"https://www.kegg.jp/entry/M00015"}],summary:!0},{id:"tpl_rxn_028",name:"Arg pathway",canonicalName:"glutamate → ornithine → arginine",participants:[{metabolite:"tpl_met_028",coefficient:-1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00028 (Ornithine biosynthesis, glutamate => ornithine); KEGG M00844 (Arginine biosynthesis, ornithine => arginine)"},provenance:[{source:"KEGG",id:"M00028",url:"https://www.kegg.jp/entry/M00028"},{source:"KEGG",id:"M00844",url:"https://www.kegg.jp/entry/M00844"}],summary:!0},{id:"tpl_rxn_029",name:"AAA pathway",canonicalName:"2-oxoglutarate → 2-aminoadipate → lysine (fungi)",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00030 (Lysine biosynthesis, AAA pathway, 2-oxoglutarate => 2-aminoadipate => lysine) — fungi (and some archaea / Thermus) make lysine from 2-oxoglutarate instead of aspartate"},provenance:[{source:"KEGG",id:"M00030",url:"https://www.kegg.jp/entry/M00030"}],summary:!0},{id:"tpl_rxn_030",name:"PRPS",canonicalName:"ribose-phosphate pyrophosphokinase",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1}],reversible:!1,ec:["2.7.6.1"],identifiers:{"kegg.reaction":["R01049"],"metanetx.reaction":["MNXR189826"],"seed.reaction":["rxn00770","rxn15108","rxn33995","rxn35356","rxn38273"],rhea:["15609","15610","15611","15612"],"bigg.reaction":["PRPPS"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01049; MetaNetX MNXR189826"},provenance:[{source:"KEGG",id:"R01049",url:"https://www.kegg.jp/entry/R01049"}]},{id:"tpl_rxn_031",name:"His pathway",canonicalName:"PRPP → histidine",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:1,main:!0}],reversible:!1,ec:[],identifiers:{},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"pathway summary of KEGG M00026 (Histidine biosynthesis, PRPP => histidine)"},provenance:[{source:"KEGG",id:"M00026",url:"https://www.kegg.jp/entry/M00026"}],summary:!0}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_002",metabolite:"tpl_met_007",direction:"in",target:{pathway:"Pentose phosphate pathway",template:"kegg-map00030"}},{id:"tpl_port_003",metabolite:"tpl_met_006",direction:"in",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_004",metabolite:"tpl_met_029",direction:"out",target:{pathway:"Alanine, aspartate and glutamate metabolism",template:"kegg-map00250"}}]},DN={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:0,shape:"label"},{id:"tpl_node_002",metabolite:"tpl_met_002",x:0,y:170,shape:"label"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:0,y:340,shape:"label"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:0,y:510,shape:"label"},{id:"tpl_node_005",metabolite:"tpl_met_013",x:-260,y:170,shape:"label"},{id:"tpl_node_006",metabolite:"tpl_met_014",x:-480,y:170,shape:"label"},{id:"tpl_node_007",metabolite:"tpl_met_015",x:-260,y:30,shape:"label"},{id:"tpl_node_008",metabolite:"tpl_met_009",x:280,y:340,shape:"label"},{id:"tpl_node_009",metabolite:"tpl_met_016",x:520,y:260,shape:"label"},{id:"tpl_node_010",metabolite:"tpl_met_017",x:520,y:340,shape:"label"},{id:"tpl_node_011",metabolite:"tpl_met_018",x:520,y:420,shape:"label"},{id:"tpl_node_012",metabolite:"tpl_met_019",x:260,y:510,shape:"label"},{id:"tpl_node_013",metabolite:"tpl_met_010",x:-260,y:510,shape:"label"},{id:"tpl_node_014",metabolite:"tpl_met_020",x:-480,y:450,shape:"label"},{id:"tpl_node_015",metabolite:"tpl_met_021",x:-480,y:570,shape:"label"},{id:"tpl_node_016",metabolite:"tpl_met_005",x:0,y:690,shape:"label"},{id:"tpl_node_017",metabolite:"tpl_met_022",x:-260,y:690,shape:"label"},{id:"tpl_node_018",metabolite:"tpl_met_023",x:-500,y:690,shape:"label"},{id:"tpl_node_019",metabolite:"tpl_met_011",x:-260,y:850,shape:"label"},{id:"tpl_node_020",metabolite:"tpl_met_024",x:-500,y:850,shape:"label"},{id:"tpl_node_021",metabolite:"tpl_met_012",x:-260,y:1010,shape:"label"},{id:"tpl_node_022",metabolite:"tpl_met_026",x:-500,y:1010,shape:"label"},{id:"tpl_node_023",metabolite:"tpl_met_025",x:-260,y:1170,shape:"label"},{id:"tpl_node_024",metabolite:"tpl_met_027",x:-500,y:1170,shape:"label"},{id:"tpl_node_025",metabolite:"tpl_met_006",x:240,y:810,shape:"label"},{id:"tpl_node_026",metabolite:"tpl_met_028",x:480,y:810,shape:"label"},{id:"tpl_node_027",metabolite:"tpl_met_030",x:480,y:660,shape:"label"},{id:"tpl_node_028",metabolite:"tpl_met_029",x:720,y:810,shape:"label"},{id:"tpl_node_029",metabolite:"tpl_met_031",x:480,y:960,shape:"label"},{id:"tpl_node_030",metabolite:"tpl_met_007",x:240,y:1130,shape:"label"},{id:"tpl_node_031",metabolite:"tpl_met_008",x:480,y:1130,shape:"label"},{id:"tpl_node_032",metabolite:"tpl_met_032",x:720,y:1130,shape:"label"},{id:"tpl_node_033",metabolite:"tpl_met_024",x:240,y:970,shape:"label"},{id:"tpl_node_034",metabolite:"tpl_met_034",x:19.7,y:409,attach:{reaction:"tpl_rxn_003",side:"in"}},{id:"tpl_node_035",metabolite:"tpl_met_033",x:19.7,y:441,attach:{reaction:"tpl_rxn_003",side:"out"}},{id:"tpl_node_036",metabolite:"tpl_met_045",x:-344.3,y:186,attach:{reaction:"tpl_rxn_005",side:"in"}},{id:"tpl_node_037",metabolite:"tpl_met_046",x:-405.4,y:186,attach:{reaction:"tpl_rxn_005",side:"out"}},{id:"tpl_node_038",metabolite:"tpl_met_047",x:95.6,y:324,attach:{reaction:"tpl_rxn_007",side:"in"}},{id:"tpl_node_039",metabolite:"tpl_met_028",x:106.2,y:494,attach:{reaction:"tpl_rxn_011",side:"in"}},{id:"tpl_node_040",metabolite:"tpl_met_006",x:177.1,y:494,attach:{reaction:"tpl_rxn_011",side:"out"}},{id:"tpl_node_041",metabolite:"tpl_met_028",x:-336.9,y:447.8,attach:{reaction:"tpl_rxn_013",side:"in"}},{id:"tpl_node_042",metabolite:"tpl_met_006",x:-402.3,y:423.5,attach:{reaction:"tpl_rxn_013",side:"out"}},{id:"tpl_node_043",metabolite:"tpl_met_033",x:19.7,y:584,attach:{reaction:"tpl_rxn_015",side:"in"}},{id:"tpl_node_044",metabolite:"tpl_met_044",x:24.3,y:568,attach:{reaction:"tpl_rxn_015",side:"in"}},{id:"tpl_node_045",metabolite:"tpl_met_034",x:19.7,y:616,attach:{reaction:"tpl_rxn_015",side:"out"}},{id:"tpl_node_046",metabolite:"tpl_met_037",x:16.6,y:632,attach:{reaction:"tpl_rxn_015",side:"out"}},{id:"tpl_node_047",metabolite:"tpl_met_028",x:-106.2,y:706,attach:{reaction:"tpl_rxn_016",side:"in"}},{id:"tpl_node_048",metabolite:"tpl_met_006",x:-177.1,y:706,attach:{reaction:"tpl_rxn_016",side:"out"}},{id:"tpl_node_049",metabolite:"tpl_met_029",x:-356.2,y:706,attach:{reaction:"tpl_rxn_017",side:"in"}},{id:"tpl_node_050",metabolite:"tpl_met_028",x:-403.8,y:706,attach:{reaction:"tpl_rxn_017",side:"out"}},{id:"tpl_node_051",metabolite:"tpl_met_041",x:-235.2,y:914,attach:{reaction:"tpl_rxn_020",side:"in"}},{id:"tpl_node_052",metabolite:"tpl_met_040",x:-235.7,y:946,attach:{reaction:"tpl_rxn_020",side:"out"}},{id:"tpl_node_053",metabolite:"tpl_met_048",x:86.5,y:734.6,attach:{reaction:"tpl_rxn_024",side:"in"}},{id:"tpl_node_054",metabolite:"tpl_met_043",x:334.3,y:794,attach:{reaction:"tpl_rxn_025",side:"in"}},{id:"tpl_node_055",metabolite:"tpl_met_041",x:293.6,y:794,attach:{reaction:"tpl_rxn_025",side:"in"}},{id:"tpl_node_056",metabolite:"tpl_met_040",x:390.3,y:794,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_057",metabolite:"tpl_met_033",x:574.3,y:794,attach:{reaction:"tpl_rxn_026",side:"in"}},{id:"tpl_node_058",metabolite:"tpl_met_043",x:549,y:794,attach:{reaction:"tpl_rxn_026",side:"in"}},{id:"tpl_node_059",metabolite:"tpl_met_034",x:625.7,y:794,attach:{reaction:"tpl_rxn_026",side:"out"}},{id:"tpl_node_060",metabolite:"tpl_met_037",x:641.9,y:794,attach:{reaction:"tpl_rxn_026",side:"out"}},{id:"tpl_node_061",metabolite:"tpl_met_033",x:334.3,y:1114,attach:{reaction:"tpl_rxn_030",side:"in"}},{id:"tpl_node_062",metabolite:"tpl_met_035",x:385.7,y:1114,attach:{reaction:"tpl_rxn_030",side:"out"}}],ports:[{id:"tpl_node_063",connector:"tpl_port_001",x:0,y:-110,from:"tpl_node_001"},{id:"tpl_node_064",connector:"tpl_port_002",x:0,y:1130,from:"tpl_node_030"},{id:"tpl_node_065",connector:"tpl_port_003",x:240,y:700,from:"tpl_node_025"},{id:"tpl_node_066",connector:"tpl_port_004",x:1010,y:810,from:"tpl_node_028"}],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_002"],targets:["tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_005",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_006",sources:["tpl_node_005"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_007",sources:["tpl_node_003"],targets:["tpl_node_008"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"curved",bend:25,label_flip:!0,label_offset:{x:-6.8,y:-20.5}},{reaction:"tpl_rxn_009",sources:["tpl_node_008"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_008"],targets:["tpl_node_011"],routing:"curved",bend:24,label_offset:{x:-6.8,y:20.4}},{reaction:"tpl_rxn_011",sources:["tpl_node_004"],targets:["tpl_node_012"],routing:"straight"},{reaction:"tpl_rxn_012",sources:["tpl_node_004"],targets:["tpl_node_013"],routing:"straight"},{reaction:"tpl_rxn_013",sources:["tpl_node_013"],targets:["tpl_node_014"],routing:"curved",bend:22,label_offset:{x:4.3,y:-15.7}},{reaction:"tpl_rxn_014",sources:["tpl_node_013"],targets:["tpl_node_015"],routing:"curved",bend:22,label_flip:!0,label_offset:{x:5.3,y:19.5}},{reaction:"tpl_rxn_015",sources:["tpl_node_004"],targets:["tpl_node_016"],routing:"straight"},{reaction:"tpl_rxn_016",sources:["tpl_node_016"],targets:["tpl_node_017"],routing:"straight"},{reaction:"tpl_rxn_017",sources:["tpl_node_017"],targets:["tpl_node_018"],routing:"straight"},{reaction:"tpl_rxn_018",sources:["tpl_node_017"],targets:["tpl_node_019"],routing:"straight"},{reaction:"tpl_rxn_019",sources:["tpl_node_019"],targets:["tpl_node_020"],routing:"straight"},{reaction:"tpl_rxn_020",sources:["tpl_node_019"],targets:["tpl_node_021"],routing:"straight"},{reaction:"tpl_rxn_021",sources:["tpl_node_021"],targets:["tpl_node_023"],routing:"straight"},{reaction:"tpl_rxn_022",sources:["tpl_node_021"],targets:["tpl_node_022"],routing:"straight"},{reaction:"tpl_rxn_023",sources:["tpl_node_023"],targets:["tpl_node_024"],routing:"straight"},{reaction:"tpl_rxn_024",sources:["tpl_node_016"],targets:["tpl_node_025"],routing:"curved",bend:27,label_offset:{x:-11.4,y:22.8}},{reaction:"tpl_rxn_025",sources:["tpl_node_025"],targets:["tpl_node_026"],routing:"straight"},{reaction:"tpl_rxn_026",sources:["tpl_node_026"],targets:["tpl_node_028"],routing:"straight"},{reaction:"tpl_rxn_027",sources:["tpl_node_026"],targets:["tpl_node_027"],routing:"straight"},{reaction:"tpl_rxn_028",sources:["tpl_node_026"],targets:["tpl_node_029"],routing:"straight"},{reaction:"tpl_rxn_029",sources:["tpl_node_025"],targets:["tpl_node_033"],routing:"straight"},{reaction:"tpl_rxn_030",sources:["tpl_node_030"],targets:["tpl_node_031"],routing:"straight"},{reaction:"tpl_rxn_031",sources:["tpl_node_031"],targets:["tpl_node_032"],routing:"straight"}],groups:[{id:"tpl_grp_001",kind:"pathway",title:"Serine family",nodes:["tpl_node_005","tpl_node_006","tpl_node_007"],fill:"#eaf2fd",padding:34},{id:"tpl_grp_002",kind:"pathway",title:"Aromatic family",nodes:["tpl_node_008","tpl_node_009","tpl_node_010","tpl_node_011"],fill:"#f1ebfb",padding:34},{id:"tpl_grp_003",kind:"pathway",title:"Pyruvate family",nodes:["tpl_node_013","tpl_node_014","tpl_node_015"],fill:"#e9f6ee",padding:34},{id:"tpl_grp_004",kind:"pathway",title:"Aspartate family",nodes:["tpl_node_017","tpl_node_018","tpl_node_019","tpl_node_020","tpl_node_021","tpl_node_022","tpl_node_023","tpl_node_024"],fill:"#fdf1e4",padding:34},{id:"tpl_grp_005",kind:"pathway",title:"Glutamate family",nodes:["tpl_node_026","tpl_node_028","tpl_node_027","tpl_node_029"],fill:"#fcebee",padding:34},{id:"tpl_grp_006",kind:"pathway",title:"Histidine",nodes:["tpl_node_031","tpl_node_032"],fill:"#e8f6f6",padding:34}],labels:[{id:"tpl_lbl_001",x:-700,y:-150,text:"Amino acid biosynthesis",size:16,weight:700,kind:"title"},{id:"tpl_lbl_002",x:-700,y:-130,text:"overview after KEGG map01230 · drawn by GEMsMAP",size:10,weight:400,italic:!0,kind:"text"}]},PN={format:EN,schema_version:GN,metadata:SN,biology:AN,layout:DN},RN="gemsmap-template",IN="1.0.0",BN={id:"central-carbon",name:"Global central carbon metabolism",description:"Glycolysis, the oxidative pentose phosphate pathway and the TCA cycle in one figure. Maps onto any reasonably annotated GEM.",pathway:"Central carbon metabolism (glycolysis + PPP + TCA)",section:"Central carbon",template_version:"2.0.0",scope:{level:"universal",taxa:[],note:"Universal core; the TCA part is mitochondrial in eukaryotes."},authors:["GEMsMAP"],created:"2026-10-02T00:00:00.000Z",modified:"2026-10-08T00:00:00.000Z",license:"MIT",tags:["central carbon","global"],citations:[],layout_kind:"composite"},HN={compartments:[{id:"cytosol",fallback:["intracellular"]},{id:"mitochondria",fallback:["cytosol","intracellular"],note:"The TCA cycle is mitochondrial in eukaryotes; prokaryote-like models run it in the cytoplasm."}],entities:[{id:"tpl_ent_001",name:"D-Glucose",short:"glc_D",formula:"C6H12O6",synonyms:["glucose","D-glucose","dextrose","D-glucopyranose","Glc"],identifiers:{"kegg.compound":["C00031"],chebi:["17634","4167"],"bigg.metabolite":["glc__D","glc_D"],"seed.compound":["cpd00027"],"metacyc.compound":["GLC","D-GLUCOSE"],hmdb:["HMDB0000122"]},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],identifiers:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glucose"},{id:"tpl_ent_002",name:"D-Glucose 6-phosphate",short:"g6p",formula:"C6H13O9P",synonyms:["glucose 6-phosphate","D-glucose 6-phosphate","glucose-6-phosphate","G6P","D-glucopyranose 6-phosphate","Robison ester"],identifiers:{"kegg.compound":["C00092"],chebi:["14314","4170","61548"],"bigg.metabolite":["g6p"],"seed.compound":["cpd00079"],"metacyc.compound":["GLC-6-P","D-GLUCOSE-6-PHOSPHATE"],hmdb:["HMDB0001401"]},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],identifiers:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glucose-6-phosphate"},{id:"tpl_ent_003",name:"D-Fructose 6-phosphate",short:"f6p",formula:"C6H13O9P",synonyms:["fructose 6-phosphate","D-fructose 6-phosphate","fructose-6-phosphate","F6P","Neuberg ester"],identifiers:{"kegg.compound":["C00085"],chebi:["15946","61527"],"bigg.metabolite":["f6p"],"seed.compound":["cpd00072"],"metacyc.compound":["FRUCTOSE-6P"],hmdb:["HMDB0000124"]},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],identifiers:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-fructose-6-phosphate"},{id:"tpl_ent_004",name:"D-Fructose 1,6-bisphosphate",short:"fdp",formula:"C6H14O12P2",synonyms:["fructose 1,6-bisphosphate","D-fructose 1,6-bisphosphate","fructose 1,6-diphosphate","fructose-1,6-bisphosphate","FBP","F16BP","Harden-Young ester"],identifiers:{"kegg.compound":["C00354"],chebi:["49299","32966"],"bigg.metabolite":["fdp"],"seed.compound":["cpd00290"],"metacyc.compound":["FRUCTOSE-16-DIPHOSPHATE"],hmdb:["HMDB0001058"]},related:[{note:"ring form of D-fructose 1,6-bisphosphate",names:["beta-D-fructose 1,6-bisphosphate","beta-D-fructofuranose 1,6-bisphosphate"],identifiers:{"kegg.compound":["C05378"],chebi:["28013"],"bigg.metabolite":["fdp_B"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-fructose-1,6-bisphosphate"},{id:"tpl_ent_005",name:"Dihydroxyacetone phosphate",short:"dhap",formula:"C3H7O6P",synonyms:["dihydroxyacetone phosphate","glycerone phosphate","DHAP","dihydroxy-acetone phosphate","glycerone-phosphate"],identifiers:{"kegg.compound":["C00111"],chebi:["16108","57642"],"bigg.metabolite":["dhap"],"seed.compound":["cpd00095"],"metacyc.compound":["DIHYDROXY-ACETONE-PHOSPHATE"],hmdb:["HMDB0001473"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"dihydroxyacetone-phosphate"},{id:"tpl_ent_006",name:"D-Glyceraldehyde 3-phosphate",short:"g3p",formula:"C3H7O6P",synonyms:["glyceraldehyde 3-phosphate","D-glyceraldehyde 3-phosphate","glyceraldehyde-3-phosphate","GAP","G3P","D-glyceraldehyde-3-phosphate"],identifiers:{"kegg.compound":["C00118"],chebi:["29052","59776"],"bigg.metabolite":["g3p"],"seed.compound":["cpd00102"],"metacyc.compound":["GAP"],hmdb:["HMDB0001112"]},related:[{note:"stereo-unspecified glyceraldehyde 3-phosphate",names:["glyceraldehyde 3-phosphate"],identifiers:{"kegg.compound":["C00661"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glyceraldehyde-3-phosphate"},{id:"tpl_ent_007",name:"3-Phospho-D-glyceroyl phosphate",short:"13dpg",formula:"C3H8O10P2",synonyms:["3-phospho-D-glyceroyl phosphate","1,3-bisphospho-D-glycerate","1,3-bisphosphoglycerate","1,3-diphosphoglycerate","glycerate 1,3-bisphosphate","1,3-BPG","13BPG","3-phospho-D-glyceroyl-phosphate"],identifiers:{"kegg.compound":["C00236"],chebi:["16001","57604"],"bigg.metabolite":["13dpg"],"seed.compound":["cpd00203"],"metacyc.compound":["DPG"],hmdb:["HMDB0001270"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"1,3-bisphosphoglycerate"},{id:"tpl_ent_008",name:"3-Phospho-D-glycerate",short:"3pg",formula:"C3H7O7P",synonyms:["3-phospho-D-glycerate","3-phosphoglycerate","glycerate 3-phosphate","3-phosphoglyceric acid","3PG","D-glycerate 3-phosphate"],identifiers:{"kegg.compound":["C00197"],chebi:["17794","58272"],"bigg.metabolite":["3pg"],"seed.compound":["cpd00169"],"metacyc.compound":["G3P"],hmdb:["HMDB0000807"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"3-phospho-D-glycerate"},{id:"tpl_ent_009",name:"2-Phospho-D-glycerate",short:"2pg",formula:"C3H7O7P",synonyms:["2-phospho-D-glycerate","D-glycerate 2-phosphate","2-phosphoglycerate","glycerate 2-phosphate","2PG","2-phosphoglyceric acid"],identifiers:{"kegg.compound":["C00631"],chebi:["17835","58289"],"bigg.metabolite":["2pg"],"seed.compound":["cpd00482"],"metacyc.compound":["2-PG"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"2-phospho-D-glycerate"},{id:"tpl_ent_010",name:"Phosphoenolpyruvate",short:"pep",formula:"C3H5O6P",synonyms:["phosphoenolpyruvate","phosphoenolpyruvic acid","PEP","phospho-enol-pyruvate"],identifiers:{"kegg.compound":["C00074"],chebi:["18021","58702"],"bigg.metabolite":["pep"],"seed.compound":["cpd00061"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],hmdb:["HMDB0000263"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"phosphoenolpyruvate"},{id:"tpl_ent_011",name:"Pyruvate",short:"pyr",formula:"C3H4O3",synonyms:["pyruvate","pyruvic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816"],"bigg.metabolite":["pyr"],"seed.compound":["cpd00020"],"metacyc.compound":["PYRUVATE"],hmdb:["HMDB0000243"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"pyruvate"},{id:"tpl_ent_012",name:"L-Lactate",short:"lac_L",formula:"C3H6O3",synonyms:["L-lactate","(S)-lactate","L-lactic acid","(S)-lactic acid","L-lac"],identifiers:{"kegg.compound":["C00186"],chebi:["16651","422"],"bigg.metabolite":["lac__L","lac_L"],"seed.compound":["cpd00159"],"metacyc.compound":["L-LACTATE"],hmdb:["HMDB0000190"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"L-lactate"},{id:"tpl_ent_013",name:"D-Lactate",short:"lac_D",formula:"C3H6O3",synonyms:["D-lactate","(R)-lactate","D-lactic acid","(R)-lactic acid","D-lac"],identifiers:{"kegg.compound":["C00256"],chebi:["16004","42111"],"bigg.metabolite":["lac__D","lac_D"],"seed.compound":["cpd00221"],"metacyc.compound":["D-LACTATE"],hmdb:["HMDB0001311"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-lactate"},{id:"tpl_ent_014",name:"Acetyl-CoA",short:"accoa",formula:"C23H38N7O17P3S",synonyms:["acetyl-CoA","acetyl coenzyme A","acetyl-coenzyme A","AcCoA"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288"],"bigg.metabolite":["accoa"],"seed.compound":["cpd00022"],"metacyc.compound":["ACETYL-COA"],hmdb:["HMDB0001206"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"acetyl-CoA"},{id:"tpl_ent_015",name:"6-Phospho-D-glucono-1,5-lactone",short:"6pgl",formula:"C6H11O9P",synonyms:["6-phospho-D-glucono-1,5-lactone","6-phosphogluconolactone","6-O-phosphono-D-glucono-1,5-lactone","D-glucono-1,5-lactone 6-phosphate","6-phosphoglucono-delta-lactone","6PGL"],identifiers:{"kegg.compound":["C01236"],chebi:["16938","57955"],"bigg.metabolite":["6pgl"],"seed.compound":["cpd00911"],"metacyc.compound":["D-6-P-GLUCONO-DELTA-LACTONE"],hmdb:["HMDB0001127"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"6-phosphogluconolactone"},{id:"tpl_ent_016",name:"6-Phospho-D-gluconate",short:"6pgc",formula:"C6H13O10P",synonyms:["6-phospho-D-gluconate","6-phosphogluconate","6-phosphogluconic acid","D-gluconate 6-phosphate","6PG"],identifiers:{"kegg.compound":["C00345"],chebi:["48928","58759"],"bigg.metabolite":["6pgc"],"seed.compound":["cpd00284"],"metacyc.compound":["CPD-2961"],hmdb:["HMDB0001316"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"6-phospho-D-gluconate"},{id:"tpl_ent_017",name:"D-Ribulose 5-phosphate",short:"ru5p_D",formula:"C5H11O8P",synonyms:["D-ribulose 5-phosphate","ribulose 5-phosphate","ribulose-5-phosphate","Ru5P"],identifiers:{"kegg.compound":["C00199"],chebi:["17363","58121"],"bigg.metabolite":["ru5p__D","ru5p_D"],"seed.compound":["cpd00171"],"metacyc.compound":["RIBULOSE-5P"],hmdb:["HMDB0000618"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-ribulose-5-phosphate"},{id:"tpl_ent_018",name:"D-Ribose 5-phosphate",short:"r5p",formula:"C5H11O8P",synonyms:["D-ribose 5-phosphate","ribose 5-phosphate","ribose-5-phosphate","R5P","alpha-D-ribose 5-phosphate"],identifiers:{"kegg.compound":["C00117"],chebi:["17797","78346"],"bigg.metabolite":["r5p"],"seed.compound":["cpd00101"],"metacyc.compound":["RIBOSE-5P"],hmdb:["HMDB0001548"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-ribose-5-phosphate"},{id:"tpl_ent_019",name:"D-Xylulose 5-phosphate",short:"xu5p_D",formula:"C5H11O8P",synonyms:["D-xylulose 5-phosphate","xylulose 5-phosphate","xylulose-5-phosphate","Xu5P"],identifiers:{"kegg.compound":["C00231"],chebi:["16332","57737"],"bigg.metabolite":["xu5p__D","xu5p_D"],"seed.compound":["cpd00198"],"metacyc.compound":["XYLULOSE-5-PHOSPHATE"],hmdb:["HMDB0000868"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-xylulose-5-phosphate"},{id:"tpl_ent_020",name:"Citrate",short:"cit",formula:"C6H8O7",synonyms:["citrate","citric acid","2-hydroxypropane-1,2,3-tricarboxylate","Cit"],identifiers:{"kegg.compound":["C00158"],chebi:["16947","30769"],"bigg.metabolite":["cit"],"seed.compound":["cpd00137"],"metacyc.compound":["CIT"],hmdb:["HMDB0000094"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"citrate"},{id:"tpl_ent_021",name:"Isocitrate",short:"icit",formula:"C6H8O7",synonyms:["isocitrate","isocitric acid","D-threo-isocitrate","threo-Ds-isocitrate","(2R,3S)-isocitrate","D-isocitrate"],identifiers:{"kegg.compound":["C00311"],chebi:["16087","30887"],"bigg.metabolite":["icit"],"seed.compound":["cpd00260"],"metacyc.compound":["THREO-DS-ISO-CITRATE"],hmdb:["HMDB0000193"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"isocitrate"},{id:"tpl_ent_022",name:"2-Oxoglutarate",short:"akg",formula:"C5H6O5",synonyms:["2-oxoglutarate","alpha-ketoglutarate","2-ketoglutarate","oxoglutarate","2-oxoglutaric acid","alpha-ketoglutaric acid","AKG","2-oxopentanedioate"],identifiers:{"kegg.compound":["C00026"],chebi:["16810","30915"],"bigg.metabolite":["akg"],"seed.compound":["cpd00024"],"metacyc.compound":["2-KETOGLUTARATE"],hmdb:["HMDB0000208"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"2-oxoglutarate"},{id:"tpl_ent_023",name:"Succinyl-CoA",short:"succoa",formula:"C25H40N7O19P3S",synonyms:["succinyl-CoA","succinyl coenzyme A","succinyl-coenzyme A","SucCoA"],identifiers:{"kegg.compound":["C00091"],chebi:["15380","57292"],"bigg.metabolite":["succoa"],"seed.compound":["cpd00078"],"metacyc.compound":["SUC-COA"],hmdb:["HMDB0001022"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"succinyl-CoA"},{id:"tpl_ent_024",name:"Succinate",short:"succ",formula:"C4H6O4",synonyms:["succinate","succinic acid","butanedioate","butanedioic acid","Succ"],identifiers:{"kegg.compound":["C00042"],chebi:["26806","30031","15741"],"bigg.metabolite":["succ"],"seed.compound":["cpd00036"],"metacyc.compound":["SUC"],hmdb:["HMDB0000254"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"succinate"},{id:"tpl_ent_025",name:"Fumarate",short:"fum",formula:"C4H4O4",synonyms:["fumarate","fumaric acid","trans-butenedioate","(E)-butenedioate","Fum"],identifiers:{"kegg.compound":["C00122"],chebi:["29806","18012"],"bigg.metabolite":["fum"],"seed.compound":["cpd00106"],"metacyc.compound":["FUM"],hmdb:["HMDB0000134"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"fumarate"},{id:"tpl_ent_026",name:"L-Malate",short:"mal_L",formula:"C4H6O5",synonyms:["L-malate","(S)-malate","L-malic acid","(S)-malic acid","Mal"],identifiers:{"kegg.compound":["C00149"],chebi:["15589","30797"],"bigg.metabolite":["mal__L","mal_L"],"seed.compound":["cpd00130"],"metacyc.compound":["MAL"],hmdb:["HMDB0000156"]},related:[{note:"stereo-unspecified malate",names:["malate","malic acid"],identifiers:{"kegg.compound":["C00711"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"L-malate"},{id:"tpl_ent_027",name:"Oxaloacetate",short:"oaa",formula:"C4H4O5",synonyms:["oxaloacetate","oxaloacetic acid","oxalacetate","2-oxosuccinate","OAA"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744"],"bigg.metabolite":["oaa"],"seed.compound":["cpd00032"],"metacyc.compound":["OXALACETIC_ACID"],hmdb:["HMDB0000223"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"oxaloacetate"},{id:"tpl_ent_028",name:"ATP",short:"atp",formula:"C10H16N5O13P3",synonyms:["ATP","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616"],"bigg.metabolite":["atp"],"seed.compound":["cpd00002"],"metacyc.compound":["ATP"],hmdb:["HMDB0000538"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ATP"},{id:"tpl_ent_029",name:"ADP",short:"adp",formula:"C10H15N5O10P2",synonyms:["ADP","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216"],"bigg.metabolite":["adp"],"seed.compound":["cpd00008"],"metacyc.compound":["ADP"],hmdb:["HMDB0001341"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ADP"},{id:"tpl_ent_030",name:"NAD+",short:"nad",formula:"C21H28N7O14P2",synonyms:["NAD+","NAD","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540"],"bigg.metabolite":["nad"],"seed.compound":["cpd00003"],"metacyc.compound":["NAD"],hmdb:["HMDB0000902"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NAD+"},{id:"tpl_ent_031",name:"Orthophosphate",short:"pi",formula:"H3PO4",synonyms:["phosphate","orthophosphate","Pi","inorganic phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078"],"bigg.metabolite":["pi"],"seed.compound":["cpd00009"],"metacyc.compound":["Pi"],hmdb:["HMDB0001429"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"phosphate"},{id:"tpl_ent_032",name:"NADH",short:"nadh",formula:"C21H29N7O14P2",synonyms:["NADH","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945"],"bigg.metabolite":["nadh"],"seed.compound":["cpd00004"],"metacyc.compound":["NADH"],hmdb:["HMDB0001487"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADH"},{id:"tpl_ent_033",name:"H2O",short:"h2o",formula:"H2O",synonyms:["H2O","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377"],"bigg.metabolite":["h2o"],"seed.compound":["cpd00001"],"metacyc.compound":["WATER"],hmdb:["HMDB0002111"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"H2O"},{id:"tpl_ent_034",name:"Coenzyme A",short:"coa",formula:"C21H36N7O16P3S",synonyms:["CoA","coenzyme A","CoA-SH"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287"],"bigg.metabolite":["coa"],"seed.compound":["cpd00010"],"metacyc.compound":["CO-A"],hmdb:["HMDB0001423"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CoA"},{id:"tpl_ent_035",name:"CO2",short:"co2",formula:"CO2",synonyms:["CO2","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526"],"bigg.metabolite":["co2"],"seed.compound":["cpd00011"],"metacyc.compound":["CARBON-DIOXIDE"],hmdb:["HMDB0001967"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CO2"},{id:"tpl_ent_036",name:"NADP+",short:"nadp",formula:"C21H29N7O17P3",synonyms:["NADP+","NADP","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349"],"bigg.metabolite":["nadp"],"seed.compound":["cpd00006"],"metacyc.compound":["NADP"],hmdb:["HMDB0000217"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADP+"},{id:"tpl_ent_037",name:"NADPH",short:"nadph",formula:"C21H30N7O17P3",synonyms:["NADPH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783"],"bigg.metabolite":["nadph"],"seed.compound":["cpd00005"],"metacyc.compound":["NADPH"],hmdb:["HMDB0000221"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADPH"},{id:"tpl_ent_038",name:"Ubiquinone",short:"q",synonyms:["ubiquinone","coenzyme Q","quinone"],identifiers:{"kegg.compound":["C00399"],chebi:["16389"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ubiquinone"},{id:"tpl_ent_039",name:"Ubiquinol",short:"qh2",synonyms:["ubiquinol","reduced coenzyme Q"],identifiers:{"kegg.compound":["C00390"],chebi:["17976"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ubiquinol"}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:"cytosol",level:"required",aliases:["glc"]},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:"cytosol",level:"required",aliases:["g6p"]},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:"cytosol",level:"required",aliases:["f6p"]},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:"cytosol",level:"required",aliases:["fdp"]},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:"cytosol",level:"required",aliases:["dhap"]},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:"cytosol",level:"required",aliases:["g3p"]},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:"cytosol",level:"required",aliases:["13dpg"]},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:"cytosol",level:"required",aliases:["3pg"]},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:"cytosol",level:"required",aliases:["2pg"]},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:"cytosol",level:"required",aliases:["pep"]},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:"cytosol",level:"required",aliases:["pyr"]},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:"cytosol",level:"optional",alternatives:["tpl_ent_013"],label:"lac",aliases:["lac"]},{id:"tpl_met_013",entity:"tpl_ent_014",compartment:"mitochondria",level:"required",ungrouped:!0,aliases:["accoa"]},{id:"tpl_met_014",entity:"tpl_ent_015",compartment:"cytosol",level:"required",aliases:["6pgl"]},{id:"tpl_met_015",entity:"tpl_ent_016",compartment:"cytosol",level:"required",aliases:["6pgc"]},{id:"tpl_met_016",entity:"tpl_ent_017",compartment:"cytosol",level:"required",aliases:["ru5p"]},{id:"tpl_met_017",entity:"tpl_ent_018",compartment:"cytosol",level:"required",aliases:["r5p"]},{id:"tpl_met_018",entity:"tpl_ent_019",compartment:"cytosol",level:"required",aliases:["xu5p"]},{id:"tpl_met_019",entity:"tpl_ent_020",compartment:"mitochondria",level:"required",aliases:["cit"]},{id:"tpl_met_020",entity:"tpl_ent_021",compartment:"mitochondria",level:"required",aliases:["icit"]},{id:"tpl_met_021",entity:"tpl_ent_022",compartment:"mitochondria",level:"required",aliases:["akg"]},{id:"tpl_met_022",entity:"tpl_ent_023",compartment:"mitochondria",level:"required",aliases:["succoa"]},{id:"tpl_met_023",entity:"tpl_ent_024",compartment:"mitochondria",level:"required",aliases:["succ"]},{id:"tpl_met_024",entity:"tpl_ent_025",compartment:"mitochondria",level:"required",aliases:["fum"]},{id:"tpl_met_025",entity:"tpl_ent_026",compartment:"mitochondria",level:"required",aliases:["mal"]},{id:"tpl_met_026",entity:"tpl_ent_027",compartment:"mitochondria",level:"required",aliases:["oaa"]},{id:"tpl_met_027",entity:"tpl_ent_028",compartment:"cytosol",level:"optional"},{id:"tpl_met_028",entity:"tpl_ent_029",compartment:"cytosol",level:"optional"},{id:"tpl_met_029",entity:"tpl_ent_030",compartment:"cytosol",level:"optional"},{id:"tpl_met_030",entity:"tpl_ent_031",compartment:"cytosol",level:"optional"},{id:"tpl_met_031",entity:"tpl_ent_032",compartment:"cytosol",level:"optional"},{id:"tpl_met_032",entity:"tpl_ent_033",compartment:"cytosol",level:"optional"},{id:"tpl_met_033",entity:"tpl_ent_034",compartment:"mitochondria",level:"optional"},{id:"tpl_met_034",entity:"tpl_ent_030",compartment:"mitochondria",level:"optional"},{id:"tpl_met_035",entity:"tpl_ent_035",compartment:"mitochondria",level:"optional"},{id:"tpl_met_036",entity:"tpl_ent_032",compartment:"mitochondria",level:"optional"},{id:"tpl_met_037",entity:"tpl_ent_036",compartment:"cytosol",level:"optional"},{id:"tpl_met_038",entity:"tpl_ent_037",compartment:"cytosol",level:"optional"},{id:"tpl_met_039",entity:"tpl_ent_035",compartment:"cytosol",level:"optional"},{id:"tpl_met_040",entity:"tpl_ent_033",compartment:"mitochondria",level:"optional"},{id:"tpl_met_041",entity:"tpl_ent_029",compartment:"mitochondria",level:"optional"},{id:"tpl_met_042",entity:"tpl_ent_031",compartment:"mitochondria",level:"optional"},{id:"tpl_met_043",entity:"tpl_ent_028",compartment:"mitochondria",level:"optional"},{id:"tpl_met_044",entity:"tpl_ent_038",compartment:"mitochondria",level:"optional"},{id:"tpl_met_045",entity:"tpl_ent_039",compartment:"mitochondria",level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"HEX",canonicalName:"hexokinase",reversible:!1,ec:["2.7.1.1","2.7.1.2"],level:"required",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_027",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_028",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["HEX1"],"kegg.reaction":["R00299"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["HEX1","HEX","GLCpts","HXK"],aliases:["HEX"]},{id:"tpl_rxn_002",name:"PGI",canonicalName:"glucose-6-phosphate isomerase",reversible:!0,ec:["5.3.1.9"],level:"required",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGI"],"kegg.reaction":["R00771"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGI"],aliases:["PGI"]},{id:"tpl_rxn_003",name:"PFK",canonicalName:"6-phosphofructokinase",reversible:!1,ec:["2.7.1.11"],level:"required",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_027",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_028",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PFK"],"kegg.reaction":["R00756"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PFK"],aliases:["PFK"]},{id:"tpl_rxn_004",name:"FBA",canonicalName:"fructose-bisphosphate aldolase",reversible:!0,ec:["4.1.2.13"],level:"required",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["FBA"],"kegg.reaction":["R01068"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["FBA"],aliases:["FBA"]},{id:"tpl_rxn_005",name:"TPI",canonicalName:"triose-phosphate isomerase",reversible:!0,ec:["5.3.1.1"],level:"required",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["TPI"],"kegg.reaction":["R01015"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["TPI"],aliases:["TPI"]},{id:"tpl_rxn_006",name:"GAPD",canonicalName:"glyceraldehyde-3-phosphate dehydrogenase",reversible:!0,ec:["1.2.1.12"],level:"required",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_029",coefficient:-1,main:!1},{metabolite:"tpl_met_030",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["GAPD"],"kegg.reaction":["R01061"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["GAPD"],aliases:["GAPD"]},{id:"tpl_rxn_007",name:"PGK",canonicalName:"phosphoglycerate kinase",reversible:!0,ec:["2.7.2.3"],level:"required",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_027",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PGK"],"kegg.reaction":["R01512"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGK"],aliases:["PGK"]},{id:"tpl_rxn_008",name:"PGM",canonicalName:"phosphoglycerate mutase",reversible:!0,ec:["5.4.2.11","5.4.2.12"],level:"required",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGM"],"kegg.reaction":["R01518"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGM"],aliases:["PGM"]},{id:"tpl_rxn_009",name:"ENO",canonicalName:"enolase",reversible:!0,ec:["4.2.1.11"],level:"required",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_032",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["ENO"],"kegg.reaction":["R00658"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ENO"],aliases:["ENO"]},{id:"tpl_rxn_010",name:"PYK",canonicalName:"pyruvate kinase",reversible:!1,ec:["2.7.1.40"],level:"required",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_027",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PYK"],"kegg.reaction":["R00200"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PYK"],aliases:["PYK"]},{id:"tpl_rxn_011",name:"LDH",canonicalName:"L-lactate dehydrogenase",reversible:!0,ec:["1.1.1.27","1.1.1.28"],level:"optional",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_031",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["LDH_L"],"kegg.reaction":["R00703"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["LDH_D","LDH_L","LDH"],aliases:["LDH"]},{id:"tpl_rxn_012",name:"PDH",canonicalName:"pyruvate dehydrogenase complex",reversible:!1,ec:["1.2.4.1","2.3.1.12"],level:"optional",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_034",coefficient:-1,main:!1},{metabolite:"tpl_met_013",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1},{metabolite:"tpl_met_036",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PDH"],"kegg.reaction":["R00209"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PDH","PDHm"],aliases:["PDH"]},{id:"tpl_rxn_013",name:"G6PDH",canonicalName:"glucose-6-phosphate dehydrogenase",reversible:!1,ec:["1.1.1.49","1.1.1.363"],level:"required",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["G6PDH2r"],"kegg.reaction":["R00835"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["G6PDH2r","G6PDH"],aliases:["G6PDH"]},{id:"tpl_rxn_014",name:"PGL",canonicalName:"6-phosphogluconolactonase",reversible:!1,ec:["3.1.1.31"],level:"required",participants:[{metabolite:"tpl_met_014",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_015",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGL"],"kegg.reaction":["R02035"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGL"],aliases:["PGL"]},{id:"tpl_rxn_015",name:"GND",canonicalName:"6-phosphogluconate dehydrogenase (decarboxylating)",reversible:!1,ec:["1.1.1.44","1.1.1.351"],level:"required",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1},{metabolite:"tpl_met_038",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["GND"],"kegg.reaction":["R01528"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["GND"],aliases:["GND"]},{id:"tpl_rxn_016",name:"RPI",canonicalName:"ribose-5-phosphate isomerase",reversible:!0,ec:["5.3.1.6"],level:"required",participants:[{metabolite:"tpl_met_016",coefficient:-1,main:!0},{metabolite:"tpl_met_017",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["RPI"],"kegg.reaction":["R01056"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["RPI"],aliases:["RPI"]},{id:"tpl_rxn_017",name:"RPE",canonicalName:"ribulose-phosphate 3-epimerase",reversible:!0,ec:["5.1.3.1"],level:"required",participants:[{metabolite:"tpl_met_016",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["RPE"],"kegg.reaction":["R01529"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["RPE"],aliases:["RPE"]},{id:"tpl_rxn_018",name:"CS",canonicalName:"citrate synthase",reversible:!1,ec:["2.3.3.1","2.3.3.16","2.3.3.3"],level:"required",participants:[{metabolite:"tpl_met_026",coefficient:-1,main:!0},{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_019",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["CS"],"kegg.reaction":["R00351"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["CS","CSm"],aliases:["CS"]},{id:"tpl_rxn_019",name:"ACONT",canonicalName:"aconitate hydratase",reversible:!0,ec:["4.2.1.3"],level:"required",participants:[{metabolite:"tpl_met_019",coefficient:-1,main:!0},{metabolite:"tpl_met_020",coefficient:1,main:!0}],identifiers:{"kegg.reaction":["R01324"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ACONT","ACONTa","ACONTm"],aliases:["ACONT"]},{id:"tpl_rxn_020",name:"ICDH",canonicalName:"isocitrate dehydrogenase",reversible:!1,ec:["1.1.1.41","1.1.1.42"],level:"required",participants:[{metabolite:"tpl_met_020",coefficient:-1,main:!0},{metabolite:"tpl_met_034",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1},{metabolite:"tpl_met_036",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["ICDHyr"],"kegg.reaction":["R00709"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ICDHyr","ICDHy","ICDHxm"],aliases:["ICDH"]},{id:"tpl_rxn_021",name:"AKGDH",canonicalName:"2-oxoglutarate dehydrogenase complex",reversible:!1,ec:["1.2.4.2","1.2.1.105"],level:"required",participants:[{metabolite:"tpl_met_021",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_034",coefficient:-1,main:!1},{metabolite:"tpl_met_022",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1},{metabolite:"tpl_met_036",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["AKGDH"],"kegg.reaction":["R08549"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["AKGDH","AKGDm"],aliases:["AKGDH"]},{id:"tpl_rxn_022",name:"SUCOAS",canonicalName:"succinyl-CoA synthetase",reversible:!0,ec:["6.2.1.4","6.2.1.5"],level:"required",participants:[{metabolite:"tpl_met_022",coefficient:-1,main:!0},{metabolite:"tpl_met_041",coefficient:-1,main:!1},{metabolite:"tpl_met_042",coefficient:-1,main:!1},{metabolite:"tpl_met_023",coefficient:1,main:!0},{metabolite:"tpl_met_043",coefficient:1,main:!1},{metabolite:"tpl_met_033",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["SUCOAS"],"kegg.reaction":["R00405"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["SUCOAS","SUCOASm"],aliases:["SUCOAS"]},{id:"tpl_rxn_023",name:"SDH",canonicalName:"succinate dehydrogenase",reversible:!1,ec:["1.3.5.1","1.3.5.4"],level:"required",participants:[{metabolite:"tpl_met_023",coefficient:-1,main:!0},{metabolite:"tpl_met_044",coefficient:-1,main:!1},{metabolite:"tpl_met_024",coefficient:1,main:!0},{metabolite:"tpl_met_045",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["SUCDi"],"kegg.reaction":["R02164"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["SUCDi","SUCD1","SUCD1m","SDH"],aliases:["SDH"]},{id:"tpl_rxn_024",name:"FUM",canonicalName:"fumarate hydratase",reversible:!0,ec:["4.2.1.2"],level:"required",participants:[{metabolite:"tpl_met_024",coefficient:-1,main:!0},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_025",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["FUM"],"kegg.reaction":["R01082"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["FUM","FUMm"],aliases:["FUM"]},{id:"tpl_rxn_025",name:"MDH",canonicalName:"malate dehydrogenase",reversible:!0,ec:["1.1.1.37"],level:"required",participants:[{metabolite:"tpl_met_025",coefficient:-1,main:!0},{metabolite:"tpl_met_034",coefficient:-1,main:!1},{metabolite:"tpl_met_026",coefficient:1,main:!0},{metabolite:"tpl_met_036",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["MDH"],"kegg.reaction":["R00342"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["MDH","MDHm"],aliases:["MDH"]}],connectors:[]},ON={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:0},{id:"tpl_node_002",metabolite:"tpl_met_002",x:0,y:60},{id:"tpl_node_003",metabolite:"tpl_met_003",x:0,y:120},{id:"tpl_node_004",metabolite:"tpl_met_004",x:0,y:180},{id:"tpl_node_005",metabolite:"tpl_met_005",x:-60,y:210,label_pos:"left"},{id:"tpl_node_006",metabolite:"tpl_met_006",x:0,y:240},{id:"tpl_node_007",metabolite:"tpl_met_007",x:0,y:300},{id:"tpl_node_008",metabolite:"tpl_met_008",x:0,y:360},{id:"tpl_node_009",metabolite:"tpl_met_009",x:0,y:420},{id:"tpl_node_010",metabolite:"tpl_met_010",x:0,y:480},{id:"tpl_node_011",metabolite:"tpl_met_011",x:0,y:540},{id:"tpl_node_012",metabolite:"tpl_met_012",x:0,y:630},{id:"tpl_node_013",metabolite:"tpl_met_013",x:110,y:540,label_pos:"top"},{id:"tpl_node_014",metabolite:"tpl_met_014",x:-120,y:60,label_pos:"top"},{id:"tpl_node_015",metabolite:"tpl_met_015",x:-220,y:60,label_pos:"top"},{id:"tpl_node_016",metabolite:"tpl_met_016",x:-220,y:150,label_pos:"left"},{id:"tpl_node_017",metabolite:"tpl_met_017",x:-280,y:228,label_pos:"left"},{id:"tpl_node_018",metabolite:"tpl_met_018",x:-160,y:228},{id:"tpl_node_019",metabolite:"tpl_met_019",x:250,y:595,label_pos:"top"},{id:"tpl_node_020",metabolite:"tpl_met_020",x:317,y:623,label_pos:"right"},{id:"tpl_node_021",metabolite:"tpl_met_021",x:345,y:690,label_pos:"right"},{id:"tpl_node_022",metabolite:"tpl_met_022",x:317,y:757,label_pos:"right"},{id:"tpl_node_023",metabolite:"tpl_met_023",x:250,y:785,label_pos:"bottom"},{id:"tpl_node_024",metabolite:"tpl_met_024",x:183,y:757,label_pos:"left"},{id:"tpl_node_025",metabolite:"tpl_met_025",x:155,y:690,label_pos:"left"},{id:"tpl_node_026",metabolite:"tpl_met_026",x:183,y:623,label_pos:"left"}],ports:[],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_004"],targets:["tpl_node_006","tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_005",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_006",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_007",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"straight"},{reaction:"tpl_rxn_009",sources:["tpl_node_009"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_010"],targets:["tpl_node_011"],routing:"straight"},{reaction:"tpl_rxn_011",sources:["tpl_node_011"],targets:["tpl_node_012"],routing:"straight"},{reaction:"tpl_rxn_012",sources:["tpl_node_011"],targets:["tpl_node_013"],routing:"straight"},{reaction:"tpl_rxn_013",sources:["tpl_node_002"],targets:["tpl_node_014"],routing:"straight"},{reaction:"tpl_rxn_014",sources:["tpl_node_014"],targets:["tpl_node_015"],routing:"straight"},{reaction:"tpl_rxn_015",sources:["tpl_node_015"],targets:["tpl_node_016"],routing:"straight"},{reaction:"tpl_rxn_016",sources:["tpl_node_016"],targets:["tpl_node_017"],routing:"straight"},{reaction:"tpl_rxn_017",sources:["tpl_node_016"],targets:["tpl_node_018"],routing:"straight"},{reaction:"tpl_rxn_018",sources:["tpl_node_026","tpl_node_013"],targets:["tpl_node_019"],routing:"curved",bend:-12},{reaction:"tpl_rxn_019",sources:["tpl_node_019"],targets:["tpl_node_020"],routing:"curved",bend:-12},{reaction:"tpl_rxn_020",sources:["tpl_node_020"],targets:["tpl_node_021"],routing:"curved",bend:-12},{reaction:"tpl_rxn_021",sources:["tpl_node_021"],targets:["tpl_node_022"],routing:"curved",bend:-12},{reaction:"tpl_rxn_022",sources:["tpl_node_022"],targets:["tpl_node_023"],routing:"curved",bend:-12},{reaction:"tpl_rxn_023",sources:["tpl_node_023"],targets:["tpl_node_024"],routing:"curved",bend:-12},{reaction:"tpl_rxn_024",sources:["tpl_node_024"],targets:["tpl_node_025"],routing:"curved",bend:-12},{reaction:"tpl_rxn_025",sources:["tpl_node_025"],targets:["tpl_node_026"],routing:"curved",bend:-12}],groups:[{id:"tpl_grp_001",kind:"pathway",title:"Glycolysis",nodes:["tpl_node_001","tpl_node_002","tpl_node_003","tpl_node_004","tpl_node_005","tpl_node_006","tpl_node_007","tpl_node_008","tpl_node_009","tpl_node_010","tpl_node_011","tpl_node_012"]},{id:"tpl_grp_002",kind:"pathway",title:"Pentose phosphate pathway",nodes:["tpl_node_002","tpl_node_014","tpl_node_015","tpl_node_016","tpl_node_017","tpl_node_018"]},{id:"tpl_grp_003",kind:"pathway",title:"TCA cycle",nodes:["tpl_node_019","tpl_node_020","tpl_node_021","tpl_node_022","tpl_node_023","tpl_node_024","tpl_node_025","tpl_node_026"]}],labels:[]},$N={format:RN,schema_version:IN,metadata:BN,biology:HN,layout:ON},LN="gemsmap-template",TN="1.0.0",FN={id:"glycolysis",name:"Glycolysis",description:"Canonical Embden–Meyerhof–Parnas glycolysis: glucose → pyruvate, with the lactate and acetyl-CoA branches.",pathway:"Glycolysis (Embden–Meyerhof–Parnas)",section:"Central carbon",template_version:"2.0.0",scope:{level:"universal",taxa:[],note:"Conserved in nearly all organisms; cytosolic."},authors:["GEMsMAP"],created:"2026-10-02T00:00:00.000Z",modified:"2026-10-08T00:00:00.000Z",license:"MIT",tags:["central carbon","glycolysis","EMP"],citations:[],layout_kind:"vertical"},XN={compartments:[{id:"cytosol",fallback:["intracellular"]},{id:"mitochondria",fallback:["cytosol","intracellular"],note:"The TCA cycle is mitochondrial in eukaryotes; prokaryote-like models run it in the cytoplasm."}],entities:[{id:"tpl_ent_001",name:"D-Glucose",short:"glc_D",formula:"C6H12O6",synonyms:["glucose","D-glucose","dextrose","D-glucopyranose","Glc"],identifiers:{"kegg.compound":["C00031"],chebi:["17634","4167"],"bigg.metabolite":["glc__D","glc_D"],"seed.compound":["cpd00027"],"metacyc.compound":["GLC","D-GLUCOSE"],hmdb:["HMDB0000122"]},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],identifiers:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glucose"},{id:"tpl_ent_002",name:"D-Glucose 6-phosphate",short:"g6p",formula:"C6H13O9P",synonyms:["glucose 6-phosphate","D-glucose 6-phosphate","glucose-6-phosphate","G6P","D-glucopyranose 6-phosphate","Robison ester"],identifiers:{"kegg.compound":["C00092"],chebi:["14314","4170","61548"],"bigg.metabolite":["g6p"],"seed.compound":["cpd00079"],"metacyc.compound":["GLC-6-P","D-GLUCOSE-6-PHOSPHATE"],hmdb:["HMDB0001401"]},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],identifiers:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glucose-6-phosphate"},{id:"tpl_ent_003",name:"D-Fructose 6-phosphate",short:"f6p",formula:"C6H13O9P",synonyms:["fructose 6-phosphate","D-fructose 6-phosphate","fructose-6-phosphate","F6P","Neuberg ester"],identifiers:{"kegg.compound":["C00085"],chebi:["15946","61527"],"bigg.metabolite":["f6p"],"seed.compound":["cpd00072"],"metacyc.compound":["FRUCTOSE-6P"],hmdb:["HMDB0000124"]},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],identifiers:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-fructose-6-phosphate"},{id:"tpl_ent_004",name:"D-Fructose 1,6-bisphosphate",short:"fdp",formula:"C6H14O12P2",synonyms:["fructose 1,6-bisphosphate","D-fructose 1,6-bisphosphate","fructose 1,6-diphosphate","fructose-1,6-bisphosphate","FBP","F16BP","Harden-Young ester"],identifiers:{"kegg.compound":["C00354"],chebi:["49299","32966"],"bigg.metabolite":["fdp"],"seed.compound":["cpd00290"],"metacyc.compound":["FRUCTOSE-16-DIPHOSPHATE"],hmdb:["HMDB0001058"]},related:[{note:"ring form of D-fructose 1,6-bisphosphate",names:["beta-D-fructose 1,6-bisphosphate","beta-D-fructofuranose 1,6-bisphosphate"],identifiers:{"kegg.compound":["C05378"],chebi:["28013"],"bigg.metabolite":["fdp_B"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-fructose-1,6-bisphosphate"},{id:"tpl_ent_005",name:"Dihydroxyacetone phosphate",short:"dhap",formula:"C3H7O6P",synonyms:["dihydroxyacetone phosphate","glycerone phosphate","DHAP","dihydroxy-acetone phosphate","glycerone-phosphate"],identifiers:{"kegg.compound":["C00111"],chebi:["16108","57642"],"bigg.metabolite":["dhap"],"seed.compound":["cpd00095"],"metacyc.compound":["DIHYDROXY-ACETONE-PHOSPHATE"],hmdb:["HMDB0001473"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"dihydroxyacetone-phosphate"},{id:"tpl_ent_006",name:"D-Glyceraldehyde 3-phosphate",short:"g3p",formula:"C3H7O6P",synonyms:["glyceraldehyde 3-phosphate","D-glyceraldehyde 3-phosphate","glyceraldehyde-3-phosphate","GAP","G3P","D-glyceraldehyde-3-phosphate"],identifiers:{"kegg.compound":["C00118"],chebi:["29052","59776"],"bigg.metabolite":["g3p"],"seed.compound":["cpd00102"],"metacyc.compound":["GAP"],hmdb:["HMDB0001112"]},related:[{note:"stereo-unspecified glyceraldehyde 3-phosphate",names:["glyceraldehyde 3-phosphate"],identifiers:{"kegg.compound":["C00661"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glyceraldehyde-3-phosphate"},{id:"tpl_ent_007",name:"3-Phospho-D-glyceroyl phosphate",short:"13dpg",formula:"C3H8O10P2",synonyms:["3-phospho-D-glyceroyl phosphate","1,3-bisphospho-D-glycerate","1,3-bisphosphoglycerate","1,3-diphosphoglycerate","glycerate 1,3-bisphosphate","1,3-BPG","13BPG","3-phospho-D-glyceroyl-phosphate"],identifiers:{"kegg.compound":["C00236"],chebi:["16001","57604"],"bigg.metabolite":["13dpg"],"seed.compound":["cpd00203"],"metacyc.compound":["DPG"],hmdb:["HMDB0001270"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"1,3-bisphosphoglycerate"},{id:"tpl_ent_008",name:"3-Phospho-D-glycerate",short:"3pg",formula:"C3H7O7P",synonyms:["3-phospho-D-glycerate","3-phosphoglycerate","glycerate 3-phosphate","3-phosphoglyceric acid","3PG","D-glycerate 3-phosphate"],identifiers:{"kegg.compound":["C00197"],chebi:["17794","58272"],"bigg.metabolite":["3pg"],"seed.compound":["cpd00169"],"metacyc.compound":["G3P"],hmdb:["HMDB0000807"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"3-phospho-D-glycerate"},{id:"tpl_ent_009",name:"2-Phospho-D-glycerate",short:"2pg",formula:"C3H7O7P",synonyms:["2-phospho-D-glycerate","D-glycerate 2-phosphate","2-phosphoglycerate","glycerate 2-phosphate","2PG","2-phosphoglyceric acid"],identifiers:{"kegg.compound":["C00631"],chebi:["17835","58289"],"bigg.metabolite":["2pg"],"seed.compound":["cpd00482"],"metacyc.compound":["2-PG"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"2-phospho-D-glycerate"},{id:"tpl_ent_010",name:"Phosphoenolpyruvate",short:"pep",formula:"C3H5O6P",synonyms:["phosphoenolpyruvate","phosphoenolpyruvic acid","PEP","phospho-enol-pyruvate"],identifiers:{"kegg.compound":["C00074"],chebi:["18021","58702"],"bigg.metabolite":["pep"],"seed.compound":["cpd00061"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],hmdb:["HMDB0000263"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"phosphoenolpyruvate"},{id:"tpl_ent_011",name:"Pyruvate",short:"pyr",formula:"C3H4O3",synonyms:["pyruvate","pyruvic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816"],"bigg.metabolite":["pyr"],"seed.compound":["cpd00020"],"metacyc.compound":["PYRUVATE"],hmdb:["HMDB0000243"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"pyruvate"},{id:"tpl_ent_012",name:"L-Lactate",short:"lac_L",formula:"C3H6O3",synonyms:["L-lactate","(S)-lactate","L-lactic acid","(S)-lactic acid","L-lac"],identifiers:{"kegg.compound":["C00186"],chebi:["16651","422"],"bigg.metabolite":["lac__L","lac_L"],"seed.compound":["cpd00159"],"metacyc.compound":["L-LACTATE"],hmdb:["HMDB0000190"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"L-lactate"},{id:"tpl_ent_013",name:"D-Lactate",short:"lac_D",formula:"C3H6O3",synonyms:["D-lactate","(R)-lactate","D-lactic acid","(R)-lactic acid","D-lac"],identifiers:{"kegg.compound":["C00256"],chebi:["16004","42111"],"bigg.metabolite":["lac__D","lac_D"],"seed.compound":["cpd00221"],"metacyc.compound":["D-LACTATE"],hmdb:["HMDB0001311"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-lactate"},{id:"tpl_ent_014",name:"Acetyl-CoA",short:"accoa",formula:"C23H38N7O17P3S",synonyms:["acetyl-CoA","acetyl coenzyme A","acetyl-coenzyme A","AcCoA"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288"],"bigg.metabolite":["accoa"],"seed.compound":["cpd00022"],"metacyc.compound":["ACETYL-COA"],hmdb:["HMDB0001206"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"acetyl-CoA"},{id:"tpl_ent_015",name:"ATP",short:"atp",formula:"C10H16N5O13P3",synonyms:["ATP","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616"],"bigg.metabolite":["atp"],"seed.compound":["cpd00002"],"metacyc.compound":["ATP"],hmdb:["HMDB0000538"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ATP"},{id:"tpl_ent_016",name:"ADP",short:"adp",formula:"C10H15N5O10P2",synonyms:["ADP","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216"],"bigg.metabolite":["adp"],"seed.compound":["cpd00008"],"metacyc.compound":["ADP"],hmdb:["HMDB0001341"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ADP"},{id:"tpl_ent_017",name:"NAD+",short:"nad",formula:"C21H28N7O14P2",synonyms:["NAD+","NAD","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540"],"bigg.metabolite":["nad"],"seed.compound":["cpd00003"],"metacyc.compound":["NAD"],hmdb:["HMDB0000902"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NAD+"},{id:"tpl_ent_018",name:"Orthophosphate",short:"pi",formula:"H3PO4",synonyms:["phosphate","orthophosphate","Pi","inorganic phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078"],"bigg.metabolite":["pi"],"seed.compound":["cpd00009"],"metacyc.compound":["Pi"],hmdb:["HMDB0001429"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"phosphate"},{id:"tpl_ent_019",name:"NADH",short:"nadh",formula:"C21H29N7O14P2",synonyms:["NADH","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945"],"bigg.metabolite":["nadh"],"seed.compound":["cpd00004"],"metacyc.compound":["NADH"],hmdb:["HMDB0001487"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADH"},{id:"tpl_ent_020",name:"H2O",short:"h2o",formula:"H2O",synonyms:["H2O","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377"],"bigg.metabolite":["h2o"],"seed.compound":["cpd00001"],"metacyc.compound":["WATER"],hmdb:["HMDB0002111"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"H2O"},{id:"tpl_ent_021",name:"Coenzyme A",short:"coa",formula:"C21H36N7O16P3S",synonyms:["CoA","coenzyme A","CoA-SH"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287"],"bigg.metabolite":["coa"],"seed.compound":["cpd00010"],"metacyc.compound":["CO-A"],hmdb:["HMDB0001423"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CoA"},{id:"tpl_ent_022",name:"CO2",short:"co2",formula:"CO2",synonyms:["CO2","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526"],"bigg.metabolite":["co2"],"seed.compound":["cpd00011"],"metacyc.compound":["CARBON-DIOXIDE"],hmdb:["HMDB0001967"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CO2"}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:"cytosol",level:"required",aliases:["glc"]},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:"cytosol",level:"required",aliases:["g6p"]},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:"cytosol",level:"required",aliases:["f6p"]},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:"cytosol",level:"required",aliases:["fdp"]},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:"cytosol",level:"required",aliases:["dhap"]},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:"cytosol",level:"required",aliases:["g3p"]},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:"cytosol",level:"required",aliases:["13dpg"]},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:"cytosol",level:"required",aliases:["3pg"]},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:"cytosol",level:"required",aliases:["2pg"]},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:"cytosol",level:"required",aliases:["pep"]},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:"cytosol",level:"required",aliases:["pyr"]},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:"cytosol",level:"optional",alternatives:["tpl_ent_013"],label:"lac",aliases:["lac"]},{id:"tpl_met_013",entity:"tpl_ent_014",compartment:"mitochondria",level:"optional",ungrouped:!0,aliases:["accoa"]},{id:"tpl_met_014",entity:"tpl_ent_015",compartment:"cytosol",level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_016",compartment:"cytosol",level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_017",compartment:"cytosol",level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_018",compartment:"cytosol",level:"optional"},{id:"tpl_met_018",entity:"tpl_ent_019",compartment:"cytosol",level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_020",compartment:"cytosol",level:"optional"},{id:"tpl_met_020",entity:"tpl_ent_021",compartment:"mitochondria",level:"optional"},{id:"tpl_met_021",entity:"tpl_ent_017",compartment:"mitochondria",level:"optional"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:"mitochondria",level:"optional"},{id:"tpl_met_023",entity:"tpl_ent_019",compartment:"mitochondria",level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"HEX",canonicalName:"hexokinase",reversible:!1,ec:["2.7.1.1","2.7.1.2"],level:"required",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_014",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_015",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["HEX1"],"kegg.reaction":["R00299"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["HEX1","HEX","GLCpts","HXK"],aliases:["HEX"]},{id:"tpl_rxn_002",name:"PGI",canonicalName:"glucose-6-phosphate isomerase",reversible:!0,ec:["5.3.1.9"],level:"required",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGI"],"kegg.reaction":["R00771"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGI"],aliases:["PGI"]},{id:"tpl_rxn_003",name:"PFK",canonicalName:"6-phosphofructokinase",reversible:!1,ec:["2.7.1.11"],level:"required",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_014",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_015",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PFK"],"kegg.reaction":["R00756"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PFK"],aliases:["PFK"]},{id:"tpl_rxn_004",name:"FBA",canonicalName:"fructose-bisphosphate aldolase",reversible:!0,ec:["4.1.2.13"],level:"required",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["FBA"],"kegg.reaction":["R01068"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["FBA"],aliases:["FBA"]},{id:"tpl_rxn_005",name:"TPI",canonicalName:"triose-phosphate isomerase",reversible:!0,ec:["5.3.1.1"],level:"required",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["TPI"],"kegg.reaction":["R01015"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["TPI"],aliases:["TPI"]},{id:"tpl_rxn_006",name:"GAPD",canonicalName:"glyceraldehyde-3-phosphate dehydrogenase",reversible:!0,ec:["1.2.1.12"],level:"required",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_017",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_018",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["GAPD"],"kegg.reaction":["R01061"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["GAPD"],aliases:["GAPD"]},{id:"tpl_rxn_007",name:"PGK",canonicalName:"phosphoglycerate kinase",reversible:!0,ec:["2.7.2.3"],level:"required",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_015",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PGK"],"kegg.reaction":["R01512"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGK"],aliases:["PGK"]},{id:"tpl_rxn_008",name:"PGM",canonicalName:"phosphoglycerate mutase",reversible:!0,ec:["5.4.2.11","5.4.2.12"],level:"required",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGM"],"kegg.reaction":["R01518"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGM"],aliases:["PGM"]},{id:"tpl_rxn_009",name:"ENO",canonicalName:"enolase",reversible:!0,ec:["4.2.1.11"],level:"required",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["ENO"],"kegg.reaction":["R00658"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ENO"],aliases:["ENO"]},{id:"tpl_rxn_010",name:"PYK",canonicalName:"pyruvate kinase",reversible:!1,ec:["2.7.1.40"],level:"required",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_015",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PYK"],"kegg.reaction":["R00200"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PYK"],aliases:["PYK"]},{id:"tpl_rxn_011",name:"LDH",canonicalName:"L-lactate dehydrogenase",reversible:!0,ec:["1.1.1.27","1.1.1.28"],level:"optional",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_016",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["LDH_L"],"kegg.reaction":["R00703"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["LDH_D","LDH_L","LDH"],aliases:["LDH"]},{id:"tpl_rxn_012",name:"PDH",canonicalName:"pyruvate dehydrogenase complex",reversible:!1,ec:["1.2.4.1","2.3.1.12"],level:"optional",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_020",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:-1,main:!1},{metabolite:"tpl_met_013",coefficient:1,main:!0},{metabolite:"tpl_met_022",coefficient:1,main:!1},{metabolite:"tpl_met_023",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["PDH"],"kegg.reaction":["R00209"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PDH","PDHm"],aliases:["PDH"]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_002",direction:"out",target:{template:"ppp",pathway:"Pentose phosphate pathway"}},{id:"tpl_port_002",metabolite:"tpl_met_013",direction:"out",target:{template:"tca",pathway:"TCA cycle"}}]},KN={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:0},{id:"tpl_node_002",metabolite:"tpl_met_002",x:0,y:60},{id:"tpl_node_003",metabolite:"tpl_met_003",x:0,y:120},{id:"tpl_node_004",metabolite:"tpl_met_004",x:0,y:180},{id:"tpl_node_005",metabolite:"tpl_met_005",x:-60,y:210,label_pos:"left"},{id:"tpl_node_006",metabolite:"tpl_met_006",x:0,y:240},{id:"tpl_node_007",metabolite:"tpl_met_007",x:0,y:300},{id:"tpl_node_008",metabolite:"tpl_met_008",x:0,y:360},{id:"tpl_node_009",metabolite:"tpl_met_009",x:0,y:420},{id:"tpl_node_010",metabolite:"tpl_met_010",x:0,y:480},{id:"tpl_node_011",metabolite:"tpl_met_011",x:0,y:540},{id:"tpl_node_012",metabolite:"tpl_met_012",x:0,y:630},{id:"tpl_node_013",metabolite:"tpl_met_013",x:110,y:540,label_pos:"top"}],ports:[],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_004"],targets:["tpl_node_006","tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_005",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_006",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_007",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"straight"},{reaction:"tpl_rxn_009",sources:["tpl_node_009"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_010"],targets:["tpl_node_011"],routing:"straight"},{reaction:"tpl_rxn_011",sources:["tpl_node_011"],targets:["tpl_node_012"],routing:"straight"},{reaction:"tpl_rxn_012",sources:["tpl_node_011"],targets:["tpl_node_013"],routing:"straight"}],groups:[],labels:[]},zN={format:LN,schema_version:TN,metadata:FN,biology:XN,layout:KN},UN="gemsmap-template",qN="1.1.0",VN={id:"kegg-map00010",name:"Glycolysis / Gluconeogenesis (KEGG map00010)",description:"Embden–Meyerhof–Parnas glycolysis and gluconeogenesis with the branches KEGG map00010 draws: glucose-1P, the 2,3-bisphosphoglycerate shunt, non-phosphorylating GAPN, pyruvate fates (lactate, ethanol, acetate, acetyl-CoA) and the bacterial PTS route of aryl-β-glucosides. Derived from KEGG; drawn by GEMsMAP.",pathway:"Glycolysis / Gluconeogenesis",section:"KEGG-derived templates",template_version:"0.1.0",scope:{level:"universal",taxa:[],note:"Core steps are conserved; G6Pase, PPDK/PPS, PDC/ADH, GAPN and the aryl-β-glucoside PTS route are organism-specific. Compartments are left unspecified (KEGG gives none): the matcher decides them in each GEM."},authors:["Drafted with an LLM (Claude Opus 5.5)"],created:"2026-10-09T00:00:00Z",modified:"2026-10-09T18:53:12Z",license:"MIT (drawing and curation); identifiers and biology from KEGG, MetaNetX and BiGG",tags:["KEGG","map00010","glycolysis","gluconeogenesis","central carbon"],citations:[{text:"Kanehisa M, Goto S. KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res 28:27-30 (2000)",doi:"10.1093/nar/28.1.27"}],layout_kind:"vertical",review_status:"ai-generated",source:{reference:"KEGG",pathway_id:"map00010",pathway_name:"Glycolysis / Gluconeogenesis",url:"https://www.genome.jp/pathway/map00010",generation_method:"KEGG flat files + KGML (structure only) → curated biological graph → identities reconciled with MetaNetX (backend client) and the BiGG tables → hand-designed layout",generated_by:"tools/kegg/kegg_template.py",retrieved:"2026-10-09"}},WN={compartments:[],entities:[{id:"tpl_ent_001",name:"D-Glucose",short:"Glucose",formula:"C6H12O6",charge:0,synonyms:["D-Glucopyranose","D-glucopyranose","D-glucose","Dextrose","Glc","Glucose","Grape sugar","dextrose","glucose"],identifiers:{"kegg.compound":["C00031"],chebi:["17634","4167","CHEBI:4167"],"metanetx.chemical":["MNXM1364061"],"bigg.metabolite":["glc_D","glc__D"],hmdb:["HMDB0000122","HMDB0304632"],"seed.compound":["cpd00027"],"metacyc.compound":["D-GLUCOSE","GLC"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00031; MetaNetX MNXM1364061; BiGG glc__D; GEMsMAP library 'D-glucose'"},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],identifiers:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}],library:"D-glucose",provenance:{source:"KEGG",id:"C00031",url:"https://www.kegg.jp/entry/C00031"}},{id:"tpl_ent_002",name:"D-Glucose 6-phosphate",short:"Glucose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-glucopyranose 6-phosphate","D-glucose 6-phosphate","G6P","Glucose 6-phosphate","Robison ester","glucose 6-phosphate","glucose-6-phosphate"],identifiers:{"kegg.compound":["C00092"],chebi:["14314","4170","61548","CHEBI:14314","CHEBI:4170","CHEBI:61548"],"metanetx.chemical":["MNXM1364111"],"bigg.metabolite":["g6p"],hmdb:["HMDB0001401","HMDB0001549","HMDB0006793"],"metacyc.compound":["D-GLUCOSE-6-PHOSPHATE","D-glucopyranose-6-phosphate","GLC-6-P"],"seed.compound":["cpd00079","cpd26836"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00092; MetaNetX MNXM1364111; BiGG g6p; GEMsMAP library 'D-glucose-6-phosphate'"},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],identifiers:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}],library:"D-glucose-6-phosphate",provenance:{source:"KEGG",id:"C00092",url:"https://www.kegg.jp/entry/C00092"}},{id:"tpl_ent_003",name:"D-Fructose 6-phosphate",short:"Fructose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-Fructose 6-phosphoric acid","D-fructose 6-phosphate","F6P","Neuberg ester","fructose 6-phosphate","fructose-6-phosphate"],identifiers:{"kegg.compound":["C00085","C05345"],chebi:["15946","61527","CHEBI:15946","CHEBI:16084","CHEBI:57634","CHEBI:61527","CHEBI:61553"],"metanetx.chemical":["MNXM1107898"],"bigg.metabolite":["f6p"],hmdb:["HMDB0000124","HMDB0003971","HMDB0257695"],"metacyc.compound":["CPD-18719","FRUCTOSE-6P"],"seed.compound":["cpd00072","cpd19035"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00085; MetaNetX MNXM1107898; BiGG f6p; GEMsMAP library 'D-fructose-6-phosphate'"},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],identifiers:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}],library:"D-fructose-6-phosphate",provenance:{source:"KEGG",id:"C00085",url:"https://www.kegg.jp/entry/C00085"}},{id:"tpl_ent_004",name:"D-Fructose 1,6-bisphosphate",short:"Fructose-1,6P₂",formula:"C6H10O12P2",charge:-4,synonyms:["D-fructose 1,6-bisphosphate","F16BP","FBP","fructose 1,6-bisphosphate","fructose 1,6-diphosphate","fructose-1,6-bisphosphate"],identifiers:{"kegg.compound":["C00354","C05378"],chebi:["32966","49299","CHEBI:16905","CHEBI:28013","CHEBI:32966","CHEBI:37736","CHEBI:49299"],"metanetx.chemical":["MNXM1364229"],"bigg.metabolite":["fdp"],hmdb:["HMDB0001058","HMDB0003973","HMDB0060444"],"metacyc.compound":["FRUCTOSE-16-DIPHOSPHATE"],"seed.compound":["cpd00290","cpd19036"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00354; MetaNetX MNXM1364229; BiGG fdp; GEMsMAP library 'D-fructose-1,6-bisphosphate'"},related:[{note:"ring form of D-fructose 1,6-bisphosphate",names:["beta-D-fructose 1,6-bisphosphate","beta-D-fructofuranose 1,6-bisphosphate"],identifiers:{"kegg.compound":["C05378"],chebi:["28013"],"bigg.metabolite":["fdp_B"]}}],library:"D-fructose-1,6-bisphosphate",provenance:{source:"KEGG",id:"C00354",url:"https://www.kegg.jp/entry/C00354"}},{id:"tpl_ent_005",name:"Dihydroxyacetone phosphate",short:"DHAP",formula:"C3H5O6P",charge:-2,synonyms:["3-Hydroxy-2-oxopropyl phosphate","DHAP","Dihydroxyacetone phosphate","dihydroxy-acetone phosphate","dihydroxyacetone phosphate","glycerone phosphate","glycerone-phosphate"],identifiers:{"kegg.compound":["C00111"],chebi:["16108","57642","CHEBI:16108","CHEBI:57642"],"metanetx.chemical":["MNXM77"],"bigg.metabolite":["dhap"],hmdb:["HMDB0001473","HMDB0011735"],"metacyc.compound":["DIHYDROXY-ACETONE-PHOSPHATE"],"seed.compound":["cpd00095"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00111; MetaNetX MNXM77; BiGG dhap; GEMsMAP library 'dihydroxyacetone-phosphate'"},library:"dihydroxyacetone-phosphate",provenance:{source:"KEGG",id:"C00111",url:"https://www.kegg.jp/entry/C00111"}},{id:"tpl_ent_006",name:"D-Glyceraldehyde 3-phosphate",short:"GAP",formula:"C3H5O6P",charge:-2,synonyms:["(2R)-2-Hydroxy-3-(phosphonooxy)-propanal","D-glyceraldehyde 3-phosphate","D-glyceraldehyde-3-phosphate","G3P","GAP","Glyceraldehyde 3-phosphate","glyceraldehyde 3-phosphate","glyceraldehyde-3-phosphate"],identifiers:{"kegg.compound":["C00118"],chebi:["29052","59776","CHEBI:29052","CHEBI:59776"],"metanetx.chemical":["MNXM1372045"],hmdb:["HMDB0001112"],"metacyc.compound":["GAP"],"seed.compound":["cpd00102"],"bigg.metabolite":["g3p"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00118; MetaNetX MNXM1372045; BiGG g3p; GEMsMAP library 'D-glyceraldehyde-3-phosphate'"},related:[{note:"stereo-unspecified glyceraldehyde 3-phosphate",names:["glyceraldehyde 3-phosphate"],identifiers:{"kegg.compound":["C00661"]}}],library:"D-glyceraldehyde-3-phosphate",provenance:{source:"KEGG",id:"C00118",url:"https://www.kegg.jp/entry/C00118"}},{id:"tpl_ent_007",name:"3-Phospho-D-glyceroyl phosphate",short:"1,3-BPG",formula:"C3H4O10P2",charge:-4,synonyms:["(R)-2-Hydroxy-3-(phosphonooxy)-1-monoanhydride with phosphoric propanoic acid","1,3-BPG","1,3-Bisphospho-D-glycerate","1,3-bisphospho-D-glycerate","1,3-bisphosphoglycerate","1,3-diphosphoglycerate","3-phospho-D-glyceroyl phosphate","D-Glycerate 1,3-diphosphate","glycerate 1,3-bisphosphate"],identifiers:{"kegg.compound":["C00236"],chebi:["16001","57604","CHEBI:16001","CHEBI:57604"],"metanetx.chemical":["MNXM1364464"],"bigg.metabolite":["13dpg"],hmdb:["HMDB0001270","HMDB0062758"],"metacyc.compound":["DPG"],"seed.compound":["cpd00203"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00236; MetaNetX MNXM1364464; BiGG 13dpg; GEMsMAP library '1,3-bisphosphoglycerate'"},library:"1,3-bisphosphoglycerate",provenance:{source:"KEGG",id:"C00236",url:"https://www.kegg.jp/entry/C00236"}},{id:"tpl_ent_008",name:"3-Phospho-D-glycerate",short:"3-PG",formula:"C3H4O7P",charge:-3,synonyms:["3-Phospho-(R)-glycerate","3-Phosphoglycerate","3-phospho-D-glycerate","3-phosphoglycerate","3-phosphoglyceric acid","3PG","D-Glycerate 3-phosphate","D-glycerate 3-phosphate","glycerate 3-phosphate"],identifiers:{"kegg.compound":["C00197","C00597"],chebi:["17794","58272","CHEBI:17050","CHEBI:17794","CHEBI:57998","CHEBI:58272","CHEBI:88005"],"metanetx.chemical":["MNXM727604"],"bigg.metabolite":["3pg"],hmdb:["HMDB0000807","HMDB0060180"],"metacyc.compound":["G3P"],"seed.compound":["cpd00169","cpd30741"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00197; MetaNetX MNXM727604; BiGG 3pg; GEMsMAP library '3-phospho-D-glycerate'"},library:"3-phospho-D-glycerate",provenance:{source:"KEGG",id:"C00197",url:"https://www.kegg.jp/entry/C00197"}},{id:"tpl_ent_009",name:"2-Phospho-D-glycerate",short:"2-PG",formula:"C3H4O7P",charge:-3,synonyms:["2-Phospho-(R)-glycerate","2-phospho-D-glycerate","2-phosphoglycerate","2-phosphoglyceric acid","2PG","D-Glycerate 2-phosphate","D-glycerate 2-phosphate","glycerate 2-phosphate"],identifiers:{"kegg.compound":["C00631"],chebi:["17835","58289","CHEBI:17835","CHEBI:24344","CHEBI:58289","CHEBI:88350"],"metanetx.chemical":["MNXM275"],"bigg.metabolite":["2pg"],hmdb:["HMDB0000362","HMDB0003391","HMDB0062707","HMDB0304085"],"metacyc.compound":["2-PG"],"seed.compound":["cpd00482"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00631; MetaNetX MNXM275; BiGG 2pg; GEMsMAP library '2-phospho-D-glycerate'"},library:"2-phospho-D-glycerate",provenance:{source:"KEGG",id:"C00631",url:"https://www.kegg.jp/entry/C00631"}},{id:"tpl_ent_010",name:"Phosphoenolpyruvate",short:"PEP",formula:"C3H2O6P",charge:-3,synonyms:["PEP","Phosphoenolpyruvic acid","phospho-enol-pyruvate","phosphoenolpyruvate","phosphoenolpyruvic acid"],identifiers:{"kegg.compound":["C00074"],chebi:["18021","58702","CHEBI:18021","CHEBI:44897","CHEBI:58702"],"metanetx.chemical":["MNXM73"],"bigg.metabolite":["pep"],hmdb:["HMDB0000263"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],"seed.compound":["cpd00061"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00074; MetaNetX MNXM73; BiGG pep; GEMsMAP library 'phosphoenolpyruvate'"},library:"phosphoenolpyruvate",provenance:{source:"KEGG",id:"C00074",url:"https://www.kegg.jp/entry/C00074"}},{id:"tpl_ent_011",name:"Pyruvate",short:"Pyruvate",formula:"C3H3O3",charge:-1,synonyms:["2-Oxopropanoate","2-Oxopropanoic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr","Pyroracemic acid","Pyruvic acid","pyruvate","pyruvic acid"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816","CHEBI:15361","CHEBI:177913","CHEBI:32816"],"metanetx.chemical":["MNXM23"],"bigg.metabolite":["pyr"],hmdb:["HMDB0000243"],"metacyc.compound":["PYRUVATE"],"seed.compound":["cpd00020"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00022; MetaNetX MNXM23; BiGG pyr; GEMsMAP library 'pyruvate'"},library:"pyruvate",provenance:{source:"KEGG",id:"C00022",url:"https://www.kegg.jp/entry/C00022"}},{id:"tpl_ent_012",name:"Acetyl-CoA",short:"Acetyl-CoA",formula:"C23H34N7O17P3S",charge:-4,synonyms:["AcCoA","Acetyl coenzyme A","acetyl coenzyme A","acetyl-CoA","acetyl-coenzyme A"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288","CHEBI:15351","CHEBI:57288"],"metanetx.chemical":["MNXM1104266"],"bigg.metabolite":["accoa"],hmdb:["HMDB0001206"],"metacyc.compound":["ACETYL-COA"],"seed.compound":["cpd00022"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00024; MetaNetX MNXM1104266; BiGG accoa; GEMsMAP library 'acetyl-CoA'"},library:"acetyl-CoA",provenance:{source:"KEGG",id:"C00024",url:"https://www.kegg.jp/entry/C00024"}},{id:"tpl_ent_013",name:"Oxaloacetate",short:"Oxaloacetate",formula:"C4H2O5",charge:-2,synonyms:["2-Oxobutanedioic acid","2-Oxosuccinic acid","2-oxosuccinate","OAA","Oxalacetic acid","Oxaloacetic acid","keto-Oxaloacetate","oxalacetate","oxaloacetate","oxaloacetic acid"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744","CHEBI:16452","CHEBI:30744"],"metanetx.chemical":["MNXM46"],"bigg.metabolite":["oaa"],hmdb:["HMDB0000223"],"metacyc.compound":["OXALACETIC_ACID"],"seed.compound":["cpd00032"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00036; MetaNetX MNXM46; BiGG oaa; GEMsMAP library 'oxaloacetate'"},library:"oxaloacetate",provenance:{source:"KEGG",id:"C00036",url:"https://www.kegg.jp/entry/C00036"}},{id:"tpl_ent_014",name:"L-Lactate",short:"L-Lactate",formula:"C3H5O3",charge:-1,synonyms:["(S)-lactate","(S)-lactic acid","L-Lactate","L-Lactic acid","L-lac","L-lactate","L-lactic acid"],identifiers:{"kegg.compound":["C00186"],chebi:["16651","422","CHEBI:16651","CHEBI:422"],"metanetx.chemical":["MNXM1371363"],"bigg.metabolite":["lac_L","lac__L"],hmdb:["HMDB0000190","HMDB0003328","HMDB0062492"],"metacyc.compound":["CPD-24844","L-LACTATE"],"seed.compound":["cpd00159"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00186; MetaNetX MNXM1371363; BiGG lac__L; GEMsMAP library 'L-lactate'"},library:"L-lactate",provenance:{source:"KEGG",id:"C00186",url:"https://www.kegg.jp/entry/C00186"}},{id:"tpl_ent_015",name:"Acetaldehyde",short:"Acetaldehyde",formula:"C2H4O",charge:0,synonyms:["Ethanal"],identifiers:{"kegg.compound":["C00084"],chebi:["CHEBI:15343"],"metanetx.chemical":["MNXM75"],"bigg.metabolite":["acald"],hmdb:["HMDB0000990"],"metacyc.compound":["ACETALD"],"seed.compound":["cpd00071"]},identity:{status:"suggested",source:"ai",note:"KEGG C00084; MetaNetX MNXM75; BiGG acald",confidence:"high"},provenance:{source:"KEGG",id:"C00084",url:"https://www.kegg.jp/entry/C00084"}},{id:"tpl_ent_016",name:"Ethanol",short:"Ethanol",formula:"C2H6O",charge:0,synonyms:["Ethyl alcohol","Methylcarbinol"],identifiers:{"kegg.compound":["C00469"],chebi:["CHEBI:16236","CHEBI:193043"],"metanetx.chemical":["MNXM1108092"],"bigg.metabolite":["etoh"],hmdb:["HMDB0000108"],"metacyc.compound":["ETOH"],"seed.compound":["cpd00363"]},identity:{status:"suggested",source:"ai",note:"KEGG C00469; MetaNetX MNXM1108092; BiGG etoh",confidence:"high"},provenance:{source:"KEGG",id:"C00469",url:"https://www.kegg.jp/entry/C00469"}},{id:"tpl_ent_017",name:"Acetate",short:"Acetate",formula:"C2H3O2",charge:-1,synonyms:["Acetic acid","Ethanoic acid"],identifiers:{"kegg.compound":["C00033"],chebi:["CHEBI:15366","CHEBI:193049","CHEBI:30089"],"metanetx.chemical":["MNXM26"],"bigg.metabolite":["ac"],hmdb:["HMDB0000042"],"metacyc.compound":["ACET","CPD-24335"],"seed.compound":["cpd00029"]},identity:{status:"suggested",source:"ai",note:"KEGG C00033; MetaNetX MNXM26; BiGG ac",confidence:"high"},provenance:{source:"KEGG",id:"C00033",url:"https://www.kegg.jp/entry/C00033"}},{id:"tpl_ent_018",name:"D-Glucose 1-phosphate",short:"Glucose-1P",formula:"C6H11O9P",charge:-2,synonyms:["Cori ester","D-Glucose alpha-1-phosphate","alpha-D-Glucose 1-phosphate"],identifiers:{"kegg.compound":["C00103"],chebi:["CHEBI:29042","CHEBI:58601"],"metanetx.chemical":["MNXM1364214"],hmdb:["HMDB0001306","HMDB0001586"],"metacyc.compound":["GLC-1-P"],"seed.compound":["cpd00089"],"bigg.metabolite":["g1p"]},identity:{status:"suggested",source:"ai",note:"KEGG C00103; MetaNetX MNXM1364214; BiGG g1p",confidence:"high"},provenance:{source:"KEGG",id:"C00103",url:"https://www.kegg.jp/entry/C00103"}},{id:"tpl_ent_019",name:"2,3-Bisphospho-D-glycerate",short:"2,3-BPG",formula:"C3H3O10P2",charge:-5,synonyms:["2,3-Diphospho-D-glycerate","D-Greenwald ester","DPG"],identifiers:{"kegg.compound":["C01159","C03339"],chebi:["CHEBI:17720","CHEBI:19324","CHEBI:28907","CHEBI:58248"],"metanetx.chemical":["MNXM892"],"bigg.metabolite":["23dpg"],hmdb:["HMDB0001294"],"metacyc.compound":["23-DIPHOSPHOGLYCERATE"],"seed.compound":["cpd00853","cpd02119"]},identity:{status:"suggested",source:"ai",note:"KEGG C01159; MetaNetX MNXM892; BiGG 23dpg",confidence:"high"},provenance:{source:"KEGG",id:"C01159",url:"https://www.kegg.jp/entry/C01159"}},{id:"tpl_ent_020",name:"Arbutin",short:"Arbutin",formula:"C12H16O7",charge:0,synonyms:["Hydroquinone-O-beta-D-glucopyranoside","Ursin","Uvasol"],identifiers:{"kegg.compound":["C06186"],chebi:["CHEBI:18305"],"metanetx.chemical":["MNXM1371473"],"bigg.metabolite":["arbt"],hmdb:["HMDB0029943"],"metacyc.compound":["HYDROQUINONE-O-BETA-D-GLUCOPYRANOSIDE"],"seed.compound":["cpd03696"]},identity:{status:"suggested",source:"ai",note:"KEGG C06186; MetaNetX MNXM1371473; BiGG arbt",confidence:"high"},provenance:{source:"KEGG",id:"C06186",url:"https://www.kegg.jp/entry/C06186"}},{id:"tpl_ent_021",name:"Arbutin 6-phosphate",short:"Arbutin-6P",formula:"C12H15O10P",charge:-2,synonyms:["Arbutin-6P"],identifiers:{"kegg.compound":["C06187"],chebi:["CHEBI:2807","CHEBI:60929"],"metanetx.chemical":["MNXM2806"],"bigg.metabolite":["arbt6p"],"metacyc.compound":["CPD-1162"],"seed.compound":["cpd03697"]},identity:{status:"suggested",source:"ai",note:"KEGG C06187; MetaNetX MNXM2806; BiGG arbt6p",confidence:"high"},provenance:{source:"KEGG",id:"C06187",url:"https://www.kegg.jp/entry/C06187"}},{id:"tpl_ent_022",name:"Salicin",short:"Salicin",formula:"C13H18O7",charge:0,synonyms:["Salicoside"],identifiers:{"kegg.compound":["C01451"],chebi:["CHEBI:17814"],"metanetx.chemical":["MNXM2561"],"bigg.metabolite":["salcn"],hmdb:["HMDB0003546"],"metacyc.compound":["CPD-1142"],"seed.compound":["cpd01030"]},identity:{status:"suggested",source:"ai",note:"KEGG C01451; MetaNetX MNXM2561; BiGG salcn",confidence:"high"},provenance:{source:"KEGG",id:"C01451",url:"https://www.kegg.jp/entry/C01451"}},{id:"tpl_ent_023",name:"Salicin 6-phosphate",short:"Salicin-6P",formula:"C13H17O10P",charge:-2,synonyms:["Salicin-6P"],identifiers:{"kegg.compound":["C06188"],chebi:["CHEBI:64794","CHEBI:9003"],"metanetx.chemical":["MNXM3356"],"bigg.metabolite":["salcn6p"],"metacyc.compound":["CPD-1181"],"seed.compound":["cpd03698"]},identity:{status:"suggested",source:"ai",note:"KEGG C06188; MetaNetX MNXM3356; BiGG salcn6p",confidence:"high"},provenance:{source:"KEGG",id:"C06188",url:"https://www.kegg.jp/entry/C06188"}},{id:"tpl_ent_024",name:"ATP",short:"ATP",formula:"C10H12N5O13P3",charge:-4,synonyms:["Adenosine 5'-triphosphate","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616","CHEBI:15422","CHEBI:237958","CHEBI:30616","CHEBI:57299"],"metanetx.chemical":["MNXM3"],"bigg.metabolite":["atp"],hmdb:["HMDB0000538"],"metacyc.compound":["ATP"],"seed.compound":["cpd00002"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00002; MetaNetX MNXM3; BiGG atp; GEMsMAP library 'ATP'"},library:"ATP",provenance:{source:"KEGG",id:"C00002",url:"https://www.kegg.jp/entry/C00002"}},{id:"tpl_ent_025",name:"ADP",short:"ADP",formula:"C10H12N5O10P2",charge:-3,synonyms:["Adenosine 5'-diphosphate","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216","CHEBI:16761","CHEBI:456216","CHEBI:87518"],"metanetx.chemical":["MNXM40333"],"bigg.metabolite":["adp"],hmdb:["HMDB0001341"],"metacyc.compound":["ADP","ADP-GROUP"],"seed.compound":["cpd00008","cpd22244"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00008; MetaNetX MNXM40333; BiGG adp; GEMsMAP library 'ADP'"},library:"ADP",provenance:{source:"KEGG",id:"C00008",url:"https://www.kegg.jp/entry/C00008"}},{id:"tpl_ent_026",name:"AMP",short:"AMP",formula:"C10H12N5O7P",charge:-2,synonyms:["5'-AMP","5'-Adenosine monophosphate","5'-Adenylic acid","Adenosine 5'-monophosphate","Adenosine 5'-phosphate","Adenylate","Adenylic acid"],identifiers:{"kegg.compound":["C00020"],chebi:["CHEBI:16027","CHEBI:40721","CHEBI:456215"],"metanetx.chemical":["MNXM728294"],"bigg.metabolite":["amp"],hmdb:["HMDB0000045"],"metacyc.compound":["AMP","AMP-GROUP"],"seed.compound":["cpd00018"]},identity:{status:"suggested",source:"ai",note:"KEGG C00020; MetaNetX MNXM728294; BiGG amp",confidence:"high"},provenance:{source:"KEGG",id:"C00020",url:"https://www.kegg.jp/entry/C00020"}},{id:"tpl_ent_027",name:"NAD+",short:"NAD⁺",formula:"C21H26N7O14P2",charge:-1,synonyms:["DPN","Diphosphopyridine nucleotide","NAD","Nadide","Nicotinamide adenine dinucleotide","beta-NAD+","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540","CHEBI:15846","CHEBI:44215","CHEBI:57540"],"metanetx.chemical":["MNXM8"],"bigg.metabolite":["nad"],hmdb:["HMDB0000902"],"metacyc.compound":["NAD"],"seed.compound":["cpd00003"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00003; MetaNetX MNXM8; BiGG nad; GEMsMAP library 'NAD+'"},library:"NAD+",provenance:{source:"KEGG",id:"C00003",url:"https://www.kegg.jp/entry/C00003"}},{id:"tpl_ent_028",name:"NADH",short:"NADH",formula:"C21H27N7O14P2",charge:-2,synonyms:["DPNH","Reduced nicotinamide adenine dinucleotide","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945","CHEBI:16908","CHEBI:57945"],"metanetx.chemical":["MNXM10"],"bigg.metabolite":["nadh"],hmdb:["HMDB0001487"],"metacyc.compound":["NADH"],"seed.compound":["cpd00004"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00004; MetaNetX MNXM10; BiGG nadh; GEMsMAP library 'NADH'"},library:"NADH",provenance:{source:"KEGG",id:"C00004",url:"https://www.kegg.jp/entry/C00004"}},{id:"tpl_ent_029",name:"NADP+",short:"NADP⁺",formula:"C21H25N7O17P3",charge:-3,synonyms:["NADP","Nicotinamide adenine dinucleotide phosphate","TPN","Triphosphopyridine nucleotide","beta-NADP+","beta-Nicotinamide adenine dinucleotide phosphate","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349","CHEBI:18009","CHEBI:25523","CHEBI:44409","CHEBI:58349"],"metanetx.chemical":["MNXM5"],"bigg.metabolite":["nadp"],hmdb:["HMDB0000217","HMDB0304435"],"metacyc.compound":["NADP"],"seed.compound":["cpd00006"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00006; MetaNetX MNXM5; BiGG nadp; GEMsMAP library 'NADP+'"},library:"NADP+",provenance:{source:"KEGG",id:"C00006",url:"https://www.kegg.jp/entry/C00006"}},{id:"tpl_ent_030",name:"NADPH",short:"NADPH",formula:"C21H26N7O17P3",charge:-4,synonyms:["Reduced nicotinamide adenine dinucleotide phosphate","TPNH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783","CHEBI:16474","CHEBI:57783"],"metanetx.chemical":["MNXM738702"],"bigg.metabolite":["nadph"],hmdb:["HMDB0000221","HMDB0000799","HMDB0006341"],"metacyc.compound":["NADPH"],"seed.compound":["cpd00005"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00005; MetaNetX MNXM738702; BiGG nadph; GEMsMAP library 'NADPH'"},library:"NADPH",provenance:{source:"KEGG",id:"C00005",url:"https://www.kegg.jp/entry/C00005"}},{id:"tpl_ent_031",name:"Orthophosphate",short:"Pᵢ",formula:"HO4P",charge:-2,synonyms:["Orthophosphoric acid","Phosphate","Phosphoric acid","Pi","inorganic phosphate","orthophosphate","phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078","CHEBI:18367","CHEBI:26020","CHEBI:26078","CHEBI:35780","CHEBI:39745","CHEBI:43474"],"metanetx.chemical":["MNXM9"],"bigg.metabolite":["pi"],hmdb:["HMDB0000973","HMDB0001429","HMDB0002105","HMDB0002142","HMDB0005947"],"seed.compound":["cpd00009","cpd27787"],"metacyc.compound":["Pi"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00009; MetaNetX MNXM9; BiGG pi; GEMsMAP library 'phosphate'"},library:"phosphate",provenance:{source:"KEGG",id:"C00009",url:"https://www.kegg.jp/entry/C00009"}},{id:"tpl_ent_032",name:"Diphosphate",short:"PPᵢ",formula:"HO7P2",charge:-3,synonyms:["Diphosphoric acid","PPi","Pyrophosphate","Pyrophosphoric acid"],identifiers:{"kegg.compound":["C00013"],chebi:["CHEBI:18361","CHEBI:29888","CHEBI:33017","CHEBI:33019","CHEBI:45212"],"metanetx.chemical":["MNXM11"],"bigg.metabolite":["ppi"],hmdb:["HMDB0000250","HMDB0304340"],"metacyc.compound":["PPI","PYROPHOSPHATE-GROUP"],"seed.compound":["cpd00012","cpd27828"]},identity:{status:"suggested",source:"ai",note:"KEGG C00013; MetaNetX MNXM11; BiGG ppi",confidence:"high"},provenance:{source:"KEGG",id:"C00013",url:"https://www.kegg.jp/entry/C00013"}},{id:"tpl_ent_033",name:"H2O",short:"H2O",formula:"H2O",charge:0,synonyms:["Water","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377","CHEBI:15377","CHEBI:29374","CHEBI:29375","CHEBI:33806","CHEBI:33811","CHEBI:33813","CHEBI:41981"],"metanetx.chemical":["WATER"],"bigg.metabolite":["h2o"],hmdb:["HMDB0002111"],"metacyc.compound":["WATER"],"seed.compound":["cpd00001"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00001; MetaNetX WATER; BiGG h2o; GEMsMAP library 'H2O'"},library:"H2O",provenance:{source:"KEGG",id:"C00001",url:"https://www.kegg.jp/entry/C00001"}},{id:"tpl_ent_034",name:"CO2",short:"CO₂",formula:"CO2",charge:0,synonyms:["Carbon dioxide","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526","CHEBI:139538","CHEBI:16526"],"metanetx.chemical":["MNXM13"],"bigg.metabolite":["co2"],hmdb:["HMDB0001967"],"metacyc.compound":["CARBON-DIOXIDE"],"seed.compound":["cpd00011"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00011; MetaNetX MNXM13; BiGG co2; GEMsMAP library 'CO2'"},library:"CO2",provenance:{source:"KEGG",id:"C00011",url:"https://www.kegg.jp/entry/C00011"}},{id:"tpl_ent_035",name:"Coenzyme A",short:"CoA",formula:"C21H32N7O16P3S",charge:-4,synonyms:["CoA-SH","Coenzyme A","coenzyme A"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287","CHEBI:15346","CHEBI:57287"],"metanetx.chemical":["MNXM727276"],"bigg.metabolite":["coa"],hmdb:["HMDB0001423","HMDB0062184"],"metacyc.compound":["CO-A","COA-GROUP"],"seed.compound":["cpd00010"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00010; MetaNetX MNXM727276; BiGG coa; GEMsMAP library 'CoA'"},library:"CoA",provenance:{source:"KEGG",id:"C00010",url:"https://www.kegg.jp/entry/C00010"}},{id:"tpl_ent_036",name:"Hydroquinone",short:"Hydroquinone",formula:"C6H6O2",charge:0,synonyms:["1,4-Benzenediol","1,4-Dihydroxybenzene","4-Hydroxyphenol","Benzene-1,4-diol","Quinol","p-Benzenediol"],identifiers:{"kegg.compound":["C00530"],chebi:["CHEBI:17594"],"metanetx.chemical":["MNXM376"],"bigg.metabolite":["hqn"],hmdb:["HMDB0002434"],"metacyc.compound":["HYDROQUINONE"],"seed.compound":["cpd00415"]},identity:{status:"suggested",source:"ai",note:"KEGG C00530; MetaNetX MNXM376; BiGG hqn",confidence:"high"},provenance:{source:"KEGG",id:"C00530",url:"https://www.kegg.jp/entry/C00530"}},{id:"tpl_ent_037",name:"Salicyl alcohol",short:"Salicyl alcohol",formula:"C7H8O2",charge:0,synonyms:["2-(Hydroxymethyl)phenol","2-Hydroxybenzyl alcohol","Saligenin"],identifiers:{"kegg.compound":["C02323"],chebi:["CHEBI:16464"],"metanetx.chemical":["MNXM1855"],"bigg.metabolite":["2hxmp"],hmdb:["HMDB0059709"],"metacyc.compound":["CPD-173"],"seed.compound":["cpd01553"]},identity:{status:"suggested",source:"ai",note:"KEGG C02323; MetaNetX MNXM1855; BiGG 2hxmp",confidence:"high"},provenance:{source:"KEGG",id:"C02323",url:"https://www.kegg.jp/entry/C02323"}},{id:"tpl_ent_038",name:"Protein N(pi)-phospho-L-histidine",short:"P(π)-His-protein",formula:"C7H9N4O5P*2",charge:0,synonyms:["Protein N-pros-phospho-L-histidine","Protein N-pros-phosphohistidine","Protein Npi-phospho-L-histidine"],identifiers:{"kegg.compound":["C04261"],"metanetx.chemical":["MNXM90093"],"seed.compound":["cpd12508"]},identity:{status:"suggested",source:"ai",note:"KEGG C04261; MetaNetX MNXM90093",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C04261",url:"https://www.kegg.jp/entry/C04261"}},{id:"tpl_ent_039",name:"Protein N(tau)-phospho-L-histidine",short:"P(τ)-His-protein",formula:"C7H9N4O5P*2",charge:0,synonyms:["Protein N-tele-phospho-L-histidine","Protein N-tele-phosphohistidine"],identifiers:{"kegg.compound":["C04262"],"metanetx.chemical":["MNXM93866"],"seed.compound":["cpd12509"]},identity:{status:"suggested",source:"ai",note:"KEGG C04262; MetaNetX MNXM93866",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C04262",url:"https://www.kegg.jp/entry/C04262"}},{id:"tpl_ent_040",name:"Protein histidine",short:"His-protein",formula:"C7H8N4O2*2",charge:0,synonyms:["Protein L-histidine","[Protein]-L-histidine"],identifiers:{"kegg.compound":["C00615"],"metanetx.chemical":["MNXM3704"],"metacyc.compound":["Protein-Histidines"],"seed.compound":["cpd11712"]},identity:{status:"suggested",source:"ai",note:"KEGG C00615; MetaNetX MNXM3704",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C00615",url:"https://www.kegg.jp/entry/C00615"}}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:null,level:"required"},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:null,level:"required"},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:null,level:"required"},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:null,level:"required"},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:null,level:"required"},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:null,level:"required"},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:null,level:"required"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:null,level:"required"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:null,level:"required"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:null,level:"required"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:null,level:"required"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:null,level:"required"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:null,level:"recommended"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:null,level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:null,level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:null,level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:null,level:"optional"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:null,level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:null,level:"optional"},{id:"tpl_met_020",entity:"tpl_ent_020",compartment:null,level:"optional"},{id:"tpl_met_021",entity:"tpl_ent_021",compartment:null,level:"optional"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:null,level:"optional"},{id:"tpl_met_023",entity:"tpl_ent_023",compartment:null,level:"optional"},{id:"tpl_met_024",entity:"tpl_ent_024",compartment:null,level:"optional"},{id:"tpl_met_025",entity:"tpl_ent_025",compartment:null,level:"optional"},{id:"tpl_met_026",entity:"tpl_ent_026",compartment:null,level:"optional"},{id:"tpl_met_027",entity:"tpl_ent_027",compartment:null,level:"optional"},{id:"tpl_met_028",entity:"tpl_ent_028",compartment:null,level:"optional"},{id:"tpl_met_029",entity:"tpl_ent_029",compartment:null,level:"optional"},{id:"tpl_met_030",entity:"tpl_ent_030",compartment:null,level:"optional"},{id:"tpl_met_031",entity:"tpl_ent_031",compartment:null,level:"optional"},{id:"tpl_met_032",entity:"tpl_ent_032",compartment:null,level:"optional"},{id:"tpl_met_033",entity:"tpl_ent_033",compartment:null,level:"optional"},{id:"tpl_met_034",entity:"tpl_ent_034",compartment:null,level:"optional"},{id:"tpl_met_035",entity:"tpl_ent_035",compartment:null,level:"optional"},{id:"tpl_met_036",entity:"tpl_ent_036",compartment:null,level:"optional"},{id:"tpl_met_037",entity:"tpl_ent_037",compartment:null,level:"optional"},{id:"tpl_met_038",entity:"tpl_ent_038",compartment:null,level:"optional"},{id:"tpl_met_039",entity:"tpl_ent_039",compartment:null,level:"optional"},{id:"tpl_met_040",entity:"tpl_ent_040",compartment:null,level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"HK",canonicalName:"hexokinase / glucokinase",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_025",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.1","2.7.1.2"],identifiers:{"kegg.reaction":["R00299"],"metanetx.reaction":["MNXR198694"],"seed.reaction":["rxn00216","rxn34232"],"metacyc.reaction":["GLUCOKIN-RXN"],rhea:["17825","17826","17827","17828"],"bigg.reaction":["HEX1"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00299 (represents map reactions R01786, R01600); MetaNetX MNXR198694; KEGG ID confirmed in the built-in template ('HEX')"},hints:["HEX1","GLCpts","HXK"],variants:[{name:"ADP-dependent glucokinase (α-D-glucose)",ec:["2.7.1.147"],identifiers:{"kegg.reaction":["R09085"]},equation:"alpha-D-Glucose + ADP <=> alpha-D-Glucose 6-phosphate + AMP"},{name:"ADP-dependent glucokinase (β-D-glucose)",ec:["2.7.1.147"],identifiers:{"kegg.reaction":["R09086"]},equation:"beta-D-Glucose + ADP <=> beta-D-Glucose 6-phosphate + AMP"},{name:"polyphosphate glucokinase (α-D-glucose)",ec:["2.7.1.63"],identifiers:{"kegg.reaction":["R02189"]},equation:"Polyphosphate + alpha-D-Glucose <=> Polyphosphate + alpha-D-Glucose 6-phosphate"},{name:"polyphosphate glucokinase (β-D-glucose)",ec:["2.7.1.63"],identifiers:{"kegg.reaction":["R02187"]},equation:"Polyphosphate + beta-D-Glucose <=> Polyphosphate + beta-D-Glucose 6-phosphate"},{name:"glucose PTS (EIIB^Glc)",ec:["2.7.1.199"],identifiers:{"kegg.reaction":["R02738"]},equation:"Protein N(pi)-phospho-L-histidine + D-Glucose <=> Protein histidine + alpha-D-Glucose 6-phosphate",note:"group translocation; in GEMs a transport reaction from extracellular glucose with PEP → pyruvate"}],provenance:[{source:"KEGG",id:"R00299",url:"https://www.kegg.jp/entry/R00299"},{source:"KEGG",id:"R01600",url:"https://www.kegg.jp/entry/R01600"},{source:"KEGG",id:"R01786",url:"https://www.kegg.jp/entry/R01786"}]},{id:"tpl_rxn_002",name:"G6Pase",canonicalName:"glucose-6-phosphatase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_001",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1}],reversible:!1,ec:["3.1.3.9","3.1.3.58"],identifiers:{"kegg.reaction":["R00303"],"metanetx.reaction":["MNXR198838"],"seed.reaction":["rxn00220"],"metacyc.reaction":["RXN66-526"],rhea:["16689","16690","16691","16692"],"bigg.reaction":["G6PP"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00303 (represents map reactions R01788); MetaNetX MNXR198838"},provenance:[{source:"KEGG",id:"R00303",url:"https://www.kegg.jp/entry/R00303"},{source:"KEGG",id:"R01788",url:"https://www.kegg.jp/entry/R01788"}]},{id:"tpl_rxn_003",name:"PGI",canonicalName:"glucose-6-phosphate isomerase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0}],reversible:!0,ec:["5.3.1.9"],identifiers:{"kegg.reaction":["R00771"],"metanetx.reaction":["MNXR197738"],"seed.reaction":["rxn00558","rxn33838","rxn34259","rxn37760"],"bigg.reaction":["PGI"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00771 (represents map reactions R13199); MetaNetX MNXR197738; BiGG links PGI1, PGI1c to this KEGG reaction but the participants differ — not used; KEGG ID confirmed in the built-in template ('PGI')"},provenance:[{source:"KEGG",id:"R00771",url:"https://www.kegg.jp/entry/R00771"},{source:"KEGG",id:"R13199",url:"https://www.kegg.jp/entry/R13199"}]},{id:"tpl_rxn_004",name:"PFK",canonicalName:"6-phosphofructokinase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_025",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.11"],identifiers:{"kegg.reaction":["R00756"],"metanetx.reaction":["MNXR145952"],"seed.reaction":["rxn00545","rxn15493","rxn19015","rxn33754","rxn34257","rxn38002","rxn38003","rxn38004"],"metacyc.reaction":["6PFRUCTPHOS-RXN"],rhea:["16109","16110","16111","16112"],"bigg.reaction":["PFK"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00756; MetaNetX MNXR145952; KEGG ID confirmed in the built-in template ('PFK')"},variants:[{name:"pyrophosphate-dependent PFK (PPi-PFK)",ec:["2.7.1.90"],identifiers:{"kegg.reaction":["R00764"]},equation:"Diphosphate + D-Fructose 6-phosphate <=> Orthophosphate + D-Fructose 1,6-bisphosphate",note:"reversible; glycolysis and gluconeogenesis in plants and some protists and bacteria"},{name:"ADP-dependent PFK",ec:["2.7.1.146"],identifiers:{"kegg.reaction":["R05805"]},equation:"ADP + D-Fructose 6-phosphate <=> AMP + D-Fructose 1,6-bisphosphate"}],provenance:[{source:"KEGG",id:"R00756",url:"https://www.kegg.jp/entry/R00756"}]},{id:"tpl_rxn_005",name:"FBPase",canonicalName:"fructose-1,6-bisphosphatase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1}],reversible:!1,ec:["3.1.3.11"],identifiers:{"kegg.reaction":["R00762"],"metanetx.reaction":["MNXR147046"],"seed.reaction":["rxn00549","rxn15494","rxn19684","rxn19685","rxn30665","rxn31218","rxn33589","rxn33591"],"metacyc.reaction":["F16BDEPHOS-RXN"],rhea:["11064","11065","11066","11067"],"bigg.reaction":["FBP"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00762; MetaNetX MNXR147046"},provenance:[{source:"KEGG",id:"R00762",url:"https://www.kegg.jp/entry/R00762"}]},{id:"tpl_rxn_006",name:"FBA",canonicalName:"fructose-bisphosphate aldolase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],reversible:!0,ec:["4.1.2.13"],identifiers:{"kegg.reaction":["R01068"],"metanetx.reaction":["MNXR153519"],"seed.reaction":["rxn00786","rxn15116","rxn19683","rxn27851","rxn31335","rxn38097"],"metacyc.reaction":["F16ALDOLASE-RXN"],rhea:["14729","14730","14731","14732"],"bigg.reaction":["FBA"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01068; MetaNetX MNXR153519; KEGG ID confirmed in the built-in template ('FBA')"},provenance:[{source:"KEGG",id:"R01068",url:"https://www.kegg.jp/entry/R01068"}]},{id:"tpl_rxn_007",name:"TPI",canonicalName:"triose-phosphate isomerase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],reversible:!0,ec:["5.3.1.1"],identifiers:{"kegg.reaction":["R01015"],"metanetx.reaction":["MNXR146574"],"seed.reaction":["rxn00747","rxn27386","rxn33035"],"metacyc.reaction":["TRIOSEPISOMERIZATION-RXN"],rhea:["18585","18586","18587","18588"],"bigg.reaction":["TPI"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01015; MetaNetX MNXR146574; KEGG ID confirmed in the built-in template ('TPI')"},provenance:[{source:"KEGG",id:"R01015",url:"https://www.kegg.jp/entry/R01015"}]},{id:"tpl_rxn_008",name:"GAPDH",canonicalName:"glyceraldehyde-3-phosphate dehydrogenase (phosphorylating)",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_031",coefficient:-1,main:!1},{metabolite:"tpl_met_027",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_028",coefficient:1,main:!1}],reversible:!0,ec:["1.2.1.12","1.2.1.59"],identifiers:{"kegg.reaction":["R01061"],"metanetx.reaction":["MNXR191943"],"seed.reaction":["rxn00781","rxn19762","rxn27871","rxn38113"],"metacyc.reaction":["GAPOXNPHOSPHN-RXN"],rhea:["10300","10301","10302","10303"],"bigg.reaction":["GAPD"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01061; MetaNetX MNXR191943; KEGG ID confirmed in the built-in template ('GAPD')"},variants:[{name:"NADP-dependent GAPDH (GapB / GapC)",ec:["1.2.1.13","1.2.1.59"],identifiers:{"kegg.reaction":["R01063"]},equation:"D-Glyceraldehyde 3-phosphate + Orthophosphate + NADP+ <=> 3-Phospho-D-glyceroyl phosphate + NADPH + H+"}],provenance:[{source:"KEGG",id:"R01061",url:"https://www.kegg.jp/entry/R01061"}]},{id:"tpl_rxn_009",name:"GAPN",canonicalName:"glyceraldehyde-3-phosphate dehydrogenase (non-phosphorylating)",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_029",coefficient:-1,main:!1},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_030",coefficient:1,main:!1}],reversible:!1,ec:["1.2.1.9","1.2.1.90"],identifiers:{"kegg.reaction":["R01058"],"metanetx.reaction":["MNXR147145"],"seed.reaction":["rxn00779"],"metacyc.reaction":["1.2.1.9-RXN"],rhea:["14669","14670","14671","14672"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01058; MetaNetX MNXR147145"},variants:[{name:"NAD-dependent GAPN",ec:["1.2.1.90"],identifiers:{"kegg.reaction":["R10860"]},equation:"D-Glyceraldehyde 3-phosphate + NAD+ + H2O <=> 3-Phospho-D-glycerate + NADH + H+"},{name:"glyceraldehyde-3-phosphate:ferredoxin oxidoreductase (GAPOR, archaea)",ec:["1.2.7.6"],identifiers:{"kegg.reaction":["R07159"]},equation:"D-Glyceraldehyde 3-phosphate + H2O + 2 Oxidized ferredoxin <=> 3-Phospho-D-glycerate + 2 H+ + 2 Reduced ferredoxin"}],provenance:[{source:"KEGG",id:"R01058",url:"https://www.kegg.jp/entry/R01058"}]},{id:"tpl_rxn_010",name:"PGK",canonicalName:"phosphoglycerate kinase",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_025",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_024",coefficient:1,main:!1}],reversible:!0,ec:["2.7.2.3"],identifiers:{"kegg.reaction":["R01512"],"metanetx.reaction":["MNXR191159"],"seed.reaction":["rxn01100","rxn20544","rxn35241","rxn38256","rxn38257"],"metacyc.reaction":["PHOSGLYPHOS-RXN"],rhea:["14801","14802","14803","14804"],"bigg.reaction":["PGK"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01512; MetaNetX MNXR191159; KEGG ID confirmed in the built-in template ('PGK')"},provenance:[{source:"KEGG",id:"R01512",url:"https://www.kegg.jp/entry/R01512"}]},{id:"tpl_rxn_011",name:"BPGM",canonicalName:"bisphosphoglycerate mutase",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!0}],reversible:!0,ec:["5.4.2.4"],identifiers:{"kegg.reaction":["R01662"],"metanetx.reaction":["MNXR191232"],"seed.reaction":["rxn01216"],"metacyc.reaction":["BISPHOSPHOGLYCERATE-MUTASE-RXN"],rhea:["17765","17766","17767","17768"],"bigg.reaction":["DPGM"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01662; MetaNetX MNXR191232"},provenance:[{source:"KEGG",id:"R01662",url:"https://www.kegg.jp/entry/R01662"}]},{id:"tpl_rxn_012",name:"PGAM",canonicalName:"phosphoglycerate mutase, priming with 2,3-BPG",participants:[{metabolite:"tpl_met_019",coefficient:-1,main:!0},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!0,ec:["5.4.2.11"],identifiers:{"kegg.reaction":["R01516"],"metanetx.reaction":["MNXR107035"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R01516; MetaNetX MNXR107035; BiGG links DPGase to this KEGG reaction but the participants differ — not used"},provenance:[{source:"KEGG",id:"R01516",url:"https://www.kegg.jp/entry/R01516"}]},{id:"tpl_rxn_013",name:"MIPP1",canonicalName:"2,3-bisphosphoglycerate 3-phosphatase",participants:[{metabolite:"tpl_met_019",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_009",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1}],reversible:!1,ec:["3.1.3.80"],identifiers:{"kegg.reaction":["R09532"],"metanetx.reaction":["MNXR112951"],"seed.reaction":["rxn16373","rxn21401"],"metacyc.reaction":["RXN-11102"],rhea:["27381","27382","27383","27384"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R09532; MetaNetX MNXR112951"},provenance:[{source:"KEGG",id:"R09532",url:"https://www.kegg.jp/entry/R09532"}]},{id:"tpl_rxn_014",name:"PGAM",canonicalName:"phosphoglycerate mutase",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0}],reversible:!0,ec:["5.4.2.11","5.4.2.12"],identifiers:{"kegg.reaction":["R01518"],"metanetx.reaction":["MNXR102547"],"seed.reaction":["rxn01106","rxn18917","rxn35234"],"metacyc.reaction":["3PGAREARR-RXN","RXN-15513"],rhea:["15901","15902","15903","15904"],"bigg.reaction":["PGM"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01518; MetaNetX MNXR102547; KEGG ID confirmed in the built-in template ('PGM')"},provenance:[{source:"KEGG",id:"R01518",url:"https://www.kegg.jp/entry/R01518"}]},{id:"tpl_rxn_015",name:"ENO",canonicalName:"enolase",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!0,ec:["4.2.1.11"],identifiers:{"kegg.reaction":["R00658"],"metanetx.reaction":["MNXR97932"],"seed.reaction":["rxn00459","rxn17748","rxn30576","rxn33498","rxn35218","rxn37952","rxn37953"],"metacyc.reaction":["2PGADEHYDRAT-RXN"],rhea:["10164","10165","10166","10167"],"bigg.reaction":["ENO"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00658; MetaNetX MNXR97932; KEGG ID confirmed in the built-in template ('ENO')"},provenance:[{source:"KEGG",id:"R00658",url:"https://www.kegg.jp/entry/R00658"}]},{id:"tpl_rxn_016",name:"PK",canonicalName:"pyruvate kinase",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_025",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_024",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.40"],identifiers:{"kegg.reaction":["R00200"],"metanetx.reaction":["MNXR103371"],"seed.reaction":["rxn00148","rxn20509","rxn35242"],"metacyc.reaction":["PEPDEPHOS-RXN"],rhea:["18157","18158","18159","18160"],"bigg.reaction":["PYK"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00200; MetaNetX MNXR103371; BiGG links PYK2 to this KEGG reaction but the participants differ — not used; KEGG ID confirmed in the built-in template ('PYK')"},provenance:[{source:"KEGG",id:"R00200",url:"https://www.kegg.jp/entry/R00200"}]},{id:"tpl_rxn_017",name:"PPDK",canonicalName:"pyruvate, phosphate dikinase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:-1,main:!1},{metabolite:"tpl_met_031",coefficient:-1,main:!1},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_026",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!0,ec:["2.7.9.1"],identifiers:{"kegg.reaction":["R00206"],"metanetx.reaction":["MNXR103107"],"seed.reaction":["rxn00151","rxn20655"],"metacyc.reaction":["PYRUVATEORTHOPHOSPHATE-DIKINASE-RXN"],rhea:["10756","10757","10758","10759"],"bigg.reaction":["PPDK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00206; MetaNetX MNXR103107"},variants:[{name:"phosphoenolpyruvate synthase (PPS)",ec:["2.7.9.2"],identifiers:{"kegg.reaction":["R00199"]},equation:"ATP + Pyruvate + H2O <=> AMP + Phosphoenolpyruvate + Orthophosphate",note:"ATP + pyruvate + H2O → AMP + PEP + Pi"}],provenance:[{source:"KEGG",id:"R00206",url:"https://www.kegg.jp/entry/R00206"}]},{id:"tpl_rxn_018",name:"PEPCK",canonicalName:"phosphoenolpyruvate carboxykinase",participants:[{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:-1,main:!1},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_025",coefficient:1,main:!1},{metabolite:"tpl_met_034",coefficient:1,main:!1}],reversible:!1,ec:["4.1.1.49"],identifiers:{"kegg.reaction":["R00341"],"metanetx.reaction":["MNXR103099"],"seed.reaction":["rxn00247","rxn35519"],"metacyc.reaction":["PEPCARBOXYKIN-RXN"],rhea:["18617","18618","18619","18620"],"bigg.reaction":["PPCK"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00341; MetaNetX MNXR103099"},variants:[{name:"GTP-dependent PEPCK (animals)",ec:["4.1.1.32"],identifiers:{"kegg.reaction":["R00431"]},equation:"GTP + Oxaloacetate <=> GDP + Phosphoenolpyruvate + CO2"},{name:"ITP-dependent PEPCK",ec:["4.1.1.32"],identifiers:{"kegg.reaction":["R00726"]},equation:"ITP + Oxaloacetate <=> IDP + Phosphoenolpyruvate + CO2"}],provenance:[{source:"KEGG",id:"R00341",url:"https://www.kegg.jp/entry/R00341"}]},{id:"tpl_rxn_019",name:"LDH",canonicalName:"L-lactate dehydrogenase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!0},{metabolite:"tpl_met_027",coefficient:1,main:!1}],reversible:!0,ec:["1.1.1.27"],identifiers:{"kegg.reaction":["R00703"],"metanetx.reaction":["MNXR101040"],"seed.reaction":["rxn00499","rxn34239","rxn34240"],"metacyc.reaction":["L-LACTATE-DEHYDROGENASE-RXN"],rhea:["23444","23445","23446","23447"],"bigg.reaction":["LDH_L"]},level:"optional",identity:{status:"confirmed",source:"builtin",note:"KEGG R00703; MetaNetX MNXR101040; KEGG ID confirmed in the built-in template ('LDH')"},provenance:[{source:"KEGG",id:"R00703",url:"https://www.kegg.jp/entry/R00703"}]},{id:"tpl_rxn_020",name:"PDH",canonicalName:"pyruvate dehydrogenase complex",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_035",coefficient:-1,main:!1},{metabolite:"tpl_met_027",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1},{metabolite:"tpl_met_028",coefficient:1,main:!1}],reversible:!1,ec:["1.2.4.1","2.3.1.12","1.8.1.4"],identifiers:{"kegg.reaction":["R00209"],"metanetx.reaction":["MNXR188625"],"seed.reaction":["rxn00154","rxn20656","rxn30418"],"metacyc.reaction":["PYRUVDEH-RXN"],rhea:["28042","28043","28044","28045"],"bigg.reaction":["PDH"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00209 (represents map reactions R00014, R03270, R02569, R07618); MetaNetX MNXR188625; BiGG links GCC2cm, PDHcr, PDHe3hr to this KEGG reaction but the participants differ — not used; drawn as the overall reaction; KEGG draws the E1/E2/E3 steps through enzyme-bound lipoyl intermediates; KEGG ID confirmed in the built-in template ('PDH')"},variants:[{name:"pyruvate:ferredoxin oxidoreductase (PFOR, anaerobes)",ec:["1.2.7.1","1.2.7.11"],identifiers:{"kegg.reaction":["R01196"]},equation:"2 Reduced ferredoxin + Acetyl-CoA + CO2 + 2 H+ <=> 2 Oxidized ferredoxin + Pyruvate + CoA"}],provenance:[{source:"KEGG",id:"R00014",url:"https://www.kegg.jp/entry/R00014"},{source:"KEGG",id:"R00209",url:"https://www.kegg.jp/entry/R00209"},{source:"KEGG",id:"R02569",url:"https://www.kegg.jp/entry/R02569"},{source:"KEGG",id:"R03270",url:"https://www.kegg.jp/entry/R03270"},{source:"KEGG",id:"R07618",url:"https://www.kegg.jp/entry/R07618"}]},{id:"tpl_rxn_021",name:"PDC",canonicalName:"pyruvate decarboxylase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_015",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1}],reversible:!1,ec:["4.1.1.1"],identifiers:{"kegg.reaction":["R00224"],"metanetx.reaction":["MNXR103379"],"seed.reaction":["rxn00168","rxn24132","rxn28118"],"metacyc.reaction":["RXN-6161"],rhea:["45484","45485","45486","45487"],"bigg.reaction":["PYRDC"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00224 (represents map reactions R00014, R00755); MetaNetX MNXR103379; drawn as the overall reaction; KEGG draws the two TPP-dependent half-reactions"},provenance:[{source:"KEGG",id:"R00014",url:"https://www.kegg.jp/entry/R00014"},{source:"KEGG",id:"R00224",url:"https://www.kegg.jp/entry/R00224"},{source:"KEGG",id:"R00755",url:"https://www.kegg.jp/entry/R00755"}]},{id:"tpl_rxn_022",name:"ADH",canonicalName:"alcohol dehydrogenase",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:1,main:!0},{metabolite:"tpl_met_027",coefficient:1,main:!1}],reversible:!0,ec:["1.1.1.1","1.1.1.71"],identifiers:{"kegg.reaction":["R00754"],"metanetx.reaction":["MNXR95725"],"seed.reaction":["rxn00543","rxn27700","rxn30083","rxn38033","rxn38034"],"metacyc.reaction":["ALCOHOL-DEHYDROG-RXN"],rhea:["25290","25291","25292","25293"],"bigg.reaction":["ALCD2x"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00754; MetaNetX MNXR95725; BiGG links ALCD1 to this KEGG reaction but the participants differ — not used"},variants:[{name:"NADP-dependent ADH",ec:["1.1.1.2","1.1.1.71"],identifiers:{"kegg.reaction":["R00746"]},equation:"Ethanol + NADP+ <=> Acetaldehyde + NADPH + H+"},{name:"quinone-dependent ADH (PQQ)",ec:["1.1.5.5"],identifiers:{"kegg.reaction":["R09479"]},equation:"Ethanol + Ubiquinone <=> Acetaldehyde + Ubiquinol"},{name:"cytochrome c-dependent ADH",ec:["1.1.2.8"],identifiers:{"kegg.reaction":["R05198"]},equation:"Ethanol + 2 Ferricytochrome c <=> 2 Ferrocytochrome c + Acetaldehyde + 2 H+"},{name:"cytochrome cL-dependent ADH (methylotrophs)",ec:["1.1.2.7"],identifiers:{"kegg.reaction":["R09127"]},equation:"Ethanol + 2 Ferricytochrome cL <=> Acetaldehyde + 2 Ferrocytochrome cL + 2 H+"}],provenance:[{source:"KEGG",id:"R00754",url:"https://www.kegg.jp/entry/R00754"}]},{id:"tpl_rxn_023",name:"ALDH",canonicalName:"aldehyde dehydrogenase",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_027",coefficient:-1,main:!1},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!0},{metabolite:"tpl_met_028",coefficient:1,main:!1}],reversible:!0,ec:["1.2.1.3","1.2.1.5"],identifiers:{"kegg.reaction":["R00710"],"metanetx.reaction":["MNXR95749"],"seed.reaction":["rxn00506","rxn19123","rxn31362"],"metacyc.reaction":["RXN66-3"],rhea:["25294","25295","25296","25297"],"bigg.reaction":["ALDD2x"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00710; MetaNetX MNXR95749"},variants:[{name:"NADP-dependent ALDH",ec:["1.2.1.4","1.2.1.5","1.2.1.-"],identifiers:{"kegg.reaction":["R00711"]},equation:"Acetaldehyde + NADP+ + H2O <=> Acetate + NADPH + H+"}],provenance:[{source:"KEGG",id:"R00710",url:"https://www.kegg.jp/entry/R00710"}]},{id:"tpl_rxn_024",name:"ACS",canonicalName:"acetyl-CoA synthetase (AMP-forming)",participants:[{metabolite:"tpl_met_017",coefficient:-1,main:!0},{metabolite:"tpl_met_024",coefficient:-1,main:!1},{metabolite:"tpl_met_035",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_026",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.2.1.1"],identifiers:{"kegg.reaction":["R00235"],"metanetx.reaction":["MNXR190571"],"seed.reaction":["rxn00175","rxn27659","rxn27660","rxn30338"],"metacyc.reaction":["ACETATE--COA-LIGASE-RXN"],rhea:["23176","23177","23178","23179"],"bigg.reaction":["ACS"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00235; MetaNetX MNXR190571"},provenance:[{source:"KEGG",id:"R00235",url:"https://www.kegg.jp/entry/R00235"}]},{id:"tpl_rxn_025",name:"ACD",canonicalName:"acetyl-CoA synthetase (ADP-forming)",participants:[{metabolite:"tpl_met_012",coefficient:-1,main:!0},{metabolite:"tpl_met_025",coefficient:-1,main:!1},{metabolite:"tpl_met_031",coefficient:-1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!0},{metabolite:"tpl_met_024",coefficient:1,main:!1},{metabolite:"tpl_met_035",coefficient:1,main:!1}],reversible:!1,ec:["6.2.1.13"],identifiers:{"kegg.reaction":["R00229"],"metanetx.reaction":["MNXR106436"],"seed.reaction":["rxn00172","rxn27657","rxn27658","rxn31758"],"metacyc.reaction":["ACETATE--COA-LIGASE-ADP-FORMING-RXN"],rhea:["15081","15082","15083","15084"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00229; MetaNetX MNXR106436"},provenance:[{source:"KEGG",id:"R00229",url:"https://www.kegg.jp/entry/R00229"}]},{id:"tpl_rxn_026",name:"PGM",canonicalName:"phosphoglucomutase",participants:[{metabolite:"tpl_met_018",coefficient:-1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!0}],reversible:!0,ec:["5.4.2.2","5.4.2.5"],identifiers:{"kegg.reaction":["R08639"],"metanetx.reaction":["MNXR145962"],"seed.reaction":["rxn00704","rxn15773","rxn33867"],"metacyc.reaction":["PHOSPHOGLUCMUT-RXN","RXN-16999"],"bigg.reaction":["PGMT"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R08639 (represents map reactions R00959); MetaNetX MNXR145962; BiGG links PGCM, PGMTh to this KEGG reaction but the participants differ — not used"},provenance:[{source:"KEGG",id:"R00959",url:"https://www.kegg.jp/entry/R00959"},{source:"KEGG",id:"R08639",url:"https://www.kegg.jp/entry/R08639"}]},{id:"tpl_rxn_027",name:"G1Pase",canonicalName:"glucose-1-phosphatase",participants:[{metabolite:"tpl_met_018",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_001",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1}],reversible:!1,ec:["3.1.3.10"],identifiers:{"kegg.reaction":["R00947"],"metanetx.reaction":["MNXR106760"],"seed.reaction":["rxn15095"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00947; MetaNetX MNXR106760"},provenance:[{source:"KEGG",id:"R00947",url:"https://www.kegg.jp/entry/R00947"}]},{id:"tpl_rxn_028",name:"PTS",canonicalName:"arbutin PTS (EIIBC^Arb)",participants:[{metabolite:"tpl_met_020",coefficient:-1,main:!0},{metabolite:"tpl_met_038",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.-"],identifiers:{"kegg.reaction":["R05132"],"metanetx.reaction":["MNXR109343"],"seed.reaction":["rxn06860"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R05132; MetaNetX MNXR109343"},provenance:[{source:"KEGG",id:"R05132",url:"https://www.kegg.jp/entry/R05132"}]},{id:"tpl_rxn_029",name:"BglA",canonicalName:"6-phospho-β-glucosidase (arbutin 6-phosphate)",participants:[{metabolite:"tpl_met_021",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_036",coefficient:1,main:!1}],reversible:!1,ec:["3.2.1.86"],identifiers:{"kegg.reaction":["R05133"],"metanetx.reaction":["MNXR109344"],"seed.reaction":["rxn03481"],"metacyc.reaction":["RXN0-5295"],rhea:["28510","28511","28512","28513"],"bigg.reaction":["AB6PGH_1"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R05133; MetaNetX MNXR109344"},provenance:[{source:"KEGG",id:"R05133",url:"https://www.kegg.jp/entry/R05133"}]},{id:"tpl_rxn_030",name:"PTS",canonicalName:"salicin PTS",participants:[{metabolite:"tpl_met_022",coefficient:-1,main:!0},{metabolite:"tpl_met_038",coefficient:-1,main:!1},{metabolite:"tpl_met_023",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.-"],identifiers:{"kegg.reaction":["R04394"],"metanetx.reaction":["MNXR108864"],"seed.reaction":["rxn06678"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R04394; MetaNetX MNXR108864"},provenance:[{source:"KEGG",id:"R04394",url:"https://www.kegg.jp/entry/R04394"}]},{id:"tpl_rxn_031",name:"BglB",canonicalName:"6-phospho-β-glucosidase (salicin 6-phosphate)",participants:[{metabolite:"tpl_met_023",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_037",coefficient:1,main:!1}],reversible:!1,ec:["3.2.1.86"],identifiers:{"kegg.reaction":["R05134"],"metanetx.reaction":["MNXR109345"],"seed.reaction":["rxn03482"],"metacyc.reaction":["RXN0-5297"],rhea:["33127","33128","33129","33130"],"bigg.reaction":["6PHBG2"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R05134; MetaNetX MNXR109345"},provenance:[{source:"KEGG",id:"R05134",url:"https://www.kegg.jp/entry/R05134"}]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_018",direction:"in",target:{pathway:"Starch and sucrose metabolism"}},{id:"tpl_port_002",metabolite:"tpl_met_002",direction:"out",target:{pathway:"Pentose phosphate pathway",template:"kegg-map00030"}},{id:"tpl_port_003",metabolite:"tpl_met_013",direction:"in",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_004",metabolite:"tpl_met_012",direction:"out",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}}]},YN={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:-90,y:0,shape:"label"},{id:"tpl_node_002",metabolite:"tpl_met_002",x:-90,y:100,shape:"label"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:-90,y:200,shape:"label"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:-90,y:300,shape:"label"},{id:"tpl_node_005",metabolite:"tpl_met_006",x:0,y:400,shape:"label"},{id:"tpl_node_006",metabolite:"tpl_met_007",x:0,y:500,shape:"label"},{id:"tpl_node_007",metabolite:"tpl_met_008",x:0,y:600,shape:"label"},{id:"tpl_node_008",metabolite:"tpl_met_009",x:0,y:700,shape:"label"},{id:"tpl_node_009",metabolite:"tpl_met_010",x:0,y:800,shape:"label"},{id:"tpl_node_010",metabolite:"tpl_met_011",x:0,y:900,shape:"label"},{id:"tpl_node_011",metabolite:"tpl_met_012",x:0,y:1030,shape:"label"},{id:"tpl_node_012",metabolite:"tpl_met_005",x:-180,y:400,shape:"label"},{id:"tpl_node_013",metabolite:"tpl_met_019",x:-200,y:600,shape:"label"},{id:"tpl_node_014",metabolite:"tpl_met_018",x:-320,y:50,shape:"label"},{id:"tpl_node_015",metabolite:"tpl_met_013",x:240,y:750,shape:"label"},{id:"tpl_node_016",metabolite:"tpl_met_014",x:-210,y:900,shape:"label"},{id:"tpl_node_017",metabolite:"tpl_met_015",x:250,y:980,shape:"label"},{id:"tpl_node_018",metabolite:"tpl_met_016",x:450,y:980,shape:"label"},{id:"tpl_node_019",metabolite:"tpl_met_017",x:250,y:1100,shape:"label"},{id:"tpl_node_020",metabolite:"tpl_met_020",x:-710,y:-110,shape:"label"},{id:"tpl_node_021",metabolite:"tpl_met_021",x:-540,y:-110,shape:"label"},{id:"tpl_node_022",metabolite:"tpl_met_022",x:-710,y:-30,shape:"label"},{id:"tpl_node_023",metabolite:"tpl_met_023",x:-540,y:-30,shape:"label"},{id:"tpl_node_024",metabolite:"tpl_met_002",x:-360,y:-110,shape:"label"},{id:"tpl_node_025",metabolite:"tpl_met_024",x:-70.3,y:34,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_026",metabolite:"tpl_met_025",x:-70.3,y:66,attach:{reaction:"tpl_rxn_001",side:"out"}},{id:"tpl_node_027",metabolite:"tpl_met_024",x:-70.3,y:234,attach:{reaction:"tpl_rxn_004",side:"in"}},{id:"tpl_node_028",metabolite:"tpl_met_025",x:-70.3,y:266,attach:{reaction:"tpl_rxn_004",side:"out"}},{id:"tpl_node_029",metabolite:"tpl_met_031",x:16.6,y:434,attach:{reaction:"tpl_rxn_008",side:"in"}},{id:"tpl_node_030",metabolite:"tpl_met_027",x:21.8,y:422,attach:{reaction:"tpl_rxn_008",side:"in"}},{id:"tpl_node_031",metabolite:"tpl_met_028",x:22.2,y:466,attach:{reaction:"tpl_rxn_008",side:"out"}},{id:"tpl_node_032",metabolite:"tpl_met_025",x:19.7,y:534,attach:{reaction:"tpl_rxn_010",side:"in"}},{id:"tpl_node_033",metabolite:"tpl_met_024",x:19.7,y:566,attach:{reaction:"tpl_rxn_010",side:"out"}},{id:"tpl_node_034",metabolite:"tpl_met_025",x:-19.7,y:834,attach:{reaction:"tpl_rxn_016",side:"in"}},{id:"tpl_node_035",metabolite:"tpl_met_024",x:-19.7,y:866,attach:{reaction:"tpl_rxn_016",side:"out"}},{id:"tpl_node_036",metabolite:"tpl_met_035",x:19.2,y:949,attach:{reaction:"tpl_rxn_020",side:"in"}},{id:"tpl_node_037",metabolite:"tpl_met_027",x:21.8,y:933,attach:{reaction:"tpl_rxn_020",side:"in"}},{id:"tpl_node_038",metabolite:"tpl_met_034",x:19.7,y:981,attach:{reaction:"tpl_rxn_020",side:"out"}},{id:"tpl_node_039",metabolite:"tpl_met_028",x:22.2,y:997,attach:{reaction:"tpl_rxn_020",side:"out"}},{id:"tpl_node_040",metabolite:"tpl_met_031",x:1.6,y:26,attach:{reaction:"tpl_rxn_002",side:"out"}},{id:"tpl_node_041",metabolite:"tpl_met_031",x:1.6,y:226,attach:{reaction:"tpl_rxn_005",side:"out"}},{id:"tpl_node_042",metabolite:"tpl_met_024",x:79.7,y:866,attach:{reaction:"tpl_rxn_017",side:"in"}},{id:"tpl_node_043",metabolite:"tpl_met_031",x:76.6,y:882,attach:{reaction:"tpl_rxn_017",side:"in"}},{id:"tpl_node_044",metabolite:"tpl_met_026",x:79.7,y:834,attach:{reaction:"tpl_rxn_017",side:"out"}},{id:"tpl_node_045",metabolite:"tpl_met_032",x:79.2,y:818,attach:{reaction:"tpl_rxn_017",side:"out"}},{id:"tpl_node_046",metabolite:"tpl_met_024",x:146.4,y:776.8,attach:{reaction:"tpl_rxn_018",side:"in"}},{id:"tpl_node_047",metabolite:"tpl_met_025",x:96.5,y:787.2,attach:{reaction:"tpl_rxn_018",side:"out"}},{id:"tpl_node_048",metabolite:"tpl_met_034",x:69,y:792.9,attach:{reaction:"tpl_rxn_018",side:"out"}},{id:"tpl_node_049",metabolite:"tpl_met_029",x:139.3,y:476,attach:{reaction:"tpl_rxn_009",side:"in"}},{id:"tpl_node_050",metabolite:"tpl_met_030",x:139.8,y:524,attach:{reaction:"tpl_rxn_009",side:"out"}},{id:"tpl_node_051",metabolite:"tpl_met_031",x:-82,y:663.1,attach:{reaction:"tpl_rxn_013",side:"out"}},{id:"tpl_node_052",metabolite:"tpl_met_031",x:-184.5,y:13.6,attach:{reaction:"tpl_rxn_027",side:"out"}},{id:"tpl_node_053",metabolite:"tpl_met_028",x:-76.8,y:916,attach:{reaction:"tpl_rxn_019",side:"in"}},{id:"tpl_node_054",metabolite:"tpl_met_027",x:-132.8,y:916,attach:{reaction:"tpl_rxn_019",side:"out"}},{id:"tpl_node_055",metabolite:"tpl_met_034",x:146.8,y:954.7,attach:{reaction:"tpl_rxn_021",side:"out"}},{id:"tpl_node_056",metabolite:"tpl_met_028",x:321.8,y:964,attach:{reaction:"tpl_rxn_022",side:"in"}},{id:"tpl_node_057",metabolite:"tpl_met_027",x:377.8,y:964,attach:{reaction:"tpl_rxn_022",side:"out"}},{id:"tpl_node_058",metabolite:"tpl_met_027",x:271.8,y:1024,attach:{reaction:"tpl_rxn_023",side:"in"}},{id:"tpl_node_059",metabolite:"tpl_met_028",x:272.2,y:1056,attach:{reaction:"tpl_rxn_023",side:"out"}},{id:"tpl_node_060",metabolite:"tpl_met_024",x:161.9,y:1027.2,attach:{reaction:"tpl_rxn_024",side:"in"}},{id:"tpl_node_061",metabolite:"tpl_met_035",x:188.2,y:1034.7,attach:{reaction:"tpl_rxn_024",side:"in"}},{id:"tpl_node_062",metabolite:"tpl_met_026",x:113.1,y:1013.5,attach:{reaction:"tpl_rxn_024",side:"out"}},{id:"tpl_node_063",metabolite:"tpl_met_032",x:86.8,y:1006.3,attach:{reaction:"tpl_rxn_024",side:"out"}},{id:"tpl_node_064",metabolite:"tpl_met_025",x:88.1,y:1102.8,attach:{reaction:"tpl_rxn_025",side:"in"}},{id:"tpl_node_065",metabolite:"tpl_met_031",x:69.1,y:1096.7,attach:{reaction:"tpl_rxn_025",side:"in"}},{id:"tpl_node_066",metabolite:"tpl_met_024",x:136.9,y:1116.5,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_067",metabolite:"tpl_met_035",x:163.2,y:1123.7,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_068",metabolite:"tpl_met_038",x:-675.3,y:-126,attach:{reaction:"tpl_rxn_028",side:"in"}},{id:"tpl_node_069",metabolite:"tpl_met_040",x:-585.6,y:-126,attach:{reaction:"tpl_rxn_028",side:"out"}},{id:"tpl_node_070",metabolite:"tpl_met_038",x:-675.3,y:-46,attach:{reaction:"tpl_rxn_030",side:"in"}},{id:"tpl_node_071",metabolite:"tpl_met_040",x:-585.6,y:-46,attach:{reaction:"tpl_rxn_030",side:"out"}},{id:"tpl_node_072",metabolite:"tpl_met_036",x:-407.5,y:-126,attach:{reaction:"tpl_rxn_029",side:"out"}},{id:"tpl_node_073",metabolite:"tpl_met_037",x:-414.2,y:-93.8,attach:{reaction:"tpl_rxn_031",side:"out"}}],ports:[{id:"tpl_node_074",connector:"tpl_port_001",x:-510,y:50,from:"tpl_node_014"},{id:"tpl_node_075",connector:"tpl_port_002",x:170,y:130,from:"tpl_node_002"},{id:"tpl_node_076",connector:"tpl_port_003",x:420,y:750,from:"tpl_node_015"},{id:"tpl_node_077",connector:"tpl_port_004",x:0,y:1150,from:"tpl_node_011"}],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_006",sources:["tpl_node_004"],targets:["tpl_node_012","tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_007",sources:["tpl_node_012"],targets:["tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_014",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"straight"},{reaction:"tpl_rxn_015",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"straight"},{reaction:"tpl_rxn_016",sources:["tpl_node_009"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_020",sources:["tpl_node_010"],targets:["tpl_node_011"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_001"],routing:"curved",bend:75,label_offset:{x:33.3,y:0}},{reaction:"tpl_rxn_005",sources:["tpl_node_004"],targets:["tpl_node_003"],routing:"curved",bend:75,label_offset:{x:33.3,y:0}},{reaction:"tpl_rxn_017",sources:["tpl_node_010"],targets:["tpl_node_009"],routing:"curved",bend:60,label_offset:{x:26.5,y:0}},{reaction:"tpl_rxn_018",sources:["tpl_node_015"],targets:["tpl_node_009"],routing:"curved",bend:25,label_flip:!0,label_offset:{x:3.4,y:16.2}},{reaction:"tpl_rxn_009",sources:["tpl_node_005"],targets:["tpl_node_007"],routing:"curved",bend:115,label_flip:!0,label_offset:{x:26.3,y:-0}},{reaction:"tpl_rxn_011",sources:["tpl_node_006"],targets:["tpl_node_013"],routing:"curved",bend:22,label_offset:{x:-8.7,y:-17.3}},{reaction:"tpl_rxn_012",sources:["tpl_node_013"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_013",sources:["tpl_node_013"],targets:["tpl_node_008"],routing:"curved",bend:22,label_offset:{x:-8.9,y:17.8}},{reaction:"tpl_rxn_026",sources:["tpl_node_014"],targets:["tpl_node_002"],routing:"curved",bend:24,label_flip:!0,label_offset:{x:3.6,y:-16.6}},{reaction:"tpl_rxn_027",sources:["tpl_node_014"],targets:["tpl_node_001"],routing:"curved",bend:24,label_flip:!0,label_offset:{x:-3.8,y:-17.3}},{reaction:"tpl_rxn_019",sources:["tpl_node_010"],targets:["tpl_node_016"],routing:"straight"},{reaction:"tpl_rxn_021",sources:["tpl_node_010"],targets:["tpl_node_017"],routing:"curved",bend:26,label_offset:{x:-5.5,y:17.1}},{reaction:"tpl_rxn_022",sources:["tpl_node_017"],targets:["tpl_node_018"],routing:"straight"},{reaction:"tpl_rxn_023",sources:["tpl_node_017"],targets:["tpl_node_019"],routing:"straight"},{reaction:"tpl_rxn_024",sources:["tpl_node_019"],targets:["tpl_node_011"],routing:"curved",bend:28,label_offset:{x:4.8,y:-17}},{reaction:"tpl_rxn_025",sources:["tpl_node_011"],targets:["tpl_node_019"],routing:"curved",bend:28,label_offset:{x:-4.5,y:16.2}},{reaction:"tpl_rxn_028",sources:["tpl_node_020"],targets:["tpl_node_021"],routing:"straight"},{reaction:"tpl_rxn_030",sources:["tpl_node_022"],targets:["tpl_node_023"],routing:"straight"},{reaction:"tpl_rxn_029",sources:["tpl_node_021"],targets:["tpl_node_024"],routing:"straight",label_flip:!0},{reaction:"tpl_rxn_031",sources:["tpl_node_023"],targets:["tpl_node_024"],routing:"curved",bend:20,label_offset:{x:7.5,y:16.9}}],groups:[{id:"tpl_grp_001",kind:"pathway",title:"Aryl-β-D-glucosides (PTS, bacteria)",nodes:["tpl_node_020","tpl_node_021","tpl_node_022","tpl_node_023","tpl_node_024"]}],labels:[{id:"tpl_lbl_001",x:-730,y:-200,text:"Glycolysis / Gluconeogenesis",size:16,weight:700,kind:"title"},{id:"tpl_lbl_002",x:-730,y:-180,text:"derived from KEGG map00010 · drawn by GEMsMAP",size:10,weight:400,italic:!0,kind:"text"},{id:"tpl_lbl_003",x:-270,y:550,text:"2,3-BPG shunt",size:11,weight:600,italic:!0,kind:"text"},{id:"tpl_lbl_004",x:300,y:930,text:"Fermentation",size:11,weight:600,italic:!0,kind:"text"}]},ZN={format:UN,schema_version:qN,metadata:VN,biology:WN,layout:YN},QN="gemsmap-template",JN="1.1.0",ew={id:"kegg-map00020",name:"Citrate cycle (TCA cycle) (KEGG map00020)",description:"The citrate cycle with the entries and exits KEGG map00020 draws: pyruvate dehydrogenase, pyruvate carboxylase and PEP carboxykinase (anaplerosis), ATP-citrate lyase (citrate cleavage, reductive TCA / lipogenesis) and cis-aconitate as the aconitase intermediate. Derived from KEGG; drawn by GEMsMAP.",pathway:"Citrate cycle (TCA cycle)",section:"KEGG-derived templates",template_version:"0.1.0",scope:{level:"universal",taxa:[],note:"The cycle is conserved; ATP-citrate lyase, PC and the ferredoxin-dependent oxidoreductases (PFOR, OGOR) are organism-specific. Compartments are left to the person mapping onto a GEM (mitochondrial in eukaryotes, cytosolic in prokaryotes)."},authors:["Drafted with an LLM (Claude Opus 5.5)"],created:"2026-10-09T00:00:00Z",modified:"2026-10-09T18:53:21Z",license:"MIT (drawing and curation); identifiers and biology from KEGG, MetaNetX and BiGG",tags:["KEGG","map00020","TCA cycle","citrate cycle","central carbon"],citations:[{text:"Kanehisa M, Goto S. KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res 28:27-30 (2000)",doi:"10.1093/nar/28.1.27"}],layout_kind:"vertical",review_status:"ai-generated",source:{reference:"KEGG",pathway_id:"map00020",pathway_name:"Citrate cycle (TCA cycle)",url:"https://www.genome.jp/pathway/map00020",generation_method:"KEGG flat files + KGML (structure only) → curated biological graph → identities reconciled with MetaNetX (backend client) and the BiGG tables → hand-designed layout",generated_by:"tools/kegg/kegg_template.py",retrieved:"2026-10-09"}},tw={compartments:[],entities:[{id:"tpl_ent_001",name:"Pyruvate",short:"Pyruvate",formula:"C3H3O3",charge:-1,synonyms:["2-Oxopropanoate","2-Oxopropanoic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr","Pyroracemic acid","Pyruvic acid","pyruvate","pyruvic acid"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816","CHEBI:15361","CHEBI:177913","CHEBI:32816"],"metanetx.chemical":["MNXM23"],"bigg.metabolite":["pyr"],hmdb:["HMDB0000243"],"metacyc.compound":["PYRUVATE"],"seed.compound":["cpd00020"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00022; MetaNetX MNXM23; BiGG pyr; GEMsMAP library 'pyruvate'"},library:"pyruvate",provenance:{source:"KEGG",id:"C00022",url:"https://www.kegg.jp/entry/C00022"}},{id:"tpl_ent_002",name:"Acetyl-CoA",short:"Acetyl-CoA",formula:"C23H34N7O17P3S",charge:-4,synonyms:["AcCoA","Acetyl coenzyme A","acetyl coenzyme A","acetyl-CoA","acetyl-coenzyme A"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288","CHEBI:15351","CHEBI:57288"],"metanetx.chemical":["MNXM1104266"],"bigg.metabolite":["accoa"],hmdb:["HMDB0001206"],"metacyc.compound":["ACETYL-COA"],"seed.compound":["cpd00022"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00024; MetaNetX MNXM1104266; BiGG accoa; GEMsMAP library 'acetyl-CoA'"},library:"acetyl-CoA",provenance:{source:"KEGG",id:"C00024",url:"https://www.kegg.jp/entry/C00024"}},{id:"tpl_ent_003",name:"Oxaloacetate",short:"Oxaloacetate",formula:"C4H2O5",charge:-2,synonyms:["2-Oxobutanedioic acid","2-Oxosuccinic acid","2-oxosuccinate","OAA","Oxalacetic acid","Oxaloacetic acid","keto-Oxaloacetate","oxalacetate","oxaloacetate","oxaloacetic acid"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744","CHEBI:16452","CHEBI:30744"],"metanetx.chemical":["MNXM46"],"bigg.metabolite":["oaa"],hmdb:["HMDB0000223"],"metacyc.compound":["OXALACETIC_ACID"],"seed.compound":["cpd00032"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00036; MetaNetX MNXM46; BiGG oaa; GEMsMAP library 'oxaloacetate'"},library:"oxaloacetate",provenance:{source:"KEGG",id:"C00036",url:"https://www.kegg.jp/entry/C00036"}},{id:"tpl_ent_004",name:"Citrate",short:"Citrate",formula:"C6H5O7",charge:-3,synonyms:["2-Hydroxy-1,2,3-propanetricarboxylic acid","2-Hydroxytricarballylic acid","2-hydroxypropane-1,2,3-tricarboxylate","Cit","Citric acid","citrate","citric acid"],identifiers:{"kegg.compound":["C00158"],chebi:["16947","30769","CHEBI:132362","CHEBI:133748","CHEBI:16947","CHEBI:30769","CHEBI:35802","CHEBI:35804","CHEBI:35806","CHEBI:35808","CHEBI:35809","CHEBI:35810","CHEBI:76049"],"metanetx.chemical":["MNXM1107752"],"bigg.metabolite":["cit"],hmdb:["HMDB0000094"],"metacyc.compound":["CIT"],"seed.compound":["cpd00137"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00158; MetaNetX MNXM1107752; BiGG cit; GEMsMAP library 'citrate'"},library:"citrate",provenance:{source:"KEGG",id:"C00158",url:"https://www.kegg.jp/entry/C00158"}},{id:"tpl_ent_005",name:"cis-Aconitate",short:"cis-Aconitate",formula:"C6H3O6",charge:-3,synonyms:["cis-Aconitic acid"],identifiers:{"kegg.compound":["C00417"],chebi:["CHEBI:16383","CHEBI:32805"],"metanetx.chemical":["MNXM1092518"],"bigg.metabolite":["acon"],hmdb:["HMDB0000072","HMDB0000461"],"metacyc.compound":["CIS-ACONITATE"],"seed.compound":["cpd00331"]},identity:{status:"suggested",source:"ai",note:"KEGG C00417; MetaNetX MNXM1092518; BiGG acon",confidence:"high"},provenance:{source:"KEGG",id:"C00417",url:"https://www.kegg.jp/entry/C00417"}},{id:"tpl_ent_006",name:"Isocitrate",short:"Isocitrate",formula:"C6H5O7",charge:-3,synonyms:["(2R,3S)-isocitrate","1-Hydroxypropane-1,2,3-tricarboxylic acid","1-Hydroxytricarballylic acid","D-isocitrate","D-threo-isocitrate","Isocitric acid","isocitrate","isocitric acid","threo-Ds-isocitrate"],identifiers:{"kegg.compound":["C00311"],chebi:["16087","30887","CHEBI:16087","CHEBI:30887","CHEBI:36453","CHEBI:36454"],"metanetx.chemical":["MNXM89661"],"bigg.metabolite":["icit"],hmdb:["HMDB0000193","HMDB0304324"],"metacyc.compound":["Isocitrate","THREO-DS-ISO-CITRATE"],"seed.compound":["cpd00260"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00311; MetaNetX MNXM89661; BiGG icit; GEMsMAP library 'isocitrate'"},library:"isocitrate",provenance:{source:"KEGG",id:"C00311",url:"https://www.kegg.jp/entry/C00311"}},{id:"tpl_ent_007",name:"2-Oxoglutarate",short:"2-Oxoglutarate",formula:"C5H4O5",charge:-2,synonyms:["2-Ketoglutaric acid","2-ketoglutarate","2-oxoglutarate","2-oxoglutaric acid","Oxoglutaric acid","alpha-Ketoglutaric acid","alpha-ketoglutarate","alpha-ketoglutaric acid","oxoglutarate"],identifiers:{"kegg.compound":["C00026"],chebi:["16810","30915","CHEBI:16810","CHEBI:178058","CHEBI:178083","CHEBI:30915","CHEBI:30916"],"metanetx.chemical":["MNXM1368744"],"bigg.metabolite":["akg"],hmdb:["HMDB0000208","HMDB0002812","HMDB0062781"],"metacyc.compound":["2-KETOGLUTARATE"],"seed.compound":["cpd00024","cpd32228"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00026; MetaNetX MNXM1368744; BiGG akg; GEMsMAP library '2-oxoglutarate'"},library:"2-oxoglutarate",provenance:{source:"KEGG",id:"C00026",url:"https://www.kegg.jp/entry/C00026"}},{id:"tpl_ent_008",name:"Succinyl-CoA",short:"Succinyl-CoA",formula:"C25H35N7O19P3S",charge:-5,synonyms:["SucCoA","Succinyl coenzyme A","succinyl coenzyme A","succinyl-CoA","succinyl-coenzyme A"],identifiers:{"kegg.compound":["C00091"],chebi:["15380","57292","CHEBI:15380","CHEBI:57292"],"metanetx.chemical":["MNXM1104774"],"bigg.metabolite":["succoa"],hmdb:["HMDB0001022"],"metacyc.compound":["SUC-COA"],"seed.compound":["cpd00078"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00091; MetaNetX MNXM1104774; BiGG succoa; GEMsMAP library 'succinyl-CoA'"},library:"succinyl-CoA",provenance:{source:"KEGG",id:"C00091",url:"https://www.kegg.jp/entry/C00091"}},{id:"tpl_ent_009",name:"Succinate",short:"Succinate",formula:"C4H4O4",charge:-2,synonyms:["Butanedionic acid","Ethylenesuccinic acid","Succ","Succinic acid","butanedioate","butanedioic acid","succinate","succinic acid"],identifiers:{"kegg.compound":["C00042"],chebi:["15741","26806","30031","CHEBI:15741","CHEBI:172952","CHEBI:30031","CHEBI:30779","CHEBI:90372"],"metanetx.chemical":["MNXM25"],"bigg.metabolite":["succ"],hmdb:["HMDB0000254"],"metacyc.compound":["SUC"],"seed.compound":["cpd00036"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00042; MetaNetX MNXM25; BiGG succ; GEMsMAP library 'succinate'"},library:"succinate",provenance:{source:"KEGG",id:"C00042",url:"https://www.kegg.jp/entry/C00042"}},{id:"tpl_ent_010",name:"Fumarate",short:"Fumarate",formula:"C4H2O4",charge:-2,synonyms:["(E)-butenedioate","Fum","Fumaric acid","fumarate","fumaric acid","trans-Butenedioic acid","trans-butenedioate"],identifiers:{"kegg.compound":["C00122"],chebi:["18012","29806","CHEBI:18012","CHEBI:29806","CHEBI:37154"],"metanetx.chemical":["MNXM737340"],"bigg.metabolite":["fum"],hmdb:["HMDB0000134"],"metacyc.compound":["FUM"],"seed.compound":["cpd00106"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00122; MetaNetX MNXM737340; BiGG fum; GEMsMAP library 'fumarate'"},library:"fumarate",provenance:{source:"KEGG",id:"C00122",url:"https://www.kegg.jp/entry/C00122"}},{id:"tpl_ent_011",name:"L-Malate",short:"Malate",formula:"C4H4O5",charge:-2,synonyms:["(S)-malate","(S)-malic acid","L-2-Hydroxybutanedioic acid","L-Apple acid","L-Malate","L-Malic acid","L-malate","L-malic acid","Mal","Malate","Malic acid"],identifiers:{"kegg.compound":["C00149","C00711"],chebi:["15589","30797","CHEBI:15589","CHEBI:15595","CHEBI:30797","CHEBI:6650"],"metanetx.chemical":["MNXM1107192"],"bigg.metabolite":["mal_L","mal__L"],hmdb:["HMDB0000156","HMDB0000744"],"metacyc.compound":["MAL","RS-Malate"],"seed.compound":["cpd00130","cpd30742"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00149; MetaNetX MNXM1107192; BiGG mal__L; GEMsMAP library 'L-malate'"},related:[{note:"stereo-unspecified malate",names:["malate","malic acid"],identifiers:{"kegg.compound":["C00711"]}}],library:"L-malate",provenance:{source:"KEGG",id:"C00149",url:"https://www.kegg.jp/entry/C00149"}},{id:"tpl_ent_012",name:"Phosphoenolpyruvate",short:"PEP",formula:"C3H2O6P",charge:-3,synonyms:["PEP","Phosphoenolpyruvic acid","phospho-enol-pyruvate","phosphoenolpyruvate","phosphoenolpyruvic acid"],identifiers:{"kegg.compound":["C00074"],chebi:["18021","58702","CHEBI:18021","CHEBI:44897","CHEBI:58702"],"metanetx.chemical":["MNXM73"],"bigg.metabolite":["pep"],hmdb:["HMDB0000263"],"metacyc.compound":["PHOSPHO-ENOL-PYRUVATE"],"seed.compound":["cpd00061"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00074; MetaNetX MNXM73; BiGG pep; GEMsMAP library 'phosphoenolpyruvate'"},library:"phosphoenolpyruvate",provenance:{source:"KEGG",id:"C00074",url:"https://www.kegg.jp/entry/C00074"}},{id:"tpl_ent_013",name:"ATP",short:"ATP",formula:"C10H12N5O13P3",charge:-4,synonyms:["Adenosine 5'-triphosphate","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616","CHEBI:15422","CHEBI:237958","CHEBI:30616","CHEBI:57299"],"metanetx.chemical":["MNXM3"],"bigg.metabolite":["atp"],hmdb:["HMDB0000538"],"metacyc.compound":["ATP"],"seed.compound":["cpd00002"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00002; MetaNetX MNXM3; BiGG atp; GEMsMAP library 'ATP'"},library:"ATP",provenance:{source:"KEGG",id:"C00002",url:"https://www.kegg.jp/entry/C00002"}},{id:"tpl_ent_014",name:"ADP",short:"ADP",formula:"C10H12N5O10P2",charge:-3,synonyms:["Adenosine 5'-diphosphate","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216","CHEBI:16761","CHEBI:456216","CHEBI:87518"],"metanetx.chemical":["MNXM40333"],"bigg.metabolite":["adp"],hmdb:["HMDB0001341"],"metacyc.compound":["ADP","ADP-GROUP"],"seed.compound":["cpd00008","cpd22244"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00008; MetaNetX MNXM40333; BiGG adp; GEMsMAP library 'ADP'"},library:"ADP",provenance:{source:"KEGG",id:"C00008",url:"https://www.kegg.jp/entry/C00008"}},{id:"tpl_ent_015",name:"Orthophosphate",short:"Pᵢ",formula:"HO4P",charge:-2,synonyms:["Orthophosphoric acid","Phosphate","Phosphoric acid","Pi","inorganic phosphate","orthophosphate","phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078","CHEBI:18367","CHEBI:26020","CHEBI:26078","CHEBI:35780","CHEBI:39745","CHEBI:43474"],"metanetx.chemical":["MNXM9"],"bigg.metabolite":["pi"],hmdb:["HMDB0000973","HMDB0001429","HMDB0002105","HMDB0002142","HMDB0005947"],"seed.compound":["cpd00009","cpd27787"],"metacyc.compound":["Pi"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00009; MetaNetX MNXM9; BiGG pi; GEMsMAP library 'phosphate'"},library:"phosphate",provenance:{source:"KEGG",id:"C00009",url:"https://www.kegg.jp/entry/C00009"}},{id:"tpl_ent_016",name:"NAD+",short:"NAD⁺",formula:"C21H26N7O14P2",charge:-1,synonyms:["DPN","Diphosphopyridine nucleotide","NAD","Nadide","Nicotinamide adenine dinucleotide","beta-NAD+","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540","CHEBI:15846","CHEBI:44215","CHEBI:57540"],"metanetx.chemical":["MNXM8"],"bigg.metabolite":["nad"],hmdb:["HMDB0000902"],"metacyc.compound":["NAD"],"seed.compound":["cpd00003"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00003; MetaNetX MNXM8; BiGG nad; GEMsMAP library 'NAD+'"},library:"NAD+",provenance:{source:"KEGG",id:"C00003",url:"https://www.kegg.jp/entry/C00003"}},{id:"tpl_ent_017",name:"NADH",short:"NADH",formula:"C21H27N7O14P2",charge:-2,synonyms:["DPNH","Reduced nicotinamide adenine dinucleotide","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945","CHEBI:16908","CHEBI:57945"],"metanetx.chemical":["MNXM10"],"bigg.metabolite":["nadh"],hmdb:["HMDB0001487"],"metacyc.compound":["NADH"],"seed.compound":["cpd00004"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00004; MetaNetX MNXM10; BiGG nadh; GEMsMAP library 'NADH'"},library:"NADH",provenance:{source:"KEGG",id:"C00004",url:"https://www.kegg.jp/entry/C00004"}},{id:"tpl_ent_018",name:"H2O",short:"H2O",formula:"H2O",charge:0,synonyms:["Water","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377","CHEBI:15377","CHEBI:29374","CHEBI:29375","CHEBI:33806","CHEBI:33811","CHEBI:33813","CHEBI:41981"],"metanetx.chemical":["WATER"],"bigg.metabolite":["h2o"],hmdb:["HMDB0002111"],"metacyc.compound":["WATER"],"seed.compound":["cpd00001"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00001; MetaNetX WATER; BiGG h2o; GEMsMAP library 'H2O'"},library:"H2O",provenance:{source:"KEGG",id:"C00001",url:"https://www.kegg.jp/entry/C00001"}},{id:"tpl_ent_019",name:"CO2",short:"CO₂",formula:"CO2",charge:0,synonyms:["Carbon dioxide","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526","CHEBI:139538","CHEBI:16526"],"metanetx.chemical":["MNXM13"],"bigg.metabolite":["co2"],hmdb:["HMDB0001967"],"metacyc.compound":["CARBON-DIOXIDE"],"seed.compound":["cpd00011"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00011; MetaNetX MNXM13; BiGG co2; GEMsMAP library 'CO2'"},library:"CO2",provenance:{source:"KEGG",id:"C00011",url:"https://www.kegg.jp/entry/C00011"}},{id:"tpl_ent_020",name:"Coenzyme A",short:"CoA",formula:"C21H32N7O16P3S",charge:-4,synonyms:["CoA-SH","Coenzyme A","coenzyme A"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287","CHEBI:15346","CHEBI:57287"],"metanetx.chemical":["MNXM727276"],"bigg.metabolite":["coa"],hmdb:["HMDB0001423","HMDB0062184"],"metacyc.compound":["CO-A","COA-GROUP"],"seed.compound":["cpd00010"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00010; MetaNetX MNXM727276; BiGG coa; GEMsMAP library 'CoA'"},library:"CoA",provenance:{source:"KEGG",id:"C00010",url:"https://www.kegg.jp/entry/C00010"}},{id:"tpl_ent_021",name:"HCO3-",short:"HCO₃⁻",formula:"CHO3",charge:-1,synonyms:["Acid carbonate","Bicarbonate","Hydrogen carbonate","Hydrogencarbonate"],identifiers:{"kegg.compound":["C00288","C01353"],chebi:["CHEBI:140315","CHEBI:17544","CHEBI:28976","CHEBI:41609"],"metanetx.chemical":["MNXM1094693"],"bigg.metabolite":["h2co3"],hmdb:["HMDB0000595","HMDB0003538","HMDB0031453"],"seed.compound":["cpd00242"]},identity:{status:"suggested",source:"ai",note:"KEGG C00288; MetaNetX MNXM1094693; BiGG h2co3",confidence:"high"},provenance:{source:"KEGG",id:"C00288",url:"https://www.kegg.jp/entry/C00288"}},{id:"tpl_ent_022",name:"Quinone",short:"Q",synonyms:[],identifiers:{"kegg.compound":["C15602"],chebi:["CHEBI:16509"],"metanetx.chemical":["MNXM1776"]},identity:{status:"suggested",source:"ai",note:"KEGG C15602; MetaNetX MNXM1776",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C15602",url:"https://www.kegg.jp/entry/C15602"}},{id:"tpl_ent_023",name:"Hydroquinone",short:"QH₂",formula:"C6H2O2*4",charge:0,synonyms:["Quinol","Reduced quinone","p-Hydroquinone"],identifiers:{"kegg.compound":["C15603"],chebi:["CHEBI:17594"],"metanetx.chemical":["MNXM4100"],"metacyc.compound":["Reduced-Quinones"],"seed.compound":["cpd30750"],"bigg.metabolite":["hqn"]},identity:{status:"suggested",source:"ai",note:"KEGG C15603; MetaNetX MNXM4100; BiGG hqn",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C15603",url:"https://www.kegg.jp/entry/C15603"}}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:null,level:"recommended"},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:null,level:"required"},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:null,level:"required"},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:null,level:"required"},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:null,level:"recommended"},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:null,level:"required"},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:null,level:"required"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:null,level:"required"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:null,level:"required"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:null,level:"required"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:null,level:"required"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:null,level:"optional"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:null,level:"optional"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:null,level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:null,level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:null,level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:null,level:"optional"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:null,level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:null,level:"optional"},{id:"tpl_met_020",entity:"tpl_ent_020",compartment:null,level:"optional"},{id:"tpl_met_021",entity:"tpl_ent_021",compartment:null,level:"optional"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:null,level:"optional"},{id:"tpl_met_023",entity:"tpl_ent_023",compartment:null,level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"PDH",canonicalName:"pyruvate dehydrogenase complex",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_020",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!1}],reversible:!1,ec:["1.2.4.1","2.3.1.12","1.8.1.4"],identifiers:{"kegg.reaction":["R00209"],"metanetx.reaction":["MNXR188625"],"seed.reaction":["rxn00154","rxn20656","rxn30418"],"metacyc.reaction":["PYRUVDEH-RXN"],rhea:["28042","28043","28044","28045"],"bigg.reaction":["PDH"]},level:"recommended",identity:{status:"confirmed",source:"builtin",note:"KEGG R00209 (represents map reactions R00014, R03270, R02569, R07618); MetaNetX MNXR188625; BiGG links GCC2cm, PDHcr, PDHe3hr to this KEGG reaction but the participants differ — not used; drawn as the overall reaction; KEGG draws the E1/E2/E3 steps through enzyme-bound lipoyl intermediates; KEGG ID confirmed in the built-in template ('PDH')"},variants:[{name:"pyruvate:ferredoxin oxidoreductase (PFOR, anaerobes; also reductive TCA)",ec:["1.2.7.1","1.2.7.11"],identifiers:{"kegg.reaction":["R01196"]},equation:"2 Reduced ferredoxin + Acetyl-CoA + CO2 + 2 H+ <=> 2 Oxidized ferredoxin + Pyruvate + CoA"}],provenance:[{source:"KEGG",id:"R00014",url:"https://www.kegg.jp/entry/R00014"},{source:"KEGG",id:"R00209",url:"https://www.kegg.jp/entry/R00209"},{source:"KEGG",id:"R02569",url:"https://www.kegg.jp/entry/R02569"},{source:"KEGG",id:"R03270",url:"https://www.kegg.jp/entry/R03270"},{source:"KEGG",id:"R07618",url:"https://www.kegg.jp/entry/R07618"}]},{id:"tpl_rxn_002",name:"CS",canonicalName:"citrate synthase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_020",coefficient:1,main:!1}],reversible:!0,ec:["2.3.3.1","2.3.3.3","2.3.3.5","2.3.3.16"],identifiers:{"kegg.reaction":["R00351"],"metanetx.reaction":["MNXR190844"],"seed.reaction":["rxn00256","rxn19316","rxn27765","rxn32388","rxn34204"],"metacyc.reaction":["CITSYN-RXN"],rhea:["16845","16846","16847","16848"],"bigg.reaction":["CS"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00351; MetaNetX MNXR190844; KEGG ID confirmed in the built-in template ('CS')"},provenance:[{source:"KEGG",id:"R00351",url:"https://www.kegg.jp/entry/R00351"}]},{id:"tpl_rxn_003",name:"ACO",canonicalName:"aconitase (citrate → cis-aconitate)",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_018",coefficient:1,main:!1}],reversible:!0,ec:["4.2.1.3"],identifiers:{"kegg.reaction":["R01325"],"metanetx.reaction":["MNXR154367"],"seed.reaction":["rxn00974","rxn19039","rxn30619","rxn31223","rxn33227","rxn33231"],"metacyc.reaction":["ACONITATEDEHYDR-RXN"],rhea:["10228","10229","10230","10231"],"bigg.reaction":["ACONTa_1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01325; MetaNetX MNXR154367"},provenance:[{source:"KEGG",id:"R01325",url:"https://www.kegg.jp/entry/R01325"}]},{id:"tpl_rxn_004",name:"ACO",canonicalName:"aconitase (cis-aconitate → isocitrate)",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:-1,main:!1},{metabolite:"tpl_met_006",coefficient:1,main:!0}],reversible:!0,ec:["4.2.1.3"],identifiers:{"kegg.reaction":["R01900"],"metanetx.reaction":["MNXR191427"],"seed.reaction":["rxn01388","rxn32587","rxn32588","rxn32589","rxn34304"],"bigg.reaction":["ACONTb"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01900; MetaNetX MNXR191427"},provenance:[{source:"KEGG",id:"R01900",url:"https://www.kegg.jp/entry/R01900"}]},{id:"tpl_rxn_005",name:"IDH",canonicalName:"isocitrate dehydrogenase",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!1}],reversible:!0,ec:["1.1.1.41","1.1.1.286"],identifiers:{"kegg.reaction":["R00709"],"metanetx.reaction":["MNXR100782"],"seed.reaction":["rxn00505","rxn30141"],"bigg.reaction":["ICDHx"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00709 (represents map reactions R01899, R00268); MetaNetX MNXR100782; BiGG links OSUCCL to this KEGG reaction but the participants differ — not used; NAD-IDH drawn; KEGG draws the NADP-IDH (variant R00267) as two half-reactions through enzyme-bound oxalosuccinate; KEGG ID confirmed in the built-in template ('ICDH')"},variants:[{name:"NADP-dependent IDH (bacteria; cytosolic / mitochondrial IDP in eukaryotes)",ec:["1.1.1.42"],identifiers:{"kegg.reaction":["R00267"]},equation:"Isocitrate + NADP+ <=> 2-Oxoglutarate + CO2 + NADPH + H+"}],provenance:[{source:"KEGG",id:"R00268",url:"https://www.kegg.jp/entry/R00268"},{source:"KEGG",id:"R00709",url:"https://www.kegg.jp/entry/R00709"},{source:"KEGG",id:"R01899",url:"https://www.kegg.jp/entry/R01899"}]},{id:"tpl_rxn_006",name:"OGDH",canonicalName:"2-oxoglutarate dehydrogenase complex",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_020",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!1}],reversible:!1,ec:["1.2.4.2","2.3.1.61","1.8.1.4"],identifiers:{"kegg.reaction":["R08549"],"metanetx.reaction":["MNXR190634"],"seed.reaction":["rxn08094","rxn17745"],"metacyc.reaction":["2OXOGLUTARATEDEH-RXN"],rhea:["27786","27787","27788","27789"],"bigg.reaction":["AKGDH"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R08549 (represents map reactions R00621, R03316, R02570, R07618); MetaNetX MNXR190634; BiGG links GCC2cm, PDHcr, PDHe3hr to this KEGG reaction but the participants differ — not used; drawn as the overall reaction; KEGG draws the E1/E2/E3 steps through enzyme-bound intermediates; KEGG ID confirmed in the built-in template ('AKGDH')"},variants:[{name:"2-oxoglutarate:ferredoxin oxidoreductase (OGOR, anaerobes; reductive TCA)",ec:["1.2.7.3","1.2.7.11"],identifiers:{"kegg.reaction":["R01197"]},equation:"2 Reduced ferredoxin + Succinyl-CoA + CO2 + 2 H+ <=> 2 Oxidized ferredoxin + 2-Oxoglutarate + CoA"}],provenance:[{source:"KEGG",id:"R00621",url:"https://www.kegg.jp/entry/R00621"},{source:"KEGG",id:"R02570",url:"https://www.kegg.jp/entry/R02570"},{source:"KEGG",id:"R03316",url:"https://www.kegg.jp/entry/R03316"},{source:"KEGG",id:"R07618",url:"https://www.kegg.jp/entry/R07618"},{source:"KEGG",id:"R08549",url:"https://www.kegg.jp/entry/R08549"}]},{id:"tpl_rxn_007",name:"SCS",canonicalName:"succinyl-CoA synthetase",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_014",coefficient:-1,main:!1},{metabolite:"tpl_met_015",coefficient:-1,main:!1},{metabolite:"tpl_met_009",coefficient:1,main:!0},{metabolite:"tpl_met_013",coefficient:1,main:!1},{metabolite:"tpl_met_020",coefficient:1,main:!1}],reversible:!0,ec:["6.2.1.5"],identifiers:{"kegg.reaction":["R00405"],"metanetx.reaction":["MNXR188878"],"seed.reaction":["rxn00285","rxn28991"],"metacyc.reaction":["SUCCCOASYN-RXN"],rhea:["17661","17662","17663","17664"],"bigg.reaction":["SUCOAS"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00405; MetaNetX MNXR188878; BiGG links SUCOAS1m to this KEGG reaction but the participants differ — not used; KEGG ID confirmed in the built-in template ('SUCOAS')"},variants:[{name:"GTP-forming SCS (animals)",ec:["6.2.1.4"],identifiers:{"kegg.reaction":["R00432"]},equation:"GTP + Succinate + CoA <=> GDP + Orthophosphate + Succinyl-CoA"},{name:"ITP-forming SCS",ec:["6.2.1.4"],identifiers:{"kegg.reaction":["R00727"]},equation:"ITP + Succinate + CoA <=> IDP + Orthophosphate + Succinyl-CoA"},{name:"succinyl-CoA:acetate CoA-transferase (SCACT, acetic acid bacteria / trypanosomes)",ec:["2.8.3.18"],identifiers:{"kegg.reaction":["R10343"]},equation:"Succinyl-CoA + Acetate <=> Acetyl-CoA + Succinate",note:"CoA goes to acetate instead of ADP + Pi"}],provenance:[{source:"KEGG",id:"R00405",url:"https://www.kegg.jp/entry/R00405"}]},{id:"tpl_rxn_008",name:"SDH",canonicalName:"succinate dehydrogenase (complex II)",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_022",coefficient:-1,main:!1},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_023",coefficient:1,main:!1}],reversible:!0,ec:["1.3.5.1"],identifiers:{"kegg.reaction":["R02164"],"metanetx.reaction":["MNXR107340"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R02164; MetaNetX MNXR107340; KEGG ID confirmed in the built-in template ('SDH')"},variants:[{name:"succinate:cytochrome c oxidoreductase",ec:["1.3.2.4"],identifiers:{"kegg.reaction":["R13137"]},equation:"Succinate + 2 Ferricytochrome c <=> Fumarate + 2 Ferrocytochrome c"}],provenance:[{source:"KEGG",id:"R02164",url:"https://www.kegg.jp/entry/R02164"}]},{id:"tpl_rxn_009",name:"FUM",canonicalName:"fumarase",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0}],reversible:!0,ec:["4.2.1.2"],identifiers:{"kegg.reaction":["R01082"],"metanetx.reaction":["MNXR99705"],"seed.reaction":["rxn00799","rxn19740","rxn33856","rxn33857","rxn33858"],"metacyc.reaction":["FUMHYDR-RXN"],rhea:["12460","12461","12462","12463"],"bigg.reaction":["FUM"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01082; MetaNetX MNXR99705; KEGG ID confirmed in the built-in template ('FUM')"},provenance:[{source:"KEGG",id:"R01082",url:"https://www.kegg.jp/entry/R01082"}]},{id:"tpl_rxn_010",name:"MDH",canonicalName:"malate dehydrogenase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_017",coefficient:1,main:!1}],reversible:!0,ec:["1.1.1.37","1.1.1.299"],identifiers:{"kegg.reaction":["R00342"],"metanetx.reaction":["MNXR101439"],"seed.reaction":["rxn00248","rxn20068","rxn23652","rxn27976","rxn34245"],"metacyc.reaction":["MALATE-DEH-RXN"],rhea:["21432","21433","21434","21435"],"bigg.reaction":["MDHi2"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R00342; MetaNetX MNXR101439; KEGG ID confirmed in the built-in template ('MDH')"},variants:[{name:"malate:quinone oxidoreductase (MQO)",ec:["1.1.5.4"],identifiers:{"kegg.reaction":["R00361"]},equation:"(S)-Malate + Quinone <=> Oxaloacetate + Hydroquinone"}],provenance:[{source:"KEGG",id:"R00342",url:"https://www.kegg.jp/entry/R00342"}]},{id:"tpl_rxn_011",name:"PC",canonicalName:"pyruvate carboxylase",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_013",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1},{metabolite:"tpl_met_015",coefficient:1,main:!1}],reversible:!1,ec:["6.4.1.1"],identifiers:{"kegg.reaction":["R00344"],"metanetx.reaction":["MNXR102391"],"seed.reaction":["rxn00250","rxn28116"],"metacyc.reaction":["PYRUVATE-CARBOXYLASE-RXN"],rhea:["20844","20845","20846","20847"],"bigg.reaction":["PC"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00344; MetaNetX MNXR102391"},provenance:[{source:"KEGG",id:"R00344",url:"https://www.kegg.jp/entry/R00344"}]},{id:"tpl_rxn_012",name:"PEPCK",canonicalName:"phosphoenolpyruvate carboxykinase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_013",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1},{metabolite:"tpl_met_019",coefficient:1,main:!1}],reversible:!1,ec:["4.1.1.49"],identifiers:{"kegg.reaction":["R00341"],"metanetx.reaction":["MNXR103099"],"seed.reaction":["rxn00247","rxn35519"],"metacyc.reaction":["PEPCARBOXYKIN-RXN"],rhea:["18617","18618","18619","18620"],"bigg.reaction":["PPCK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00341; MetaNetX MNXR103099"},variants:[{name:"GTP-dependent PEPCK (animals)",ec:["4.1.1.32"],identifiers:{"kegg.reaction":["R00431"]},equation:"GTP + Oxaloacetate <=> GDP + Phosphoenolpyruvate + CO2"},{name:"ITP-dependent PEPCK",ec:["4.1.1.32"],identifiers:{"kegg.reaction":["R00726"]},equation:"ITP + Oxaloacetate <=> IDP + Phosphoenolpyruvate + CO2"}],provenance:[{source:"KEGG",id:"R00341",url:"https://www.kegg.jp/entry/R00341"}]},{id:"tpl_rxn_013",name:"ACL",canonicalName:"ATP-citrate lyase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_013",coefficient:-1,main:!1},{metabolite:"tpl_met_020",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1},{metabolite:"tpl_met_015",coefficient:1,main:!1}],reversible:!0,ec:["2.3.3.8"],identifiers:{"kegg.reaction":["R00352"],"metanetx.reaction":["MNXR190533"],"seed.reaction":["rxn00257","rxn33091","rxn33092"],"metacyc.reaction":["ATP-CITRATE-PRO-S--LYASE-RXN"],rhea:["21160","21161","21162","21163"],"bigg.reaction":["ACITL"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00352; MetaNetX MNXR190533"},provenance:[{source:"KEGG",id:"R00352",url:"https://www.kegg.jp/entry/R00352"}]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_002",metabolite:"tpl_met_012",direction:"out",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_003",metabolite:"tpl_met_002",direction:"out",target:{pathway:"Fatty acid biosynthesis"}},{id:"tpl_port_004",metabolite:"tpl_met_007",direction:"out",target:{pathway:"Alanine, aspartate and glutamate metabolism"}},{id:"tpl_port_005",metabolite:"tpl_met_008",direction:"in",target:{pathway:"Valine, leucine and isoleucine degradation"}},{id:"tpl_port_006",metabolite:"tpl_met_006",direction:"out",target:{pathway:"Glyoxylate and dicarboxylate metabolism"}}]},nw={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_003",x:-90,y:-230,shape:"label"},{id:"tpl_node_002",metabolite:"tpl_met_004",x:90,y:-230,shape:"label"},{id:"tpl_node_003",metabolite:"tpl_met_005",x:220,y:-120,shape:"label"},{id:"tpl_node_004",metabolite:"tpl_met_006",x:250,y:40,shape:"label"},{id:"tpl_node_005",metabolite:"tpl_met_007",x:160,y:190,shape:"label"},{id:"tpl_node_006",metabolite:"tpl_met_008",x:0,y:250,shape:"label"},{id:"tpl_node_007",metabolite:"tpl_met_009",x:-160,y:190,shape:"label"},{id:"tpl_node_008",metabolite:"tpl_met_010",x:-250,y:40,shape:"label"},{id:"tpl_node_009",metabolite:"tpl_met_011",x:-220,y:-130,shape:"label"},{id:"tpl_node_010",metabolite:"tpl_met_002",x:0,y:-370,shape:"label"},{id:"tpl_node_011",metabolite:"tpl_met_001",x:0,y:-490,shape:"label"},{id:"tpl_node_012",metabolite:"tpl_met_012",x:-330,y:-330,shape:"label"},{id:"tpl_node_013",metabolite:"tpl_met_002",x:240,y:-390,shape:"label"},{id:"tpl_node_014",metabolite:"tpl_met_003",x:330,y:-250,shape:"label"},{id:"tpl_node_015",metabolite:"tpl_met_020",x:19.2,y:-446,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_016",metabolite:"tpl_met_016",x:21.8,y:-462,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_017",metabolite:"tpl_met_019",x:19.7,y:-414,attach:{reaction:"tpl_rxn_001",side:"out"}},{id:"tpl_node_018",metabolite:"tpl_met_017",x:22.2,y:-398,attach:{reaction:"tpl_rxn_001",side:"out"}},{id:"tpl_node_019",metabolite:"tpl_met_020",x:53,y:-271.2,attach:{reaction:"tpl_rxn_002",side:"out"}},{id:"tpl_node_020",metabolite:"tpl_met_016",x:250.8,y:116.8,attach:{reaction:"tpl_rxn_005",side:"in"}},{id:"tpl_node_021",metabolite:"tpl_met_019",x:227.1,y:152.7,attach:{reaction:"tpl_rxn_005",side:"out"}},{id:"tpl_node_022",metabolite:"tpl_met_017",x:213.2,y:180.2,attach:{reaction:"tpl_rxn_005",side:"out"}},{id:"tpl_node_023",metabolite:"tpl_met_020",x:115.6,y:244.9,attach:{reaction:"tpl_rxn_006",side:"in"}},{id:"tpl_node_024",metabolite:"tpl_met_016",x:149.3,y:233.2,attach:{reaction:"tpl_rxn_006",side:"in"}},{id:"tpl_node_025",metabolite:"tpl_met_019",x:69.2,y:262.5,attach:{reaction:"tpl_rxn_006",side:"out"}},{id:"tpl_node_026",metabolite:"tpl_met_017",x:35.3,y:276.2,attach:{reaction:"tpl_rxn_006",side:"out"}},{id:"tpl_node_027",metabolite:"tpl_met_014",x:-69.2,y:262.5,attach:{reaction:"tpl_rxn_007",side:"in"}},{id:"tpl_node_028",metabolite:"tpl_met_015",x:-49.3,y:268.8,attach:{reaction:"tpl_rxn_007",side:"in"}},{id:"tpl_node_029",metabolite:"tpl_met_013",x:-116.1,y:244.9,attach:{reaction:"tpl_rxn_007",side:"out"}},{id:"tpl_node_030",metabolite:"tpl_met_020",x:-142.3,y:234.9,attach:{reaction:"tpl_rxn_007",side:"out"}},{id:"tpl_node_031",metabolite:"tpl_met_022",x:-224.7,y:148.2,attach:{reaction:"tpl_rxn_008",side:"in"}},{id:"tpl_node_032",metabolite:"tpl_met_023",x:-248.7,y:116.8,attach:{reaction:"tpl_rxn_008",side:"out"}},{id:"tpl_node_033",metabolite:"tpl_met_016",x:-198.2,y:-194.6,attach:{reaction:"tpl_rxn_010",side:"in"}},{id:"tpl_node_034",metabolite:"tpl_met_017",x:-157.9,y:-226,attach:{reaction:"tpl_rxn_010",side:"out"}},{id:"tpl_node_035",metabolite:"tpl_met_013",x:-45.2,y:-380.4,attach:{reaction:"tpl_rxn_011",side:"in"}},{id:"tpl_node_036",metabolite:"tpl_met_021",x:-31.9,y:-405.4,attach:{reaction:"tpl_rxn_011",side:"in"}},{id:"tpl_node_037",metabolite:"tpl_met_014",x:-57.8,y:-344.1,attach:{reaction:"tpl_rxn_011",side:"out"}},{id:"tpl_node_038",metabolite:"tpl_met_015",x:-67.2,y:-325.8,attach:{reaction:"tpl_rxn_011",side:"out"}},{id:"tpl_node_039",metabolite:"tpl_met_013",x:-184.4,y:-276.6,attach:{reaction:"tpl_rxn_012",side:"in"}},{id:"tpl_node_040",metabolite:"tpl_met_014",x:-230.4,y:-295.8,attach:{reaction:"tpl_rxn_012",side:"out"}},{id:"tpl_node_041",metabolite:"tpl_met_019",x:-257.7,y:-307.2,attach:{reaction:"tpl_rxn_012",side:"out"}},{id:"tpl_node_042",metabolite:"tpl_met_013",x:173.2,y:-246.9,attach:{reaction:"tpl_rxn_013",side:"in"}},{id:"tpl_node_043",metabolite:"tpl_met_020",x:147.3,y:-235.2,attach:{reaction:"tpl_rxn_013",side:"in"}},{id:"tpl_node_044",metabolite:"tpl_met_014",x:218.2,y:-267.7,attach:{reaction:"tpl_rxn_013",side:"out"}},{id:"tpl_node_045",metabolite:"tpl_met_015",x:237.1,y:-277.8,attach:{reaction:"tpl_rxn_013",side:"out"}}],ports:[{id:"tpl_node_046",connector:"tpl_port_001",x:0,y:-600,from:"tpl_node_011"},{id:"tpl_node_047",connector:"tpl_port_002",x:-540,y:-330,from:"tpl_node_012"},{id:"tpl_node_048",connector:"tpl_port_003",x:240,y:-490,from:"tpl_node_013"},{id:"tpl_node_049",connector:"tpl_port_004",x:400,y:300,from:"tpl_node_005"},{id:"tpl_node_050",connector:"tpl_port_005",x:0,y:370,from:"tpl_node_006"},{id:"tpl_node_051",connector:"tpl_port_006",x:520,y:40,from:"tpl_node_004"}],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_011"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_010","tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"curved",bend:-17},{reaction:"tpl_rxn_004",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"curved",bend:-16},{reaction:"tpl_rxn_005",sources:["tpl_node_004"],targets:["tpl_node_005"],routing:"curved",bend:-17},{reaction:"tpl_rxn_006",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"curved",bend:-17},{reaction:"tpl_rxn_007",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"curved",bend:-17},{reaction:"tpl_rxn_008",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"curved",bend:-17},{reaction:"tpl_rxn_009",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"curved",bend:-17},{reaction:"tpl_rxn_010",sources:["tpl_node_009"],targets:["tpl_node_001"],routing:"curved",bend:-16},{reaction:"tpl_rxn_011",sources:["tpl_node_011"],targets:["tpl_node_001"],routing:"curved",bend:28},{reaction:"tpl_rxn_012",sources:["tpl_node_001"],targets:["tpl_node_012"],routing:"curved",bend:26,label_offset:{x:7.3,y:-17.4}},{reaction:"tpl_rxn_013",sources:["tpl_node_002"],targets:["tpl_node_013","tpl_node_014"],routing:"straight",label_flip:!0}],groups:[],labels:[{id:"tpl_lbl_001",x:-680,y:-690,text:"Citrate cycle (TCA cycle)",size:16,weight:700,kind:"title"},{id:"tpl_lbl_002",x:-680,y:-670,text:"derived from KEGG map00020 · drawn by GEMsMAP",size:10,weight:400,italic:!0,kind:"text"},{id:"tpl_lbl_003",x:-30,y:0,text:"TCA cycle",size:13,weight:600,italic:!0,kind:"text"}]},iw={format:QN,schema_version:JN,metadata:ew,biology:tw,layout:nw},aw="gemsmap-template",sw="1.1.0",ow={id:"kegg-map00030",name:"Pentose phosphate pathway (KEGG map00030)",description:"Oxidative and non-oxidative pentose phosphate pathway with the routes KEGG map00030 draws around it: Entner–Doudoroff, periplasmic glucose oxidation and the 2-ketogluconate route (bacteria), the non- and semi-phosphorylative ED (archaea), ribose / PRPP / deoxyribose, the ribulose monophosphate (RuMP) shunt of methylotrophs, sedoheptulose kinase and phosphoketolase. Derived from KEGG; drawn by GEMsMAP.",pathway:"Pentose phosphate pathway",section:"KEGG-derived templates",template_version:"0.1.0",scope:{level:"universal",taxa:[],note:"The oxidative and non-oxidative phases are conserved; ED, glucose oxidation, the archaeal routes, RuMP and phosphoketolase are organism-specific (optional). Compartments are chosen by the person mapping onto a GEM (cytosol, plastid…)."},authors:["Drafted with an LLM (Claude Opus 5.5)"],created:"2026-10-09T00:00:00Z",modified:"2026-10-09T18:53:30Z",license:"MIT (drawing and curation); identifiers and biology from KEGG, MetaNetX and BiGG",tags:["KEGG","map00030","pentose phosphate pathway","Entner-Doudoroff","central carbon"],citations:[{text:"Kanehisa M, Goto S. KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res 28:27-30 (2000)",doi:"10.1093/nar/28.1.27"}],layout_kind:"vertical",review_status:"ai-generated",source:{reference:"KEGG",pathway_id:"map00030",pathway_name:"Pentose phosphate pathway",url:"https://www.genome.jp/pathway/map00030",generation_method:"KEGG flat files + KGML (structure only) → curated biological graph → identities reconciled with MetaNetX (backend client) and the BiGG tables → hand-designed layout",generated_by:"tools/kegg/kegg_template.py",retrieved:"2026-10-09"}},lw={compartments:[],entities:[{id:"tpl_ent_001",name:"D-Glucose 6-phosphate",short:"Glucose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-glucopyranose 6-phosphate","D-glucose 6-phosphate","G6P","Glucose 6-phosphate","Robison ester","glucose 6-phosphate","glucose-6-phosphate"],identifiers:{"kegg.compound":["C00092"],chebi:["14314","4170","61548","CHEBI:14314","CHEBI:4170","CHEBI:61548"],"metanetx.chemical":["MNXM1364111"],"bigg.metabolite":["g6p"],hmdb:["HMDB0001401","HMDB0001549","HMDB0006793"],"metacyc.compound":["D-GLUCOSE-6-PHOSPHATE","D-glucopyranose-6-phosphate","GLC-6-P"],"seed.compound":["cpd00079","cpd26836"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00092; MetaNetX MNXM1364111; BiGG g6p; GEMsMAP library 'D-glucose-6-phosphate'"},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],identifiers:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}],library:"D-glucose-6-phosphate",provenance:{source:"KEGG",id:"C00092",url:"https://www.kegg.jp/entry/C00092"}},{id:"tpl_ent_002",name:"6-Phospho-D-glucono-1,5-lactone",short:"6P-Gluconolactone",formula:"C6H9O9P",charge:-2,synonyms:["6-O-phosphono-D-glucono-1,5-lactone","6-Phospho-D-glucono-1,5-lactone","6-phospho-D-glucono-1,5-lactone","6-phosphoglucono-delta-lactone","6-phosphogluconolactone","6PGL","D-glucono-1,5-lactone 6-phosphate"],identifiers:{"kegg.compound":["C01236"],chebi:["16938","57955","CHEBI:16938","CHEBI:57955"],"metanetx.chemical":["MNXM1104491"],"bigg.metabolite":["6pgl"],hmdb:["HMDB0001127"],"metacyc.compound":["D-6-P-GLUCONO-DELTA-LACTONE"],"seed.compound":["cpd00911"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C01236; MetaNetX MNXM1104491; BiGG 6pgl; GEMsMAP library '6-phosphogluconolactone'"},library:"6-phosphogluconolactone",provenance:{source:"KEGG",id:"C01236",url:"https://www.kegg.jp/entry/C01236"}},{id:"tpl_ent_003",name:"6-Phospho-D-gluconate",short:"6P-Gluconate",formula:"C6H10O10P",charge:-3,synonyms:["6-phospho-D-gluconate","6-phosphogluconate","6-phosphogluconic acid","6PG","D-gluconate 6-phosphate"],identifiers:{"kegg.compound":["C00345"],chebi:["48928","58759","CHEBI:16863","CHEBI:48928","CHEBI:58759"],"metanetx.chemical":["MNXM734080"],"bigg.metabolite":["6pgc"],hmdb:["HMDB0001316"],"metacyc.compound":["CPD-2961"],"seed.compound":["cpd00284"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00345; MetaNetX MNXM734080; BiGG 6pgc; GEMsMAP library '6-phospho-D-gluconate'"},library:"6-phospho-D-gluconate",provenance:{source:"KEGG",id:"C00345",url:"https://www.kegg.jp/entry/C00345"}},{id:"tpl_ent_004",name:"D-Ribulose 5-phosphate",short:"Ribulose-5P",formula:"C5H9O8P",charge:-2,synonyms:["D-ribulose 5-phosphate","Ru5P","ribulose 5-phosphate","ribulose-5-phosphate"],identifiers:{"kegg.compound":["C00199"],chebi:["17363","58121","CHEBI:17363","CHEBI:37455","CHEBI:58121"],"metanetx.chemical":["MNXM145"],"bigg.metabolite":["ru5p_D","ru5p__D"],hmdb:["HMDB0000618","HMDB0002033","HMDB0002694"],"metacyc.compound":["RIBULOSE-5P"],"seed.compound":["cpd00171"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00199; MetaNetX MNXM145; BiGG ru5p__D; GEMsMAP library 'D-ribulose-5-phosphate'"},library:"D-ribulose-5-phosphate",provenance:{source:"KEGG",id:"C00199",url:"https://www.kegg.jp/entry/C00199"}},{id:"tpl_ent_005",name:"D-Ribose 5-phosphate",short:"Ribose-5P",formula:"C5H11O8P",charge:0,synonyms:["D-ribose 5-phosphate","R5P","Ribose 5-phosphate","alpha-D-ribose 5-phosphate","ribose 5-phosphate","ribose-5-phosphate"],identifiers:{"kegg.compound":["C00117","C03736"],chebi:["17797","78346","CHEBI:140679","CHEBI:17797","CHEBI:18189","CHEBI:52742","CHEBI:78346"],"metanetx.chemical":["MNXM1363910"],"bigg.metabolite":["r5p"],hmdb:["HMDB0001548"],"metacyc.compound":["CPD-15317","CPD-15318","RIBOSE-5P"],"seed.compound":["cpd00101","cpd19028"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00117; MetaNetX MNXM1363910; BiGG r5p; GEMsMAP library 'D-ribose-5-phosphate'"},library:"D-ribose-5-phosphate",provenance:{source:"KEGG",id:"C00117",url:"https://www.kegg.jp/entry/C00117"}},{id:"tpl_ent_006",name:"D-Xylulose 5-phosphate",short:"Xylulose-5P",formula:"C5H9O8P",charge:-2,synonyms:["D-xylulose 5-phosphate","Xu5P","xylulose 5-phosphate","xylulose-5-phosphate"],identifiers:{"kegg.compound":["C00231"],chebi:["16332","57737","CHEBI:16332","CHEBI:27354","CHEBI:57737"],"metanetx.chemical":["MNXM186"],"bigg.metabolite":["xu5p_D","xu5p__D"],hmdb:["HMDB0000868","HMDB0006212"],"metacyc.compound":["XYLULOSE-5-PHOSPHATE"],"seed.compound":["cpd00198"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00231; MetaNetX MNXM186; BiGG xu5p__D; GEMsMAP library 'D-xylulose-5-phosphate'"},library:"D-xylulose-5-phosphate",provenance:{source:"KEGG",id:"C00231",url:"https://www.kegg.jp/entry/C00231"}},{id:"tpl_ent_007",name:"Sedoheptulose 7-phosphate",short:"Sedoheptulose-7P",formula:"C7H13O10P",charge:-2,synonyms:["D-Sedoheptulose 7-phosphate","D-altro-Heptulose 7-phosphate","altro-Heptulose 7-phosphate"],identifiers:{"kegg.compound":["C05382"],chebi:["CHEBI:15721","CHEBI:57483"],"metanetx.chemical":["MNXM733314"],"bigg.metabolite":["s7p"],"metacyc.compound":["D-SEDOHEPTULOSE-7-P"],"seed.compound":["cpd00238"]},identity:{status:"suggested",source:"ai",note:"KEGG C05382; MetaNetX MNXM733314; BiGG s7p",confidence:"high"},provenance:{source:"KEGG",id:"C05382",url:"https://www.kegg.jp/entry/C05382"}},{id:"tpl_ent_008",name:"D-Glyceraldehyde 3-phosphate",short:"GAP",formula:"C3H5O6P",charge:-2,synonyms:["(2R)-2-Hydroxy-3-(phosphonooxy)-propanal","D-glyceraldehyde 3-phosphate","D-glyceraldehyde-3-phosphate","G3P","GAP","Glyceraldehyde 3-phosphate","glyceraldehyde 3-phosphate","glyceraldehyde-3-phosphate"],identifiers:{"kegg.compound":["C00118"],chebi:["29052","59776","CHEBI:29052","CHEBI:59776"],"metanetx.chemical":["MNXM1372045"],hmdb:["HMDB0001112"],"metacyc.compound":["GAP"],"seed.compound":["cpd00102"],"bigg.metabolite":["g3p"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00118; MetaNetX MNXM1372045; BiGG g3p; GEMsMAP library 'D-glyceraldehyde-3-phosphate'"},related:[{note:"stereo-unspecified glyceraldehyde 3-phosphate",names:["glyceraldehyde 3-phosphate"],identifiers:{"kegg.compound":["C00661"]}}],library:"D-glyceraldehyde-3-phosphate",provenance:{source:"KEGG",id:"C00118",url:"https://www.kegg.jp/entry/C00118"}},{id:"tpl_ent_009",name:"D-Erythrose 4-phosphate",short:"Erythrose-4P",formula:"C4H7O7P",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00279"],chebi:["CHEBI:16897","CHEBI:48153"],"metanetx.chemical":["MNXM258"],"bigg.metabolite":["e4p"],hmdb:["HMDB0001321"],"metacyc.compound":["ERYTHROSE-4P"],"seed.compound":["cpd00236"]},identity:{status:"suggested",source:"ai",note:"KEGG C00279; MetaNetX MNXM258; BiGG e4p",confidence:"high"},provenance:{source:"KEGG",id:"C00279",url:"https://www.kegg.jp/entry/C00279"}},{id:"tpl_ent_010",name:"D-Fructose 6-phosphate",short:"Fructose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-Fructose 6-phosphoric acid","D-fructose 6-phosphate","F6P","Neuberg ester","fructose 6-phosphate","fructose-6-phosphate"],identifiers:{"kegg.compound":["C00085","C05345"],chebi:["15946","61527","CHEBI:15946","CHEBI:16084","CHEBI:57634","CHEBI:61527","CHEBI:61553"],"metanetx.chemical":["MNXM1107898"],"bigg.metabolite":["f6p"],hmdb:["HMDB0000124","HMDB0003971","HMDB0257695"],"metacyc.compound":["CPD-18719","FRUCTOSE-6P"],"seed.compound":["cpd00072","cpd19035"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00085; MetaNetX MNXM1107898; BiGG f6p; GEMsMAP library 'D-fructose-6-phosphate'"},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],identifiers:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}],library:"D-fructose-6-phosphate",provenance:{source:"KEGG",id:"C00085",url:"https://www.kegg.jp/entry/C00085"}},{id:"tpl_ent_011",name:"2-Dehydro-3-deoxy-6-phospho-D-gluconate",short:"KDPG",formula:"C6H8O9P",charge:-3,synonyms:["2-Dehydro-3-deoxy-D-gluconate 6-phosphate","2-Keto-3-deoxy-6-phosphogluconate","6-Phospho-2-dehydro-3-deoxy-D-gluconate"],identifiers:{"kegg.compound":["C04442"],chebi:["CHEBI:15925","CHEBI:57569"],"metanetx.chemical":["MNXM649"],"bigg.metabolite":["2ddg6p"],hmdb:["HMDB0001376"],"metacyc.compound":["2-KETO-3-DEOXY-6-P-GLUCONATE"],"seed.compound":["cpd02711"]},identity:{status:"suggested",source:"ai",note:"KEGG C04442; MetaNetX MNXM649; BiGG 2ddg6p",confidence:"high"},provenance:{source:"KEGG",id:"C04442",url:"https://www.kegg.jp/entry/C04442"}},{id:"tpl_ent_012",name:"Pyruvate",short:"Pyruvate",formula:"C3H3O3",charge:-1,synonyms:["2-Oxopropanoate","2-Oxopropanoic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr","Pyroracemic acid","Pyruvic acid","pyruvate","pyruvic acid"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816","CHEBI:15361","CHEBI:177913","CHEBI:32816"],"metanetx.chemical":["MNXM23"],"bigg.metabolite":["pyr"],hmdb:["HMDB0000243"],"metacyc.compound":["PYRUVATE"],"seed.compound":["cpd00020"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00022; MetaNetX MNXM23; BiGG pyr; GEMsMAP library 'pyruvate'"},library:"pyruvate",provenance:{source:"KEGG",id:"C00022",url:"https://www.kegg.jp/entry/C00022"}},{id:"tpl_ent_013",name:"D-Glucose",short:"Glucose",formula:"C6H12O6",charge:0,synonyms:["D-Glucopyranose","D-glucopyranose","D-glucose","Dextrose","Glc","Glucose","Grape sugar","dextrose","glucose"],identifiers:{"kegg.compound":["C00031"],chebi:["17634","4167","CHEBI:4167"],"metanetx.chemical":["MNXM1364061"],"bigg.metabolite":["glc_D","glc__D"],hmdb:["HMDB0000122","HMDB0304632"],"seed.compound":["cpd00027"],"metacyc.compound":["D-GLUCOSE","GLC"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00031; MetaNetX MNXM1364061; BiGG glc__D; GEMsMAP library 'D-glucose'"},related:[{note:"anomer of D-glucose",names:["alpha-D-glucose","beta-D-glucose","alpha-D-glucopyranose","beta-D-glucopyranose"],identifiers:{"kegg.compound":["C00267","C00221"],chebi:["17925","15903"],"bigg.metabolite":["glc__aD","glc__bD"],"metacyc.compound":["ALPHA-GLUCOSE","GLC-D-BETA"]}}],library:"D-glucose",provenance:{source:"KEGG",id:"C00031",url:"https://www.kegg.jp/entry/C00031"}},{id:"tpl_ent_014",name:"D-Glucono-1,5-lactone",short:"Gluconolactone",formula:"C6H10O6",charge:0,synonyms:["1,5-Gluconolactone","D-Gluconolactone","Gluconic acid lactone","Gluconic lactone","Gluconolactone","delta-Gluconolactone"],identifiers:{"kegg.compound":["C00198"],chebi:["CHEBI:16217","CHEBI:74105"],"metanetx.chemical":["MNXM1369177"],"bigg.metabolite":["g15lac"],hmdb:["HMDB0000150","HMDB0246042"],"metacyc.compound":["D-Aldonolactones","GLC-D-LACTONE"],"seed.compound":["cpd00170","cpd21926","cpd26808"]},identity:{status:"suggested",source:"ai",note:"KEGG C00198; MetaNetX MNXM1369177; BiGG g15lac",confidence:"high"},provenance:{source:"KEGG",id:"C00198",url:"https://www.kegg.jp/entry/C00198"}},{id:"tpl_ent_015",name:"D-Gluconic acid",short:"Gluconate",formula:"C6H11O7",charge:-1,synonyms:["D-Gluconate","D-gluco-Hexonic acid"],identifiers:{"kegg.compound":["C00257"],chebi:["CHEBI:18391","CHEBI:24265","CHEBI:24266","CHEBI:33198"],"metanetx.chemical":["MNXM341"],"bigg.metabolite":["glcn"],hmdb:["HMDB0000625","HMDB0003373"],"metacyc.compound":["GLUCONATE"],"seed.compound":["cpd00222"]},identity:{status:"suggested",source:"ai",note:"KEGG C00257; MetaNetX MNXM341; BiGG glcn",confidence:"high"},provenance:{source:"KEGG",id:"C00257",url:"https://www.kegg.jp/entry/C00257"}},{id:"tpl_ent_016",name:"2-Keto-D-gluconic acid",short:"2-Ketogluconate",formula:"C6H9O7",charge:-1,synonyms:["2-Dehydro-D-gluconate","2-Dehydro-D-gluconic acid","alpha-D-arabino-2-Hexulosonic acid"],identifiers:{"kegg.compound":["C06473"],chebi:["CHEBI:16808","CHEBI:27469"],"metanetx.chemical":["MNXM582"],"bigg.metabolite":["2dhglcn"],"metacyc.compound":["CPD-377"],"seed.compound":["cpd00480","cpd03889"]},identity:{status:"suggested",source:"ai",note:"KEGG C06473; MetaNetX MNXM582; BiGG 2dhglcn",confidence:"high"},provenance:{source:"KEGG",id:"C06473",url:"https://www.kegg.jp/entry/C06473"}},{id:"tpl_ent_017",name:"6-Phospho-2-dehydro-D-gluconate",short:"2-Keto-6P-gluconate",formula:"C6H8O10P",charge:-3,synonyms:["2-Dehydro-D-gluconate 6-phosphate"],identifiers:{"kegg.compound":["C01218"],chebi:["CHEBI:15865","CHEBI:20750","CHEBI:2229"],"metanetx.chemical":["MNXM1218"],"bigg.metabolite":["6p2dhglcn"],"metacyc.compound":["CPD-339"],"seed.compound":["cpd00896"]},identity:{status:"suggested",source:"ai",note:"KEGG C01218; MetaNetX MNXM1218; BiGG 6p2dhglcn",confidence:"high"},provenance:{source:"KEGG",id:"C01218",url:"https://www.kegg.jp/entry/C01218"}},{id:"tpl_ent_018",name:"2-Dehydro-3-deoxy-D-gluconate",short:"KDG",formula:"C6H9O6",charge:-1,synonyms:["2-Dehydro-3-deoxy-D-gluconic acid","2-Keto-3-deoxy-D-gluconate"],identifiers:{"kegg.compound":["C00204"],chebi:["CHEBI:17032","CHEBI:57990"],"metanetx.chemical":["MNXM440"],"bigg.metabolite":["2ddglcn"],"metacyc.compound":["2-DEHYDRO-3-DEOXY-D-GLUCONATE"],"seed.compound":["cpd00176"]},identity:{status:"suggested",source:"ai",note:"KEGG C00204; MetaNetX MNXM440; BiGG 2ddglcn",confidence:"high"},provenance:{source:"KEGG",id:"C00204",url:"https://www.kegg.jp/entry/C00204"}},{id:"tpl_ent_019",name:"D-Glyceraldehyde",short:"Glyceraldehyde",formula:"C3H6O3",charge:0,synonyms:[],identifiers:{"kegg.compound":["C00577"],chebi:["CHEBI:17378"],"metanetx.chemical":["MNXM435"],"bigg.metabolite":["glyald"],"metacyc.compound":["GLYCERALD","Glyco-CT-Superclass-TRI"],"seed.compound":["cpd00448"]},identity:{status:"suggested",source:"ai",note:"KEGG C00577; MetaNetX MNXM435; BiGG glyald",confidence:"high"},provenance:{source:"KEGG",id:"C00577",url:"https://www.kegg.jp/entry/C00577"}},{id:"tpl_ent_020",name:"D-Glycerate",short:"Glycerate",formula:"C3H5O4",charge:-1,synonyms:["(R)-Glycerate","Glycerate","Glyceric acid"],identifiers:{"kegg.compound":["C00258"],chebi:["CHEBI:16659","CHEBI:32398","CHEBI:33508","CHEBI:33871"],"metanetx.chemical":["MNXM1136254"],"bigg.metabolite":["glyc__R"],hmdb:["HMDB0000139"],"metacyc.compound":["GLYCERATE","Glycerates"],"seed.compound":["cpd00223"]},identity:{status:"suggested",source:"ai",note:"KEGG C00258; MetaNetX MNXM1136254; BiGG glyc__R",confidence:"high"},provenance:{source:"KEGG",id:"C00258",url:"https://www.kegg.jp/entry/C00258"}},{id:"tpl_ent_021",name:"2-Phospho-D-glycerate",short:"2-PG",formula:"C3H4O7P",charge:-3,synonyms:["2-Phospho-(R)-glycerate","2-phospho-D-glycerate","2-phosphoglycerate","2-phosphoglyceric acid","2PG","D-Glycerate 2-phosphate","D-glycerate 2-phosphate","glycerate 2-phosphate"],identifiers:{"kegg.compound":["C00631"],chebi:["17835","58289","CHEBI:17835","CHEBI:24344","CHEBI:58289","CHEBI:88350"],"metanetx.chemical":["MNXM275"],"bigg.metabolite":["2pg"],hmdb:["HMDB0000362","HMDB0003391","HMDB0062707","HMDB0304085"],"metacyc.compound":["2-PG"],"seed.compound":["cpd00482"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00631; MetaNetX MNXM275; BiGG 2pg; GEMsMAP library '2-phospho-D-glycerate'"},library:"2-phospho-D-glycerate",provenance:{source:"KEGG",id:"C00631",url:"https://www.kegg.jp/entry/C00631"}},{id:"tpl_ent_022",name:"D-arabino-Hex-3-ulose 6-phosphate",short:"Hexulose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-arabino-3-Hexulose 6-phosphate","D-arabino-6-Phospho-hex-3-ulose"],identifiers:{"kegg.compound":["C06019"],chebi:["CHEBI:27973","CHEBI:58542"],"metanetx.chemical":["MNXM1659"],"metacyc.compound":["CPD-26"],"seed.compound":["cpd03583"]},identity:{status:"suggested",source:"ai",note:"KEGG C06019; MetaNetX MNXM1659",confidence:"high"},provenance:{source:"KEGG",id:"C06019",url:"https://www.kegg.jp/entry/C06019"}},{id:"tpl_ent_023",name:"Sedoheptulose",short:"Sedoheptulose",formula:"C7H14O7",charge:0,synonyms:["D-Sedoheptulose","D-altro-Heptulose","Volemulose"],identifiers:{"kegg.compound":["C02076","C08355"],chebi:["CHEBI:167607","CHEBI:16802","CHEBI:27520"],"metanetx.chemical":["MNXM1364232"],hmdb:["HMDB0003219"],"metacyc.compound":["CPD-19338"],"seed.compound":["cpd05269"]},identity:{status:"suggested",source:"ai",note:"KEGG C02076; MetaNetX MNXM1364232",confidence:"high"},provenance:{source:"KEGG",id:"C02076",url:"https://www.kegg.jp/entry/C02076"}},{id:"tpl_ent_024",name:"5-Phospho-alpha-D-ribose 1-diphosphate",short:"PRPP",formula:"C5H8O14P3",charge:-5,synonyms:["5-Phosphoribosyl 1-pyrophosphate","5-Phosphoribosyl diphosphate","PRPP"],identifiers:{"kegg.compound":["C00119"],chebi:["CHEBI:17111","CHEBI:58017"],"metanetx.chemical":["MNXM1104453"],"bigg.metabolite":["prpp"],hmdb:["HMDB0000280"],"metacyc.compound":["PRPP"],"seed.compound":["cpd00103"]},identity:{status:"suggested",source:"ai",note:"KEGG C00119; MetaNetX MNXM1104453; BiGG prpp",confidence:"high"},provenance:{source:"KEGG",id:"C00119",url:"https://www.kegg.jp/entry/C00119"}},{id:"tpl_ent_025",name:"D-Ribose",short:"Ribose",formula:"C5H10O5",charge:0,synonyms:[],identifiers:{"kegg.compound":["C00121"],chebi:["CHEBI:47013"],"metanetx.chemical":["MNXM1108051"],"bigg.metabolite":["rib__D"],hmdb:["HMDB0000283","HMDB0012194"],"metacyc.compound":["D-Ribofuranose"],"seed.compound":["cpd00105"]},identity:{status:"suggested",source:"ai",note:"KEGG C00121; MetaNetX MNXM1108051; BiGG rib__D",confidence:"high"},provenance:{source:"KEGG",id:"C00121",url:"https://www.kegg.jp/entry/C00121"}},{id:"tpl_ent_026",name:"alpha-D-Ribose 1-phosphate",short:"Ribose-1P",formula:"C5H9O8P",charge:-2,synonyms:["D-Ribose 1-phosphate","Ribose 1-phosphate"],identifiers:{"kegg.compound":["C00620"],chebi:["CHEBI:16300","CHEBI:35425","CHEBI:57720"],"metanetx.chemical":["MNXM1103205"],"bigg.metabolite":["r1p"],hmdb:["HMDB0001489"],"metacyc.compound":["RIBOSE-1P"],"seed.compound":["cpd00475"]},identity:{status:"suggested",source:"ai",note:"KEGG C00620; MetaNetX MNXM1103205; BiGG r1p",confidence:"high"},provenance:{source:"KEGG",id:"C00620",url:"https://www.kegg.jp/entry/C00620"}},{id:"tpl_ent_027",name:"D-Ribose 1,5-bisphosphate",short:"Ribose-1,5P₂",formula:"C5H8O11P2",charge:-4,synonyms:["Ribose 1,5-bisphosphate","alpha-D-Ribose 1,5-bisphosphate"],identifiers:{"kegg.compound":["C01151"],chebi:["CHEBI:17994","CHEBI:58345","CHEBI:68688","CHEBI:68819"],"metanetx.chemical":["MNXM740983"],"bigg.metabolite":["r15bp"],hmdb:["HMDB0011688"],"metacyc.compound":["RIBOSE-15-BISPHOSPHATE"],"seed.compound":["cpd00847"]},identity:{status:"suggested",source:"ai",note:"KEGG C01151; MetaNetX MNXM740983; BiGG r15bp",confidence:"high"},provenance:{source:"KEGG",id:"C01151",url:"https://www.kegg.jp/entry/C01151"}},{id:"tpl_ent_028",name:"D-Ribulose 1,5-bisphosphate",short:"Ribulose-1,5P₂",formula:"C5H8O11P2",charge:-4,synonyms:[],identifiers:{"kegg.compound":["C01182"],chebi:["CHEBI:16710","CHEBI:57870"],"metanetx.chemical":["MNXM1106709"],hmdb:["HMDB0304322"],"metacyc.compound":["D-RIBULOSE-15-P2"],"seed.compound":["cpd00871","cpd29644"]},identity:{status:"suggested",source:"ai",note:"KEGG C01182; MetaNetX MNXM1106709",confidence:"high"},provenance:{source:"KEGG",id:"C01182",url:"https://www.kegg.jp/entry/C01182"}},{id:"tpl_ent_029",name:"Deoxyribose",short:"Deoxyribose",formula:"C5H10O4",charge:0,synonyms:["2-Deoxy-D-erythro-pentose","2-Deoxy-D-ribose","Thyminose"],identifiers:{"kegg.compound":["C01801"],chebi:["CHEBI:28816","CHEBI:90761"],"metanetx.chemical":["MNXM1371289"],"bigg.metabolite":["drib"],"metacyc.compound":["2-Deoxy-D-Ribofuranose"],"seed.compound":["cpd01242"]},identity:{status:"suggested",source:"ai",note:"KEGG C01801; MetaNetX MNXM1371289; BiGG drib",confidence:"high"},provenance:{source:"KEGG",id:"C01801",url:"https://www.kegg.jp/entry/C01801"}},{id:"tpl_ent_030",name:"2-Deoxy-D-ribose 1-phosphate",short:"Deoxyribose-1P",formula:"C5H9O7P",charge:-2,synonyms:["2-Deoxy-alpha-D-ribose 1-phosphate"],identifiers:{"kegg.compound":["C00672"],chebi:["CHEBI:11563","CHEBI:28542","CHEBI:57259","CHEBI:58576"],"metanetx.chemical":["MNXM1108138"],"bigg.metabolite":["2dr1p"],hmdb:["HMDB0001351"],"metacyc.compound":["DEOXY-D-RIBOSE-1-PHOSPHATE","DEOXY-RIBOSE-1P"],"seed.compound":["cpd00509","cpd26845"]},identity:{status:"suggested",source:"ai",note:"KEGG C00672; MetaNetX MNXM1108138; BiGG 2dr1p",confidence:"high"},provenance:{source:"KEGG",id:"C00672",url:"https://www.kegg.jp/entry/C00672"}},{id:"tpl_ent_031",name:"2-Deoxy-D-ribose 5-phosphate",short:"Deoxyribose-5P",formula:"C5H9O7P",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00673"],chebi:["CHEBI:16132","CHEBI:190741","CHEBI:55513","CHEBI:62877"],"metanetx.chemical":["MNXM732594"],"bigg.metabolite":["2dr5p"],"metacyc.compound":["DEOXY-RIBOSE-5P"],"seed.compound":["cpd00510","cpd26846"]},identity:{status:"suggested",source:"ai",note:"KEGG C00673; MetaNetX MNXM732594; BiGG 2dr5p",confidence:"high"},provenance:{source:"KEGG",id:"C00673",url:"https://www.kegg.jp/entry/C00673"}},{id:"tpl_ent_032",name:"ATP",short:"ATP",formula:"C10H12N5O13P3",charge:-4,synonyms:["Adenosine 5'-triphosphate","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616","CHEBI:15422","CHEBI:237958","CHEBI:30616","CHEBI:57299"],"metanetx.chemical":["MNXM3"],"bigg.metabolite":["atp"],hmdb:["HMDB0000538"],"metacyc.compound":["ATP"],"seed.compound":["cpd00002"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00002; MetaNetX MNXM3; BiGG atp; GEMsMAP library 'ATP'"},library:"ATP",provenance:{source:"KEGG",id:"C00002",url:"https://www.kegg.jp/entry/C00002"}},{id:"tpl_ent_033",name:"ADP",short:"ADP",formula:"C10H12N5O10P2",charge:-3,synonyms:["Adenosine 5'-diphosphate","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216","CHEBI:16761","CHEBI:456216","CHEBI:87518"],"metanetx.chemical":["MNXM40333"],"bigg.metabolite":["adp"],hmdb:["HMDB0001341"],"metacyc.compound":["ADP","ADP-GROUP"],"seed.compound":["cpd00008","cpd22244"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00008; MetaNetX MNXM40333; BiGG adp; GEMsMAP library 'ADP'"},library:"ADP",provenance:{source:"KEGG",id:"C00008",url:"https://www.kegg.jp/entry/C00008"}},{id:"tpl_ent_034",name:"AMP",short:"AMP",formula:"C10H12N5O7P",charge:-2,synonyms:["5'-AMP","5'-Adenosine monophosphate","5'-Adenylic acid","Adenosine 5'-monophosphate","Adenosine 5'-phosphate","Adenylate","Adenylic acid"],identifiers:{"kegg.compound":["C00020"],chebi:["CHEBI:16027","CHEBI:40721","CHEBI:456215"],"metanetx.chemical":["MNXM728294"],"bigg.metabolite":["amp"],hmdb:["HMDB0000045"],"metacyc.compound":["AMP","AMP-GROUP"],"seed.compound":["cpd00018"]},identity:{status:"suggested",source:"ai",note:"KEGG C00020; MetaNetX MNXM728294; BiGG amp",confidence:"high"},provenance:{source:"KEGG",id:"C00020",url:"https://www.kegg.jp/entry/C00020"}},{id:"tpl_ent_037",name:"NADP+",short:"NADP⁺",formula:"C21H25N7O17P3",charge:-3,synonyms:["NADP","Nicotinamide adenine dinucleotide phosphate","TPN","Triphosphopyridine nucleotide","beta-NADP+","beta-Nicotinamide adenine dinucleotide phosphate","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349","CHEBI:18009","CHEBI:25523","CHEBI:44409","CHEBI:58349"],"metanetx.chemical":["MNXM5"],"bigg.metabolite":["nadp"],hmdb:["HMDB0000217","HMDB0304435"],"metacyc.compound":["NADP"],"seed.compound":["cpd00006"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00006; MetaNetX MNXM5; BiGG nadp; GEMsMAP library 'NADP+'"},library:"NADP+",provenance:{source:"KEGG",id:"C00006",url:"https://www.kegg.jp/entry/C00006"}},{id:"tpl_ent_038",name:"NADPH",short:"NADPH",formula:"C21H26N7O17P3",charge:-4,synonyms:["Reduced nicotinamide adenine dinucleotide phosphate","TPNH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783","CHEBI:16474","CHEBI:57783"],"metanetx.chemical":["MNXM738702"],"bigg.metabolite":["nadph"],hmdb:["HMDB0000221","HMDB0000799","HMDB0006341"],"metacyc.compound":["NADPH"],"seed.compound":["cpd00005"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00005; MetaNetX MNXM738702; BiGG nadph; GEMsMAP library 'NADPH'"},library:"NADPH",provenance:{source:"KEGG",id:"C00005",url:"https://www.kegg.jp/entry/C00005"}},{id:"tpl_ent_039",name:"Orthophosphate",short:"Pᵢ",formula:"HO4P",charge:-2,synonyms:["Orthophosphoric acid","Phosphate","Phosphoric acid","Pi","inorganic phosphate","orthophosphate","phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078","CHEBI:18367","CHEBI:26020","CHEBI:26078","CHEBI:35780","CHEBI:39745","CHEBI:43474"],"metanetx.chemical":["MNXM9"],"bigg.metabolite":["pi"],hmdb:["HMDB0000973","HMDB0001429","HMDB0002105","HMDB0002142","HMDB0005947"],"seed.compound":["cpd00009","cpd27787"],"metacyc.compound":["Pi"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00009; MetaNetX MNXM9; BiGG pi; GEMsMAP library 'phosphate'"},library:"phosphate",provenance:{source:"KEGG",id:"C00009",url:"https://www.kegg.jp/entry/C00009"}},{id:"tpl_ent_040",name:"H2O",short:"H2O",formula:"H2O",charge:0,synonyms:["Water","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377","CHEBI:15377","CHEBI:29374","CHEBI:29375","CHEBI:33806","CHEBI:33811","CHEBI:33813","CHEBI:41981"],"metanetx.chemical":["WATER"],"bigg.metabolite":["h2o"],hmdb:["HMDB0002111"],"metacyc.compound":["WATER"],"seed.compound":["cpd00001"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00001; MetaNetX WATER; BiGG h2o; GEMsMAP library 'H2O'"},library:"H2O",provenance:{source:"KEGG",id:"C00001",url:"https://www.kegg.jp/entry/C00001"}},{id:"tpl_ent_041",name:"CO2",short:"CO₂",formula:"CO2",charge:0,synonyms:["Carbon dioxide","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526","CHEBI:139538","CHEBI:16526"],"metanetx.chemical":["MNXM13"],"bigg.metabolite":["co2"],hmdb:["HMDB0001967"],"metacyc.compound":["CARBON-DIOXIDE"],"seed.compound":["cpd00011"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00011; MetaNetX MNXM13; BiGG co2; GEMsMAP library 'CO2'"},library:"CO2",provenance:{source:"KEGG",id:"C00011",url:"https://www.kegg.jp/entry/C00011"}},{id:"tpl_ent_042",name:"FAD",short:"FAD",formula:"C27H33N9O15P2",charge:0,synonyms:["Flavin adenine dinucleotide"],identifiers:{"kegg.compound":["C00016"],chebi:["CHEBI:16238","CHEBI:57692"],"metanetx.chemical":["MNXM1364149"],"bigg.metabolite":["fad"],hmdb:["HMDB0001248"],"metacyc.compound":["FAD"],"seed.compound":["cpd00015"]},identity:{status:"suggested",source:"ai",note:"KEGG C00016; MetaNetX MNXM1364149; BiGG fad",confidence:"high"},provenance:{source:"KEGG",id:"C00016",url:"https://www.kegg.jp/entry/C00016"}},{id:"tpl_ent_043",name:"FADH2",short:"FADH₂",formula:"C27H33N9O15P2",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C01352"],chebi:["CHEBI:17877","CHEBI:58307"],"metanetx.chemical":["MNXM1105762"],"bigg.metabolite":["fadh2"],hmdb:["HMDB0001197","HMDB0006252","HMDB0006358"],"metacyc.compound":["FADH2","Red-FADH2-Flavoproteins"],"seed.compound":["cpd00982"]},identity:{status:"suggested",source:"ai",note:"KEGG C01352; MetaNetX MNXM1105762; BiGG fadh2",confidence:"high"},provenance:{source:"KEGG",id:"C01352",url:"https://www.kegg.jp/entry/C01352"}},{id:"tpl_ent_044",name:"Quinone",short:"Q",synonyms:[],identifiers:{"kegg.compound":["C15602"],chebi:["CHEBI:16509"],"metanetx.chemical":["MNXM1776"]},identity:{status:"suggested",source:"ai",note:"KEGG C15602; MetaNetX MNXM1776",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C15602",url:"https://www.kegg.jp/entry/C15602"}},{id:"tpl_ent_045",name:"Hydroquinone",short:"QH₂",formula:"C6H2O2*4",charge:0,synonyms:["Quinol","Reduced quinone","p-Hydroquinone"],identifiers:{"kegg.compound":["C15603"],chebi:["CHEBI:17594"],"metanetx.chemical":["MNXM4100"],"metacyc.compound":["Reduced-Quinones"],"seed.compound":["cpd30750"],"bigg.metabolite":["hqn"]},identity:{status:"suggested",source:"ai",note:"KEGG C15603; MetaNetX MNXM4100; BiGG hqn",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C15603",url:"https://www.kegg.jp/entry/C15603"}},{id:"tpl_ent_046",name:"Acetaldehyde",short:"Acetaldehyde",formula:"C2H4O",charge:0,synonyms:["Ethanal"],identifiers:{"kegg.compound":["C00084"],chebi:["CHEBI:15343"],"metanetx.chemical":["MNXM75"],"bigg.metabolite":["acald"],hmdb:["HMDB0000990"],"metacyc.compound":["ACETALD"],"seed.compound":["cpd00071"]},identity:{status:"suggested",source:"ai",note:"KEGG C00084; MetaNetX MNXM75; BiGG acald",confidence:"high"},provenance:{source:"KEGG",id:"C00084",url:"https://www.kegg.jp/entry/C00084"}},{id:"tpl_ent_047",name:"Formaldehyde",short:"Formaldehyde",formula:"CH2O",charge:0,synonyms:["Formalin","Methanal","Methylene oxide","Oxomethane","Oxomethylene"],identifiers:{"kegg.compound":["C00067"],chebi:["CHEBI:16842"],"metanetx.chemical":["MNXM1364673"],"bigg.metabolite":["fald"],hmdb:["HMDB0001426"],"seed.compound":["cpd00055"]},identity:{status:"suggested",source:"ai",note:"KEGG C00067; MetaNetX MNXM1364673; BiGG fald",confidence:"high"},provenance:{source:"KEGG",id:"C00067",url:"https://www.kegg.jp/entry/C00067"}},{id:"tpl_ent_048",name:"Acetyl phosphate",short:"Acetyl-P",formula:"C2H3O5P",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00227"],chebi:["CHEBI:13711","CHEBI:15350","CHEBI:22191"],"metanetx.chemical":["MNXM280"],"bigg.metabolite":["actp"],hmdb:["HMDB0001494"],"metacyc.compound":["ACETYL-P"],"seed.compound":["cpd00196"]},identity:{status:"suggested",source:"ai",note:"KEGG C00227; MetaNetX MNXM280; BiGG actp",confidence:"high"},provenance:{source:"KEGG",id:"C00227",url:"https://www.kegg.jp/entry/C00227"}}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:null,level:"required"},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:null,level:"required"},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:null,level:"required"},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:null,level:"required"},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:null,level:"required"},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:null,level:"required"},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:null,level:"required"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:null,level:"required"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:null,level:"required"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:null,level:"required"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:null,level:"recommended"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:null,level:"recommended"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:null,level:"optional"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:null,level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:null,level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:null,level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:null,level:"optional"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:null,level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:null,level:"optional"},{id:"tpl_met_020",entity:"tpl_ent_020",compartment:null,level:"optional"},{id:"tpl_met_021",entity:"tpl_ent_021",compartment:null,level:"optional"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:null,level:"optional"},{id:"tpl_met_023",entity:"tpl_ent_023",compartment:null,level:"optional"},{id:"tpl_met_024",entity:"tpl_ent_024",compartment:null,level:"optional"},{id:"tpl_met_025",entity:"tpl_ent_025",compartment:null,level:"optional"},{id:"tpl_met_026",entity:"tpl_ent_026",compartment:null,level:"optional"},{id:"tpl_met_027",entity:"tpl_ent_027",compartment:null,level:"optional"},{id:"tpl_met_028",entity:"tpl_ent_028",compartment:null,level:"optional"},{id:"tpl_met_029",entity:"tpl_ent_029",compartment:null,level:"optional"},{id:"tpl_met_030",entity:"tpl_ent_030",compartment:null,level:"optional"},{id:"tpl_met_031",entity:"tpl_ent_031",compartment:null,level:"optional"},{id:"tpl_met_032",entity:"tpl_ent_032",compartment:null,level:"optional"},{id:"tpl_met_033",entity:"tpl_ent_033",compartment:null,level:"optional"},{id:"tpl_met_034",entity:"tpl_ent_034",compartment:null,level:"optional"},{id:"tpl_met_037",entity:"tpl_ent_037",compartment:null,level:"optional"},{id:"tpl_met_038",entity:"tpl_ent_038",compartment:null,level:"optional"},{id:"tpl_met_039",entity:"tpl_ent_039",compartment:null,level:"optional"},{id:"tpl_met_040",entity:"tpl_ent_040",compartment:null,level:"optional"},{id:"tpl_met_041",entity:"tpl_ent_041",compartment:null,level:"optional"},{id:"tpl_met_042",entity:"tpl_ent_042",compartment:null,level:"optional"},{id:"tpl_met_043",entity:"tpl_ent_043",compartment:null,level:"optional"},{id:"tpl_met_044",entity:"tpl_ent_044",compartment:null,level:"optional"},{id:"tpl_met_045",entity:"tpl_ent_045",compartment:null,level:"optional"},{id:"tpl_met_046",entity:"tpl_ent_046",compartment:null,level:"optional"},{id:"tpl_met_047",entity:"tpl_ent_047",compartment:null,level:"optional"},{id:"tpl_met_048",entity:"tpl_ent_048",compartment:null,level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"G6PDH",canonicalName:"glucose-6-phosphate dehydrogenase",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1}],reversible:!1,ec:["1.1.1.49","1.1.1.363"],identifiers:{"kegg.reaction":["R02736"],"metanetx.reaction":["MNXR191105"],"seed.reaction":["rxn01975","rxn19775","rxn27877","rxn38115"],"bigg.reaction":["G6PBDH"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R02736; MetaNetX MNXR191105"},variants:[{name:"NAD-dependent G6PDH",ec:["1.1.1.363","1.1.1.388"],identifiers:{"kegg.reaction":["R10907"]},equation:"beta-D-Glucose 6-phosphate + NAD+ <=> D-Glucono-1,5-lactone 6-phosphate + NADH + H+"}],provenance:[{source:"KEGG",id:"R02736",url:"https://www.kegg.jp/entry/R02736"}]},{id:"tpl_rxn_002",name:"PGL",canonicalName:"6-phosphogluconolactonase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0}],reversible:!1,ec:["3.1.1.31"],identifiers:{"kegg.reaction":["R02035"],"metanetx.reaction":["MNXR188641"],"seed.reaction":["rxn01476","rxn19017","rxn19018"],"metacyc.reaction":["6PGLUCONOLACT-RXN"],rhea:["12556","12557","12558","12559"],"bigg.reaction":["PGL"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R02035; MetaNetX MNXR188641; KEGG ID confirmed in the built-in template ('PGL')"},provenance:[{source:"KEGG",id:"R02035",url:"https://www.kegg.jp/entry/R02035"}]},{id:"tpl_rxn_003",name:"GND",canonicalName:"6-phosphogluconate dehydrogenase (decarboxylating)",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_041",coefficient:1,main:!1},{metabolite:"tpl_met_038",coefficient:1,main:!1}],reversible:!1,ec:["1.1.1.44","1.1.1.351"],identifiers:{"kegg.reaction":["R01528"],"metanetx.reaction":["MNXR100389"],"seed.reaction":["rxn01115","rxn27624","rxn33304","rxn33323","rxn38006","rxn38009"],"metacyc.reaction":["RXN-9952"],rhea:["10116","10117","10118","10119"],"bigg.reaction":["GND"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01528; MetaNetX MNXR100389; KEGG ID confirmed in the built-in template ('GND')"},variants:[{name:"NAD-dependent GND",ec:["1.1.1.343","1.1.1.351"],identifiers:{"kegg.reaction":["R10221"]},equation:"6-Phospho-D-gluconate + NAD+ <=> D-Ribulose 5-phosphate + CO2 + NADH + H+"}],provenance:[{source:"KEGG",id:"R01528",url:"https://www.kegg.jp/entry/R01528"}]},{id:"tpl_rxn_004",name:"RPI",canonicalName:"ribose-5-phosphate isomerase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0}],reversible:!0,ec:["5.3.1.6"],identifiers:{"kegg.reaction":["R01056"],"metanetx.reaction":["MNXR189850"],"seed.reaction":["rxn00777","rxn15114","rxn28141","rxn34267","rxn38284"],"bigg.reaction":["RPI"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01056; MetaNetX MNXR189850; KEGG ID confirmed in the built-in template ('RPI')"},provenance:[{source:"KEGG",id:"R01056",url:"https://www.kegg.jp/entry/R01056"}]},{id:"tpl_rxn_005",name:"RPE",canonicalName:"ribulose-phosphate 3-epimerase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],reversible:!0,ec:["5.1.3.1"],identifiers:{"kegg.reaction":["R01529"],"metanetx.reaction":["MNXR104083"],"seed.reaction":["rxn01116","rxn28146"],"metacyc.reaction":["RIBULP3EPIM-RXN"],rhea:["13677","13678","13679","13680"],"bigg.reaction":["RPE"]},level:"required",identity:{status:"confirmed",source:"builtin",note:"KEGG R01529; MetaNetX MNXR104083; KEGG ID confirmed in the built-in template ('RPE')"},provenance:[{source:"KEGG",id:"R01529",url:"https://www.kegg.jp/entry/R01529"}]},{id:"tpl_rxn_006",name:"TKT",canonicalName:"transketolase (sedoheptulose-7P)",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!0}],reversible:!0,ec:["2.2.1.1"],identifiers:{"kegg.reaction":["R01641"],"metanetx.reaction":["MNXR152015"],"seed.reaction":["rxn01200","rxn15228","rxn27495","rxn34273"],"bigg.reaction":["TKT1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01641; MetaNetX MNXR152015"},provenance:[{source:"KEGG",id:"R01641",url:"https://www.kegg.jp/entry/R01641"}]},{id:"tpl_rxn_007",name:"TAL",canonicalName:"transaldolase",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0}],reversible:!0,ec:["2.2.1.2"],identifiers:{"kegg.reaction":["R08575"],"metanetx.reaction":["MNXR112107"],"seed.reaction":["rxn01333","rxn15751","rxn29919","rxn33316","rxn33318"],"metacyc.reaction":["TRANSALDOL-RXN"],rhea:["17053","17054","17055","17056"],"bigg.reaction":["TALA"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R08575; MetaNetX MNXR112107; BiGG links TAL to this KEGG reaction but the participants differ — not used"},provenance:[{source:"KEGG",id:"R08575",url:"https://www.kegg.jp/entry/R08575"}]},{id:"tpl_rxn_008",name:"TKT",canonicalName:"transketolase (erythrose-4P)",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!0}],reversible:!0,ec:["2.2.1.1"],identifiers:{"kegg.reaction":["R01067"],"metanetx.reaction":["MNXR106812"],"seed.reaction":["rxn00785","rxn15271","rxn27536","rxn31366"],"metacyc.reaction":["2TRANSKETO-RXN"],rhea:["27626","27627","27628","27629"],"bigg.reaction":["TKT2"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01067; MetaNetX MNXR106812"},provenance:[{source:"KEGG",id:"R01067",url:"https://www.kegg.jp/entry/R01067"}]},{id:"tpl_rxn_009",name:"EDD",canonicalName:"6-phosphogluconate dehydratase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["4.2.1.12"],identifiers:{"kegg.reaction":["R02036"],"metanetx.reaction":["MNXR97898"],"seed.reaction":["rxn01477"],"metacyc.reaction":["PGLUCONDEHYDRAT-RXN"],rhea:["17277","17278","17279","17280"],"bigg.reaction":["EDD"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R02036; MetaNetX MNXR97898"},provenance:[{source:"KEGG",id:"R02036",url:"https://www.kegg.jp/entry/R02036"}]},{id:"tpl_rxn_010",name:"EDA",canonicalName:"KDPG aldolase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_012",coefficient:1,main:!0}],reversible:!0,ec:["4.1.2.14","4.1.2.55"],identifiers:{"kegg.reaction":["R05605"],"metanetx.reaction":["MNXR153444"],"seed.reaction":["rxn03884"],"metacyc.reaction":["KDPGALDOL-RXN"],rhea:["17089","17090","17091","17092"],"bigg.reaction":["EDA"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R05605; MetaNetX MNXR153444"},provenance:[{source:"KEGG",id:"R05605",url:"https://www.kegg.jp/entry/R05605"}]},{id:"tpl_rxn_011",name:"GDH",canonicalName:"glucose dehydrogenase (quinone, PQQ)",participants:[{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_044",coefficient:-1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!0},{metabolite:"tpl_met_045",coefficient:1,main:!1}],reversible:!1,ec:["1.1.5.9"],identifiers:{"kegg.reaction":["R00305"],"metanetx.reaction":["MNXR106464"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R00305; MetaNetX MNXR106464"},variants:[{name:"glucose dehydrogenase (ubiquinone)",ec:["1.1.5.2"],identifiers:{"kegg.reaction":["R06620"]},equation:"D-Glucose + Ubiquinone <=> D-Glucono-1,5-lactone + Ubiquinol"},{name:"glucose 1-dehydrogenase (NADP)",ec:["1.1.1.119","1.1.1.359","1.1.1.360"],identifiers:{"kegg.reaction":["R07147"]},equation:"D-Glucose + NADP+ <=> D-Glucono-1,5-lactone + NADPH + H+"},{name:"glucose 1-dehydrogenase (NAD, β-D-glucose)",ec:["1.1.1.47"],identifiers:{"kegg.reaction":["R01520"]},equation:"beta-D-Glucose + NAD+ <=> D-Glucono-1,5-lactone + NADH + H+"},{name:"glucose 1-dehydrogenase (NADP, β-D-glucose)",ec:["1.1.1.47"],identifiers:{"kegg.reaction":["R01521"]},equation:"beta-D-Glucose + NADP+ <=> D-Glucono-1,5-lactone + NADPH + H+"},{name:"glucose oxidase (O₂ → H₂O₂, β-D-glucose)",ec:["1.1.3.4","1.1.3.5"],identifiers:{"kegg.reaction":["R01522"]},equation:"beta-D-Glucose + Oxygen <=> D-Glucono-1,5-lactone + Hydrogen peroxide"}],provenance:[{source:"KEGG",id:"R00305",url:"https://www.kegg.jp/entry/R00305"}]},{id:"tpl_rxn_012",name:"GNL",canonicalName:"gluconolactonase",participants:[{metabolite:"tpl_met_014",coefficient:-1,main:!0},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_015",coefficient:1,main:!0}],reversible:!1,ec:["3.1.1.17"],identifiers:{"kegg.reaction":["R01519"],"metanetx.reaction":["MNXR147357"],"seed.reaction":["rxn01107"],"metacyc.reaction":["GLUCONOLACT-RXN"],rhea:["10440","10441","10442","10443"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01519; MetaNetX MNXR147357"},provenance:[{source:"KEGG",id:"R01519",url:"https://www.kegg.jp/entry/R01519"}]},{id:"tpl_rxn_013",name:"GNTK",canonicalName:"gluconokinase",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.12"],identifiers:{"kegg.reaction":["R01737"],"metanetx.reaction":["MNXR100390"],"seed.reaction":["rxn01275","rxn34226"],"metacyc.reaction":["GLUCONOKIN-RXN"],rhea:["19433","19434","19435","19436"],"bigg.reaction":["GNKr"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01737; MetaNetX MNXR100390"},provenance:[{source:"KEGG",id:"R01737",url:"https://www.kegg.jp/entry/R01737"}]},{id:"tpl_rxn_014",name:"GADH",canonicalName:"gluconate 2-dehydrogenase",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_042",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:1,main:!0},{metabolite:"tpl_met_043",coefficient:1,main:!1}],reversible:!1,ec:["1.1.99.3"],identifiers:{"kegg.reaction":["R01741"],"metanetx.reaction":["MNXR192085"],"seed.reaction":["rxn01279","rxn14117"],"metacyc.reaction":["RXN-14204"],rhea:["30779","30780","30781","30782"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01741; MetaNetX MNXR192085"},variants:[{name:"2-ketogluconate reductase (NADP, reversible)",ec:["1.1.1.215"],identifiers:{"kegg.reaction":["R01739"]},equation:"D-Gluconic acid + NADP+ <=> 2-Keto-D-gluconic acid + NADPH + H+"}],provenance:[{source:"KEGG",id:"R01741",url:"https://www.kegg.jp/entry/R01741"}]},{id:"tpl_rxn_015",name:"KGUK",canonicalName:"2-ketogluconokinase",participants:[{metabolite:"tpl_met_016",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.13"],identifiers:{"kegg.reaction":["R02658"],"metanetx.reaction":["MNXR94789"],"seed.reaction":["rxn01921","rxn14220"],"metacyc.reaction":["DEHYDOGLUCONOKINASE-RXN"],rhea:["10788","10789","10790","10791"],"bigg.reaction":["2DHGLCK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R02658; MetaNetX MNXR94789"},provenance:[{source:"KEGG",id:"R02658",url:"https://www.kegg.jp/entry/R02658"}]},{id:"tpl_rxn_016",name:"KGUD",canonicalName:"2-ketogluconate-6-phosphate reductase",participants:[{metabolite:"tpl_met_017",coefficient:-1,main:!0},{metabolite:"tpl_met_038",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_037",coefficient:1,main:!1}],reversible:null,ec:["1.1.1.43"],identifiers:{"kegg.reaction":["R02034"],"metanetx.reaction":["MNXR102540"],"seed.reaction":["rxn01475"],rhea:["16817","16818","16819","16820"],"bigg.reaction":["PGLCNDH"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R02034; MetaNetX MNXR102540; curator: KGML lists R02034 as irreversible in the oxidative direction (6P-gluconate → 2-keto-6P-gluconate), but the 2-ketogluconate route (Pseudomonas KguD) reduces 2-keto-6P-gluconate to 6P-gluconate; drawn in the physiological direction, reversibility left open"},variants:[{name:"NAD-dependent form",ec:["1.1.1.43"],identifiers:{"kegg.reaction":["R02032"]},equation:"6-Phospho-D-gluconate + NAD+ <=> 6-Phospho-2-dehydro-D-gluconate + NADH + H+"}],provenance:[{source:"KEGG",id:"R02034",url:"https://www.kegg.jp/entry/R02034"}]},{id:"tpl_rxn_017",name:"GAD",canonicalName:"gluconate dehydratase",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:1,main:!0},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["4.2.1.39","4.2.1.140"],identifiers:{"kegg.reaction":["R01538"],"metanetx.reaction":["MNXR139050"],"seed.reaction":["rxn01121"],"metacyc.reaction":["GLUCONATE-DEHYDRATASE-RXN"],rhea:["21612","21613","21614","21615"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01538; MetaNetX MNXR139050"},provenance:[{source:"KEGG",id:"R01538",url:"https://www.kegg.jp/entry/R01538"}]},{id:"tpl_rxn_018",name:"KDGK",canonicalName:"2-keto-3-deoxygluconate kinase",participants:[{metabolite:"tpl_met_018",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.45","2.7.1.178"],identifiers:{"kegg.reaction":["R01541"],"metanetx.reaction":["MNXR138209"],"seed.reaction":["rxn01123"],"metacyc.reaction":["DEOXYGLUCONOKIN-RXN"],rhea:["14797","14798","14799","14800"],"bigg.reaction":["DDGLK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01541; MetaNetX MNXR138209"},provenance:[{source:"KEGG",id:"R01541",url:"https://www.kegg.jp/entry/R01541"}]},{id:"tpl_rxn_019",name:"KDGA",canonicalName:"2-keto-3-deoxygluconate aldolase",participants:[{metabolite:"tpl_met_018",coefficient:-1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!0},{metabolite:"tpl_met_012",coefficient:1,main:!0}],reversible:!0,ec:["4.1.2.51","4.1.2.55"],identifiers:{"kegg.reaction":["R08570"],"metanetx.reaction":["MNXR139622"],"seed.reaction":["rxn15750","rxn32049","rxn32050"],"metacyc.reaction":["DHDOGALDOL-RXN"],rhea:["35583","35584","35585","35586"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R08570; MetaNetX MNXR139622"},provenance:[{source:"KEGG",id:"R08570",url:"https://www.kegg.jp/entry/R08570"}]},{id:"tpl_rxn_020",name:"GADH",canonicalName:"glyceraldehyde dehydrogenase (NADP)",participants:[{metabolite:"tpl_met_019",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_020",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1}],reversible:!1,ec:["1.2.1.89"],identifiers:{"kegg.reaction":["R10615"],"metanetx.reaction":["MNXR113942"],"seed.reaction":["rxn40365"],"metacyc.reaction":["RXN-15115"],rhea:["40163","40164","40165","40166"],"bigg.reaction":["GLYALDDy"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10615; MetaNetX MNXR113942"},variants:[{name:"glyceraldehyde:ferredoxin oxidoreductase (GAOR)",ec:["1.2.7.5"],identifiers:{"kegg.reaction":["R08571"]},equation:"D-Glyceraldehyde + H2O + Oxidized ferredoxin <=> D-Glycerate + H+ + Reduced ferredoxin"},{name:"glyceraldehyde dehydrogenase (acceptor)",ec:["1.2.99.8"],identifiers:{"kegg.reaction":["R10324"]},equation:"D-Glyceraldehyde + H2O + Acceptor <=> D-Glycerate + Reduced acceptor"}],provenance:[{source:"KEGG",id:"R10615",url:"https://www.kegg.jp/entry/R10615"}]},{id:"tpl_rxn_021",name:"GK",canonicalName:"glycerate 2-kinase",participants:[{metabolite:"tpl_met_020",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.165"],identifiers:{"kegg.reaction":["R08572"],"metanetx.reaction":["MNXR100329"],"seed.reaction":["rxn08647","rxn27876"],"metacyc.reaction":["GKI-RXN"],rhea:["27377","27378","27379","27380"],"bigg.reaction":["GLYCK2"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R08572; MetaNetX MNXR100329"},provenance:[{source:"KEGG",id:"R08572",url:"https://www.kegg.jp/entry/R08572"}]},{id:"tpl_rxn_022",name:"HPS",canonicalName:"3-hexulose-6-phosphate synthase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_047",coefficient:-1,main:!1},{metabolite:"tpl_met_022",coefficient:1,main:!0}],reversible:!0,ec:["4.1.2.43"],identifiers:{"kegg.reaction":["R05338"],"metanetx.reaction":["MNXR109495"],"seed.reaction":["rxn03643"],"metacyc.reaction":["R10-RXN"],rhea:["25201","25202","25203","25204"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R05338; MetaNetX MNXR109495"},provenance:[{source:"KEGG",id:"R05338",url:"https://www.kegg.jp/entry/R05338"}]},{id:"tpl_rxn_023",name:"PHI",canonicalName:"6-phospho-3-hexuloisomerase",participants:[{metabolite:"tpl_met_022",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0}],reversible:!0,ec:["5.3.1.27"],identifiers:{"kegg.reaction":["R05339"],"metanetx.reaction":["MNXR109496"],"seed.reaction":["rxn03644","rxn16622"],"metacyc.reaction":["R12-RXN"],rhea:["25900","25901","25902","25903"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R05339; MetaNetX MNXR109496"},provenance:[{source:"KEGG",id:"R05339",url:"https://www.kegg.jp/entry/R05339"}]},{id:"tpl_rxn_024",name:"SHPK",canonicalName:"sedoheptulokinase",participants:[{metabolite:"tpl_met_023",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.14"],identifiers:{"kegg.reaction":["R01844"],"metanetx.reaction":["MNXR147449"],"seed.reaction":["rxn15272"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01844; MetaNetX MNXR147449"},provenance:[{source:"KEGG",id:"R01844",url:"https://www.kegg.jp/entry/R01844"}]},{id:"tpl_rxn_025",name:"XPK",canonicalName:"phosphoketolase",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_039",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_048",coefficient:1,main:!1},{metabolite:"tpl_met_040",coefficient:1,main:!1}],reversible:!1,ec:["4.1.2.9"],identifiers:{"kegg.reaction":["R01621"],"metanetx.reaction":["MNXR107093"],"seed.reaction":["rxn01187"],"metacyc.reaction":["PHOSPHOKETOLASE-RXN"],rhea:["10468","10469","10470","10471"],"bigg.reaction":["PKETX"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01621; MetaNetX MNXR107093"},provenance:[{source:"KEGG",id:"R01621",url:"https://www.kegg.jp/entry/R01621"}]},{id:"tpl_rxn_026",name:"RBK",canonicalName:"ribokinase",participants:[{metabolite:"tpl_met_025",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!0,ec:["2.7.1.15"],identifiers:{"kegg.reaction":["R01051"],"metanetx.reaction":["MNXR189840"],"seed.reaction":["rxn00772","rxn30058","rxn33469"],"metacyc.reaction":["RIBOKIN-RXN"],rhea:["13697","13698","13699","13700"],"bigg.reaction":["RBK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01051; MetaNetX MNXR189840"},provenance:[{source:"KEGG",id:"R01051",url:"https://www.kegg.jp/entry/R01051"}]},{id:"tpl_rxn_027",name:"PPM",canonicalName:"phosphopentomutase (ribose)",participants:[{metabolite:"tpl_met_026",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0}],reversible:!0,ec:["5.4.2.2","5.4.2.7"],identifiers:{"kegg.reaction":["R01057"],"metanetx.reaction":["MNXR189820"],"seed.reaction":["rxn00778","rxn15115","rxn32821","rxn34262"],rhea:["18793","18794","18795","18796"],"bigg.reaction":["PPM"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01057; MetaNetX MNXR189820"},provenance:[{source:"KEGG",id:"R01057",url:"https://www.kegg.jp/entry/R01057"}]},{id:"tpl_rxn_028",name:"PRPS",canonicalName:"ribose-phosphate pyrophosphokinase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_024",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1}],reversible:!0,ec:["2.7.6.1"],identifiers:{"kegg.reaction":["R01049"],"metanetx.reaction":["MNXR189826"],"seed.reaction":["rxn00770","rxn15108","rxn33995","rxn35356","rxn38273"],rhea:["15609","15610","15611","15612"],"bigg.reaction":["PRPPS"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01049; MetaNetX MNXR189826"},provenance:[{source:"KEGG",id:"R01049",url:"https://www.kegg.jp/entry/R01049"}]},{id:"tpl_rxn_029",name:"R1PK",canonicalName:"ribose 1-phosphate kinase",participants:[{metabolite:"tpl_met_026",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_027",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.1.239"],identifiers:{"kegg.reaction":["R13089"],"metanetx.reaction":["MNXR188738"],"seed.reaction":["rxn09221"],"metacyc.reaction":["RXN0-1402"],rhea:["29775","29776","29777","29778"],"bigg.reaction":["R1PK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R13089 (represents map reactions R06837); MetaNetX MNXR188738"},variants:[{name:"ADP-dependent ribose-1-phosphate kinase (archaea)",ec:["2.7.1.212"],identifiers:{"kegg.reaction":["R11535"]},equation:"ADP + alpha-D-Ribose 1-phosphate <=> AMP + D-Ribose 1,5-bisphosphate"}],provenance:[{source:"KEGG",id:"R06837",url:"https://www.kegg.jp/entry/R06837"},{source:"KEGG",id:"R13089",url:"https://www.kegg.jp/entry/R13089"}]},{id:"tpl_rxn_030",name:"PRPK",canonicalName:"ribose 1,5-bisphosphate phosphokinase",participants:[{metabolite:"tpl_met_027",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_024",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!1,ec:["2.7.4.23"],identifiers:{"kegg.reaction":["R06836"],"metanetx.reaction":["MNXR188736"],"seed.reaction":["rxn04651"],"metacyc.reaction":["RXN0-1401"],rhea:["20109","20110","20111","20112"],"bigg.reaction":["R15BPK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R06836; MetaNetX MNXR188736"},provenance:[{source:"KEGG",id:"R06836",url:"https://www.kegg.jp/entry/R06836"}]},{id:"tpl_rxn_031",name:"R15PI",canonicalName:"ribose 1,5-bisphosphate isomerase",participants:[{metabolite:"tpl_met_027",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:1,main:!0}],reversible:!1,ec:["5.3.1.29"],identifiers:{"kegg.reaction":["R10555"],"metanetx.reaction":["MNXR191187"],"seed.reaction":["rxn10594"],"metacyc.reaction":["RXN-8801"],rhea:["32243","32244","32245","32246"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10555; MetaNetX MNXR191187"},provenance:[{source:"KEGG",id:"R10555",url:"https://www.kegg.jp/entry/R10555"}]},{id:"tpl_rxn_032",name:"DRBK",canonicalName:"deoxyribokinase",participants:[{metabolite:"tpl_met_029",coefficient:-1,main:!0},{metabolite:"tpl_met_032",coefficient:-1,main:!1},{metabolite:"tpl_met_031",coefficient:1,main:!0},{metabolite:"tpl_met_033",coefficient:1,main:!1}],reversible:!0,ec:["2.7.1.15","2.7.1.229"],identifiers:{"kegg.reaction":["R02750"],"metanetx.reaction":["MNXR198113"],"seed.reaction":["rxn01987","rxn46094"],rhea:["30871","30872","30873","30874"],"bigg.reaction":["DRBK"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R02750; MetaNetX MNXR198113"},provenance:[{source:"KEGG",id:"R02750",url:"https://www.kegg.jp/entry/R02750"}]},{id:"tpl_rxn_033",name:"PPM",canonicalName:"phosphopentomutase (deoxyribose)",participants:[{metabolite:"tpl_met_030",coefficient:-1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!0}],reversible:!0,ec:["5.4.2.7"],identifiers:{"kegg.reaction":["R02749"],"metanetx.reaction":["MNXR146101"],"seed.reaction":["rxn01986","rxn19378","rxn30648","rxn32641","rxn32644"],"metacyc.reaction":["D-PPENTOMUT-RXN"],rhea:["27658","27659","27660","27661"],"bigg.reaction":["PPM2"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R02749; MetaNetX MNXR146101"},provenance:[{source:"KEGG",id:"R02749",url:"https://www.kegg.jp/entry/R02749"}]},{id:"tpl_rxn_034",name:"DERA",canonicalName:"deoxyribose-phosphate aldolase",participants:[{metabolite:"tpl_met_031",coefficient:-1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_046",coefficient:1,main:!1}],reversible:!0,ec:["4.1.2.4"],identifiers:{"kegg.reaction":["R01066"],"metanetx.reaction":["MNXR153401"],"seed.reaction":["rxn00784","rxn19461","rxn32827","rxn32853"],"metacyc.reaction":["DEOXYRIBOSE-P-ALD-RXN"],rhea:["12821","12822","12823","12824"],"bigg.reaction":["DRPA"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01066; MetaNetX MNXR153401"},provenance:[{source:"KEGG",id:"R01066",url:"https://www.kegg.jp/entry/R01066"}]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_002",metabolite:"tpl_met_010",direction:"out",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_003",metabolite:"tpl_met_008",direction:"out",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_004",metabolite:"tpl_met_024",direction:"out",target:{pathway:"Purine metabolism"}}]},rw={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:0,shape:"label"},{id:"tpl_node_002",metabolite:"tpl_met_002",x:200,y:0,shape:"label"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:400,y:0,shape:"label"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:670,y:0,shape:"label"},{id:"tpl_node_005",metabolite:"tpl_met_013",x:0,y:-200,shape:"label"},{id:"tpl_node_006",metabolite:"tpl_met_014",x:200,y:-200,shape:"label"},{id:"tpl_node_007",metabolite:"tpl_met_015",x:400,y:-200,shape:"label"},{id:"tpl_node_008",metabolite:"tpl_met_016",x:640,y:-200,shape:"label"},{id:"tpl_node_009",metabolite:"tpl_met_017",x:640,y:-100,shape:"label"},{id:"tpl_node_010",metabolite:"tpl_met_005",x:570,y:170,shape:"label"},{id:"tpl_node_011",metabolite:"tpl_met_006",x:770,y:170,shape:"label"},{id:"tpl_node_012",metabolite:"tpl_met_007",x:570,y:340,shape:"label"},{id:"tpl_node_013",metabolite:"tpl_met_008",x:770,y:340,shape:"label"},{id:"tpl_node_014",metabolite:"tpl_met_010",x:570,y:510,shape:"label"},{id:"tpl_node_015",metabolite:"tpl_met_009",x:770,y:510,shape:"label"},{id:"tpl_node_016",metabolite:"tpl_met_006",x:970,y:510,shape:"label"},{id:"tpl_node_017",metabolite:"tpl_met_010",x:770,y:680,shape:"label"},{id:"tpl_node_018",metabolite:"tpl_met_008",x:970,y:680,shape:"label"},{id:"tpl_node_019",metabolite:"tpl_met_011",x:400,y:170,shape:"label"},{id:"tpl_node_020",metabolite:"tpl_met_008",x:330,y:340,shape:"label"},{id:"tpl_node_021",metabolite:"tpl_met_012",x:470,y:340,shape:"label"},{id:"tpl_node_022",metabolite:"tpl_met_015",x:100,y:340,shape:"label"},{id:"tpl_node_023",metabolite:"tpl_met_018",x:100,y:510,shape:"label"},{id:"tpl_node_024",metabolite:"tpl_met_011",x:260,y:510,shape:"label"},{id:"tpl_node_025",metabolite:"tpl_met_019",x:0,y:680,shape:"label"},{id:"tpl_node_026",metabolite:"tpl_met_012",x:200,y:680,shape:"label"},{id:"tpl_node_027",metabolite:"tpl_met_020",x:0,y:850,shape:"label"},{id:"tpl_node_028",metabolite:"tpl_met_021",x:0,y:1020,shape:"label"},{id:"tpl_node_029",metabolite:"tpl_met_022",x:920,y:0,shape:"label"},{id:"tpl_node_030",metabolite:"tpl_met_010",x:920,y:-150,shape:"label"},{id:"tpl_node_031",metabolite:"tpl_met_023",x:440,y:450,shape:"label"},{id:"tpl_node_032",metabolite:"tpl_met_008",x:970,y:170,shape:"label"},{id:"tpl_node_033",metabolite:"tpl_met_025",x:400,y:830,shape:"label"},{id:"tpl_node_034",metabolite:"tpl_met_005",x:600,y:830,shape:"label"},{id:"tpl_node_035",metabolite:"tpl_met_026",x:800,y:830,shape:"label"},{id:"tpl_node_036",metabolite:"tpl_met_024",x:600,y:990,shape:"label"},{id:"tpl_node_037",metabolite:"tpl_met_027",x:800,y:990,shape:"label"},{id:"tpl_node_038",metabolite:"tpl_met_028",x:1e3,y:990,shape:"label"},{id:"tpl_node_039",metabolite:"tpl_met_029",x:400,y:1130,shape:"label"},{id:"tpl_node_040",metabolite:"tpl_met_031",x:600,y:1130,shape:"label"},{id:"tpl_node_041",metabolite:"tpl_met_030",x:800,y:1130,shape:"label"},{id:"tpl_node_042",metabolite:"tpl_met_008",x:600,y:1280,shape:"label"},{id:"tpl_node_043",metabolite:"tpl_met_037",x:69.7,y:-16,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_044",metabolite:"tpl_met_038",x:130.8,y:-16,attach:{reaction:"tpl_rxn_001",side:"out"}},{id:"tpl_node_045",metabolite:"tpl_met_037",x:504.7,y:-16,attach:{reaction:"tpl_rxn_003",side:"in"}},{id:"tpl_node_046",metabolite:"tpl_met_041",x:560.7,y:-16,attach:{reaction:"tpl_rxn_003",side:"out"}},{id:"tpl_node_047",metabolite:"tpl_met_038",x:601.4,y:-16,attach:{reaction:"tpl_rxn_003",side:"out"}},{id:"tpl_node_048",metabolite:"tpl_met_044",x:79.4,y:-216,attach:{reaction:"tpl_rxn_011",side:"in"}},{id:"tpl_node_049",metabolite:"tpl_met_045",x:125.7,y:-216,attach:{reaction:"tpl_rxn_011",side:"out"}},{id:"tpl_node_050",metabolite:"tpl_met_032",x:419.7,y:-116,attach:{reaction:"tpl_rxn_013",side:"in"}},{id:"tpl_node_051",metabolite:"tpl_met_033",x:419.7,y:-84,attach:{reaction:"tpl_rxn_013",side:"out"}},{id:"tpl_node_052",metabolite:"tpl_met_042",x:494.3,y:-216,attach:{reaction:"tpl_rxn_014",side:"in"}},{id:"tpl_node_053",metabolite:"tpl_met_043",x:550.8,y:-216,attach:{reaction:"tpl_rxn_014",side:"out"}},{id:"tpl_node_054",metabolite:"tpl_met_032",x:659.7,y:-166,attach:{reaction:"tpl_rxn_015",side:"in"}},{id:"tpl_node_055",metabolite:"tpl_met_033",x:659.7,y:-134,attach:{reaction:"tpl_rxn_015",side:"out"}},{id:"tpl_node_056",metabolite:"tpl_met_038",x:545.5,y:-65.8,attach:{reaction:"tpl_rxn_016",side:"in"}},{id:"tpl_node_057",metabolite:"tpl_met_037",x:491.1,y:-43.3,attach:{reaction:"tpl_rxn_016",side:"out"}},{id:"tpl_node_058",metabolite:"tpl_met_032",x:154.3,y:494,attach:{reaction:"tpl_rxn_018",side:"in"}},{id:"tpl_node_059",metabolite:"tpl_met_033",x:205.7,y:494,attach:{reaction:"tpl_rxn_018",side:"out"}},{id:"tpl_node_060",metabolite:"tpl_met_037",x:24.3,y:749,attach:{reaction:"tpl_rxn_020",side:"in"}},{id:"tpl_node_061",metabolite:"tpl_met_038",x:24.8,y:781,attach:{reaction:"tpl_rxn_020",side:"out"}},{id:"tpl_node_062",metabolite:"tpl_met_032",x:19.7,y:919,attach:{reaction:"tpl_rxn_021",side:"in"}},{id:"tpl_node_063",metabolite:"tpl_met_033",x:19.7,y:951,attach:{reaction:"tpl_rxn_021",side:"out"}},{id:"tpl_node_064",metabolite:"tpl_met_047",x:752.5,y:-16,attach:{reaction:"tpl_rxn_022",side:"in"}},{id:"tpl_node_065",metabolite:"tpl_met_032",x:489.6,y:413,attach:{reaction:"tpl_rxn_024",side:"in"}},{id:"tpl_node_066",metabolite:"tpl_met_033",x:525.3,y:382.8,attach:{reaction:"tpl_rxn_024",side:"out"}},{id:"tpl_node_067",metabolite:"tpl_met_039",x:847.4,y:154,attach:{reaction:"tpl_rxn_025",side:"in"}},{id:"tpl_node_068",metabolite:"tpl_met_048",x:904.6,y:154,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_069",metabolite:"tpl_met_032",x:474.3,y:814,attach:{reaction:"tpl_rxn_026",side:"in"}},{id:"tpl_node_070",metabolite:"tpl_met_033",x:525.7,y:814,attach:{reaction:"tpl_rxn_026",side:"out"}},{id:"tpl_node_071",metabolite:"tpl_met_032",x:619.7,y:894,attach:{reaction:"tpl_rxn_028",side:"in"}},{id:"tpl_node_072",metabolite:"tpl_met_034",x:619.7,y:926,attach:{reaction:"tpl_rxn_028",side:"out"}},{id:"tpl_node_073",metabolite:"tpl_met_032",x:819.7,y:894,attach:{reaction:"tpl_rxn_029",side:"in"}},{id:"tpl_node_074",metabolite:"tpl_met_033",x:819.7,y:926,attach:{reaction:"tpl_rxn_029",side:"out"}},{id:"tpl_node_075",metabolite:"tpl_met_032",x:725.7,y:1006,attach:{reaction:"tpl_rxn_030",side:"in"}},{id:"tpl_node_076",metabolite:"tpl_met_033",x:674.3,y:1006,attach:{reaction:"tpl_rxn_030",side:"out"}},{id:"tpl_node_077",metabolite:"tpl_met_032",x:474.3,y:1114,attach:{reaction:"tpl_rxn_032",side:"in"}},{id:"tpl_node_078",metabolite:"tpl_met_033",x:525.7,y:1114,attach:{reaction:"tpl_rxn_032",side:"out"}},{id:"tpl_node_079",metabolite:"tpl_met_046",x:636.5,y:1221,attach:{reaction:"tpl_rxn_034",side:"out"}}],ports:[{id:"tpl_node_080",connector:"tpl_port_001",x:-260,y:0,from:"tpl_node_001"},{id:"tpl_node_081",connector:"tpl_port_002",x:570,y:600,from:"tpl_node_014"},{id:"tpl_node_082",connector:"tpl_port_003",x:1020,y:340,from:"tpl_node_013"},{id:"tpl_node_083",connector:"tpl_port_004",x:370,y:990,from:"tpl_node_036"}],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_004"],targets:["tpl_node_010"],routing:"curved",bend:20},{reaction:"tpl_rxn_005",sources:["tpl_node_004"],targets:["tpl_node_011"],routing:"curved",bend:20,label_flip:!0},{reaction:"tpl_rxn_006",sources:["tpl_node_010","tpl_node_011"],targets:["tpl_node_012","tpl_node_013"],routing:"straight"},{reaction:"tpl_rxn_007",sources:["tpl_node_012","tpl_node_013"],targets:["tpl_node_014","tpl_node_015"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_015","tpl_node_016"],targets:["tpl_node_017","tpl_node_018"],routing:"straight"},{reaction:"tpl_rxn_009",sources:["tpl_node_003"],targets:["tpl_node_019"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_019"],targets:["tpl_node_020","tpl_node_021"],routing:"straight"},{reaction:"tpl_rxn_011",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_012",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"straight"},{reaction:"tpl_rxn_013",sources:["tpl_node_007"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_014",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"straight"},{reaction:"tpl_rxn_015",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"straight"},{reaction:"tpl_rxn_016",sources:["tpl_node_009"],targets:["tpl_node_003"],routing:"curved",bend:26,label_offset:{x:-8.3,y:-19.9}},{reaction:"tpl_rxn_017",sources:["tpl_node_022"],targets:["tpl_node_023"],routing:"straight"},{reaction:"tpl_rxn_018",sources:["tpl_node_023"],targets:["tpl_node_024"],routing:"straight"},{reaction:"tpl_rxn_019",sources:["tpl_node_023"],targets:["tpl_node_025","tpl_node_026"],routing:"straight"},{reaction:"tpl_rxn_020",sources:["tpl_node_025"],targets:["tpl_node_027"],routing:"straight"},{reaction:"tpl_rxn_021",sources:["tpl_node_027"],targets:["tpl_node_028"],routing:"straight"},{reaction:"tpl_rxn_022",sources:["tpl_node_004"],targets:["tpl_node_029"],routing:"straight"},{reaction:"tpl_rxn_023",sources:["tpl_node_029"],targets:["tpl_node_030"],routing:"straight"},{reaction:"tpl_rxn_024",sources:["tpl_node_031"],targets:["tpl_node_012"],routing:"curved",bend:17,label_flip:!0,label_offset:{x:-13.6,y:-16}},{reaction:"tpl_rxn_025",sources:["tpl_node_011"],targets:["tpl_node_032"],routing:"straight"},{reaction:"tpl_rxn_026",sources:["tpl_node_033"],targets:["tpl_node_034"],routing:"straight"},{reaction:"tpl_rxn_027",sources:["tpl_node_035"],targets:["tpl_node_034"],routing:"straight"},{reaction:"tpl_rxn_028",sources:["tpl_node_034"],targets:["tpl_node_036"],routing:"straight"},{reaction:"tpl_rxn_029",sources:["tpl_node_035"],targets:["tpl_node_037"],routing:"straight"},{reaction:"tpl_rxn_030",sources:["tpl_node_037"],targets:["tpl_node_036"],routing:"straight"},{reaction:"tpl_rxn_031",sources:["tpl_node_037"],targets:["tpl_node_038"],routing:"straight"},{reaction:"tpl_rxn_032",sources:["tpl_node_039"],targets:["tpl_node_040"],routing:"straight"},{reaction:"tpl_rxn_033",sources:["tpl_node_041"],targets:["tpl_node_040"],routing:"straight"},{reaction:"tpl_rxn_034",sources:["tpl_node_040"],targets:["tpl_node_042"],routing:"straight"}],groups:[{id:"tpl_grp_001",kind:"pathway",title:"Glucose oxidation · 2-ketogluconate (bacteria)",nodes:["tpl_node_005","tpl_node_006","tpl_node_007","tpl_node_008","tpl_node_009"]},{id:"tpl_grp_002",kind:"pathway",title:"Non- / semi-phosphorylative ED (archaea)",nodes:["tpl_node_022","tpl_node_023","tpl_node_024","tpl_node_025","tpl_node_026","tpl_node_027","tpl_node_028"]},{id:"tpl_grp_003",kind:"pathway",title:"Ribose, PRPP and deoxyribose",nodes:["tpl_node_033","tpl_node_034","tpl_node_035","tpl_node_036","tpl_node_037","tpl_node_038","tpl_node_039","tpl_node_040","tpl_node_041","tpl_node_042"]},{id:"tpl_grp_004",kind:"pathway",title:"RuMP (methylotrophs)",nodes:["tpl_node_029","tpl_node_030"]}],labels:[{id:"tpl_lbl_001",x:180,y:260,text:"Entner–Doudoroff",size:11,weight:600,italic:!0,kind:"text"},{id:"tpl_lbl_002",x:-300,y:-340,text:"Pentose phosphate pathway",size:16,weight:700,kind:"title"},{id:"tpl_lbl_003",x:-300,y:-320,text:"derived from KEGG map00030 · drawn by GEMsMAP",size:10,weight:400,italic:!0,kind:"text"}]},cw={format:aw,schema_version:sw,metadata:ow,biology:lw,layout:rw},dw="gemsmap-template",mw="1.1.0",uw={id:"kegg-map00250",name:"Alanine, aspartate and glutamate metabolism (KEGG map00250)",description:"Nitrogen assimilation and the amino acids made directly from central-carbon keto acids: glutamate / glutamine (GDH, GS-GOGAT, glutaminase), aspartate / asparagine, alanine, the GABA shunt, and the nitrogen glutamine and aspartate donate to carbamoyl phosphate, pyrimidines, purines, arginine and amino sugars; N-acetylaspartate / NAAG of the vertebrate brain. Derived from KEGG; drawn by GEMsMAP.",pathway:"Alanine, aspartate and glutamate metabolism",section:"KEGG-derived templates",template_version:"0.1.0",scope:{level:"universal",taxa:[],note:"GDH, GS, transaminases and asparagine synthesis are conserved; GOGAT (bacteria, plants, fungi), the GABA shunt, D-aspartate and NAA / NAAG (vertebrate brain) are organism-specific. Compartments are chosen by the person mapping onto a GEM."},authors:["Drafted with an LLM (Claude Opus 5.5)"],created:"2026-10-09T00:00:00Z",modified:"2026-10-09T18:53:40Z",license:"MIT (drawing and curation); identifiers and biology from KEGG, MetaNetX and BiGG",tags:["KEGG","map00250","amino acids","glutamate","aspartate","nitrogen assimilation"],citations:[{text:"Kanehisa M, Goto S. KEGG: Kyoto Encyclopedia of Genes and Genomes. Nucleic Acids Res 28:27-30 (2000)",doi:"10.1093/nar/28.1.27"}],layout_kind:"vertical",review_status:"ai-generated",source:{reference:"KEGG",pathway_id:"map00250",pathway_name:"Alanine, aspartate and glutamate metabolism",url:"https://www.genome.jp/pathway/map00250",generation_method:"KEGG flat files + KGML (structure only) → curated biological graph → identities reconciled with MetaNetX (backend client) and the BiGG tables → hand-designed layout",generated_by:"tools/kegg/kegg_template.py",retrieved:"2026-10-09"}},pw={compartments:[],entities:[{id:"tpl_ent_001",name:"2-Oxoglutarate",short:"2-Oxoglutarate",formula:"C5H4O5",charge:-2,synonyms:["2-Ketoglutaric acid","2-ketoglutarate","2-oxoglutarate","2-oxoglutaric acid","Oxoglutaric acid","alpha-Ketoglutaric acid","alpha-ketoglutarate","alpha-ketoglutaric acid","oxoglutarate"],identifiers:{"kegg.compound":["C00026"],chebi:["16810","30915","CHEBI:16810","CHEBI:178058","CHEBI:178083","CHEBI:30915","CHEBI:30916"],"metanetx.chemical":["MNXM1368744"],"bigg.metabolite":["akg"],hmdb:["HMDB0000208","HMDB0002812","HMDB0062781"],"metacyc.compound":["2-KETOGLUTARATE"],"seed.compound":["cpd00024","cpd32228"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00026; MetaNetX MNXM1368744; BiGG akg; GEMsMAP library '2-oxoglutarate'"},library:"2-oxoglutarate",provenance:{source:"KEGG",id:"C00026",url:"https://www.kegg.jp/entry/C00026"}},{id:"tpl_ent_002",name:"L-Glutamate",short:"Glutamate",formula:"C5H8NO4",charge:-1,synonyms:["Glutamate","L-Glutamic acid","L-Glutaminic acid"],identifiers:{"kegg.compound":["C00025"],chebi:["CHEBI:16015","CHEBI:192079","CHEBI:29985","CHEBI:29988"],"metanetx.chemical":["MNXM741173"],"bigg.metabolite":["glu__L"],hmdb:["HMDB0000148"],"metacyc.compound":["GLT"],"seed.compound":["cpd00023"]},identity:{status:"suggested",source:"ai",note:"KEGG C00025; MetaNetX MNXM741173; BiGG glu__L",confidence:"high"},provenance:{source:"KEGG",id:"C00025",url:"https://www.kegg.jp/entry/C00025"}},{id:"tpl_ent_003",name:"L-Glutamine",short:"Glutamine",formula:"C5H10N2O3",charge:0,synonyms:["L-2-Aminoglutaramic acid"],identifiers:{"kegg.compound":["C00064","C00303"],chebi:["CHEBI:18050","CHEBI:28300","CHEBI:32665","CHEBI:32666","CHEBI:32678","CHEBI:32679","CHEBI:58359"],"metanetx.chemical":["MNXM37"],"bigg.metabolite":["gln__L"],hmdb:["HMDB0000641"],"metacyc.compound":["GLN"],"seed.compound":["cpd00053","cpd00253"]},identity:{status:"suggested",source:"ai",note:"KEGG C00064; MetaNetX MNXM37; BiGG gln__L",confidence:"high"},provenance:{source:"KEGG",id:"C00064",url:"https://www.kegg.jp/entry/C00064"}},{id:"tpl_ent_004",name:"Oxaloacetate",short:"Oxaloacetate",formula:"C4H2O5",charge:-2,synonyms:["2-Oxobutanedioic acid","2-Oxosuccinic acid","2-oxosuccinate","OAA","Oxalacetic acid","Oxaloacetic acid","keto-Oxaloacetate","oxalacetate","oxaloacetate","oxaloacetic acid"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744","CHEBI:16452","CHEBI:30744"],"metanetx.chemical":["MNXM46"],"bigg.metabolite":["oaa"],hmdb:["HMDB0000223"],"metacyc.compound":["OXALACETIC_ACID"],"seed.compound":["cpd00032"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00036; MetaNetX MNXM46; BiGG oaa; GEMsMAP library 'oxaloacetate'"},library:"oxaloacetate",provenance:{source:"KEGG",id:"C00036",url:"https://www.kegg.jp/entry/C00036"}},{id:"tpl_ent_005",name:"L-Aspartate",short:"Aspartate",formula:"C4H6NO4",charge:-1,synonyms:["2-Aminosuccinic acid","L-Asp","L-Aspartic acid"],identifiers:{"kegg.compound":["C00049"],chebi:["CHEBI:17053","CHEBI:176631","CHEBI:192076","CHEBI:29991","CHEBI:29993"],"metanetx.chemical":["MNXM1364497"],"bigg.metabolite":["asp__L"],hmdb:["HMDB0000191"],"metacyc.compound":["L-ASPARTATE"],"seed.compound":["cpd00041"]},identity:{status:"suggested",source:"ai",note:"KEGG C00049; MetaNetX MNXM1364497; BiGG asp__L",confidence:"high"},provenance:{source:"KEGG",id:"C00049",url:"https://www.kegg.jp/entry/C00049"}},{id:"tpl_ent_006",name:"L-Asparagine",short:"Asparagine",formula:"C4H8N2O3",charge:0,synonyms:["2-Aminosuccinamic acid"],identifiers:{"kegg.compound":["C00152"],chebi:["CHEBI:17196","CHEBI:32650","CHEBI:32651","CHEBI:58048"],"metanetx.chemical":["MNXM1107821"],"bigg.metabolite":["asn__L"],hmdb:["HMDB0000168"],"metacyc.compound":["ASN"],"seed.compound":["cpd00132"]},identity:{status:"suggested",source:"ai",note:"KEGG C00152; MetaNetX MNXM1107821; BiGG asn__L",confidence:"high"},provenance:{source:"KEGG",id:"C00152",url:"https://www.kegg.jp/entry/C00152"}},{id:"tpl_ent_007",name:"Pyruvate",short:"Pyruvate",formula:"C3H3O3",charge:-1,synonyms:["2-Oxopropanoate","2-Oxopropanoic acid","2-oxopropanoate","2-oxopropanoic acid","Pyr","Pyroracemic acid","Pyruvic acid","pyruvate","pyruvic acid"],identifiers:{"kegg.compound":["C00022"],chebi:["15361","32816","CHEBI:15361","CHEBI:177913","CHEBI:32816"],"metanetx.chemical":["MNXM23"],"bigg.metabolite":["pyr"],hmdb:["HMDB0000243"],"metacyc.compound":["PYRUVATE"],"seed.compound":["cpd00020"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00022; MetaNetX MNXM23; BiGG pyr; GEMsMAP library 'pyruvate'"},library:"pyruvate",provenance:{source:"KEGG",id:"C00022",url:"https://www.kegg.jp/entry/C00022"}},{id:"tpl_ent_008",name:"L-Alanine",short:"Alanine",formula:"C3H7NO2",charge:0,synonyms:["L-2-Aminopropionic acid","L-alpha-Alanine"],identifiers:{"kegg.compound":["C00041"],chebi:["CHEBI:16977","CHEBI:229589","CHEBI:32431","CHEBI:32432","CHEBI:57972","CHEBI:76050"],"metanetx.chemical":["MNXM1105732"],"bigg.metabolite":["ala__L"],hmdb:["HMDB0000161"],"metacyc.compound":["L-ALPHA-ALANINE"],"seed.compound":["cpd00035"]},identity:{status:"suggested",source:"ai",note:"KEGG C00041; MetaNetX MNXM1105732; BiGG ala__L",confidence:"high"},provenance:{source:"KEGG",id:"C00041",url:"https://www.kegg.jp/entry/C00041"}},{id:"tpl_ent_009",name:"Fumarate",short:"Fumarate",formula:"C4H2O4",charge:-2,synonyms:["(E)-butenedioate","Fum","Fumaric acid","fumarate","fumaric acid","trans-Butenedioic acid","trans-butenedioate"],identifiers:{"kegg.compound":["C00122"],chebi:["18012","29806","CHEBI:18012","CHEBI:29806","CHEBI:37154"],"metanetx.chemical":["MNXM737340"],"bigg.metabolite":["fum"],hmdb:["HMDB0000134"],"metacyc.compound":["FUM"],"seed.compound":["cpd00106"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00122; MetaNetX MNXM737340; BiGG fum; GEMsMAP library 'fumarate'"},library:"fumarate",provenance:{source:"KEGG",id:"C00122",url:"https://www.kegg.jp/entry/C00122"}},{id:"tpl_ent_010",name:"4-Aminobutanoate",short:"GABA",formula:"C4H9NO2",charge:0,synonyms:["4-Aminobutanoic acid","4-Aminobutyrate","4-Aminobutyric acid","GABA","gamma-Aminobutyric acid"],identifiers:{"kegg.compound":["C00334"],chebi:["CHEBI:16865","CHEBI:30566","CHEBI:59888"],"metanetx.chemical":["MNXM192"],"bigg.metabolite":["4abut"],hmdb:["HMDB0000112"],"metacyc.compound":["4-AMINO-BUTYRATE"],"seed.compound":["cpd00281"]},identity:{status:"suggested",source:"ai",note:"KEGG C00334; MetaNetX MNXM192; BiGG 4abut",confidence:"high"},provenance:{source:"KEGG",id:"C00334",url:"https://www.kegg.jp/entry/C00334"}},{id:"tpl_ent_011",name:"Succinate semialdehyde",short:"Succinate semialdehyde",formula:"C4H5O3",charge:-1,synonyms:["4-Oxobutanoate","Succinic semialdehyde"],identifiers:{"kegg.compound":["C00232"],chebi:["CHEBI:16265","CHEBI:26805","CHEBI:57706"],"metanetx.chemical":["MNXM172"],"bigg.metabolite":["sucsal"],hmdb:["HMDB0001259"],"metacyc.compound":["SUCC-S-ALD"],"seed.compound":["cpd00199"]},identity:{status:"suggested",source:"ai",note:"KEGG C00232; MetaNetX MNXM172; BiGG sucsal",confidence:"high"},provenance:{source:"KEGG",id:"C00232",url:"https://www.kegg.jp/entry/C00232"}},{id:"tpl_ent_012",name:"Succinate",short:"Succinate",formula:"C4H4O4",charge:-2,synonyms:["Butanedionic acid","Ethylenesuccinic acid","Succ","Succinic acid","butanedioate","butanedioic acid","succinate","succinic acid"],identifiers:{"kegg.compound":["C00042"],chebi:["15741","26806","30031","CHEBI:15741","CHEBI:172952","CHEBI:30031","CHEBI:30779","CHEBI:90372"],"metanetx.chemical":["MNXM25"],"bigg.metabolite":["succ"],hmdb:["HMDB0000254"],"metacyc.compound":["SUC"],"seed.compound":["cpd00036"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00042; MetaNetX MNXM25; BiGG succ; GEMsMAP library 'succinate'"},library:"succinate",provenance:{source:"KEGG",id:"C00042",url:"https://www.kegg.jp/entry/C00042"}},{id:"tpl_ent_013",name:"(S)-1-Pyrroline-5-carboxylate",short:"P5C",formula:"C5H6NO2",charge:-1,synonyms:["1-Pyrroline-5-carboxylate","L-1-Pyrroline-5-carboxylate"],identifiers:{"kegg.compound":["C03912","C04322"],chebi:["CHEBI:1372","CHEBI:15893","CHEBI:17388","CHEBI:371"],"metanetx.chemical":["MNXM1105060"],"bigg.metabolite":["pyr5carb"],hmdb:["HMDB0001301","HMDB0002240"],"metacyc.compound":["CPD-478","L-DELTA1-PYRROLINE_5-CARBOXYLATE"],"seed.compound":["cpd02431","cpd02651"]},identity:{status:"suggested",source:"ai",note:"KEGG C03912; MetaNetX MNXM1105060; BiGG pyr5carb",confidence:"high"},provenance:{source:"KEGG",id:"C03912",url:"https://www.kegg.jp/entry/C03912"}},{id:"tpl_ent_014",name:"D-Aspartate",short:"D-Aspartate",formula:"C4H6NO4",charge:-1,synonyms:["D-Aspartic acid"],identifiers:{"kegg.compound":["C00402"],chebi:["CHEBI:17364","CHEBI:176632","CHEBI:177910","CHEBI:29990","CHEBI:29994"],"metanetx.chemical":["MNXM1364496"],hmdb:["HMDB0006483"],"metacyc.compound":["CPD-302"],"seed.compound":["cpd00320"],"bigg.metabolite":["asp__D"]},identity:{status:"suggested",source:"ai",note:"KEGG C00402; MetaNetX MNXM1364496; BiGG asp__D",confidence:"high"},provenance:{source:"KEGG",id:"C00402",url:"https://www.kegg.jp/entry/C00402"}},{id:"tpl_ent_015",name:"2-Oxosuccinamate",short:"2-Oxosuccinamate",formula:"C4H4NO4",charge:-1,synonyms:["2-Oxosuccinamic acid","Oxaloacetamide","gamma-Aminooxaloacetate"],identifiers:{"kegg.compound":["C02362"],chebi:["CHEBI:16327","CHEBI:57735"],"metanetx.chemical":["MNXM1091726"],"bigg.metabolite":["2oxosucc"],hmdb:["HMDB0060350"],"metacyc.compound":["2-OXOSUCCINAMATE"],"seed.compound":["cpd01577"]},identity:{status:"suggested",source:"ai",note:"KEGG C02362; MetaNetX MNXM1091726; BiGG 2oxosucc",confidence:"high"},provenance:{source:"KEGG",id:"C02362",url:"https://www.kegg.jp/entry/C02362"}},{id:"tpl_ent_016",name:"2-Oxoglutaramate",short:"2-Oxoglutaramate",formula:"C5H6NO4",charge:-1,synonyms:["2-Ketoglutaramate","2-Oxoglutaramic acid","alpha-Ketoglutaramate"],identifiers:{"kegg.compound":["C00940"],chebi:["CHEBI:16769","CHEBI:30882"],"metanetx.chemical":["MNXM1091725"],"bigg.metabolite":["2ogm"],hmdb:["HMDB0001552"],"metacyc.compound":["2-KETO-GLUTARAMATE"],"seed.compound":["cpd00695"]},identity:{status:"suggested",source:"ai",note:"KEGG C00940; MetaNetX MNXM1091725; BiGG 2ogm",confidence:"high"},provenance:{source:"KEGG",id:"C00940",url:"https://www.kegg.jp/entry/C00940"}},{id:"tpl_ent_017",name:"Carbamoyl phosphate",short:"Carbamoyl-P",formula:"CH2NO5P",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00169"],chebi:["CHEBI:17672","CHEBI:58228"],"metanetx.chemical":["MNXM138"],"bigg.metabolite":["cbp"],hmdb:["HMDB0001096"],"metacyc.compound":["CARBAMOYL-P"],"seed.compound":["cpd00146"]},identity:{status:"suggested",source:"ai",note:"KEGG C00169; MetaNetX MNXM138; BiGG cbp",confidence:"high"},provenance:{source:"KEGG",id:"C00169",url:"https://www.kegg.jp/entry/C00169"}},{id:"tpl_ent_018",name:"N-Carbamoyl-L-aspartate",short:"N-Carbamoyl-Asp",formula:"C5H6N2O5",charge:-2,synonyms:[],identifiers:{"kegg.compound":["C00438"],chebi:["CHEBI:15859","CHEBI:32814"],"metanetx.chemical":["MNXM465"],"bigg.metabolite":["cbasp"],hmdb:["HMDB0000828"],"metacyc.compound":["CARBAMYUL-L-ASPARTATE"],"seed.compound":["cpd00343"]},identity:{status:"suggested",source:"ai",note:"KEGG C00438; MetaNetX MNXM465; BiGG cbasp",confidence:"high"},provenance:{source:"KEGG",id:"C00438",url:"https://www.kegg.jp/entry/C00438"}},{id:"tpl_ent_019",name:"D-Glucosamine 6-phosphate",short:"Glucosamine-6P",formula:"C6H13NO8P",charge:-1,synonyms:["D-Glucosamine phosphate"],identifiers:{"kegg.compound":["C00352"],chebi:["CHEBI:15873","CHEBI:47987","CHEBI:58725","CHEBI:75989"],"metanetx.chemical":["MNXM1104065"],"bigg.metabolite":["gam6p"],hmdb:["HMDB0001254"],"metacyc.compound":["CPD-13469","D-GLUCOSAMINE-6-P"],"seed.compound":["cpd00288","cpd23898"]},identity:{status:"suggested",source:"ai",note:"KEGG C00352; MetaNetX MNXM1104065; BiGG gam6p (also linked by MetaNetX); several BiGG metabolites: gam6p, gam6p_any",confidence:"high"},provenance:{source:"KEGG",id:"C00352",url:"https://www.kegg.jp/entry/C00352"}},{id:"tpl_ent_020",name:"5-Phosphoribosylamine",short:"PRA",formula:"C5H11NO7P",charge:-1,synonyms:["5-Phospho-D-ribosylamine","5-Phospho-beta-D-ribosylamine","5-Phosphoribosyl-1-amine"],identifiers:{"kegg.compound":["C03090"],chebi:["CHEBI:37737","CHEBI:58681"],"metanetx.chemical":["MNXM1363982"],"bigg.metabolite":["pram"],hmdb:["HMDB0001128","HMDB0002347"],"metacyc.compound":["5-P-BETA-D-RIBOSYL-AMINE"],"seed.compound":["cpd01982"]},identity:{status:"suggested",source:"ai",note:"KEGG C03090; MetaNetX MNXM1363982; BiGG pram",confidence:"high"},provenance:{source:"KEGG",id:"C03090",url:"https://www.kegg.jp/entry/C03090"}},{id:"tpl_ent_021",name:"N-(L-Arginino)succinate",short:"Argininosuccinate",formula:"C10H18N4O6",charge:0,synonyms:["2-(Nomega-L-Arginino)succinate","L-Argininosuccinate","L-Argininosuccinic acid","L-Arginosuccinic acid"],identifiers:{"kegg.compound":["C03406"],chebi:["CHEBI:15682","CHEBI:184023","CHEBI:57472"],"metanetx.chemical":["MNXM722743"],"bigg.metabolite":["argsuc"],hmdb:["HMDB0000052","HMDB0001006"],"metacyc.compound":["L-ARGININO-SUCCINATE"],"seed.compound":["cpd02152","cpd29673"]},identity:{status:"suggested",source:"ai",note:"KEGG C03406; MetaNetX MNXM722743; BiGG argsuc",confidence:"high"},provenance:{source:"KEGG",id:"C03406",url:"https://www.kegg.jp/entry/C03406"}},{id:"tpl_ent_022",name:"L-Arginine",short:"Arginine",formula:"C6H15N4O2",charge:1,synonyms:["(S)-2-Amino-5-guanidinovaleric acid","L-Arg"],identifiers:{"kegg.compound":["C00062"],chebi:["CHEBI:16467","CHEBI:32681","CHEBI:32682","CHEBI:32683"],"metanetx.chemical":["MNXM739527"],"bigg.metabolite":["arg__L"],hmdb:["HMDB0000517","HMDB0062762"],"metacyc.compound":["ARG"],"seed.compound":["cpd00051"]},identity:{status:"suggested",source:"ai",note:"KEGG C00062; MetaNetX MNXM739527; BiGG arg__L",confidence:"high"},provenance:{source:"KEGG",id:"C00062",url:"https://www.kegg.jp/entry/C00062"}},{id:"tpl_ent_023",name:"N6-(1,2-Dicarboxyethyl)-AMP",short:"Adenylosuccinate",formula:"C14H18N5O11P",charge:0,synonyms:["Adenylosuccinate","Adenylosuccinic acid","N6-(1,2-Dicarboxyethyl)AMP"],identifiers:{"kegg.compound":["C03794"],chebi:["CHEBI:15919","CHEBI:57567"],"metanetx.chemical":["MNXM1103622"],"bigg.metabolite":["dcamp"],hmdb:["HMDB0000536","HMDB0001332","HMDB0011633","HMDB0059653"],"metacyc.compound":["ADENYLOSUCC"],"seed.compound":["cpd02375"]},identity:{status:"suggested",source:"ai",note:"KEGG C03794; MetaNetX MNXM1103622; BiGG dcamp",confidence:"high"},provenance:{source:"KEGG",id:"C03794",url:"https://www.kegg.jp/entry/C03794"}},{id:"tpl_ent_024",name:"N-Acetyl-L-aspartate",short:"N-Acetyl-Asp",formula:"C6H7NO5",charge:-2,synonyms:["N-Acetyl-L-aspartic acid"],identifiers:{"kegg.compound":["C01042"],chebi:["CHEBI:16953","CHEBI:176586","CHEBI:21547"],"metanetx.chemical":["MNXM2139"],"bigg.metabolite":["Nacasp"],hmdb:["HMDB0000812"],"metacyc.compound":["CPD-420"],"seed.compound":["cpd00767"]},identity:{status:"suggested",source:"ai",note:"KEGG C01042; MetaNetX MNXM2139; BiGG Nacasp",confidence:"high"},provenance:{source:"KEGG",id:"C01042",url:"https://www.kegg.jp/entry/C01042"}},{id:"tpl_ent_025",name:"N-Acetylaspartylglutamate",short:"NAAG",formula:"C11H13N2O8",charge:-3,synonyms:["Isospaglumic acid","N-Acetyl-L-aspartyl-L-glutamate","NAAG"],identifiers:{"kegg.compound":["C12270"],chebi:["CHEBI:191259","CHEBI:73688","CHEBI:76931"],"metanetx.chemical":["MNXM1371055"],hmdb:["HMDB0001067"],"metacyc.compound":["CPD-13266"],"seed.compound":["cpd09049"]},identity:{status:"suggested",source:"ai",note:"KEGG C12270; MetaNetX MNXM1371055",confidence:"high"},provenance:{source:"KEGG",id:"C12270",url:"https://www.kegg.jp/entry/C12270"}},{id:"tpl_ent_026",name:"N-Acetylaspartylglutamylglutamate",short:"NAAG₂",formula:"C16H19N3O11",charge:-4,synonyms:["N-Acetyl-L-aspartyl-L-glutamyl-L-glutamate","NAAG2"],identifiers:{"kegg.compound":["C20776"],chebi:["CHEBI:76935","CHEBI:77064"],"metanetx.chemical":["MNXM146183"],"metacyc.compound":["CPD-16471"],"seed.compound":["cpd31341"]},identity:{status:"suggested",source:"ai",note:"KEGG C20776; MetaNetX MNXM146183",confidence:"high"},provenance:{source:"KEGG",id:"C20776",url:"https://www.kegg.jp/entry/C20776"}},{id:"tpl_ent_027",name:"beta-Citryl-L-glutamate",short:"β-Citryl-Glu",formula:"C11H11NO10",charge:-4,synonyms:["beta-Citrylglutamate"],identifiers:{"kegg.compound":["C20775"],chebi:["CHEBI:76942","CHEBI:77065"],"metanetx.chemical":["MNXM736093"],hmdb:["HMDB0241915"],"metacyc.compound":["CPD-16470"],"seed.compound":["cpd31340"]},identity:{status:"suggested",source:"ai",note:"KEGG C20775; MetaNetX MNXM736093",confidence:"high"},provenance:{source:"KEGG",id:"C20775",url:"https://www.kegg.jp/entry/C20775"}},{id:"tpl_ent_028",name:"ATP",short:"ATP",formula:"C10H12N5O13P3",charge:-4,synonyms:["Adenosine 5'-triphosphate","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616","CHEBI:15422","CHEBI:237958","CHEBI:30616","CHEBI:57299"],"metanetx.chemical":["MNXM3"],"bigg.metabolite":["atp"],hmdb:["HMDB0000538"],"metacyc.compound":["ATP"],"seed.compound":["cpd00002"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00002; MetaNetX MNXM3; BiGG atp; GEMsMAP library 'ATP'"},library:"ATP",provenance:{source:"KEGG",id:"C00002",url:"https://www.kegg.jp/entry/C00002"}},{id:"tpl_ent_029",name:"ADP",short:"ADP",formula:"C10H12N5O10P2",charge:-3,synonyms:["Adenosine 5'-diphosphate","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216","CHEBI:16761","CHEBI:456216","CHEBI:87518"],"metanetx.chemical":["MNXM40333"],"bigg.metabolite":["adp"],hmdb:["HMDB0001341"],"metacyc.compound":["ADP","ADP-GROUP"],"seed.compound":["cpd00008","cpd22244"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00008; MetaNetX MNXM40333; BiGG adp; GEMsMAP library 'ADP'"},library:"ADP",provenance:{source:"KEGG",id:"C00008",url:"https://www.kegg.jp/entry/C00008"}},{id:"tpl_ent_030",name:"AMP",short:"AMP",formula:"C10H12N5O7P",charge:-2,synonyms:["5'-AMP","5'-Adenosine monophosphate","5'-Adenylic acid","Adenosine 5'-monophosphate","Adenosine 5'-phosphate","Adenylate","Adenylic acid"],identifiers:{"kegg.compound":["C00020"],chebi:["CHEBI:16027","CHEBI:40721","CHEBI:456215"],"metanetx.chemical":["MNXM728294"],"bigg.metabolite":["amp"],hmdb:["HMDB0000045"],"metacyc.compound":["AMP","AMP-GROUP"],"seed.compound":["cpd00018"]},identity:{status:"suggested",source:"ai",note:"KEGG C00020; MetaNetX MNXM728294; BiGG amp",confidence:"high"},provenance:{source:"KEGG",id:"C00020",url:"https://www.kegg.jp/entry/C00020"}},{id:"tpl_ent_031",name:"Diphosphate",short:"PPᵢ",formula:"HO7P2",charge:-3,synonyms:["Diphosphoric acid","PPi","Pyrophosphate","Pyrophosphoric acid"],identifiers:{"kegg.compound":["C00013"],chebi:["CHEBI:18361","CHEBI:29888","CHEBI:33017","CHEBI:33019","CHEBI:45212"],"metanetx.chemical":["MNXM11"],"bigg.metabolite":["ppi"],hmdb:["HMDB0000250","HMDB0304340"],"metacyc.compound":["PPI","PYROPHOSPHATE-GROUP"],"seed.compound":["cpd00012","cpd27828"]},identity:{status:"suggested",source:"ai",note:"KEGG C00013; MetaNetX MNXM11; BiGG ppi",confidence:"high"},provenance:{source:"KEGG",id:"C00013",url:"https://www.kegg.jp/entry/C00013"}},{id:"tpl_ent_032",name:"Orthophosphate",short:"Pᵢ",formula:"HO4P",charge:-2,synonyms:["Orthophosphoric acid","Phosphate","Phosphoric acid","Pi","inorganic phosphate","orthophosphate","phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078","CHEBI:18367","CHEBI:26020","CHEBI:26078","CHEBI:35780","CHEBI:39745","CHEBI:43474"],"metanetx.chemical":["MNXM9"],"bigg.metabolite":["pi"],hmdb:["HMDB0000973","HMDB0001429","HMDB0002105","HMDB0002142","HMDB0005947"],"seed.compound":["cpd00009","cpd27787"],"metacyc.compound":["Pi"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00009; MetaNetX MNXM9; BiGG pi; GEMsMAP library 'phosphate'"},library:"phosphate",provenance:{source:"KEGG",id:"C00009",url:"https://www.kegg.jp/entry/C00009"}},{id:"tpl_ent_033",name:"NAD+",short:"NAD⁺",formula:"C21H26N7O14P2",charge:-1,synonyms:["DPN","Diphosphopyridine nucleotide","NAD","Nadide","Nicotinamide adenine dinucleotide","beta-NAD+","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540","CHEBI:15846","CHEBI:44215","CHEBI:57540"],"metanetx.chemical":["MNXM8"],"bigg.metabolite":["nad"],hmdb:["HMDB0000902"],"metacyc.compound":["NAD"],"seed.compound":["cpd00003"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00003; MetaNetX MNXM8; BiGG nad; GEMsMAP library 'NAD+'"},library:"NAD+",provenance:{source:"KEGG",id:"C00003",url:"https://www.kegg.jp/entry/C00003"}},{id:"tpl_ent_034",name:"NADH",short:"NADH",formula:"C21H27N7O14P2",charge:-2,synonyms:["DPNH","Reduced nicotinamide adenine dinucleotide","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945","CHEBI:16908","CHEBI:57945"],"metanetx.chemical":["MNXM10"],"bigg.metabolite":["nadh"],hmdb:["HMDB0001487"],"metacyc.compound":["NADH"],"seed.compound":["cpd00004"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00004; MetaNetX MNXM10; BiGG nadh; GEMsMAP library 'NADH'"},library:"NADH",provenance:{source:"KEGG",id:"C00004",url:"https://www.kegg.jp/entry/C00004"}},{id:"tpl_ent_035",name:"NADP+",short:"NADP⁺",formula:"C21H25N7O17P3",charge:-3,synonyms:["NADP","Nicotinamide adenine dinucleotide phosphate","TPN","Triphosphopyridine nucleotide","beta-NADP+","beta-Nicotinamide adenine dinucleotide phosphate","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349","CHEBI:18009","CHEBI:25523","CHEBI:44409","CHEBI:58349"],"metanetx.chemical":["MNXM5"],"bigg.metabolite":["nadp"],hmdb:["HMDB0000217","HMDB0304435"],"metacyc.compound":["NADP"],"seed.compound":["cpd00006"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00006; MetaNetX MNXM5; BiGG nadp; GEMsMAP library 'NADP+'"},library:"NADP+",provenance:{source:"KEGG",id:"C00006",url:"https://www.kegg.jp/entry/C00006"}},{id:"tpl_ent_036",name:"NADPH",short:"NADPH",formula:"C21H26N7O17P3",charge:-4,synonyms:["Reduced nicotinamide adenine dinucleotide phosphate","TPNH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783","CHEBI:16474","CHEBI:57783"],"metanetx.chemical":["MNXM738702"],"bigg.metabolite":["nadph"],hmdb:["HMDB0000221","HMDB0000799","HMDB0006341"],"metacyc.compound":["NADPH"],"seed.compound":["cpd00005"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00005; MetaNetX MNXM738702; BiGG nadph; GEMsMAP library 'NADPH'"},library:"NADPH",provenance:{source:"KEGG",id:"C00005",url:"https://www.kegg.jp/entry/C00005"}},{id:"tpl_ent_037",name:"H2O",short:"H2O",formula:"H2O",charge:0,synonyms:["Water","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377","CHEBI:15377","CHEBI:29374","CHEBI:29375","CHEBI:33806","CHEBI:33811","CHEBI:33813","CHEBI:41981"],"metanetx.chemical":["WATER"],"bigg.metabolite":["h2o"],hmdb:["HMDB0002111"],"metacyc.compound":["WATER"],"seed.compound":["cpd00001"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00001; MetaNetX WATER; BiGG h2o; GEMsMAP library 'H2O'"},library:"H2O",provenance:{source:"KEGG",id:"C00001",url:"https://www.kegg.jp/entry/C00001"}},{id:"tpl_ent_038",name:"CO2",short:"CO₂",formula:"CO2",charge:0,synonyms:["Carbon dioxide","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526","CHEBI:139538","CHEBI:16526"],"metanetx.chemical":["MNXM13"],"bigg.metabolite":["co2"],hmdb:["HMDB0001967"],"metacyc.compound":["CARBON-DIOXIDE"],"seed.compound":["cpd00011"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00011; MetaNetX MNXM13; BiGG co2; GEMsMAP library 'CO2'"},library:"CO2",provenance:{source:"KEGG",id:"C00011",url:"https://www.kegg.jp/entry/C00011"}},{id:"tpl_ent_039",name:"Ammonia",short:"NH₃",formula:"H4N",charge:1,synonyms:["NH3"],identifiers:{"kegg.compound":["C00014","C01342"],chebi:["CHEBI:135980","CHEBI:16134","CHEBI:28938"],"metanetx.chemical":["MNXM729302"],"bigg.metabolite":["nh4"],hmdb:["HMDB0000051","HMDB0041827"],"metacyc.compound":["AMMONIA","AMMONIUM"],"seed.compound":["cpd00013","cpd19013"]},identity:{status:"suggested",source:"ai",note:"KEGG C00014; MetaNetX MNXM729302; BiGG nh4",confidence:"high"},provenance:{source:"KEGG",id:"C00014",url:"https://www.kegg.jp/entry/C00014"}},{id:"tpl_ent_040",name:"HCO3-",short:"HCO₃⁻",formula:"CHO3",charge:-1,synonyms:["Acid carbonate","Bicarbonate","Hydrogen carbonate","Hydrogencarbonate"],identifiers:{"kegg.compound":["C00288","C01353"],chebi:["CHEBI:140315","CHEBI:17544","CHEBI:28976","CHEBI:41609"],"metanetx.chemical":["MNXM1094693"],"bigg.metabolite":["h2co3"],hmdb:["HMDB0000595","HMDB0003538","HMDB0031453"],"seed.compound":["cpd00242"]},identity:{status:"suggested",source:"ai",note:"KEGG C00288; MetaNetX MNXM1094693; BiGG h2co3",confidence:"high"},provenance:{source:"KEGG",id:"C00288",url:"https://www.kegg.jp/entry/C00288"}},{id:"tpl_ent_041",name:"Coenzyme A",short:"CoA",formula:"C21H32N7O16P3S",charge:-4,synonyms:["CoA-SH","Coenzyme A","coenzyme A"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287","CHEBI:15346","CHEBI:57287"],"metanetx.chemical":["MNXM727276"],"bigg.metabolite":["coa"],hmdb:["HMDB0001423","HMDB0062184"],"metacyc.compound":["CO-A","COA-GROUP"],"seed.compound":["cpd00010"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00010; MetaNetX MNXM727276; BiGG coa; GEMsMAP library 'CoA'"},library:"CoA",provenance:{source:"KEGG",id:"C00010",url:"https://www.kegg.jp/entry/C00010"}},{id:"tpl_ent_042",name:"Acetyl-CoA",short:"Acetyl-CoA",formula:"C23H34N7O17P3S",charge:-4,synonyms:["AcCoA","Acetyl coenzyme A","acetyl coenzyme A","acetyl-CoA","acetyl-coenzyme A"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288","CHEBI:15351","CHEBI:57288"],"metanetx.chemical":["MNXM1104266"],"bigg.metabolite":["accoa"],hmdb:["HMDB0001206"],"metacyc.compound":["ACETYL-COA"],"seed.compound":["cpd00022"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00024; MetaNetX MNXM1104266; BiGG accoa; GEMsMAP library 'acetyl-CoA'"},library:"acetyl-CoA",provenance:{source:"KEGG",id:"C00024",url:"https://www.kegg.jp/entry/C00024"}},{id:"tpl_ent_043",name:"Acetate",short:"Acetate",formula:"C2H3O2",charge:-1,synonyms:["Acetic acid","Ethanoic acid"],identifiers:{"kegg.compound":["C00033"],chebi:["CHEBI:15366","CHEBI:193049","CHEBI:30089"],"metanetx.chemical":["MNXM26"],"bigg.metabolite":["ac"],hmdb:["HMDB0000042"],"metacyc.compound":["ACET","CPD-24335"],"seed.compound":["cpd00029"]},identity:{status:"suggested",source:"ai",note:"KEGG C00033; MetaNetX MNXM26; BiGG ac",confidence:"high"},provenance:{source:"KEGG",id:"C00033",url:"https://www.kegg.jp/entry/C00033"}},{id:"tpl_ent_044",name:"GTP",short:"GTP",formula:"C10H12N5O14P3",charge:-4,synonyms:["Guanosine 5'-triphosphate"],identifiers:{"kegg.compound":["C00044"],chebi:["CHEBI:15996","CHEBI:37565","CHEBI:57600"],"metanetx.chemical":["MNXM1103553"],"bigg.metabolite":["gtp"],hmdb:["HMDB0001273"],"metacyc.compound":["GTP"],"seed.compound":["cpd00038"]},identity:{status:"suggested",source:"ai",note:"KEGG C00044; MetaNetX MNXM1103553; BiGG gtp",confidence:"high"},provenance:{source:"KEGG",id:"C00044",url:"https://www.kegg.jp/entry/C00044"}},{id:"tpl_ent_045",name:"GDP",short:"GDP",formula:"C10H12N5O11P2",charge:-3,synonyms:["Guanosine 5'-diphosphate","Guanosine diphosphate"],identifiers:{"kegg.compound":["C00035"],chebi:["CHEBI:17552","CHEBI:58189","CHEBI:65180"],"metanetx.chemical":["MNXM1103285"],"bigg.metabolite":["gdp"],hmdb:["HMDB0001201"],"metacyc.compound":["GDP","GDP-GROUP"],"seed.compound":["cpd00031"]},identity:{status:"suggested",source:"ai",note:"KEGG C00035; MetaNetX MNXM1103285; BiGG gdp",confidence:"high"},provenance:{source:"KEGG",id:"C00035",url:"https://www.kegg.jp/entry/C00035"}},{id:"tpl_ent_046",name:"IMP",short:"IMP",formula:"C10H11N4O8P",charge:-2,synonyms:["5'-Inosinate","5'-Inosine monophosphate","5'-Inosinic acid","Inosine 5'-monophosphate","Inosine 5'-phosphate","Inosine monophosphate","Inosinic acid"],identifiers:{"kegg.compound":["C00130"],chebi:["CHEBI:17202","CHEBI:58053"],"metanetx.chemical":["MNXM1101868"],"bigg.metabolite":["imp"],hmdb:["HMDB0000175"],"metacyc.compound":["IMP"],"seed.compound":["cpd00114"]},identity:{status:"suggested",source:"ai",note:"KEGG C00130; MetaNetX MNXM1101868; BiGG imp",confidence:"high"},provenance:{source:"KEGG",id:"C00130",url:"https://www.kegg.jp/entry/C00130"}},{id:"tpl_ent_047",name:"L-Citrulline",short:"Citrulline",formula:"C6H13N3O3",charge:0,synonyms:["2-Amino-5-ureidovaleric acid","Citrulline"],identifiers:{"kegg.compound":["C00327"],chebi:["CHEBI:16349","CHEBI:192078","CHEBI:57743"],"metanetx.chemical":["MNXM732471"],"bigg.metabolite":["citr__L"],hmdb:["HMDB0000904"],"metacyc.compound":["L-CITRULLINE"],"seed.compound":["cpd00274"]},identity:{status:"suggested",source:"ai",note:"KEGG C00327; MetaNetX MNXM732471; BiGG citr__L",confidence:"high"},provenance:{source:"KEGG",id:"C00327",url:"https://www.kegg.jp/entry/C00327"}},{id:"tpl_ent_048",name:"Citrate",short:"Citrate",formula:"C6H5O7",charge:-3,synonyms:["2-Hydroxy-1,2,3-propanetricarboxylic acid","2-Hydroxytricarballylic acid","2-hydroxypropane-1,2,3-tricarboxylate","Cit","Citric acid","citrate","citric acid"],identifiers:{"kegg.compound":["C00158"],chebi:["16947","30769","CHEBI:132362","CHEBI:133748","CHEBI:16947","CHEBI:30769","CHEBI:35802","CHEBI:35804","CHEBI:35806","CHEBI:35808","CHEBI:35809","CHEBI:35810","CHEBI:76049"],"metanetx.chemical":["MNXM1107752"],"bigg.metabolite":["cit"],hmdb:["HMDB0000094"],"metacyc.compound":["CIT"],"seed.compound":["cpd00137"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00158; MetaNetX MNXM1107752; BiGG cit; GEMsMAP library 'citrate'"},library:"citrate",provenance:{source:"KEGG",id:"C00158",url:"https://www.kegg.jp/entry/C00158"}},{id:"tpl_ent_049",name:"D-Fructose 6-phosphate",short:"Fructose-6P",formula:"C6H11O9P",charge:-2,synonyms:["D-Fructose 6-phosphoric acid","D-fructose 6-phosphate","F6P","Neuberg ester","fructose 6-phosphate","fructose-6-phosphate"],identifiers:{"kegg.compound":["C00085","C05345"],chebi:["15946","61527","CHEBI:15946","CHEBI:16084","CHEBI:57634","CHEBI:61527","CHEBI:61553"],"metanetx.chemical":["MNXM1107898"],"bigg.metabolite":["f6p"],hmdb:["HMDB0000124","HMDB0003971","HMDB0257695"],"metacyc.compound":["CPD-18719","FRUCTOSE-6P"],"seed.compound":["cpd00072","cpd19035"]},identity:{status:"confirmed",source:"builtin",note:"KEGG C00085; MetaNetX MNXM1107898; BiGG f6p; GEMsMAP library 'D-fructose-6-phosphate'"},related:[{note:"ring form of D-fructose 6-phosphate",names:["beta-D-fructose 6-phosphate","beta-D-fructofuranose 6-phosphate"],identifiers:{"kegg.compound":["C05345"],chebi:["16084","57634"],"bigg.metabolite":["f6p_B"]}}],library:"D-fructose-6-phosphate",provenance:{source:"KEGG",id:"C00085",url:"https://www.kegg.jp/entry/C00085"}},{id:"tpl_ent_050",name:"5-Phospho-alpha-D-ribose 1-diphosphate",short:"PRPP",formula:"C5H8O14P3",charge:-5,synonyms:["5-Phosphoribosyl 1-pyrophosphate","5-Phosphoribosyl diphosphate","PRPP"],identifiers:{"kegg.compound":["C00119"],chebi:["CHEBI:17111","CHEBI:58017"],"metanetx.chemical":["MNXM1104453"],"bigg.metabolite":["prpp"],hmdb:["HMDB0000280"],"metacyc.compound":["PRPP"],"seed.compound":["cpd00103"]},identity:{status:"suggested",source:"ai",note:"KEGG C00119; MetaNetX MNXM1104453; BiGG prpp",confidence:"high"},provenance:{source:"KEGG",id:"C00119",url:"https://www.kegg.jp/entry/C00119"}},{id:"tpl_ent_051",name:"Oxygen",short:"O₂",formula:"O2",charge:0,synonyms:["O2"],identifiers:{"kegg.compound":["C00007"],chebi:["CHEBI:15379","CHEBI:25805","CHEBI:26689","CHEBI:29793"],"metanetx.chemical":["MNXM735438"],"bigg.metabolite":["o2"],hmdb:["HMDB0001377"],"metacyc.compound":["OXYGEN-MOLECULE"],"seed.compound":["cpd00007"]},identity:{status:"suggested",source:"ai",note:"KEGG C00007; MetaNetX MNXM735438; BiGG o2",confidence:"high"},provenance:{source:"KEGG",id:"C00007",url:"https://www.kegg.jp/entry/C00007"}},{id:"tpl_ent_052",name:"Hydrogen peroxide",short:"H₂O₂",formula:"H2O2",charge:0,synonyms:["H2O2","Oxydol"],identifiers:{"kegg.compound":["C00027"],chebi:["CHEBI:16240","CHEBI:29192"],"metanetx.chemical":["MNXM732620"],"bigg.metabolite":["h2o2"],hmdb:["HMDB0003125","HMDB0006491"],"metacyc.compound":["HYDROGEN-PEROXIDE"],"seed.compound":["cpd00025"]},identity:{status:"suggested",source:"ai",note:"KEGG C00027; MetaNetX MNXM732620; BiGG h2o2",confidence:"high"},provenance:{source:"KEGG",id:"C00027",url:"https://www.kegg.jp/entry/C00027"}},{id:"tpl_ent_053",name:"2-Oxo acid",short:"2-Oxo acid",formula:"C2HO3*",charge:0,synonyms:["2-Oxo carboxylate","2-Oxocarboxylate","2-Oxocarboxylic acid"],identifiers:{"kegg.compound":["C00161"],chebi:["CHEBI:30871","CHEBI:35910"],"metanetx.chemical":["MNXM730321"]},identity:{status:"suggested",source:"ai",note:"KEGG C00161; MetaNetX MNXM730321",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C00161",url:"https://www.kegg.jp/entry/C00161"}},{id:"tpl_ent_054",name:"L-Amino acid",short:"L-Amino acid",formula:"C2H4NO2*",charge:0,synonyms:["L-2-Amino acid"],identifiers:{"kegg.compound":["C00151"],chebi:["CHEBI:15705","CHEBI:59814","CHEBI:59869"],"metanetx.chemical":["MNXM381"],"metacyc.compound":["L-Amino-Acids"],"seed.compound":["cpd11623"]},identity:{status:"suggested",source:"ai",note:"KEGG C00151; MetaNetX MNXM381",confidence:"probable"},generic:!0,provenance:{source:"KEGG",id:"C00151",url:"https://www.kegg.jp/entry/C00151"}}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:null,level:"required"},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:null,level:"required"},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:null,level:"required"},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:null,level:"required"},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:null,level:"required"},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:null,level:"required"},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:null,level:"required"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:null,level:"required"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:null,level:"recommended"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:null,level:"recommended"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:null,level:"recommended"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:null,level:"recommended"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:null,level:"optional"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:null,level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:null,level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:null,level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:null,level:"recommended"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:null,level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:null,level:"optional"},{id:"tpl_met_020",entity:"tpl_ent_020",compartment:null,level:"optional"},{id:"tpl_met_021",entity:"tpl_ent_021",compartment:null,level:"optional"},{id:"tpl_met_022",entity:"tpl_ent_022",compartment:null,level:"optional"},{id:"tpl_met_023",entity:"tpl_ent_023",compartment:null,level:"optional"},{id:"tpl_met_024",entity:"tpl_ent_024",compartment:null,level:"optional"},{id:"tpl_met_025",entity:"tpl_ent_025",compartment:null,level:"optional"},{id:"tpl_met_026",entity:"tpl_ent_026",compartment:null,level:"optional"},{id:"tpl_met_027",entity:"tpl_ent_027",compartment:null,level:"optional"},{id:"tpl_met_028",entity:"tpl_ent_028",compartment:null,level:"optional"},{id:"tpl_met_029",entity:"tpl_ent_029",compartment:null,level:"optional"},{id:"tpl_met_030",entity:"tpl_ent_030",compartment:null,level:"optional"},{id:"tpl_met_031",entity:"tpl_ent_031",compartment:null,level:"optional"},{id:"tpl_met_032",entity:"tpl_ent_032",compartment:null,level:"optional"},{id:"tpl_met_033",entity:"tpl_ent_033",compartment:null,level:"optional"},{id:"tpl_met_034",entity:"tpl_ent_034",compartment:null,level:"optional"},{id:"tpl_met_035",entity:"tpl_ent_035",compartment:null,level:"optional"},{id:"tpl_met_036",entity:"tpl_ent_036",compartment:null,level:"optional"},{id:"tpl_met_037",entity:"tpl_ent_037",compartment:null,level:"optional"},{id:"tpl_met_038",entity:"tpl_ent_038",compartment:null,level:"optional"},{id:"tpl_met_039",entity:"tpl_ent_039",compartment:null,level:"optional"},{id:"tpl_met_040",entity:"tpl_ent_040",compartment:null,level:"optional"},{id:"tpl_met_041",entity:"tpl_ent_041",compartment:null,level:"optional"},{id:"tpl_met_042",entity:"tpl_ent_042",compartment:null,level:"optional"},{id:"tpl_met_043",entity:"tpl_ent_043",compartment:null,level:"optional"},{id:"tpl_met_044",entity:"tpl_ent_044",compartment:null,level:"optional"},{id:"tpl_met_045",entity:"tpl_ent_045",compartment:null,level:"optional"},{id:"tpl_met_046",entity:"tpl_ent_046",compartment:null,level:"optional"},{id:"tpl_met_047",entity:"tpl_ent_047",compartment:null,level:"optional"},{id:"tpl_met_048",entity:"tpl_ent_048",compartment:null,level:"optional"},{id:"tpl_met_049",entity:"tpl_ent_049",compartment:null,level:"optional"},{id:"tpl_met_050",entity:"tpl_ent_050",compartment:null,level:"optional"},{id:"tpl_met_051",entity:"tpl_ent_051",compartment:null,level:"optional"},{id:"tpl_met_052",entity:"tpl_ent_052",compartment:null,level:"optional"},{id:"tpl_met_053",entity:"tpl_ent_053",compartment:null,level:"optional"},{id:"tpl_met_054",entity:"tpl_ent_054",compartment:null,level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"GDH",canonicalName:"glutamate dehydrogenase (NADP)",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_039",coefficient:-1,main:!1},{metabolite:"tpl_met_036",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1},{metabolite:"tpl_met_037",coefficient:1,main:!1}],reversible:!0,ec:["1.4.1.3","1.4.1.4","1.4.1.13"],identifiers:{"kegg.reaction":["R00248"],"metanetx.reaction":["MNXR100086"],"seed.reaction":["rxn00184","rxn27887","rxn30023","rxn33943","rxn34794"],"metacyc.reaction":["GLUTDEHYD-RXN","RXN-20084"],rhea:["11612","11613","11614","11615"],"bigg.reaction":["GLUDy_1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00248; MetaNetX MNXR100086"},variants:[{name:"NAD-dependent GDH (catabolic)",ec:["1.4.1.2","1.4.1.3","1.4.1.14"],identifiers:{"kegg.reaction":["R00243"]},equation:"L-Glutamate + NAD+ + H2O <=> 2-Oxoglutarate + Ammonia + NADH + H+"}],provenance:[{source:"KEGG",id:"R00248",url:"https://www.kegg.jp/entry/R00248"}]},{id:"tpl_rxn_002",name:"GS",canonicalName:"glutamine synthetase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_039",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.3.1.2"],identifiers:{"kegg.reaction":["R00253"],"metanetx.reaction":["MNXR100024"],"seed.reaction":["rxn00187","rxn19835","rxn19836","rxn30022","rxn33952","rxn33953","rxn34791","rxn34792"],"metacyc.reaction":["GLUTAMINESYN-RXN"],rhea:["16169","16170","16171","16172"],"bigg.reaction":["GLNS"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00253; MetaNetX MNXR100024"},provenance:[{source:"KEGG",id:"R00253",url:"https://www.kegg.jp/entry/R00253"}]},{id:"tpl_rxn_003",name:"GOGAT",canonicalName:"glutamate synthase (NADPH)",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_001",coefficient:-1,main:!1},{metabolite:"tpl_met_036",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:2,main:!0},{metabolite:"tpl_met_035",coefficient:1,main:!1}],reversible:!1,ec:["1.4.1.13"],identifiers:{"kegg.reaction":["R00114"],"metanetx.reaction":["MNXR100291"],"seed.reaction":["rxn00085","rxn27889","rxn33967"],"metacyc.reaction":["GLUTAMATESYN-RXN"],rhea:["15501","15502","15503","15504"],"bigg.reaction":["GLUSy"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00114; MetaNetX MNXR100291; Gln + 2-oxoglutarate → 2 Glu: 2-oxoglutarate drawn beside the arrow"},variants:[{name:"NADH-dependent GOGAT",ec:["1.4.1.14"],identifiers:{"kegg.reaction":["R00093"]},equation:"2 L-Glutamate + NAD+ <=> L-Glutamine + 2-Oxoglutarate + NADH + H+"}],provenance:[{source:"KEGG",id:"R00114",url:"https://www.kegg.jp/entry/R00114"}]},{id:"tpl_rxn_004",name:"GLS",canonicalName:"glutaminase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["1.4.1.13","1.4.1.14","1.4.7.1","2.6.1.85","2.6.1.123","3.5.1.2","3.5.1.38","4.3.2.10","4.3.3.6","6.3.4.2","6.3.5.2","6.3.5.4","6.3.5.5","6.3.5.13"],identifiers:{"kegg.reaction":["R00256"],"metanetx.reaction":["MNXR100030"],"seed.reaction":["rxn00189","rxn19831","rxn29962","rxn30024","rxn30680","rxn34787"],"metacyc.reaction":["GLUTAMIN-RXN","RXN-22710"],rhea:["15889","15890","15891","15892"],"bigg.reaction":["GLUN_1"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00256; MetaNetX MNXR100030"},provenance:[{source:"KEGG",id:"R00256",url:"https://www.kegg.jp/entry/R00256"}]},{id:"tpl_rxn_005",name:"AST",canonicalName:"aspartate aminotransferase",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_002",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_001",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.1"],identifiers:{"kegg.reaction":["R00355"],"metanetx.reaction":["MNXR192556"],"seed.reaction":["rxn00260","rxn27719","rxn27720","rxn30355"],"metacyc.reaction":["ASPAMINOTRANS-RXN","RXN-13697"],rhea:["21824","21825","21826","21827"],"bigg.reaction":["ASPTA"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00355; MetaNetX MNXR192556"},variants:[{name:"L-aspartate oxidase (Asp + O₂ → OAA + NH₃ + H₂O₂; NAD biosynthesis)",ec:["1.4.3.2","1.4.3.16"],identifiers:{"kegg.reaction":["R00357"]},equation:"L-Aspartate + H2O + Oxygen <=> Oxaloacetate + Ammonia + Hydrogen peroxide"}],provenance:[{source:"KEGG",id:"R00355",url:"https://www.kegg.jp/entry/R00355"}]},{id:"tpl_rxn_006",name:"AspA",canonicalName:"aspartate ammonia-lyase (aspartase)",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["4.3.1.1"],identifiers:{"kegg.reaction":["R00490"],"metanetx.reaction":["MNXR96099"],"seed.reaction":["rxn00347","rxn29994"],"metacyc.reaction":["ASPARTASE-RXN"],rhea:["16601","16602","16603","16604"],"bigg.reaction":["ASPT"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00490; MetaNetX MNXR96099"},provenance:[{source:"KEGG",id:"R00490",url:"https://www.kegg.jp/entry/R00490"}]},{id:"tpl_rxn_007",name:"ASNS",canonicalName:"asparagine synthetase (glutamine-hydrolysing)",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:-1,main:!1},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_006",coefficient:1,main:!0},{metabolite:"tpl_met_030",coefficient:1,main:!1},{metabolite:"tpl_met_031",coefficient:1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!0,ec:["6.3.5.4"],identifiers:{"kegg.reaction":["R00578"],"metanetx.reaction":["MNXR153021"],"seed.reaction":["rxn00416","rxn32227","rxn38046"],"metacyc.reaction":["ASNSYNB-RXN"],rhea:["12228","12229","12230","12231"],"bigg.reaction":["ASNS1"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00578; MetaNetX MNXR153021"},variants:[{name:"ammonia-dependent asparagine synthetase (AsnA)",ec:["6.3.1.1","6.3.5.4"],identifiers:{"kegg.reaction":["R00483"]},equation:"ATP + L-Aspartate + Ammonia <=> AMP + Diphosphate + L-Asparagine"}],provenance:[{source:"KEGG",id:"R00578",url:"https://www.kegg.jp/entry/R00578"}]},{id:"tpl_rxn_008",name:"ASNase",canonicalName:"asparaginase",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["3.5.1.1","3.5.1.38","3.5.5.4"],identifiers:{"kegg.reaction":["R00485"],"metanetx.reaction":["MNXR192440"],"seed.reaction":["rxn00342","rxn19208","rxn29950","rxn29992","rxn30353","rxn30618","rxn34558"],"metacyc.reaction":["ASPARAGHYD-RXN"],rhea:["21016","21017","21018","21019"],"bigg.reaction":["ASNN"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00485; MetaNetX MNXR192440"},provenance:[{source:"KEGG",id:"R00485",url:"https://www.kegg.jp/entry/R00485"}]},{id:"tpl_rxn_009",name:"ASNT",canonicalName:"asparagine transaminase",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_053",coefficient:-1,main:!1},{metabolite:"tpl_met_015",coefficient:1,main:!0},{metabolite:"tpl_met_054",coefficient:1,main:!1}],reversible:!1,ec:["2.6.1.14"],identifiers:{"kegg.reaction":["R01346"],"metanetx.reaction":["MNXR147259"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"probable",note:"KEGG R01346; MetaNetX MNXR147259"},provenance:[{source:"KEGG",id:"R01346",url:"https://www.kegg.jp/entry/R01346"}]},{id:"tpl_rxn_010",name:"NIT2",canonicalName:"ω-amidase (2-oxosuccinamate)",participants:[{metabolite:"tpl_met_015",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["3.5.1.3"],identifiers:{"kegg.reaction":["R00348"],"metanetx.reaction":["MNXR106485"],"seed.reaction":["rxn00254","rxn20013","rxn24177"],"metacyc.reaction":["RXN-6562"],rhea:["59412","59413","59414","59415"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00348; MetaNetX MNXR106485"},provenance:[{source:"KEGG",id:"R00348",url:"https://www.kegg.jp/entry/R00348"}]},{id:"tpl_rxn_011",name:"RacD",canonicalName:"aspartate racemase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!0}],reversible:!1,ec:["5.1.1.13"],identifiers:{"kegg.reaction":["R00491"],"metanetx.reaction":["MNXR198897"],"seed.reaction":["rxn00348"],"metacyc.reaction":["ASPARTATE-RACEMASE-RXN"],rhea:["14973","14974","14975","14976"],"bigg.reaction":["ASPR"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00491; MetaNetX MNXR198897"},provenance:[{source:"KEGG",id:"R00491",url:"https://www.kegg.jp/entry/R00491"}]},{id:"tpl_rxn_012",name:"DDO",canonicalName:"D-aspartate oxidase",participants:[{metabolite:"tpl_met_014",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_051",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1},{metabolite:"tpl_met_052",coefficient:1,main:!1}],reversible:!1,ec:["1.4.3.1","1.4.3.15"],identifiers:{"kegg.reaction":["R00359"],"metanetx.reaction":["MNXR198918"],"seed.reaction":["rxn00263","rxn19368","rxn47884"],"metacyc.reaction":["D-ASPARTATE-OXIDASE-RXN"],rhea:["12512","12513","12514","12515"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00359; MetaNetX MNXR198918; BiGG reactions only in other compartments: DASPO1p"},provenance:[{source:"KEGG",id:"R00359",url:"https://www.kegg.jp/entry/R00359"}]},{id:"tpl_rxn_013",name:"AsdA",canonicalName:"aspartate 4-decarboxylase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1}],reversible:!1,ec:["4.1.1.12"],identifiers:{"kegg.reaction":["R00397"],"metanetx.reaction":["MNXR96078"],"seed.reaction":["rxn00279"],"metacyc.reaction":["ASPARTATE-4-DECARBOXYLASE-RXN"],rhea:["12621","12622","12623","12624"],"bigg.reaction":["ASP4DC"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00397; MetaNetX MNXR96078"},provenance:[{source:"KEGG",id:"R00397",url:"https://www.kegg.jp/entry/R00397"}]},{id:"tpl_rxn_014",name:"ALT",canonicalName:"alanine aminotransferase",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_002",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0},{metabolite:"tpl_met_001",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.2"],identifiers:{"kegg.reaction":["R00258"],"metanetx.reaction":["MNXR95698"],"seed.reaction":["rxn00191","rxn27697","rxn27698","rxn31211","rxn38028","rxn38029"],"metacyc.reaction":["ALANINE-AMINOTRANSFERASE-RXN","RXN-13698"],rhea:["19453","19454","19455","19456"],"bigg.reaction":["ALATA_L"]},level:"required",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00258; MetaNetX MNXR95698"},variants:[{name:"alanine dehydrogenase (NADH, NH₃)",ec:["1.4.1.1"],identifiers:{"kegg.reaction":["R00396"]},equation:"L-Alanine + NAD+ + H2O <=> Pyruvate + Ammonia + NADH + H+"},{name:"alanine–oxaloacetate aminotransferase (Asp as amino donor)",ec:["2.6.1.12"],identifiers:{"kegg.reaction":["R00400"]},equation:"L-Alanine + Oxaloacetate <=> Pyruvate + L-Aspartate"},{name:"alanine–glyoxylate aminotransferase (Ala → Pyr, glyoxylate → Gly)",ec:["2.6.1.44","2.6.1.-"],identifiers:{"kegg.reaction":["R00369"]},equation:"L-Alanine + Glyoxylate <=> Pyruvate + Glycine"}],provenance:[{source:"KEGG",id:"R00258",url:"https://www.kegg.jp/entry/R00258"}]},{id:"tpl_rxn_015",name:"GTK",canonicalName:"glutamine–pyruvate transaminase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_007",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!1}],reversible:!1,ec:["2.6.1.15"],identifiers:{"kegg.reaction":["R00576"],"metanetx.reaction":["MNXR105309"],"seed.reaction":["rxn00415"],"metacyc.reaction":["GLUTAMINE--PYRUVATE-AMINOTRANSFERASE-RXN"],rhea:["10400","10401","10402","10403"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00576; MetaNetX MNXR105309"},provenance:[{source:"KEGG",id:"R00576",url:"https://www.kegg.jp/entry/R00576"}]},{id:"tpl_rxn_016",name:"NIT2",canonicalName:"ω-amidase (2-oxoglutaramate)",participants:[{metabolite:"tpl_met_016",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_001",coefficient:1,main:!0},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["3.5.1.3","3.5.1.111"],identifiers:{"kegg.reaction":["R00269"],"metanetx.reaction":["MNXR105306"],"seed.reaction":["rxn00200","rxn23361","rxn31885"],"metacyc.reaction":["RXN-13072"],rhea:["32963","32964","32965","32966"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00269; MetaNetX MNXR105306"},provenance:[{source:"KEGG",id:"R00269",url:"https://www.kegg.jp/entry/R00269"}]},{id:"tpl_rxn_017",name:"P5CDH",canonicalName:"1-pyrroline-5-carboxylate dehydrogenase",participants:[{metabolite:"tpl_met_013",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_037",coefficient:-2,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1}],reversible:!0,ec:["1.2.1.88"],identifiers:{"kegg.reaction":["R00707"],"metanetx.reaction":["MNXR102301"],"seed.reaction":["rxn00503","rxn20649","rxn32901"],rhea:["16417","16418","16419","16420"],"bigg.reaction":["P5CD"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00707; MetaNetX MNXR102301"},variants:[{name:"NADP-dependent P5CDH",ec:["1.2.1.88"],identifiers:{"kegg.reaction":["R00708"]},equation:"(S)-1-Pyrroline-5-carboxylate + NADP+ + 2 H2O <=> L-Glutamate + NADPH + H+"}],provenance:[{source:"KEGG",id:"R00707",url:"https://www.kegg.jp/entry/R00707"}]},{id:"tpl_rxn_018",name:"GAD",canonicalName:"glutamate decarboxylase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1}],reversible:!1,ec:["4.1.1.15"],identifiers:{"kegg.reaction":["R00261"],"metanetx.reaction":["MNXR95942"],"seed.reaction":["rxn00194","rxn34786"],"metacyc.reaction":["GLUTDECARBOX-RXN"],rhea:["17785","17786","17787","17788"],"bigg.reaction":["GLUDC"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00261; MetaNetX MNXR95942"},provenance:[{source:"KEGG",id:"R00261",url:"https://www.kegg.jp/entry/R00261"}]},{id:"tpl_rxn_019",name:"GABA-T",canonicalName:"4-aminobutyrate aminotransferase",participants:[{metabolite:"tpl_met_010",coefficient:-1,main:!0},{metabolite:"tpl_met_001",coefficient:-1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!0,ec:["2.6.1.19"],identifiers:{"kegg.reaction":["R01648"],"metanetx.reaction":["MNXR95186"],"seed.reaction":["rxn01204","rxn19742","rxn27867"],"metacyc.reaction":["GABATRANSAM-RXN"],rhea:["23352","23353","23354","23355"],"bigg.reaction":["ABTA"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01648; MetaNetX MNXR95186"},variants:[{name:"GABA–pyruvate transaminase (Pyr → Ala)",ec:["2.6.1.96"],identifiers:{"kegg.reaction":["R10178"]},equation:"4-Aminobutanoate + Pyruvate <=> Succinate semialdehyde + L-Alanine"}],provenance:[{source:"KEGG",id:"R01648",url:"https://www.kegg.jp/entry/R01648"}]},{id:"tpl_rxn_020",name:"SSADH",canonicalName:"succinate-semialdehyde dehydrogenase",participants:[{metabolite:"tpl_met_011",coefficient:-1,main:!0},{metabolite:"tpl_met_033",coefficient:-1,main:!1},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:1,main:!0},{metabolite:"tpl_met_034",coefficient:1,main:!1}],reversible:!1,ec:["1.2.1.16","1.2.1.24"],identifiers:{"kegg.reaction":["R00713"],"metanetx.reaction":["MNXR104540"],"seed.reaction":["rxn00508","rxn27251","rxn31894"],"metacyc.reaction":["SUCCINATE-SEMIALDEHYDE-DEHYDROGENASE-RXN"],rhea:["13217","13218","13219","13220"],"bigg.reaction":["SSALx"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00713; MetaNetX MNXR104540"},variants:[{name:"NADP-dependent SSADH",ec:["1.2.1.16","1.2.1.79"],identifiers:{"kegg.reaction":["R00714"]},equation:"Succinate semialdehyde + NADP+ + H2O <=> Succinate + NADPH + H+"}],provenance:[{source:"KEGG",id:"R00713",url:"https://www.kegg.jp/entry/R00713"}]},{id:"tpl_rxn_021",name:"CPS",canonicalName:"carbamoyl-phosphate synthase (glutamine-hydrolysing)",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-2,main:!1},{metabolite:"tpl_met_040",coefficient:-1,main:!1},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_017",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:2,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!1,ec:["6.3.5.5"],identifiers:{"kegg.reaction":["R00575"],"metanetx.reaction":["MNXR96485"],"seed.reaction":["rxn00414","rxn27743","rxn30627","rxn31216","rxn38060"],"metacyc.reaction":["CARBPSYN-RXN"],rhea:["18633","18634","18635","18636"],"bigg.reaction":["CBPS"]},level:"recommended",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00575; MetaNetX MNXR96485"},variants:[{name:"ammonia-dependent CPS (CPS I, urea cycle)",ec:["6.3.4.16"],identifiers:{"kegg.reaction":["R00149"]},equation:"2 ATP + Ammonia + CO2 + H2O <=> 2 ADP + Orthophosphate + Carbamoyl phosphate"}],provenance:[{source:"KEGG",id:"R00575",url:"https://www.kegg.jp/entry/R00575"}]},{id:"tpl_rxn_022",name:"GFAT",canonicalName:"glutamine–fructose-6-phosphate transaminase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_049",coefficient:-1,main:!1},{metabolite:"tpl_met_019",coefficient:1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!1,ec:["2.6.1.16"],identifiers:{"kegg.reaction":["R00768"],"metanetx.reaction":["MNXR144996"],"seed.reaction":["rxn00555","rxn15064","rxn32367","rxn32369","rxn32371"],"metacyc.reaction":["L-GLN-FRUCT-6-P-AMINOTRANS-RXN"],rhea:["13237","13238","13239","13240"],"bigg.reaction":["GF6PTA"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00768; MetaNetX MNXR144996"},provenance:[{source:"KEGG",id:"R00768",url:"https://www.kegg.jp/entry/R00768"}]},{id:"tpl_rxn_023",name:"PPAT",canonicalName:"amidophosphoribosyltransferase",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_050",coefficient:-1,main:!1},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_020",coefficient:1,main:!0},{metabolite:"tpl_met_031",coefficient:1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!1,ec:["2.4.2.14"],identifiers:{"kegg.reaction":["R01072"],"metanetx.reaction":["MNXR188137"],"seed.reaction":["rxn00790","rxn28100","rxn34051"],"metacyc.reaction":["PRPPAMIDOTRANS-RXN"],rhea:["14905","14906","14907","14908"],"bigg.reaction":["GLUPRT"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01072; MetaNetX MNXR188137"},provenance:[{source:"KEGG",id:"R01072",url:"https://www.kegg.jp/entry/R01072"}]},{id:"tpl_rxn_024",name:"ATCase",canonicalName:"aspartate carbamoyltransferase",participants:[{metabolite:"tpl_met_017",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:-1,main:!1},{metabolite:"tpl_met_018",coefficient:1,main:!0},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["2.1.3.2"],identifiers:{"kegg.reaction":["R01397"],"metanetx.reaction":["MNXR192558"],"seed.reaction":["rxn01018","rxn27725","rxn35448"],"metacyc.reaction":["ASPCARBTRANS-RXN"],rhea:["20013","20014","20015","20016"],"bigg.reaction":["ASPCT_1"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01397; MetaNetX MNXR192558; carbamoyl-P → N-carbamoyl-Asp drawn; aspartate written beside the arrow"},provenance:[{source:"KEGG",id:"R01397",url:"https://www.kegg.jp/entry/R01397"}]},{id:"tpl_rxn_025",name:"URAH",canonicalName:"β-ureidopropionase (N-carbamoyl-aspartate)",participants:[{metabolite:"tpl_met_018",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_038",coefficient:1,main:!1},{metabolite:"tpl_met_039",coefficient:1,main:!1}],reversible:!1,ec:["3.5.1.7"],identifiers:{"kegg.reaction":["R00484"],"metanetx.reaction":["MNXR106552"],"seed.reaction":["rxn00341","rxn43279"],"metacyc.reaction":["UREIDOSUCCINASE-RXN"],rhea:["14365","14366","14367","14368"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00484; MetaNetX MNXR106552"},provenance:[{source:"KEGG",id:"R00484",url:"https://www.kegg.jp/entry/R00484"}]},{id:"tpl_rxn_026",name:"ASS",canonicalName:"argininosuccinate synthase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_047",coefficient:-1,main:!1},{metabolite:"tpl_met_021",coefficient:1,main:!0},{metabolite:"tpl_met_030",coefficient:1,main:!1},{metabolite:"tpl_met_031",coefficient:1,main:!1}],reversible:!1,ec:["6.3.4.5"],identifiers:{"kegg.reaction":["R01954"],"metanetx.reaction":["MNXR138060"],"seed.reaction":["rxn01434","rxn27717","rxn29991"],"metacyc.reaction":["ARGSUCCINSYN-RXN"],rhea:["10932","10933","10934","10935"],"bigg.reaction":["ARGSS"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01954; MetaNetX MNXR138060"},provenance:[{source:"KEGG",id:"R01954",url:"https://www.kegg.jp/entry/R01954"}]},{id:"tpl_rxn_027",name:"ASL",canonicalName:"argininosuccinate lyase",participants:[{metabolite:"tpl_met_021",coefficient:-1,main:!0},{metabolite:"tpl_met_022",coefficient:1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0}],reversible:!1,ec:["4.3.2.1"],identifiers:{"kegg.reaction":["R01086"],"metanetx.reaction":["MNXR138059"],"seed.reaction":["rxn00802","rxn27716","rxn29990"],"metacyc.reaction":["ARGSUCCINLYA-RXN"],rhea:["24020","24021","24022","24023"],"bigg.reaction":["ARGSL"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01086; MetaNetX MNXR138059"},provenance:[{source:"KEGG",id:"R01086",url:"https://www.kegg.jp/entry/R01086"}]},{id:"tpl_rxn_028",name:"ADSS",canonicalName:"adenylosuccinate synthase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_044",coefficient:-1,main:!1},{metabolite:"tpl_met_046",coefficient:-1,main:!1},{metabolite:"tpl_met_023",coefficient:1,main:!0},{metabolite:"tpl_met_045",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.3.4.4"],identifiers:{"kegg.reaction":["R01135"],"metanetx.reaction":["MNXR192666"],"seed.reaction":["rxn00838","rxn27686"],"metacyc.reaction":["ADENYLOSUCCINATE-SYNTHASE-RXN"],rhea:["15753","15754","15755","15756"],"bigg.reaction":["ADSS"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01135; MetaNetX MNXR192666"},provenance:[{source:"KEGG",id:"R01135",url:"https://www.kegg.jp/entry/R01135"}]},{id:"tpl_rxn_029",name:"ADSL",canonicalName:"adenylosuccinate lyase",participants:[{metabolite:"tpl_met_023",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:1,main:!0},{metabolite:"tpl_met_030",coefficient:1,main:!1}],reversible:!1,ec:["4.3.2.2"],identifiers:{"kegg.reaction":["R01083"],"metanetx.reaction":["MNXR190613"],"seed.reaction":["rxn00800","rxn27708"],"metacyc.reaction":["AMPSYN-RXN"],rhea:["16853","16854","16855","16856"],"bigg.reaction":["ADSL1r"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R01083; MetaNetX MNXR190613"},provenance:[{source:"KEGG",id:"R01083",url:"https://www.kegg.jp/entry/R01083"}]},{id:"tpl_rxn_030",name:"NAT8L",canonicalName:"aspartate N-acetyltransferase",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_042",coefficient:-1,main:!1},{metabolite:"tpl_met_024",coefficient:1,main:!0},{metabolite:"tpl_met_041",coefficient:1,main:!1}],reversible:!1,ec:["2.3.1.17"],identifiers:{"kegg.reaction":["R00487"],"metanetx.reaction":["MNXR189094"],"seed.reaction":["rxn00344"],"metacyc.reaction":["ASPARTATE-N-ACETYLTRANSFERASE-RXN"],rhea:["14165","14166","14167","14168"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00487; MetaNetX MNXR189094; BiGG reactions only in other compartments: ASPNATm"},provenance:[{source:"KEGG",id:"R00487",url:"https://www.kegg.jp/entry/R00487"}]},{id:"tpl_rxn_031",name:"ASPA",canonicalName:"aspartoacylase",participants:[{metabolite:"tpl_met_024",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_043",coefficient:1,main:!1}],reversible:!1,ec:["3.5.1.15"],identifiers:{"kegg.reaction":["R00488"],"metanetx.reaction":["MNXR106555"],"seed.reaction":["rxn00345"],"metacyc.reaction":["RXN-13680"],rhea:["59408","59409","59410","59411"],"bigg.reaction":["NACASPAH"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R00488; MetaNetX MNXR106555"},provenance:[{source:"KEGG",id:"R00488",url:"https://www.kegg.jp/entry/R00488"}]},{id:"tpl_rxn_032",name:"RIMKLA",canonicalName:"N-acetylaspartylglutamate synthase",participants:[{metabolite:"tpl_met_024",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:-1,main:!1},{metabolite:"tpl_met_025",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.3.2.41","6.3.2.42"],identifiers:{"kegg.reaction":["R10678"],"metanetx.reaction":["MNXR113998"],"seed.reaction":["rxn40420"],"metacyc.reaction":["RXN-15265"],rhea:["40035","40036","40037","40038"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10678; MetaNetX MNXR113998"},provenance:[{source:"KEGG",id:"R10678",url:"https://www.kegg.jp/entry/R10678"}]},{id:"tpl_rxn_033",name:"GCPII",canonicalName:"glutamate carboxypeptidase II (NAAG)",participants:[{metabolite:"tpl_met_025",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_024",coefficient:1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!1,ec:["3.4.17.21"],identifiers:{"kegg.reaction":["R10687"],"metanetx.reaction":["MNXR114007"],"seed.reaction":["rxn40429"],rhea:["68356","68357","68358","68359"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10687; MetaNetX MNXR114007"},provenance:[{source:"KEGG",id:"R10687",url:"https://www.kegg.jp/entry/R10687"}]},{id:"tpl_rxn_034",name:"RIMKLB",canonicalName:"N-acetylaspartylglutamylglutamate synthase",participants:[{metabolite:"tpl_met_025",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:-1,main:!1},{metabolite:"tpl_met_026",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.3.2.42"],identifiers:{"kegg.reaction":["R10693"],"metanetx.reaction":["MNXR114013"],"seed.reaction":["rxn40434"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10693; MetaNetX MNXR114013"},provenance:[{source:"KEGG",id:"R10693",url:"https://www.kegg.jp/entry/R10693"}]},{id:"tpl_rxn_035",name:"GCPII",canonicalName:"glutamate carboxypeptidase II (NAAG₂)",participants:[{metabolite:"tpl_met_026",coefficient:-1,main:!0},{metabolite:"tpl_met_037",coefficient:-1,main:!1},{metabolite:"tpl_met_025",coefficient:1,main:!0},{metabolite:"tpl_met_002",coefficient:1,main:!1}],reversible:!1,ec:["3.4.17.21"],identifiers:{"kegg.reaction":["R10688"],"metanetx.reaction":["MNXR114008"],"seed.reaction":["rxn40430"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10688; MetaNetX MNXR114008"},provenance:[{source:"KEGG",id:"R10688",url:"https://www.kegg.jp/entry/R10688"}]},{id:"tpl_rxn_036",name:"RIMKLB",canonicalName:"β-citrylglutamate synthase",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_028",coefficient:-1,main:!1},{metabolite:"tpl_met_048",coefficient:-1,main:!1},{metabolite:"tpl_met_027",coefficient:1,main:!0},{metabolite:"tpl_met_029",coefficient:1,main:!1},{metabolite:"tpl_met_032",coefficient:1,main:!1}],reversible:!1,ec:["6.3.1.17"],identifiers:{"kegg.reaction":["R10677"],"metanetx.reaction":["MNXR113997"],"seed.reaction":["rxn40419"],"metacyc.reaction":["RXN-15266"],rhea:["40043","40044","40045","40046"]},level:"optional",identity:{status:"suggested",source:"ai",confidence:"high",note:"KEGG R10677; MetaNetX MNXR113997"},provenance:[{source:"KEGG",id:"R10677",url:"https://www.kegg.jp/entry/R10677"}]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_002",metabolite:"tpl_met_004",direction:"in",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_003",metabolite:"tpl_met_009",direction:"out",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_004",metabolite:"tpl_met_012",direction:"out",target:{pathway:"Citrate cycle (TCA cycle)",template:"kegg-map00020"}},{id:"tpl_port_005",metabolite:"tpl_met_007",direction:"in",target:{pathway:"Glycolysis / Gluconeogenesis",template:"kegg-map00010"}},{id:"tpl_port_006",metabolite:"tpl_met_013",direction:"in",target:{pathway:"Arginine and proline metabolism"}},{id:"tpl_port_007",metabolite:"tpl_met_018",direction:"out",target:{pathway:"Pyrimidine metabolism"}},{id:"tpl_port_008",metabolite:"tpl_met_020",direction:"out",target:{pathway:"Purine metabolism"}},{id:"tpl_port_009",metabolite:"tpl_met_019",direction:"out",target:{pathway:"Amino sugar and nucleotide sugar metabolism"}},{id:"tpl_port_010",metabolite:"tpl_met_022",direction:"out",target:{pathway:"Arginine biosynthesis"}}]},hw={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:-220,shape:"label"},{id:"tpl_node_002",metabolite:"tpl_met_002",x:0,y:0,shape:"label"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:0,y:260,shape:"label"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:-480,y:-220,shape:"label"},{id:"tpl_node_005",metabolite:"tpl_met_005",x:-480,y:0,shape:"label"},{id:"tpl_node_006",metabolite:"tpl_met_006",x:-480,y:260,shape:"label"},{id:"tpl_node_007",metabolite:"tpl_met_009",x:-300,y:-180,shape:"label"},{id:"tpl_node_008",metabolite:"tpl_met_014",x:-720,y:-110,shape:"label"},{id:"tpl_node_009",metabolite:"tpl_met_015",x:-740,y:260,shape:"label"},{id:"tpl_node_010",metabolite:"tpl_met_004",x:-740,y:100,shape:"label"},{id:"tpl_node_011",metabolite:"tpl_met_008",x:-240,y:0,shape:"label"},{id:"tpl_node_012",metabolite:"tpl_met_013",x:-200,y:170,shape:"label"},{id:"tpl_node_013",metabolite:"tpl_met_007",x:240,y:-420,shape:"label"},{id:"tpl_node_014",metabolite:"tpl_met_008",x:480,y:-420,shape:"label"},{id:"tpl_node_015",metabolite:"tpl_met_010",x:260,y:0,shape:"label"},{id:"tpl_node_016",metabolite:"tpl_met_011",x:260,y:-220,shape:"label"},{id:"tpl_node_017",metabolite:"tpl_met_012",x:520,y:-220,shape:"label"},{id:"tpl_node_018",metabolite:"tpl_met_016",x:260,y:260,shape:"label"},{id:"tpl_node_019",metabolite:"tpl_met_001",x:520,y:260,shape:"label"},{id:"tpl_node_020",metabolite:"tpl_met_017",x:0,y:480,shape:"label"},{id:"tpl_node_021",metabolite:"tpl_met_019",x:-180,y:460,shape:"label"},{id:"tpl_node_022",metabolite:"tpl_met_020",x:180,y:460,shape:"label"},{id:"tpl_node_023",metabolite:"tpl_met_005",x:-240,y:700,shape:"label"},{id:"tpl_node_024",metabolite:"tpl_met_018",x:0,y:700,shape:"label"},{id:"tpl_node_025",metabolite:"tpl_met_021",x:-480,y:700,shape:"label"},{id:"tpl_node_026",metabolite:"tpl_met_022",x:-720,y:620,shape:"label"},{id:"tpl_node_027",metabolite:"tpl_met_009",x:-720,y:780,shape:"label"},{id:"tpl_node_028",metabolite:"tpl_met_023",x:-240,y:900,shape:"label"},{id:"tpl_node_029",metabolite:"tpl_met_009",x:-480,y:900,shape:"label"},{id:"tpl_node_030",metabolite:"tpl_met_005",x:520,y:560,shape:"label"},{id:"tpl_node_031",metabolite:"tpl_met_024",x:520,y:720,shape:"label"},{id:"tpl_node_032",metabolite:"tpl_met_025",x:760,y:720,shape:"label"},{id:"tpl_node_033",metabolite:"tpl_met_026",x:1e3,y:720,shape:"label"},{id:"tpl_node_034",metabolite:"tpl_met_002",x:760,y:880,shape:"label"},{id:"tpl_node_035",metabolite:"tpl_met_027",x:1e3,y:880,shape:"label"},{id:"tpl_node_036",metabolite:"tpl_met_039",x:19.7,y:-126,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_037",metabolite:"tpl_met_036",x:24.8,y:-142,attach:{reaction:"tpl_rxn_001",side:"in"}},{id:"tpl_node_038",metabolite:"tpl_met_035",x:24.3,y:-94,attach:{reaction:"tpl_rxn_001",side:"out"}},{id:"tpl_node_039",metabolite:"tpl_met_028",x:19.7,y:114,attach:{reaction:"tpl_rxn_002",side:"in"}},{id:"tpl_node_040",metabolite:"tpl_met_039",x:19.7,y:98,attach:{reaction:"tpl_rxn_002",side:"in"}},{id:"tpl_node_041",metabolite:"tpl_met_029",x:19.7,y:146,attach:{reaction:"tpl_rxn_002",side:"out"}},{id:"tpl_node_042",metabolite:"tpl_met_032",x:16.6,y:162,attach:{reaction:"tpl_rxn_002",side:"out"}},{id:"tpl_node_043",metabolite:"tpl_met_001",x:121.1,y:154,attach:{reaction:"tpl_rxn_003",side:"in"}},{id:"tpl_node_044",metabolite:"tpl_met_036",x:104.8,y:184,attach:{reaction:"tpl_rxn_003",side:"in"}},{id:"tpl_node_045",metabolite:"tpl_met_035",x:104.3,y:106,attach:{reaction:"tpl_rxn_003",side:"out"}},{id:"tpl_node_046",metabolite:"tpl_met_039",x:-99.7,y:106,attach:{reaction:"tpl_rxn_004",side:"out"}},{id:"tpl_node_047",metabolite:"tpl_met_002",x:-510.2,y:-126,attach:{reaction:"tpl_rxn_005",side:"in"}},{id:"tpl_node_048",metabolite:"tpl_met_001",x:-521.1,y:-94,attach:{reaction:"tpl_rxn_005",side:"out"}},{id:"tpl_node_049",metabolite:"tpl_met_039",x:-376.6,y:-108.9,attach:{reaction:"tpl_rxn_006",side:"out"}},{id:"tpl_node_050",metabolite:"tpl_met_028",x:-460.3,y:114,attach:{reaction:"tpl_rxn_007",side:"in"}},{id:"tpl_node_051",metabolite:"tpl_met_003",x:-450.7,y:92,attach:{reaction:"tpl_rxn_007",side:"in"}},{id:"tpl_node_052",metabolite:"tpl_met_030",x:-460.3,y:146,attach:{reaction:"tpl_rxn_007",side:"out"}},{id:"tpl_node_053",metabolite:"tpl_met_002",x:-449.8,y:168,attach:{reaction:"tpl_rxn_007",side:"out"}},{id:"tpl_node_054",metabolite:"tpl_met_039",x:-579.7,y:106,attach:{reaction:"tpl_rxn_008",side:"out"}},{id:"tpl_node_055",metabolite:"tpl_met_053",x:-571.2,y:276,attach:{reaction:"tpl_rxn_009",side:"in"}},{id:"tpl_node_056",metabolite:"tpl_met_054",x:-652,y:276,attach:{reaction:"tpl_rxn_009",side:"out"}},{id:"tpl_node_057",metabolite:"tpl_met_039",x:-759.7,y:164,attach:{reaction:"tpl_rxn_010",side:"out"}},{id:"tpl_node_058",metabolite:"tpl_met_051",x:-623.6,y:-162.5,attach:{reaction:"tpl_rxn_012",side:"in"}},{id:"tpl_node_059",metabolite:"tpl_met_039",x:-580.2,y:-181.3,attach:{reaction:"tpl_rxn_012",side:"out"}},{id:"tpl_node_060",metabolite:"tpl_met_052",x:-546.4,y:-195.6,attach:{reaction:"tpl_rxn_012",side:"out"}},{id:"tpl_node_061",metabolite:"tpl_met_038",x:-334.3,y:-16,attach:{reaction:"tpl_rxn_013",side:"out"}},{id:"tpl_node_062",metabolite:"tpl_met_002",x:323.8,y:-436,attach:{reaction:"tpl_rxn_014",side:"in"}},{id:"tpl_node_063",metabolite:"tpl_met_001",x:407.1,y:-436,attach:{reaction:"tpl_rxn_014",side:"out"}},{id:"tpl_node_064",metabolite:"tpl_met_007",x:94.9,y:244,attach:{reaction:"tpl_rxn_015",side:"in"}},{id:"tpl_node_065",metabolite:"tpl_met_008",x:161.1,y:244,attach:{reaction:"tpl_rxn_015",side:"out"}},{id:"tpl_node_066",metabolite:"tpl_met_039",x:415.7,y:244,attach:{reaction:"tpl_rxn_016",side:"out"}},{id:"tpl_node_067",metabolite:"tpl_met_033",x:-121.5,y:98.3,attach:{reaction:"tpl_rxn_017",side:"in"}},{id:"tpl_node_068",metabolite:"tpl_met_034",x:-83,y:65.9,attach:{reaction:"tpl_rxn_017",side:"out"}},{id:"tpl_node_069",metabolite:"tpl_met_038",x:155.7,y:-16,attach:{reaction:"tpl_rxn_018",side:"out"}},{id:"tpl_node_070",metabolite:"tpl_met_001",x:218.9,y:-94,attach:{reaction:"tpl_rxn_019",side:"in"}},{id:"tpl_node_071",metabolite:"tpl_met_002",x:229.8,y:-126,attach:{reaction:"tpl_rxn_019",side:"out"}},{id:"tpl_node_072",metabolite:"tpl_met_033",x:362.2,y:-236,attach:{reaction:"tpl_rxn_020",side:"in"}},{id:"tpl_node_073",metabolite:"tpl_met_034",x:418.2,y:-236,attach:{reaction:"tpl_rxn_020",side:"out"}},{id:"tpl_node_074",metabolite:"tpl_met_028",x:19.7,y:354,attach:{reaction:"tpl_rxn_021",side:"in"}},{id:"tpl_node_075",metabolite:"tpl_met_040",x:24.3,y:332,attach:{reaction:"tpl_rxn_021",side:"in"}},{id:"tpl_node_076",metabolite:"tpl_met_029",x:19.7,y:386,attach:{reaction:"tpl_rxn_021",side:"out"}},{id:"tpl_node_077",metabolite:"tpl_met_002",x:30.2,y:408,attach:{reaction:"tpl_rxn_021",side:"out"}},{id:"tpl_node_078",metabolite:"tpl_met_049",x:-72.4,y:330.6,attach:{reaction:"tpl_rxn_022",side:"in"}},{id:"tpl_node_079",metabolite:"tpl_met_002",x:-111.3,y:380.6,attach:{reaction:"tpl_rxn_022",side:"out"}},{id:"tpl_node_080",metabolite:"tpl_met_050",x:76.7,y:339.4,attach:{reaction:"tpl_rxn_023",side:"in"}},{id:"tpl_node_081",metabolite:"tpl_met_031",x:109.4,y:372.4,attach:{reaction:"tpl_rxn_023",side:"out"}},{id:"tpl_node_082",metabolite:"tpl_met_002",x:137,y:415.3,attach:{reaction:"tpl_rxn_023",side:"out"}},{id:"tpl_node_083",metabolite:"tpl_met_005",x:31.2,y:574,attach:{reaction:"tpl_rxn_024",side:"in"}},{id:"tpl_node_084",metabolite:"tpl_met_032",x:16.6,y:606,attach:{reaction:"tpl_rxn_024",side:"out"}},{id:"tpl_node_085",metabolite:"tpl_met_038",x:-145.7,y:716,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_086",metabolite:"tpl_met_039",x:-171,y:716,attach:{reaction:"tpl_rxn_025",side:"out"}},{id:"tpl_node_087",metabolite:"tpl_met_028",x:-334.3,y:716,attach:{reaction:"tpl_rxn_026",side:"in"}},{id:"tpl_node_088",metabolite:"tpl_met_047",x:-279.7,y:716,attach:{reaction:"tpl_rxn_026",side:"in"}},{id:"tpl_node_089",metabolite:"tpl_met_030",x:-385.7,y:716,attach:{reaction:"tpl_rxn_026",side:"out"}},{id:"tpl_node_090",metabolite:"tpl_met_031",x:-409.6,y:716,attach:{reaction:"tpl_rxn_026",side:"out"}},{id:"tpl_node_091",metabolite:"tpl_met_044",x:-220.3,y:784,attach:{reaction:"tpl_rxn_028",side:"in"}},{id:"tpl_node_092",metabolite:"tpl_met_046",x:-220.3,y:768,attach:{reaction:"tpl_rxn_028",side:"in"}},{id:"tpl_node_093",metabolite:"tpl_met_045",x:-220.3,y:816,attach:{reaction:"tpl_rxn_028",side:"out"}},{id:"tpl_node_094",metabolite:"tpl_met_032",x:-223.4,y:832,attach:{reaction:"tpl_rxn_028",side:"out"}},{id:"tpl_node_095",metabolite:"tpl_met_030",x:-385.7,y:916,attach:{reaction:"tpl_rxn_029",side:"out"}},{id:"tpl_node_096",metabolite:"tpl_met_042",x:553.3,y:624,attach:{reaction:"tpl_rxn_030",side:"in"}},{id:"tpl_node_097",metabolite:"tpl_met_041",x:539.2,y:656,attach:{reaction:"tpl_rxn_030",side:"out"}},{id:"tpl_node_098",metabolite:"tpl_met_043",x:433,y:624,attach:{reaction:"tpl_rxn_031",side:"out"}},{id:"tpl_node_099",metabolite:"tpl_met_028",x:614.3,y:704,attach:{reaction:"tpl_rxn_032",side:"in"}},{id:"tpl_node_100",metabolite:"tpl_met_002",x:557.3,y:704,attach:{reaction:"tpl_rxn_032",side:"in"}},{id:"tpl_node_101",metabolite:"tpl_met_029",x:665.7,y:704,attach:{reaction:"tpl_rxn_032",side:"out"}},{id:"tpl_node_102",metabolite:"tpl_met_032",x:681.9,y:704,attach:{reaction:"tpl_rxn_032",side:"out"}},{id:"tpl_node_103",metabolite:"tpl_met_002",x:603.8,y:776,attach:{reaction:"tpl_rxn_033",side:"out"}},{id:"tpl_node_104",metabolite:"tpl_met_028",x:854.3,y:704,attach:{reaction:"tpl_rxn_034",side:"in"}},{id:"tpl_node_105",metabolite:"tpl_met_002",x:797.3,y:704,attach:{reaction:"tpl_rxn_034",side:"in"}},{id:"tpl_node_106",metabolite:"tpl_met_029",x:905.7,y:704,attach:{reaction:"tpl_rxn_034",side:"out"}},{id:"tpl_node_107",metabolite:"tpl_met_032",x:921.9,y:704,attach:{reaction:"tpl_rxn_034",side:"out"}},{id:"tpl_node_108",metabolite:"tpl_met_002",x:843.8,y:776,attach:{reaction:"tpl_rxn_035",side:"out"}},{id:"tpl_node_109",metabolite:"tpl_met_028",x:854.3,y:864,attach:{reaction:"tpl_rxn_036",side:"in"}},{id:"tpl_node_110",metabolite:"tpl_met_048",x:809.8,y:864,attach:{reaction:"tpl_rxn_036",side:"in"}},{id:"tpl_node_111",metabolite:"tpl_met_029",x:905.7,y:864,attach:{reaction:"tpl_rxn_036",side:"out"}},{id:"tpl_node_112",metabolite:"tpl_met_032",x:921.9,y:864,attach:{reaction:"tpl_rxn_036",side:"out"}}],ports:[{id:"tpl_node_113",connector:"tpl_port_001",x:0,y:-340,from:"tpl_node_001"},{id:"tpl_node_114",connector:"tpl_port_002",x:-480,y:-340,from:"tpl_node_004"},{id:"tpl_node_115",connector:"tpl_port_003",x:-300,y:-320,from:"tpl_node_007"},{id:"tpl_node_116",connector:"tpl_port_004",x:760,y:-220,from:"tpl_node_017"},{id:"tpl_node_117",connector:"tpl_port_005",x:240,y:-540,from:"tpl_node_013"},{id:"tpl_node_118",connector:"tpl_port_006",x:-200,y:300,from:"tpl_node_012"},{id:"tpl_node_119",connector:"tpl_port_007",x:0,y:820,from:"tpl_node_024"},{id:"tpl_node_120",connector:"tpl_port_008",x:180,y:580,from:"tpl_node_022"},{id:"tpl_node_121",connector:"tpl_port_009",x:-480,y:460,from:"tpl_node_021"},{id:"tpl_node_122",connector:"tpl_port_010",x:-720,y:520,from:"tpl_node_026"}],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_002"],routing:"curved",bend:80},{reaction:"tpl_rxn_004",sources:["tpl_node_003"],targets:["tpl_node_002"],routing:"curved",bend:80,label_flip:!0},{reaction:"tpl_rxn_005",sources:["tpl_node_004"],targets:["tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_006",sources:["tpl_node_005"],targets:["tpl_node_007"],routing:"curved",bend:25,label_flip:!0,label_offset:{x:-14.4,y:-14.4}},{reaction:"tpl_rxn_007",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"straight"},{reaction:"tpl_rxn_008",sources:["tpl_node_006"],targets:["tpl_node_005"],routing:"curved",bend:80,label_flip:!0},{reaction:"tpl_rxn_009",sources:["tpl_node_006"],targets:["tpl_node_009"],routing:"straight"},{reaction:"tpl_rxn_010",sources:["tpl_node_009"],targets:["tpl_node_010"],routing:"straight"},{reaction:"tpl_rxn_011",sources:["tpl_node_005"],targets:["tpl_node_008"],routing:"curved",bend:26,label_offset:{x:8.1,y:-17.7}},{reaction:"tpl_rxn_012",sources:["tpl_node_008"],targets:["tpl_node_004"],routing:"curved",bend:26,label_flip:!0,label_offset:{x:-7.8,y:-17.1}},{reaction:"tpl_rxn_013",sources:["tpl_node_005"],targets:["tpl_node_011"],routing:"straight"},{reaction:"tpl_rxn_014",sources:["tpl_node_013"],targets:["tpl_node_014"],routing:"straight"},{reaction:"tpl_rxn_015",sources:["tpl_node_003"],targets:["tpl_node_018"],routing:"straight"},{reaction:"tpl_rxn_016",sources:["tpl_node_018"],targets:["tpl_node_019"],routing:"straight"},{reaction:"tpl_rxn_017",sources:["tpl_node_012"],targets:["tpl_node_002"],routing:"curved",bend:26,label_flip:!0,label_offset:{x:-14.8,y:-17.4}},{reaction:"tpl_rxn_018",sources:["tpl_node_002"],targets:["tpl_node_015"],routing:"straight"},{reaction:"tpl_rxn_019",sources:["tpl_node_015"],targets:["tpl_node_016"],routing:"straight"},{reaction:"tpl_rxn_020",sources:["tpl_node_016"],targets:["tpl_node_017"],routing:"straight"},{reaction:"tpl_rxn_021",sources:["tpl_node_003"],targets:["tpl_node_020"],routing:"straight"},{reaction:"tpl_rxn_022",sources:["tpl_node_003"],targets:["tpl_node_021"],routing:"curved",bend:27,label_flip:!0},{reaction:"tpl_rxn_023",sources:["tpl_node_003"],targets:["tpl_node_022"],routing:"curved",bend:27,label_flip:!0},{reaction:"tpl_rxn_024",sources:["tpl_node_020"],targets:["tpl_node_024"],routing:"straight"},{reaction:"tpl_rxn_025",sources:["tpl_node_024"],targets:["tpl_node_023"],routing:"straight"},{reaction:"tpl_rxn_026",sources:["tpl_node_023"],targets:["tpl_node_025"],routing:"straight"},{reaction:"tpl_rxn_027",sources:["tpl_node_025"],targets:["tpl_node_026","tpl_node_027"],routing:"straight"},{reaction:"tpl_rxn_028",sources:["tpl_node_023"],targets:["tpl_node_028"],routing:"straight"},{reaction:"tpl_rxn_029",sources:["tpl_node_028"],targets:["tpl_node_029"],routing:"straight"},{reaction:"tpl_rxn_030",sources:["tpl_node_030"],targets:["tpl_node_031"],routing:"straight"},{reaction:"tpl_rxn_031",sources:["tpl_node_031"],targets:["tpl_node_030"],routing:"curved",bend:60,label_flip:!0},{reaction:"tpl_rxn_032",sources:["tpl_node_031"],targets:["tpl_node_032"],routing:"straight"},{reaction:"tpl_rxn_033",sources:["tpl_node_032"],targets:["tpl_node_031"],routing:"curved",bend:40,label_flip:!0,label_offset:{x:0,y:14.5}},{reaction:"tpl_rxn_034",sources:["tpl_node_032"],targets:["tpl_node_033"],routing:"straight"},{reaction:"tpl_rxn_035",sources:["tpl_node_033"],targets:["tpl_node_032"],routing:"curved",bend:40,label_flip:!0,label_offset:{x:0,y:14.5}},{reaction:"tpl_rxn_036",sources:["tpl_node_034"],targets:["tpl_node_035"],routing:"straight"}],groups:[{id:"tpl_grp_001",kind:"pathway",title:"GABA shunt",nodes:["tpl_node_015","tpl_node_016","tpl_node_017"]},{id:"tpl_grp_002",kind:"pathway",title:"N-Acetylaspartate · NAAG (vertebrate brain)",nodes:["tpl_node_030","tpl_node_031","tpl_node_032","tpl_node_033","tpl_node_034","tpl_node_035"]}],labels:[{id:"tpl_lbl_001",x:-900,y:-640,text:"Alanine, aspartate and glutamate metabolism",size:16,weight:700,kind:"title"},{id:"tpl_lbl_002",x:-900,y:-620,text:"derived from KEGG map00250 · drawn by GEMsMAP",size:10,weight:400,italic:!0,kind:"text"}]},fw={format:dw,schema_version:mw,metadata:uw,biology:pw,layout:hw},gw="gemsmap-template",bw="1.0.0",yw={id:"ppp",name:"Pentose phosphate (oxidative)",description:"Oxidative pentose phosphate pathway: glucose 6-phosphate → ribulose 5-phosphate, ribose 5-phosphate and xylulose 5-phosphate.",pathway:"Pentose phosphate pathway, oxidative branch",section:"Central carbon",template_version:"2.0.0",scope:{level:"universal",taxa:[],note:"Conserved; cytosolic."},authors:["GEMsMAP"],created:"2026-10-02T00:00:00.000Z",modified:"2026-10-08T00:00:00.000Z",license:"MIT",tags:["central carbon","pentose phosphate","NADPH"],citations:[],layout_kind:"branched"},xw={compartments:[{id:"cytosol",fallback:["intracellular"]}],entities:[{id:"tpl_ent_001",name:"D-Glucose 6-phosphate",short:"g6p",formula:"C6H13O9P",synonyms:["glucose 6-phosphate","D-glucose 6-phosphate","glucose-6-phosphate","G6P","D-glucopyranose 6-phosphate","Robison ester"],identifiers:{"kegg.compound":["C00092"],chebi:["14314","4170","61548"],"bigg.metabolite":["g6p"],"seed.compound":["cpd00079"],"metacyc.compound":["GLC-6-P","D-GLUCOSE-6-PHOSPHATE"],hmdb:["HMDB0001401"]},related:[{note:"anomer of D-glucose 6-phosphate",names:["alpha-D-glucose 6-phosphate","beta-D-glucose 6-phosphate"],identifiers:{"kegg.compound":["C00668","C01172"],"bigg.metabolite":["g6p_A","g6p_B"],"metacyc.compound":["ALPHA-GLC-6-P","GLC-6-P-BETA"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-glucose-6-phosphate"},{id:"tpl_ent_002",name:"6-Phospho-D-glucono-1,5-lactone",short:"6pgl",formula:"C6H11O9P",synonyms:["6-phospho-D-glucono-1,5-lactone","6-phosphogluconolactone","6-O-phosphono-D-glucono-1,5-lactone","D-glucono-1,5-lactone 6-phosphate","6-phosphoglucono-delta-lactone","6PGL"],identifiers:{"kegg.compound":["C01236"],chebi:["16938","57955"],"bigg.metabolite":["6pgl"],"seed.compound":["cpd00911"],"metacyc.compound":["D-6-P-GLUCONO-DELTA-LACTONE"],hmdb:["HMDB0001127"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"6-phosphogluconolactone"},{id:"tpl_ent_003",name:"6-Phospho-D-gluconate",short:"6pgc",formula:"C6H13O10P",synonyms:["6-phospho-D-gluconate","6-phosphogluconate","6-phosphogluconic acid","D-gluconate 6-phosphate","6PG"],identifiers:{"kegg.compound":["C00345"],chebi:["48928","58759"],"bigg.metabolite":["6pgc"],"seed.compound":["cpd00284"],"metacyc.compound":["CPD-2961"],hmdb:["HMDB0001316"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"6-phospho-D-gluconate"},{id:"tpl_ent_004",name:"D-Ribulose 5-phosphate",short:"ru5p_D",formula:"C5H11O8P",synonyms:["D-ribulose 5-phosphate","ribulose 5-phosphate","ribulose-5-phosphate","Ru5P"],identifiers:{"kegg.compound":["C00199"],chebi:["17363","58121"],"bigg.metabolite":["ru5p__D","ru5p_D"],"seed.compound":["cpd00171"],"metacyc.compound":["RIBULOSE-5P"],hmdb:["HMDB0000618"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-ribulose-5-phosphate"},{id:"tpl_ent_005",name:"D-Ribose 5-phosphate",short:"r5p",formula:"C5H11O8P",synonyms:["D-ribose 5-phosphate","ribose 5-phosphate","ribose-5-phosphate","R5P","alpha-D-ribose 5-phosphate"],identifiers:{"kegg.compound":["C00117"],chebi:["17797","78346"],"bigg.metabolite":["r5p"],"seed.compound":["cpd00101"],"metacyc.compound":["RIBOSE-5P"],hmdb:["HMDB0001548"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-ribose-5-phosphate"},{id:"tpl_ent_006",name:"D-Xylulose 5-phosphate",short:"xu5p_D",formula:"C5H11O8P",synonyms:["D-xylulose 5-phosphate","xylulose 5-phosphate","xylulose-5-phosphate","Xu5P"],identifiers:{"kegg.compound":["C00231"],chebi:["16332","57737"],"bigg.metabolite":["xu5p__D","xu5p_D"],"seed.compound":["cpd00198"],"metacyc.compound":["XYLULOSE-5-PHOSPHATE"],hmdb:["HMDB0000868"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"D-xylulose-5-phosphate"},{id:"tpl_ent_007",name:"NADP+",short:"nadp",formula:"C21H29N7O17P3",synonyms:["NADP+","NADP","nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00006"],chebi:["18009","58349"],"bigg.metabolite":["nadp"],"seed.compound":["cpd00006"],"metacyc.compound":["NADP"],hmdb:["HMDB0000217"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADP+"},{id:"tpl_ent_008",name:"NADPH",short:"nadph",formula:"C21H30N7O17P3",synonyms:["NADPH","reduced nicotinamide adenine dinucleotide phosphate"],identifiers:{"kegg.compound":["C00005"],chebi:["16474","57783"],"bigg.metabolite":["nadph"],"seed.compound":["cpd00005"],"metacyc.compound":["NADPH"],hmdb:["HMDB0000221"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADPH"},{id:"tpl_ent_009",name:"H2O",short:"h2o",formula:"H2O",synonyms:["H2O","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377"],"bigg.metabolite":["h2o"],"seed.compound":["cpd00001"],"metacyc.compound":["WATER"],hmdb:["HMDB0002111"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"H2O"},{id:"tpl_ent_010",name:"CO2",short:"co2",formula:"CO2",synonyms:["CO2","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526"],"bigg.metabolite":["co2"],"seed.compound":["cpd00011"],"metacyc.compound":["CARBON-DIOXIDE"],hmdb:["HMDB0001967"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CO2"}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:"cytosol",level:"required",aliases:["g6p"]},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:"cytosol",level:"required",aliases:["6pgl"]},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:"cytosol",level:"required",aliases:["6pgc"]},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:"cytosol",level:"required",aliases:["ru5p"]},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:"cytosol",level:"required",aliases:["r5p"]},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:"cytosol",level:"required",aliases:["xu5p"]},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:"cytosol",level:"optional"},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:"cytosol",level:"optional"},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:"cytosol",level:"optional"},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:"cytosol",level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"G6PDH",canonicalName:"glucose-6-phosphate dehydrogenase",reversible:!1,ec:["1.1.1.49","1.1.1.363"],level:"required",participants:[{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_007",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_008",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["G6PDH2r"],"kegg.reaction":["R00835"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["G6PDH2r","G6PDH"],aliases:["G6PDH"]},{id:"tpl_rxn_002",name:"PGL",canonicalName:"6-phosphogluconolactonase",reversible:!1,ec:["3.1.1.31"],level:"required",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_009",coefficient:-1,main:!1},{metabolite:"tpl_met_003",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["PGL"],"kegg.reaction":["R02035"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["PGL"],aliases:["PGL"]},{id:"tpl_rxn_003",name:"GND",canonicalName:"6-phosphogluconate dehydrogenase (decarboxylating)",reversible:!1,ec:["1.1.1.44","1.1.1.351"],level:"required",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_007",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_010",coefficient:1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["GND"],"kegg.reaction":["R01528"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["GND"],aliases:["GND"]},{id:"tpl_rxn_004",name:"RPI",canonicalName:"ribose-5-phosphate isomerase",reversible:!0,ec:["5.3.1.6"],level:"required",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_005",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["RPI"],"kegg.reaction":["R01056"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["RPI"],aliases:["RPI"]},{id:"tpl_rxn_005",name:"RPE",canonicalName:"ribulose-phosphate 3-epimerase",reversible:!0,ec:["5.1.3.1"],level:"required",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_006",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["RPE"],"kegg.reaction":["R01529"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["RPE"],aliases:["RPE"]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{template:"glycolysis",pathway:"Glycolysis"}}]},_w={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:0,y:60},{id:"tpl_node_002",metabolite:"tpl_met_002",x:-120,y:60,label_pos:"top"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:-220,y:60,label_pos:"top"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:-220,y:150,label_pos:"left"},{id:"tpl_node_005",metabolite:"tpl_met_005",x:-280,y:228,label_pos:"left"},{id:"tpl_node_006",metabolite:"tpl_met_006",x:-160,y:228}],ports:[],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_001"],targets:["tpl_node_002"],routing:"straight"},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"straight"},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"straight"},{reaction:"tpl_rxn_004",sources:["tpl_node_004"],targets:["tpl_node_005"],routing:"straight"},{reaction:"tpl_rxn_005",sources:["tpl_node_004"],targets:["tpl_node_006"],routing:"straight"}],groups:[],labels:[]},vw={format:gw,schema_version:bw,metadata:yw,biology:xw,layout:_w},jw="gemsmap-template",Nw="1.0.0",ww={id:"tca",name:"TCA cycle",description:"Krebs cycle with acetyl-CoA entry, drawn as a circle.",pathway:"Tricarboxylic acid cycle",section:"Central carbon",template_version:"2.0.0",scope:{level:"universal",taxa:[],note:"Mitochondrial in eukaryotes, cytosolic in prokaryotes."},authors:["GEMsMAP"],created:"2026-10-02T00:00:00.000Z",modified:"2026-10-08T00:00:00.000Z",license:"MIT",tags:["central carbon","TCA","Krebs cycle"],citations:[],layout_kind:"circular"},Cw={compartments:[{id:"mitochondria",fallback:["cytosol","intracellular"],note:"The TCA cycle is mitochondrial in eukaryotes; prokaryote-like models run it in the cytoplasm."}],entities:[{id:"tpl_ent_001",name:"Acetyl-CoA",short:"accoa",formula:"C23H38N7O17P3S",synonyms:["acetyl-CoA","acetyl coenzyme A","acetyl-coenzyme A","AcCoA"],identifiers:{"kegg.compound":["C00024"],chebi:["15351","57288"],"bigg.metabolite":["accoa"],"seed.compound":["cpd00022"],"metacyc.compound":["ACETYL-COA"],hmdb:["HMDB0001206"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"acetyl-CoA"},{id:"tpl_ent_002",name:"Citrate",short:"cit",formula:"C6H8O7",synonyms:["citrate","citric acid","2-hydroxypropane-1,2,3-tricarboxylate","Cit"],identifiers:{"kegg.compound":["C00158"],chebi:["16947","30769"],"bigg.metabolite":["cit"],"seed.compound":["cpd00137"],"metacyc.compound":["CIT"],hmdb:["HMDB0000094"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"citrate"},{id:"tpl_ent_003",name:"Isocitrate",short:"icit",formula:"C6H8O7",synonyms:["isocitrate","isocitric acid","D-threo-isocitrate","threo-Ds-isocitrate","(2R,3S)-isocitrate","D-isocitrate"],identifiers:{"kegg.compound":["C00311"],chebi:["16087","30887"],"bigg.metabolite":["icit"],"seed.compound":["cpd00260"],"metacyc.compound":["THREO-DS-ISO-CITRATE"],hmdb:["HMDB0000193"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"isocitrate"},{id:"tpl_ent_004",name:"2-Oxoglutarate",short:"akg",formula:"C5H6O5",synonyms:["2-oxoglutarate","alpha-ketoglutarate","2-ketoglutarate","oxoglutarate","2-oxoglutaric acid","alpha-ketoglutaric acid","AKG","2-oxopentanedioate"],identifiers:{"kegg.compound":["C00026"],chebi:["16810","30915"],"bigg.metabolite":["akg"],"seed.compound":["cpd00024"],"metacyc.compound":["2-KETOGLUTARATE"],hmdb:["HMDB0000208"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"2-oxoglutarate"},{id:"tpl_ent_005",name:"Succinyl-CoA",short:"succoa",formula:"C25H40N7O19P3S",synonyms:["succinyl-CoA","succinyl coenzyme A","succinyl-coenzyme A","SucCoA"],identifiers:{"kegg.compound":["C00091"],chebi:["15380","57292"],"bigg.metabolite":["succoa"],"seed.compound":["cpd00078"],"metacyc.compound":["SUC-COA"],hmdb:["HMDB0001022"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"succinyl-CoA"},{id:"tpl_ent_006",name:"Succinate",short:"succ",formula:"C4H6O4",synonyms:["succinate","succinic acid","butanedioate","butanedioic acid","Succ"],identifiers:{"kegg.compound":["C00042"],chebi:["26806","30031","15741"],"bigg.metabolite":["succ"],"seed.compound":["cpd00036"],"metacyc.compound":["SUC"],hmdb:["HMDB0000254"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"succinate"},{id:"tpl_ent_007",name:"Fumarate",short:"fum",formula:"C4H4O4",synonyms:["fumarate","fumaric acid","trans-butenedioate","(E)-butenedioate","Fum"],identifiers:{"kegg.compound":["C00122"],chebi:["29806","18012"],"bigg.metabolite":["fum"],"seed.compound":["cpd00106"],"metacyc.compound":["FUM"],hmdb:["HMDB0000134"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"fumarate"},{id:"tpl_ent_008",name:"L-Malate",short:"mal_L",formula:"C4H6O5",synonyms:["L-malate","(S)-malate","L-malic acid","(S)-malic acid","Mal"],identifiers:{"kegg.compound":["C00149"],chebi:["15589","30797"],"bigg.metabolite":["mal__L","mal_L"],"seed.compound":["cpd00130"],"metacyc.compound":["MAL"],hmdb:["HMDB0000156"]},related:[{note:"stereo-unspecified malate",names:["malate","malic acid"],identifiers:{"kegg.compound":["C00711"]}}],identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"L-malate"},{id:"tpl_ent_009",name:"Oxaloacetate",short:"oaa",formula:"C4H4O5",synonyms:["oxaloacetate","oxaloacetic acid","oxalacetate","2-oxosuccinate","OAA"],identifiers:{"kegg.compound":["C00036"],chebi:["16452","30744"],"bigg.metabolite":["oaa"],"seed.compound":["cpd00032"],"metacyc.compound":["OXALACETIC_ACID"],hmdb:["HMDB0000223"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"oxaloacetate"},{id:"tpl_ent_010",name:"H2O",short:"h2o",formula:"H2O",synonyms:["H2O","water"],identifiers:{"kegg.compound":["C00001"],chebi:["15377"],"bigg.metabolite":["h2o"],"seed.compound":["cpd00001"],"metacyc.compound":["WATER"],hmdb:["HMDB0002111"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"H2O"},{id:"tpl_ent_011",name:"Coenzyme A",short:"coa",formula:"C21H36N7O16P3S",synonyms:["CoA","coenzyme A","CoA-SH"],identifiers:{"kegg.compound":["C00010"],chebi:["15346","57287"],"bigg.metabolite":["coa"],"seed.compound":["cpd00010"],"metacyc.compound":["CO-A"],hmdb:["HMDB0001423"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CoA"},{id:"tpl_ent_012",name:"NAD+",short:"nad",formula:"C21H28N7O14P2",synonyms:["NAD+","NAD","nicotinamide adenine dinucleotide","oxidized nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00003"],chebi:["15846","57540"],"bigg.metabolite":["nad"],"seed.compound":["cpd00003"],"metacyc.compound":["NAD"],hmdb:["HMDB0000902"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NAD+"},{id:"tpl_ent_013",name:"CO2",short:"co2",formula:"CO2",synonyms:["CO2","carbon dioxide"],identifiers:{"kegg.compound":["C00011"],chebi:["16526"],"bigg.metabolite":["co2"],"seed.compound":["cpd00011"],"metacyc.compound":["CARBON-DIOXIDE"],hmdb:["HMDB0001967"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"CO2"},{id:"tpl_ent_014",name:"NADH",short:"nadh",formula:"C21H29N7O14P2",synonyms:["NADH","reduced nicotinamide adenine dinucleotide"],identifiers:{"kegg.compound":["C00004"],chebi:["16908","57945"],"bigg.metabolite":["nadh"],"seed.compound":["cpd00004"],"metacyc.compound":["NADH"],hmdb:["HMDB0001487"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"NADH"},{id:"tpl_ent_015",name:"ADP",short:"adp",formula:"C10H15N5O10P2",synonyms:["ADP","adenosine 5'-diphosphate","adenosine diphosphate"],identifiers:{"kegg.compound":["C00008"],chebi:["16761","456216"],"bigg.metabolite":["adp"],"seed.compound":["cpd00008"],"metacyc.compound":["ADP"],hmdb:["HMDB0001341"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ADP"},{id:"tpl_ent_016",name:"Orthophosphate",short:"pi",formula:"H3PO4",synonyms:["phosphate","orthophosphate","Pi","inorganic phosphate"],identifiers:{"kegg.compound":["C00009"],chebi:["18367","26078"],"bigg.metabolite":["pi"],"seed.compound":["cpd00009"],"metacyc.compound":["Pi"],hmdb:["HMDB0001429"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"phosphate"},{id:"tpl_ent_017",name:"ATP",short:"atp",formula:"C10H16N5O13P3",synonyms:["ATP","adenosine 5'-triphosphate","adenosine triphosphate"],identifiers:{"kegg.compound":["C00002"],chebi:["15422","30616"],"bigg.metabolite":["atp"],"seed.compound":["cpd00002"],"metacyc.compound":["ATP"],hmdb:["HMDB0000538"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ATP"},{id:"tpl_ent_018",name:"Ubiquinone",short:"q",synonyms:["ubiquinone","coenzyme Q","quinone"],identifiers:{"kegg.compound":["C00399"],chebi:["16389"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ubiquinone"},{id:"tpl_ent_019",name:"Ubiquinol",short:"qh2",synonyms:["ubiquinol","reduced coenzyme Q"],identifiers:{"kegg.compound":["C00390"],chebi:["17976"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP canonical library (identifiers verified by hand)"},library:"ubiquinol"}],metabolites:[{id:"tpl_met_001",entity:"tpl_ent_001",compartment:"mitochondria",level:"required",ungrouped:!0,aliases:["accoa"]},{id:"tpl_met_002",entity:"tpl_ent_002",compartment:"mitochondria",level:"required",aliases:["cit"]},{id:"tpl_met_003",entity:"tpl_ent_003",compartment:"mitochondria",level:"required",aliases:["icit"]},{id:"tpl_met_004",entity:"tpl_ent_004",compartment:"mitochondria",level:"required",aliases:["akg"]},{id:"tpl_met_005",entity:"tpl_ent_005",compartment:"mitochondria",level:"required",aliases:["succoa"]},{id:"tpl_met_006",entity:"tpl_ent_006",compartment:"mitochondria",level:"required",aliases:["succ"]},{id:"tpl_met_007",entity:"tpl_ent_007",compartment:"mitochondria",level:"required",aliases:["fum"]},{id:"tpl_met_008",entity:"tpl_ent_008",compartment:"mitochondria",level:"required",aliases:["mal"]},{id:"tpl_met_009",entity:"tpl_ent_009",compartment:"mitochondria",level:"required",aliases:["oaa"]},{id:"tpl_met_010",entity:"tpl_ent_010",compartment:"mitochondria",level:"optional"},{id:"tpl_met_011",entity:"tpl_ent_011",compartment:"mitochondria",level:"optional"},{id:"tpl_met_012",entity:"tpl_ent_012",compartment:"mitochondria",level:"optional"},{id:"tpl_met_013",entity:"tpl_ent_013",compartment:"mitochondria",level:"optional"},{id:"tpl_met_014",entity:"tpl_ent_014",compartment:"mitochondria",level:"optional"},{id:"tpl_met_015",entity:"tpl_ent_015",compartment:"mitochondria",level:"optional"},{id:"tpl_met_016",entity:"tpl_ent_016",compartment:"mitochondria",level:"optional"},{id:"tpl_met_017",entity:"tpl_ent_017",compartment:"mitochondria",level:"optional"},{id:"tpl_met_018",entity:"tpl_ent_018",compartment:"mitochondria",level:"optional"},{id:"tpl_met_019",entity:"tpl_ent_019",compartment:"mitochondria",level:"optional"}],reactions:[{id:"tpl_rxn_001",name:"CS",canonicalName:"citrate synthase",reversible:!1,ec:["2.3.3.1","2.3.3.16","2.3.3.3"],level:"required",participants:[{metabolite:"tpl_met_009",coefficient:-1,main:!0},{metabolite:"tpl_met_001",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:-1,main:!1},{metabolite:"tpl_met_002",coefficient:1,main:!0},{metabolite:"tpl_met_011",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["CS"],"kegg.reaction":["R00351"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["CS","CSm"],aliases:["CS"]},{id:"tpl_rxn_002",name:"ACONT",canonicalName:"aconitate hydratase",reversible:!0,ec:["4.2.1.3"],level:"required",participants:[{metabolite:"tpl_met_002",coefficient:-1,main:!0},{metabolite:"tpl_met_003",coefficient:1,main:!0}],identifiers:{"kegg.reaction":["R01324"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ACONT","ACONTa","ACONTm"],aliases:["ACONT"]},{id:"tpl_rxn_003",name:"ICDH",canonicalName:"isocitrate dehydrogenase",reversible:!1,ec:["1.1.1.41","1.1.1.42"],level:"required",participants:[{metabolite:"tpl_met_003",coefficient:-1,main:!0},{metabolite:"tpl_met_012",coefficient:-1,main:!1},{metabolite:"tpl_met_004",coefficient:1,main:!0},{metabolite:"tpl_met_013",coefficient:1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["ICDHyr"],"kegg.reaction":["R00709"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["ICDHyr","ICDHy","ICDHxm"],aliases:["ICDH"]},{id:"tpl_rxn_004",name:"AKGDH",canonicalName:"2-oxoglutarate dehydrogenase complex",reversible:!1,ec:["1.2.4.2","1.2.1.105"],level:"required",participants:[{metabolite:"tpl_met_004",coefficient:-1,main:!0},{metabolite:"tpl_met_011",coefficient:-1,main:!1},{metabolite:"tpl_met_012",coefficient:-1,main:!1},{metabolite:"tpl_met_005",coefficient:1,main:!0},{metabolite:"tpl_met_013",coefficient:1,main:!1},{metabolite:"tpl_met_014",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["AKGDH"],"kegg.reaction":["R08549"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["AKGDH","AKGDm"],aliases:["AKGDH"]},{id:"tpl_rxn_005",name:"SUCOAS",canonicalName:"succinyl-CoA synthetase",reversible:!0,ec:["6.2.1.4","6.2.1.5"],level:"required",participants:[{metabolite:"tpl_met_005",coefficient:-1,main:!0},{metabolite:"tpl_met_015",coefficient:-1,main:!1},{metabolite:"tpl_met_016",coefficient:-1,main:!1},{metabolite:"tpl_met_006",coefficient:1,main:!0},{metabolite:"tpl_met_017",coefficient:1,main:!1},{metabolite:"tpl_met_011",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["SUCOAS"],"kegg.reaction":["R00405"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["SUCOAS","SUCOASm"],aliases:["SUCOAS"]},{id:"tpl_rxn_006",name:"SDH",canonicalName:"succinate dehydrogenase",reversible:!1,ec:["1.3.5.1","1.3.5.4"],level:"required",participants:[{metabolite:"tpl_met_006",coefficient:-1,main:!0},{metabolite:"tpl_met_018",coefficient:-1,main:!1},{metabolite:"tpl_met_007",coefficient:1,main:!0},{metabolite:"tpl_met_019",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["SUCDi"],"kegg.reaction":["R02164"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["SUCDi","SUCD1","SUCD1m","SDH"],aliases:["SDH"]},{id:"tpl_rxn_007",name:"FUM",canonicalName:"fumarate hydratase",reversible:!0,ec:["4.2.1.2"],level:"required",participants:[{metabolite:"tpl_met_007",coefficient:-1,main:!0},{metabolite:"tpl_met_010",coefficient:-1,main:!1},{metabolite:"tpl_met_008",coefficient:1,main:!0}],identifiers:{"bigg.reaction":["FUM"],"kegg.reaction":["R01082"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["FUM","FUMm"],aliases:["FUM"]},{id:"tpl_rxn_008",name:"MDH",canonicalName:"malate dehydrogenase",reversible:!0,ec:["1.1.1.37"],level:"required",participants:[{metabolite:"tpl_met_008",coefficient:-1,main:!0},{metabolite:"tpl_met_012",coefficient:-1,main:!1},{metabolite:"tpl_met_009",coefficient:1,main:!0},{metabolite:"tpl_met_014",coefficient:1,main:!1}],identifiers:{"bigg.reaction":["MDH"],"kegg.reaction":["R00342"]},identity:{status:"confirmed",source:"builtin",note:"GEMsMAP built-in template; KEGG reaction IDs checked against the KEGG equation"},hints:["MDH","MDHm"],aliases:["MDH"]}],connectors:[{id:"tpl_port_001",metabolite:"tpl_met_001",direction:"in",target:{template:"glycolysis",pathway:"Glycolysis"}}]},kw={nodes:[{id:"tpl_node_001",metabolite:"tpl_met_001",x:-140,y:10,label_pos:"top"},{id:"tpl_node_002",metabolite:"tpl_met_002",x:0,y:-5,label_pos:"top"},{id:"tpl_node_003",metabolite:"tpl_met_003",x:67,y:23,label_pos:"right"},{id:"tpl_node_004",metabolite:"tpl_met_004",x:95,y:90,label_pos:"right"},{id:"tpl_node_005",metabolite:"tpl_met_005",x:67,y:157,label_pos:"right"},{id:"tpl_node_006",metabolite:"tpl_met_006",x:0,y:185,label_pos:"bottom"},{id:"tpl_node_007",metabolite:"tpl_met_007",x:-67,y:157,label_pos:"left"},{id:"tpl_node_008",metabolite:"tpl_met_008",x:-95,y:90,label_pos:"left"},{id:"tpl_node_009",metabolite:"tpl_met_009",x:-67,y:23,label_pos:"left"}],ports:[],reactions:[{reaction:"tpl_rxn_001",sources:["tpl_node_009","tpl_node_001"],targets:["tpl_node_002"],routing:"curved",bend:-12},{reaction:"tpl_rxn_002",sources:["tpl_node_002"],targets:["tpl_node_003"],routing:"curved",bend:-12},{reaction:"tpl_rxn_003",sources:["tpl_node_003"],targets:["tpl_node_004"],routing:"curved",bend:-12},{reaction:"tpl_rxn_004",sources:["tpl_node_004"],targets:["tpl_node_005"],routing:"curved",bend:-12},{reaction:"tpl_rxn_005",sources:["tpl_node_005"],targets:["tpl_node_006"],routing:"curved",bend:-12},{reaction:"tpl_rxn_006",sources:["tpl_node_006"],targets:["tpl_node_007"],routing:"curved",bend:-12},{reaction:"tpl_rxn_007",sources:["tpl_node_007"],targets:["tpl_node_008"],routing:"curved",bend:-12},{reaction:"tpl_rxn_008",sources:["tpl_node_008"],targets:["tpl_node_009"],routing:"curved",bend:-12}],groups:[],labels:[]},Mw={format:jw,schema_version:Nw,metadata:ww,biology:Cw,layout:kw},Ka="gemsmap-template",Ew="metmap-template",w1=e=>e===Ka||e===Ew,Fp="1.1.0",Gw=".gemsmap-template.json",rl=[{id:"cytosol",label:"Cytosol",canonical:"CYTOSOL"},{id:"mitochondria",label:"Mitochondria",canonical:"MITOCHONDRION"},{id:"mitochondrial_intermembrane",label:"Mitochondrial intermembrane space",canonical:"MITO_IMS"},{id:"extracellular",label:"Extracellular",canonical:"EXTRACELLULAR"},{id:"periplasm",label:"Periplasm",canonical:"PERIPLASM"},{id:"peroxisome",label:"Peroxisome",canonical:"PEROXISOME"},{id:"nucleus",label:"Nucleus",canonical:"NUCLEUS"},{id:"endoplasmic_reticulum",label:"Endoplasmic reticulum",canonical:"ER"},{id:"golgi",label:"Golgi",canonical:"GOLGI"},{id:"vacuole",label:"Vacuole",canonical:"VACUOLE"},{id:"lysosome",label:"Lysosome",canonical:"LYSOSOME"},{id:"chloroplast",label:"Chloroplast / plastid",canonical:"CHLOROPLAST"},{id:"thylakoid",label:"Thylakoid",canonical:"THYLAKOID"},{id:"membrane",label:"Membrane / cell envelope",canonical:"CELL_ENVELOPE"}],Xp=new Map(rl.map(e=>[e.id,e])),Md=e=>typeof e=="string"&&Xp.has(e),wi=e=>{var t;return e?((t=Xp.get(e))==null?void 0:t.label)??e:"no compartment"},nf=e=>e==="intracellular"?"INTRACELLULAR":Xp.get(e).canonical,C1=["metanetx.chemical","kegg.compound","chebi","bigg.metabolite","seed.compound","metacyc.compound","hmdb","inchikey"],Sw=["metanetx.reaction","kegg.reaction","rhea","bigg.reaction","seed.reaction","metacyc.reaction"],eu={universal:"Universal / conserved",prokaryotic:"Prokaryotic",eukaryotic:"Eukaryotic",fungal:"Fungal",yeast:"Yeast",mammalian:"Mammalian",plant:"Plant","species-specific":"Species-specific",other:"Other taxonomic group"};function qi(e,t){let i=0;const a=new RegExp(`^${t}_(\\d+)$`);for(const s of e){const o=s.match(a);o&&(i=Math.max(i,+o[1]))}return`${t}_${String(i+1).padStart(3,"0")}`}const Zt={entity:"tpl_ent",metabolite:"tpl_met",reaction:"tpl_rxn",connector:"tpl_port",node:"tpl_node",group:"tpl_grp",label:"tpl_lbl"};function k1(e="New template",t=""){const i=new Date().toISOString();return{format:Ka,schema_version:Fp,metadata:{id:`tpl_${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-4)}`,name:e,description:"",pathway:e,section:"My templates",template_version:"0.1.0",scope:{level:"universal",taxa:[]},authors:t?[t]:[],created:i,modified:i,license:"CC-BY-4.0",tags:[],citations:[],layout_kind:"free"},biology:{compartments:[{id:"cytosol",fallback:["intracellular"]}],entities:[],metabolites:[],reactions:[],connectors:[]},layout:{nodes:[],ports:[],reactions:[],groups:[],labels:[]}}}const Aw=["kegg.compound","chebi","metanetx.chemical","seed.compound","bigg.metabolite"];function Dw(e,t){var i;if(e.library)return e.library;for(const a of Aw){const s=(i=e.identifiers[a])==null?void 0:i[0];if(s)return`${a}:${s}`}return`${t}/${e.id}`}function Pw(e,t){var i;return{id:t,name:e.name,short:e.short||e.name,formula:e.formula,synonyms:e.synonyms,xrefs:e.identifiers,related:(i=e.related)==null?void 0:i.map(a=>({note:a.note,names:a.names,xrefs:a.identifiers}))}}const Rw={cytosol:[]};function af(e,t){if(!t)return{preferred:["INTRACELLULAR"]};const i=e.biology.compartments.find(s=>s.id===t),a=i?i.fallback:[...Rw[t]??["cytosol"],"intracellular"];return{preferred:[nf(t)],fallback:a.map(nf),...i!=null&&i.note?{note:i.note}:{}}}function Iw(e){const t=new Set(e.layout.nodes.filter(d=>!d.attach).map(d=>d.metabolite)),i=new Map;for(const d of e.biology.metabolites)t.has(d.id)&&i.set(d.compartment??"",(i.get(d.compartment??"")??0)+1);const a=[...i.entries()].sort((d,f)=>f[1]-d[1]).map(([d])=>d);if(!a.length)return"no compartment yet";const s=a[0],o=s?e.biology.compartments.find(d=>d.id===s):void 0,l=o==null?void 0:o.fallback.find(d=>d!=="intracellular"),r=s?wi(s).toLowerCase():"unspecified",c=a.slice(1).filter(Boolean).map(d=>wi(d).toLowerCase());return`${r}${l?` (${wi(l).toLowerCase()} in models without it)`:""}${c.length?` + ${c.join(", ")}`:""}`}const sf=new WeakMap;function Sc(e){var _,x;const t=sf.get(e);if(t)return t;const i=e.metadata.id,a=new Set(e.layout.nodes.filter(v=>!v.attach).map(v=>v.metabolite)),s=new Map,o={};for(const v of e.biology.entities){let j=Dw(v,i);o[j]&&(j=`${i}/${v.id}`),s.set(v.id,j),o[j]=Pw(v,j)}const l={},r=new Map,c=v=>v??"unspecified",d=e.biology.metabolites.filter(v=>a.has(v.id));for(const v of d){const j=c(v.compartment);l[j]??(l[j]=af(e,v.compartment)),r.set(j,(r.get(j)??0)+1)}const f=(_=[...r.entries()].sort((v,j)=>j[1]-v[1])[0])==null?void 0:_[0];l.default=f?l[f]:af(e,"cytosol");const u=d.map(v=>{var j,N;return{slot:v.id,entity:s.get(v.entity)??`${i}/${v.entity}`,level:v.level,rule:c(v.compartment),...(j=v.alternatives)!=null&&j.length?{alternatives:v.alternatives.map(C=>s.get(C)).filter(C=>!!C)}:{},...v.label?{label:v.label}:{},...v.role?{role:v.role}:{},...v.ungrouped?{ungrouped:!0}:{},...(N=v.aliases)!=null&&N.length?{aliases:v.aliases}:{}}}),p=new Set(u.map(v=>v.slot)),m=[];for(const v of e.biology.reactions){const j=v.participants.filter(k=>k.main&&k.coefficient<0&&p.has(k.metabolite)).map(k=>k.metabolite),N=v.participants.filter(k=>k.main&&k.coefficient>0&&p.has(k.metabolite)).map(k=>k.metabolite);if(!j.length||!N.length)continue;const C=[...new Set([...v.identifiers["bigg.reaction"]??[],...v.hints??[],...(v.variants??[]).flatMap(k=>k.identifiers["bigg.reaction"]??[])])],w=[...new Set([...v.ec,...(v.variants??[]).flatMap(k=>k.ec)])];m.push({id:v.id,sources:j,targets:N,name:v.name,level:v.level,...w.length?{ec:w}:{},...C.length?{hints:C}:{},...(x=v.aliases)!=null&&x.length?{aliases:v.aliases}:{}})}const h={};for(const v of e.layout.nodes)!v.attach&&!h[v.metabolite]&&(h[v.metabolite]={x:v.x,y:v.y,...v.label_pos?{labelPos:v.label_pos}:{}});const g=new Map(e.layout.nodes.map(v=>[v.id,v.metabolite])),y={};for(const v of e.layout.reactions)y[v.reaction]={routing:v.routing,...v.bend!=null?{bend:v.bend}:{}};const b={id:i,name:e.metadata.name,version:e.metadata.template_version,author:e.metadata.authors.join(", ")||"unknown",description:e.metadata.description,section:e.metadata.section??"My templates",compartmentSummary:Iw(e),compartmentRules:l,biology:{slots:u,reactions:m,connectors:e.biology.connectors.filter(v=>p.has(v.metabolite)).map(v=>({slot:v.metabolite,direction:v.direction,...v.target.template?{to:v.target.template}:{}}))},layout:{kind:e.metadata.layout_kind==="free"||!e.metadata.layout_kind?"branched":e.metadata.layout_kind,nodes:h,reactions:y,groups:e.layout.groups.map(v=>({title:v.title,slots:[...new Set(v.nodes.map(j=>g.get(j)).filter(j=>!!j&&p.has(j)))]}))},entities:o,source:e};return sf.set(e,b),b}const cl=[$N,zN,Mw,vw,PN,ZN,iw,cw,fw],Ac=e=>Sc(cl.find(t=>t.metadata.id===e)),Bw=Ac("central-carbon"),Hw=Ac("glycolysis"),Ow=Ac("tca"),$w=Ac("ppp"),Lw=[Bw,Hw,Ow,$w],M1=(e,t)=>e.biology.slots.find(i=>i.slot===t)??e.biology.slots.find(i=>{var a;return(a=i.aliases)==null?void 0:a.includes(t)}),Ed=(e,t)=>({id:`chain-${t?"v":"h"}-${e}`,name:`${t?"Vertical":"Horizontal"} chain (${e})`,description:"Linear pathway skeleton",category:"shape",nodes:Array.from({length:e},(i,a)=>({key:`n${a}`,x:t?0:a*80,y:t?a*60:0,label:`M${a+1}`,labelPos:t?"right":"bottom"})),reactions:Array.from({length:e-1},(i,a)=>({sources:[`n${a}`],targets:[`n${a+1}`],label:`R${a+1}`}))}),of=e=>{const t=Math.max(60,60*e/(2*Math.PI));return{id:`cycle-${e}`,name:`Cycle (${e})`,description:"Circular pathway (TCA, urea, glyoxylate …)",category:"shape",nodes:Array.from({length:e},(i,a)=>{const s=-Math.PI/2+2*Math.PI*a/e,o=Math.round(t*Math.cos(s)),l=Math.round(t*Math.sin(s));return{key:`n${a}`,x:o,y:l,label:`M${a+1}`,labelPos:Math.abs(o)<5?l<0?"top":"bottom":o>0?"right":"left"}}),reactions:Array.from({length:e},(i,a)=>({sources:[`n${a}`],targets:[`n${(a+1)%e}`],label:`R${a+1}`,routing:"curved",bend:-Math.round(t*.12)}))}},Tw={id:"branch",name:"Branch point (1 → 3)",description:"Divergent node, e.g. pyruvate",category:"shape",nodes:[{key:"a",x:0,y:0,label:"A"},{key:"b",x:0,y:70,label:"B"},{key:"c",x:-90,y:140,label:"C",labelPos:"left"},{key:"d",x:0,y:140,label:"D"},{key:"e",x:90,y:140,label:"E"}],reactions:[{sources:["a"],targets:["b"],label:"R1"},{sources:["b"],targets:["c"],label:"R2"},{sources:["b"],targets:["d"],label:"R3"},{sources:["b"],targets:["e"],label:"R4"}]},Fw={id:"merge",name:"Condensation (2 → 1)",description:"Two substrates, one product (e.g. citrate synthase)",category:"shape",nodes:[{key:"a",x:-60,y:0,label:"A",labelPos:"left"},{key:"b",x:60,y:0,label:"B"},{key:"c",x:0,y:90,label:"C"}],reactions:[{sources:["a","b"],targets:["c"],label:"R1"}]};function Kp(e){var s;const t=e.biology.slots.map(o=>{const l=Is(e,o.entity),r=e.layout.nodes[o.slot];return{key:o.slot,x:r.x,y:r.y,label:o.label??(l==null?void 0:l.short)??o.slot,labelPos:r.labelPos,role:o.role,hints:l?[...[l,...(o.alternatives??[]).map(c=>Is(e,c))].flatMap(c=>(c==null?void 0:c.xrefs["bigg.metabolite"])??[]),l.name,...l.synonyms.slice(0,2)]:void 0}}),i=e.biology.reactions.map(o=>{var l;return{sources:o.sources,targets:o.targets,label:o.name,hints:o.hints,...((l=e.layout.reactions)==null?void 0:l[o.id])??{}}}),a=(s=e.layout.groups)==null?void 0:s.map(o=>({title:o.title,keys:o.slots,kind:"pathway"}));return{id:e.id,name:e.name,description:e.description,category:"pathway",nodes:t,reactions:i,groups:a,spec:e}}const zp=[...Lw.map(Kp),Ed(4,!0),Ed(6,!0),Ed(4,!1),of(6),of(8),Tw,Fw];function Xw(e,t,i="c"){const a=Object.values(e.metabolites);for(const s of t){if(e.metabolites[s])return s;const o=s.toLowerCase(),l=a.filter(r=>bt(r.id).toLowerCase()===o);if(l.length)return(l.find(r=>r.compartment===i)??l[0]).id}for(const s of t){const o=s.toLowerCase(),l=a.filter(r=>r.name.toLowerCase()===o);if(l.length)return(l.find(r=>r.compartment===i)??l[0]).id}}function Cs(e,t,i){const a=e.sources.map(o=>{var l;return(l=t[o])==null?void 0:l.metaboliteId}).filter(Boolean),s=e.targets.map(o=>{var l;return(l=t[o])==null?void 0:l.metaboliteId}).filter(Boolean);if(!a.length||!s.length)return!1;for(const o of a)for(const l of s){const r=Tp(i,o,l,e.hints??[],{ec:e.ec});if(r.length){const c=r[0];return e.reactionId=c.reactionIds[0],e.lumped=c.reactionIds.length>1?c.reactionIds:void 0,e.reversedToModel=c.reversed,!0}}return!1}function tu(e,t,i){const a={...e.nodes},s={...e.reactions};let o=0,l=0,r=0,c=0;for(const d of Object.values(a)){if(i&&!i.has(d.id)||d.template||d.attach||d.metaboliteId&&t.metabolites[d.metaboliteId])continue;r++;const f=[...d.hints??[],...d.label?[d.label]:[]],u=Xw(t,f);u&&(a[d.id]={...d,metaboliteId:u},o++)}for(const d of Object.values(s)){if(i&&!d.sources.concat(d.targets).some(u=>i.has(u))||d.reactionId&&t.reactions[d.reactionId])continue;c++;const f={...d};Cs(f,a,t)&&(s[d.id]=f,l++)}return{doc:{...e,nodes:a,reactions:s},nodes:o,reactions:l,totalNodes:r,totalReactions:c}}function Kw(e,t,i,a){const s=new Set(i),o=i.map(u=>t.nodes[u]).filter(Boolean),l=Math.min(...o.map(u=>u.x)),r=Math.min(...o.map(u=>u.y)),c=o.map(u=>{const p=u.metaboliteId&&(a==null?void 0:a.metabolites[u.metaboliteId]),m=Array.from(new Set([...u.metaboliteId?[bt(u.metaboliteId)]:[],...p?[p.name]:[],...u.hints??[]]));return{key:u.id,x:u.x-l,y:u.y-r,label:u.label??(u.metaboliteId?bt(u.metaboliteId):"M"),hints:m,labelPos:u.labelPos,role:u.role}}),d=Object.values(t.reactions).filter(u=>u.sources.every(p=>s.has(p))&&u.targets.every(p=>s.has(p))).map(u=>({sources:u.sources,targets:u.targets,routing:u.routing,bend:u.bend,role:u.role,label:u.label??(u.reactionId?bt(u.reactionId):void 0),hints:Array.from(new Set([...u.reactionId?[bt(u.reactionId)]:[],...(u.lumped??[]).map(bt),...u.hints??[]]))})),f=Object.values(t.groups).filter(u=>u.nodeIds.some(p=>s.has(p))).map(u=>({title:u.title,keys:u.nodeIds.filter(p=>s.has(p)),kind:u.kind}));return{id:"user-"+Date.now().toString(36),name:e,description:`${c.length} slots · ${d.length} reactions`,category:"user",nodes:c,reactions:d,groups:f}}const E1="gemsmap.userTemplates";function zw(){try{return JSON.parse(localStorage.getItem(E1)||"[]")}catch{return[]}}function lf(e){try{localStorage.setItem(E1,JSON.stringify(e))}catch{}}const Ft=Ts(()=>({user:[],loaded:!1})),G1="templates.library.v1";let rf=null;function S1(){return rf??(rf=Cc(G1).then(e=>{Ft.setState({user:Array.isArray(e)?e.map(t=>({...t,format:Ka})):[],loaded:!0})})),rf}const A1=()=>Xr(G1,Ft.getState().user),Up=e=>cl.some(t=>t.metadata.id===e);function Dc(e=Ft.getState().user){return[...cl.map(t=>({file:t,kind:"builtin"})),...[...e].sort((t,i)=>i.metadata.modified.localeCompare(t.metadata.modified)).map(t=>({file:t,kind:"user"}))]}function D1(e){return cl.find(t=>t.metadata.id===e)??Ft.getState().user.find(t=>t.metadata.id===e)}function Uw(e){const t=D1(e);return t?Sc(t):void 0}function dl(e){if(Up(e.metadata.id))throw new Error("Built-in templates are read-only — duplicate it first");const t={...e,format:Ka,schema_version:Fp,metadata:{...e.metadata,modified:new Date().toISOString()}},i=Ft.getState().user.filter(a=>a.metadata.id!==t.metadata.id);return Ft.setState({user:[...i,t]}),A1(),t}function qw(e){Ft.setState({user:Ft.getState().user.filter(t=>t.metadata.id!==e)}),A1()}const qp=()=>`tpl_${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-4)}`;function Vp(e,t){const i=new Date().toISOString(),a=structuredClone(e);return a.metadata={...a.metadata,id:qp(),name:t??`${e.metadata.name} — copy`,template_version:"1.0.0",created:i,modified:i,section:"My templates",derived_from:{id:e.metadata.id,name:e.metadata.name,template_version:e.metadata.template_version}},delete a.validation,a}const dn={CYTOSOL:"cytosol",MITOCHONDRION:"mitochondrion",MITO_IMS:"mitochondrial intermembrane space",EXTRACELLULAR:"extracellular",PERIPLASM:"periplasm",NUCLEUS:"nucleus",PEROXISOME:"peroxisome",ER:"endoplasmic reticulum",GOLGI:"Golgi",VACUOLE:"vacuole",LYSOSOME:"lysosome",CHLOROPLAST:"chloroplast / plastid",THYLAKOID:"thylakoid",CELL_ENVELOPE:"cell envelope / membrane",BOUNDARY:"boundary",UNKNOWN:"unknown compartment",INTRACELLULAR:"intracellular"},Vw=new Set(["EXTRACELLULAR","BOUNDARY","PERIPLASM"]),P1=new Set(["MITOCHONDRION","MITO_IMS","NUCLEUS","PEROXISOME","ER","GOLGI","VACUOLE","LYSOSOME","CHLOROPLAST","THYLAKOID"]),Zo=e=>!Vw.has(e)&&e!=="UNKNOWN",cf=[[/intermembrane/,"MITO_IMS"],[/mitochond|^mito\b|matrix/,"MITOCHONDRION"],[/cyto(sol|plasm)|^cytosolic|^cyt$/,"CYTOSOL"],[/extra.?cellular|^external|^extraorganism|^medium$|^environment/,"EXTRACELLULAR"],[/periplasm/,"PERIPLASM"],[/peroxisom|glyoxysom|microbod/,"PEROXISOME"],[/endoplasmic|reticulum/,"ER"],[/golgi/,"GOLGI"],[/vacuol/,"VACUOLE"],[/lysosom/,"LYSOSOME"],[/nucle(us|ar|oplasm)/,"NUCLEUS"],[/thylakoid/,"THYLAKOID"],[/chloroplast|plastid|stroma/,"CHLOROPLAST"],[/boundary/,"BOUNDARY"],[/envelope|membrane/,"CELL_ENVELOPE"]],df={c:"CYTOSOL",cy:"CYTOSOL",cyt:"CYTOSOL",cyto:"CYTOSOL",cytosol:"CYTOSOL",cytoplasm:"CYTOSOL",m:"MITOCHONDRION",mi:"MITOCHONDRION",mt:"MITOCHONDRION",mito:"MITOCHONDRION",mitochondria:"MITOCHONDRION",mitochondrion:"MITOCHONDRION",im:"MITO_IMS",e:"EXTRACELLULAR",ex:"EXTRACELLULAR",ext:"EXTRACELLULAR",extr:"EXTRACELLULAR",extracellular:"EXTRACELLULAR",x:"PEROXISOME",px:"PEROXISOME",per:"PEROXISOME",r:"ER",er:"ER",g:"GOLGI",n:"NUCLEUS",v:"VACUOLE",vac:"VACUOLE",l:"LYSOSOME",h:"CHLOROPLAST",chl:"CHLOROPLAST",u:"THYLAKOID",b:"BOUNDARY",boundary:"BOUNDARY"};function mf(e,t,i){const a=(t||"").toLowerCase().trim();for(const[o,l]of cf)if(a&&o.test(a))return{canonical:l,source:"name"};const s=e.toLowerCase().replace(/^c_/,"").replace(/\d+$/,"");if(s==="p")return{canonical:i?"PEROXISOME":"PERIPLASM",source:"context"};if(df[s])return{canonical:df[s],source:"id"};for(const[o,l]of cf)if(o.test(s))return{canonical:l,source:"id"};return{canonical:"UNKNOWN",source:"unknown"}}function R1(e){const t=new Set(Object.keys(e.compartments));for(const o of Object.values(e.metabolites))t.add(o.compartment);const i=[...t].map(o=>({id:o,name:e.compartments[o]??"",...mf(o,e.compartments[o]??"",!1)})),a=i.some(o=>P1.has(o.canonical)),s=new Map;for(const o of i)s.set(o.id,o.source==="context"?{...o,...mf(o.id,o.name,a)}:o);return s}function Ww(e,t){const i=new Set;for(const l of Object.values(t.metabolites))i.add(l.compartment);const a=new Set;for(const[l,r]of e)i.has(l)&&a.add(r.canonical);const s=[...a].filter(l=>P1.has(l)),o=[...a].filter(Zo);return s.length?{kind:"eukaryote-like",present:a,summary:`Eukaryote-like compartments: ${s.map(l=>dn[l]).join(", ")}`}:o.length<=1?{kind:a.has("PERIPLASM")?"prokaryote-like":"single-compartment",present:a,summary:a.has("PERIPLASM")?"Prokaryote-like (cytoplasm + periplasm)":"One intracellular compartment (prokaryote-like or compartment-free model)"}:{kind:"prokaryote-like",present:a,summary:"No organelles detected (prokaryote-like)"}}function Yw(e,t){const i=s=>s==="INTRACELLULAR"?t.present.has("CYTOSOL")?"CYTOSOL":[...t.present].find(Zo)??null:t.present.has(s)?s:null;for(const s of e.preferred){const o=i(s);if(o)return{expected:o,usedFallback:!1}}const a=e.preferred.map(s=>dn[s]).join(" / ");for(const s of e.fallback??[]){const o=i(s);if(o)return{expected:o,usedFallback:!0,message:`Expected ${a}; no such compartment in this model — searching the ${dn[o]}.`}}return{expected:null,usedFallback:!0,message:`Expected ${a}; no compatible compartment found in this model.`}}const sa={"kegg.compound":"KEGG",chebi:"ChEBI","bigg.metabolite":"BiGG","metanetx.chemical":"MetaNetX","seed.compound":"ModelSEED","metacyc.compound":"MetaCyc",hmdb:"HMDB",vmh:"VMH",reactome:"Reactome",inchikey:"InChIKey","pubchem.compound":"PubChem",lipidmaps:"LIPID MAPS","kegg.reaction":"KEGG reaction","bigg.reaction":"BiGG reaction","metanetx.reaction":"MetaNetX reaction","seed.reaction":"ModelSEED reaction","metacyc.reaction":"MetaCyc reaction",rhea:"Rhea","ec-code":"EC"},Zw={kegg:"kegg.compound",keggcompound:"kegg.compound",keggid:"kegg.compound",keggcpd:"kegg.compound",keggligand:"kegg.compound",chebi:"chebi",chebiid:"chebi",bigg:"bigg.metabolite",biggmetabolite:"bigg.metabolite",biggid:"bigg.metabolite",metanetx:"metanetx.chemical",metanetxchemical:"metanetx.chemical",mnx:"metanetx.chemical",mnxm:"metanetx.chemical",metanetxmnxchemical:"metanetx.chemical",seed:"seed.compound",seedcompound:"seed.compound",modelseed:"seed.compound",modelseedcompound:"seed.compound",metacyc:"metacyc.compound",metacyccompound:"metacyc.compound",biocyc:"metacyc.compound",hmdb:"hmdb",vmh:"vmh",vmhmetabolite:"vmh",reactome:"reactome",reactomecompound:"reactome",inchikey:"inchikey",pubchem:"pubchem.compound",pubchemcompound:"pubchem.compound",lipidmaps:"lipidmaps",keggreaction:"kegg.reaction",biggreaction:"bigg.reaction",metanetxreaction:"metanetx.reaction",seedreaction:"seed.reaction",metacycreaction:"metacyc.reaction",rhea:"rhea",eccode:"ec-code",ec:"ec-code",ecnumber:"ec-code"},Qw=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function ri(e,t){let i=t.trim();if(!i)return null;switch(i=i.replace(/^https?:\/\/[^/]*(identifiers\.org|bioregistry\.io|n2t\.net)\/+/i,""),i=i.replace(/^([a-z][a-z.]*)[/:](?=.)/i,(a,s)=>nu(s)?"":a),e){case"kegg.compound":{const a=i.match(/\b([CDG]\d{5})\b/i);if(!a)return null;const s=a[1].toUpperCase();return s[0]==="C"?`kegg.compound:${s}`:null}case"chebi":{const a=i.match(/(\d+)\s*$/);return a?`chebi:${+a[1]}`:null}case"metanetx.chemical":{const a=i.match(/(MNXM\d+|WATER|BIOMASS)/i);return a?`metanetx.chemical:${a[1].toUpperCase()}`:null}case"seed.compound":{const a=i.match(/cpd\d{5}/i);return a?`seed.compound:${a[0].toLowerCase()}`:null}case"hmdb":{const a=i.match(/HMDB(\d+)/i);return a?`hmdb:HMDB${a[1].padStart(7,"0")}`:null}case"metacyc.compound":{const a=i.replace(/^(META|METACYC|BIOCYC)[:/]/i,"").trim();return a?`metacyc.compound:${a.toUpperCase()}`:null}case"inchikey":{const a=i.match(/[A-Z]{14}-[A-Z]{10}-[A-Z]/i);return a?`inchikey:${a[0].toUpperCase()}`:null}case"bigg.metabolite":{const a=i.replace(/^M_/,"");return a?`bigg.metabolite:${a}`:null}case"kegg.reaction":{const a=i.match(/R\d{5}/i);return a?`kegg.reaction:${a[0].toUpperCase()}`:null}case"metanetx.reaction":{const a=i.match(/MNXR\d+/i);return a?`metanetx.reaction:${a[0].toUpperCase()}`:null}case"seed.reaction":{const a=i.match(/rxn\d{5}/i);return a?`seed.reaction:${a[0].toLowerCase()}`:null}case"rhea":{const a=i.match(/(\d+)\s*$/);return a?`rhea:${+a[1]}`:null}case"ec-code":{const a=i.match(/\d+\.[\d-]+\.[\d-]+\.[\dn-]+/);return a?`ec-code:${a[0]}`:null}default:return`${e}:${i}`}}function nu(e){return Zw[Qw(e)]??null}function Jw(e){const t=new Set;if(!e)return t;const i=(a,s)=>{for(const o of s.split(/[;,|]\s*|\s+/)){let l=a;const r=o.match(/identifiers\.org\/+([a-z.]+)[/:]/i)??o.match(/^(CHEBI|MNXM|HMDB|cpd(?=\d)|C\d{5})/i);if(r){const d=r[1];l=/^chebi$/i.test(d)?"chebi":/^mnxm$/i.test(d)?"metanetx.chemical":/^hmdb$/i.test(d)?"hmdb":/^cpd$/i.test(d)?"seed.compound":/^C\d{5}$/i.test(d)?l??"kegg.compound":nu(d)??l}if(!l)continue;const c=ri(l,o);c&&t.add(c)}};for(const[a,s]of Object.entries(e)){const o=nu(a),l=Array.isArray(s)?s:[s];for(const r of l)typeof r=="string"&&i(o,r)}return t}function eC(e,t){const i=[],a=e.replace(/^M_/,""),s=a.match(/^(C\d{5})(?![0-9])/);s&&i.push(`kegg.compound:${s[1]}`);const o=a.match(/^(cpd\d{5})(?![0-9])/i);o&&i.push(`seed.compound:${o[1].toLowerCase()}`);const l=a.match(/^(MNXM\d+)(?![0-9])/);return l&&i.push(`metanetx.chemical:${l[1]}`),i.length?{xrefs:i,biggBase:null}:{xrefs:i,biggBase:tC(a,t)}}function tC(e,t){const i=t.replace(/^C_/,""),a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(i){const s=new RegExp(`(\\[${a}\\]|\\(${a}\\)|[_-]${a})$`);if(s.test(e))return e.replace(s,"")}return e.replace(/\[[a-z0-9]+\]$/i,"")}const Wp=e=>e.toLowerCase().replace(/[-_]+/g,"_"),nC={α:"alpha",β:"beta",γ:"gamma",δ:"delta",ω:"omega"},uf="cytosol|cytoplasm|cytoplasmic|mitochondri[a-z]*|extracellular|periplasm|peroxisom[a-z]*|nucleus|vacuol[a-z]*|golgi|endoplasmic reticulum|lysosom[a-z]*|chloroplast|plastid|boundary",iC=[/\s*\[[^\]]{1,24}\]\s*$/,new RegExp(`\\s*\\((?:${uf})\\)\\s*$`),new RegExp(`\\s*[-,]\\s*(?:${uf})\\s*$`),/\s*\(\s*\d*\s*[+-]\s*\d*\s*\)\s*$/];function Yp(e){let t=(e||"").normalize("NFKC");t=t.replace(/[αβγδω]/g,i=>nC[i]).toLowerCase(),t=t.replace(/[‐-―−]/g,"-").replace(/[′’]/g,"'");for(let i=0;i<2;i++)for(const a of iC)t=t.replace(a,"");return t.replace(/\s+/g," ").replace(/^[\s.,;:]+|[\s.,;:]+$/g,"")}const $t=e=>Yp(e).replace(/[\s\-,'()[\]{}_]/g,""),I1=e=>$t(Yp(e).replace(/(^|[\s(,-])(alpha|beta|a|b)-(?=[a-z(])/g,"$1").replace(/(pyranose|furanose)/g,"ose"));function pf(e){const t=Yp(e),i=new Set,a=new Set;for(const s of t.matchAll(/(?:^|[\s,(-])(dl|d|l)-(?=[a-z0-9(])/g))i.add(s[1]);for(const s of t.matchAll(/\((\d*[rs](?:,\d*[rs])*)\)-/g))for(const o of s[1].split(","))a.add(o.replace(/\d/g,""));return{dl:i,rs:a}}function aC(e,t){const i=pf(e),a=pf(t),s=(o,l)=>o.size>0&&l.size>0&&![...o].some(r=>l.has(r));return s(i.dl,a.dl)||s(i.rs,a.rs)}function iu(e){if(!e||/[()*]|R(?![a-z])|X(?![a-z])|n$/.test(e))return null;const t={};for(const i of e.matchAll(/([A-Z][a-z]?)(\d*)/g))!i[1]||i[1]==="H"||(t[i[1]]=(t[i[1]]??0)+(i[2]?+i[2]:1));return Object.keys(t).length?t:null}function sC(e,t){const i=iu(e),a=iu(t);if(!i||!a)return null;const s=new Set([...Object.keys(i),...Object.keys(a)]);for(const o of s)if((i[o]??0)!==(a[o]??0))return"conflict";return"match"}const hf=new WeakMap,oC=new Set([...["C00001","C00002","C00003","C00004","C00005","C00006","C00007","C00008","C00009","C00010","C00011","C00013","C00014","C00020","C00080"].map(e=>`kegg.compound:${e}`),...["cpd00001","cpd00002","cpd00003","cpd00004","cpd00005","cpd00006","cpd00007","cpd00008","cpd00009","cpd00010","cpd00011","cpd00012","cpd00013","cpd00018","cpd00067"].map(e=>`seed.compound:${e}`)]),lC=/^(coa|coenzyme-?a|h\+?|proton|ammonia|nh3|pyrophosphate|diphosphate)$/i,Qa=(e,t,i)=>{if(!t)return;const a=e.get(t);a?a.includes(i)||a.push(i):e.set(t,[i])};function oa(e){var x;const t=hf.get(e);if(t)return t;const i=R1(e),a=Ww(i,e),s=new Map,o=new Map,l=new Map,r=new Map,c=new Map,d=new Map,f=new Map;for(const v of Object.values(e.metabolites)){const j=Jw(v.annotation),{xrefs:N,biggBase:C}=eC(v.id,v.compartment),w={id:v.id,name:v.name,formula:v.formula,compartment:v.compartment,canonical:((x=i.get(v.compartment))==null?void 0:x.canonical)??"UNKNOWN",xrefs:j,idXrefs:N,biggBase:C,compact:$t(v.name),relaxed:I1(v.name)};s.set(v.id,w);for(const k of j)Qa(o,k,v.id);for(const k of N)Qa(l,k,v.id);C&&(Qa(r,C,v.id),Qa(c,Wp(C),v.id)),Qa(d,w.compact,v.id),Qa(f,w.relaxed,v.id)}const u=v=>{const j=e.metabolites[v];if(!j)return!1;if(Fa(j)||lC.test(j.name.trim()))return!0;const N=s.get(v);return!!N&&[...N.idXrefs,...N.xrefs].some(C=>oC.has(C))},p=v=>{var j;return((j=s.get(v))==null?void 0:j.relaxed)||v},m=new Map,h=v=>{let j=m.get(v);if(j!==void 0)return j;const N=e.reactions[v];if(j=!1,N&&new Set(Object.keys(N.stoichiometry).map(w=>{var k;return(k=e.metabolites[w])==null?void 0:k.compartment})).size>1){const w=H=>new Set(Object.entries(N.stoichiometry).filter(([G,M])=>M*H>0&&!u(G)).map(([G])=>p(G))),k=w(-1),P=w(1);j=k.size>0&&k.size===P.size&&[...k].every(H=>P.has(H))}return m.set(v,j),j},g=new Map,y=Gc(e),b=v=>{let j=g.get(v);if(j)return j;j=new Map;for(const N of y.get(v)??[]){if(h(N))continue;const C=e.reactions[N],w=C.stoichiometry[v];for(const[k,P]of Object.entries(C.stoichiometry))k===v||Math.sign(P)===Math.sign(w)||u(k)||j.has(k)||j.set(k,N)}return g.set(v,j),j},_={model:e,fingerprint:cC(e),compartments:i,context:a,mets:s,byXref:o,byIdXref:l,byBigg:r,byBiggLoose:c,byCompact:d,byRelaxed:f,neighbours:b,isTransport:h,isCurrency:u};return hf.set(e,_),_}function rC(e,t=0){let i=3735928559^t,a=1103547991^t;for(let s=0;s<e.length;s++){const o=e.charCodeAt(s);i=Math.imul(i^o,2654435761),a=Math.imul(a^o,1597334677)}return i=Math.imul(i^i>>>16,2246822507)^Math.imul(a^a>>>13,3266489909),a=Math.imul(a^a>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),(4294967296*(2097151&a)+(i>>>0)).toString(16).padStart(14,"0")}const ff=new WeakMap;function cC(e){const t=ff.get(e);if(t)return t;const i=Object.values(e.metabolites).map(o=>`${o.id}@${o.compartment}`).sort().join("|"),a=Object.values(e.reactions).filter(o=>{var l;return!((l=o.meta)!=null&&l.virtual)}).map(o=>`${o.id}:${Object.entries(o.stoichiometry).sort(([l],[r])=>l<r?-1:1).map(([l,r])=>`${l}*${+r.toFixed(6)}`).join(",")}`).sort().join("|"),s=rC(i+"#"+a);return ff.set(e,s),s}const Pc=(e,t)=>`${e}@${t??"any"}`,B1="gemsmap.mappingProfiles",dC=30;function H1(){try{return JSON.parse(localStorage.getItem(B1)||"{}")}catch{return{}}}function la(e){return H1()[e]??null}function bo(e){try{const t=H1();t[e.fingerprint]=e;const i=Object.values(t).sort((a,s)=>s.updated.localeCompare(a.updated)).slice(0,dC);localStorage.setItem(B1,JSON.stringify(Object.fromEntries(i.map(a=>[a.fingerprint,a]))))}catch{}}function au(e,t,i){const a=new Date().toISOString(),s=e&&e.fingerprint===t.fingerprint?e:{fingerprint:t.fingerprint,modelId:t.id,modelName:t.name,updated:a,entries:{}};return{...s,updated:a,entries:{...s.entries,[Pc(i.entity,i.compartment)]:{...i,confirmedAt:a}}}}function mC(e,t,i){const a={...e.entries};return delete a[Pc(t,i)],{...e,updated:new Date().toISOString(),entries:a}}function uC(e){const t=la(e.fingerprint);bo(t?{...t,entries:{...e.entries,...t.entries}}:e)}const pC="1.0.0",O1=.8,su=.55,hC=.08,fC=e=>e>=O1?"high":e>=su?"medium":"low",ei=e=>e==="confirmed"||e==="auto_high"||e==="provisional",gf=e=>1-e.reduce((t,i)=>t*(1-i),1),Gd=e=>Math.round(e*100)/100,bf=new WeakMap;function $1(e){const t=bf.get(e);if(t)return t;const i=s=>Object.entries(s).flatMap(([o,l])=>o==="bigg.metabolite"?[]:(l??[]).map(r=>ri(o,r)??`${o}:${r}`)),a={exact:new Set(i(e.xrefs)),related:new Map,bigg:new Set(e.xrefs["bigg.metabolite"]??[]),biggRelated:new Map,biggLoose:new Set((e.xrefs["bigg.metabolite"]??[]).map(Wp)),names:new Set([e.name,...e.synonyms].map($t)),relaxed:new Set([e.name,...e.synonyms].map(I1)),relatedNames:new Map};for(const s of e.related??[]){for(const o of i(s.xrefs))a.related.set(o,s.note);for(const o of s.xrefs["bigg.metabolite"]??[])a.biggRelated.set(o,s.note);for(const o of s.names)a.relatedNames.set($t(o),s.note)}return bf.set(e,a),a}const Hl=e=>{const t=e.indexOf(":");return`${sa[e.slice(0,t)]??e.slice(0,t)} ${e.slice(t+1)}`};function gC(e,t){const i=$1(t),a=new Set,s=o=>o==null?void 0:o.forEach(l=>a.add(l));for(const o of[...i.exact,...i.related.keys()])s(e.byXref.get(o)),s(e.byIdXref.get(o));for(const o of[...i.bigg,...i.biggRelated.keys()])s(e.byBigg.get(o));for(const o of i.biggLoose)s(e.byBiggLoose.get(o));for(const o of[...i.names,...i.relatedNames.keys()])s(e.byCompact.get(o));for(const o of i.relaxed)s(e.byRelaxed.get(o));return a}function yf(e,t){const i=$1(t),a=[],s=[],o=[];let l=null;const r=[...e.xrefs].filter(_=>i.exact.has(_)),c=[...e.xrefs].filter(_=>i.related.has(_)),d=e.idXrefs.filter(_=>i.exact.has(_)),f=e.idXrefs.filter(_=>i.related.has(_)),u=!!e.biggBase&&i.bigg.has(e.biggBase),p=e.biggBase?i.biggRelated.get(e.biggBase):void 0,m=!u&&!p&&!!e.biggBase&&i.biggLoose.has(Wp(e.biggBase));if(r.length){const _=new Set(r.map(x=>x.slice(0,x.indexOf(":"))));s.push(Math.min(.92,.85+.035*(_.size-1))),a.push({channel:"annotation",ok:!0,text:`${r.slice(0,3).map(Hl).join(", ")} in the model annotation`}),l="model annotation",o.push("ID")}else(d.length||u)&&(s.push(.7),a.push({channel:"id",ok:!0,text:d.length?`ID ${e.id} encodes ${d.map(Hl).join(", ")}`:`ID ${e.id} is the BiGG identifier ${e.biggBase}`}),l="ID pattern",o.push("ID"));if(!r.length&&!d.length&&!u){const _=c[0]??f[0];if(_||p){s.push(c.length?.6:.5);const x=_?i.related.get(_):p;a.push({channel:"related",ok:!0,text:`${_?Hl(_):`BiGG ${e.biggBase}`} — ${x} (related form, not the exact identity)`}),l="related form",o.push("related-form ID")}else m&&(s.push(.45),a.push({channel:"id",ok:!0,text:`ID ${e.id} resembles BiGG ${[...i.bigg][0]} (string similarity only)`}),l="ID pattern",o.push("ID-like"))}const h=i.names.has(e.compact),g=!h&&(i.relaxed.has(e.relaxed)||i.relatedNames.has(e.compact));if(h?(s.push(.6),a.push({channel:"name",ok:!0,text:`Name “${e.name}” matches ${t.name}`}),l??(l="name"),o.push("name")):g&&(s.push(.4),a.push({channel:"name",ok:!0,text:`Name “${e.name}” matches ${t.name} up to anomeric/ring form`}),l??(l="related form"),o.push("related name")),!s.length)return{identity:0,evidence:a,method:"name",parts:o};const y=sC(e.formula,t.formula);let b=gf(s);if(y==="match"?(b=gf([b,.25]),a.push({channel:"formula",ok:!0,text:`Formula ${e.formula} consistent with ${t.formula} (H not compared)`}),o.push("formula")):y==="conflict"?(b*=.35,a.push({channel:"formula",ok:!1,text:`Formula ${e.formula} differs from ${t.formula}`})):a.push({channel:"formula",ok:null,text:e.formula?`Formula ${e.formula} not comparable`:"No formula in the model"}),!h&&aC(e.name,t.name)&&(b*=.3,a.push({channel:"stereo",ok:!1,text:`Stereochemistry of “${e.name}” contradicts ${t.name}`})),!r.length&&!c.length&&e.xrefs.size){const _=[...e.xrefs].filter(x=>{const v=x.slice(0,x.indexOf(":"));return[...i.exact].some(j=>j.startsWith(v+":"))});_.length&&(b*=.6,a.push({channel:"annotation",ok:!1,text:`Annotated as ${_.slice(0,2).map(Hl).join(", ")}, not ${t.name}`}))}return{identity:Math.min(.99,b),evidence:a,method:l??"name",parts:o}}function xf(e,t,i){const a=e.compartments.get(t.compartment),s=`${t.compartment}${a!=null&&a.name&&a.name!==t.compartment?` “${a.name}”`:""}`,o=dn[t.canonical];if(!i.expected)return{factor:Zo(t.canonical)?.8:.4,ev:{channel:"compartment",ok:null,text:`${o} (${s}); no expected compartment in this model`}};if(t.canonical===i.expected)return i.usedFallback?{factor:.97,ev:{channel:"compartment",ok:!0,text:`${o} (${s}) — fallback compartment for this model`}}:{factor:1,ev:{channel:"compartment",ok:!0,text:`${o} (${s}) as expected`}};const l=dn[i.expected];return t.canonical==="UNKNOWN"?{factor:.8,ev:{channel:"compartment",ok:null,text:`Compartment ${s} not recognised; expected ${l}`}}:Zo(t.canonical)?{factor:.65,ev:{channel:"compartment",ok:!1,text:`${o} (${s}) — expected ${l}`}}:{factor:.35,ev:{channel:"compartment",ok:!1,text:`${o} (${s}) — expected ${l}; outside the cell is transport, not pathway chemistry`}}}function bC(e,t,i){const a=e.neighbours(t);for(const[s,o]of a)if(i.has(s))return{strength:1,text:`${s} via ${o}`};for(const[s,o]of a){const l=e.neighbours(s);if(!(l.size>40)){for(const[r,c]of l)if(r!==t&&i.has(r))return{strength:.6,text:`${r} in two steps (${o} → ${s} → ${c})`}}}return null}function Zp(e,t,i={}){const a=oa(t),s=new Set,o=xC(e),l=e.biology.slots.map(x=>{var H,G;const v=Is(e,x.entity);if(!v)throw new Error(`Template ${e.id}: unknown entity ${x.entity}`);const j=e.compartmentRules[x.rule??"default"]??e.compartmentRules.default,N=Yw(j,a.context);N.message&&s.add(j.note?`${j.note} ${N.message}`:N.message);const C={slot:x,entity:v,expected:N,base:[],ranked:[]},w=new Set,k=[v,...(x.alternatives??[]).map(M=>Is(e,M)).filter(M=>!!M)];for(const M of k)for(const A of gC(a,M)){if(w.has(A))continue;const X=a.mets.get(A),I=yf(X,M);if(I.identity<.3)continue;w.add(A);const K=M!==v,L=xf(a,X,N);C.base.push({metId:A,name:X.name,compartment:X.compartment,compartmentLabel:dn[X.canonical],identity:I.identity*(K?.85:1),compartmentFactor:L.factor,method:I.method,parts:I.parts,entity:M.id,evidence:[...K?[{channel:"name",ok:null,text:`Alternative entity for this slot: ${M.name}`}]:[],...I.evidence,L.ev]})}const P=i.overrides&&x.slot in i.overrides?i.overrides[x.slot]:void 0;if(P!==void 0)C.forced={metId:P,method:"user choice"};else{const M=(H=i.profile)==null?void 0:H.entries[Pc(v.id,N.expected)];M&&(M.metaboliteId===null||t.metabolites[M.metaboliteId]?C.forced={metId:M.metaboliteId,method:"saved profile",via:M.via}:C.staleProfile=`Saved mapping ${M.metaboliteId} is no longer in this model`)}if((G=C.forced)!=null&&G.metId&&!w.has(C.forced.metId)){const M=a.mets.get(C.forced.metId);if(M){const A=yf(M,v),X=xf(a,M,N);C.base.push({metId:M.id,name:M.name,compartment:M.compartment,compartmentLabel:dn[M.canonical],identity:A.identity,compartmentFactor:X.factor,method:A.method,parts:A.parts,entity:v.id,evidence:[...A.evidence,X.ev]})}}return C}),r=new Map(l.map(x=>[x.slot.slot,x]));let c=new Map;for(let x=0;x<2;x++){const v=new Map;for(const j of l){const N=c.get(j.slot.slot);x===1&&(N!=null&&N.chosen)?v.set(j.slot.slot,new Set([N.chosen.metId])):v.set(j.slot.slot,new Set([...j.base].sort((C,w)=>w.identity*w.compartmentFactor-C.identity*C.compartmentFactor).filter(C=>C.identity*C.compartmentFactor>=.4).slice(0,6).map(C=>C.metId)))}for(const j of l){const N=(o.get(j.slot.slot)??[]).filter(C=>{var w;return(((w=v.get(C.slot))==null?void 0:w.size)??0)>0});j.ranked=j.base.map(C=>{const w=[...C.evidence];let k=1;if(N.length){let M=0;for(const A of N){const X=bC(a,C.metId,v.get(A.slot)),I=r.get(A.slot).entity.name;M+=(X==null?void 0:X.strength)??0,w.push(X?{channel:"topology",ok:!0,text:`Linked to ${I}: ${X.text}${X.strength===1?` (template step ${A.step})`:""}`}:{channel:"topology",ok:!1,text:`No reaction to any ${I} candidate (template step ${A.step})`})}k=.7+.35*(M/N.length)}else a.neighbours(C.metId).size||(k=.75,w.push({channel:"topology",ok:!1,text:"Not converted by any chemical reaction in the model"}));const P=Gd(Math.min(.99,C.identity*C.compartmentFactor*k)),H=[...C.parts],G=`${H.length?H.join(" + ")+" match":"Weak match"}${C.compartmentFactor<.9?", compartment mismatch":""}${k>=1?" · pathway-linked":k<=.75&&N.length?" · no pathway link":""}`;return{metId:C.metId,name:C.name,compartment:C.compartment,compartmentLabel:C.compartmentLabel,identity:Gd(C.identity),compartmentFactor:C.compartmentFactor,topologyFactor:Gd(k),score:P,confidence:fC(P),method:C.method,evidence:w,summary:G,entity:C.entity}}).sort((C,w)=>w.score-C.score||C.metId.localeCompare(w.metId))}c=yC(l)}const d=l.map(x=>{const v=c.get(x.slot.slot);return{slot:x.slot,entity:x.entity,expected:x.expected,status:v.status,chosen:v.chosen,candidates:x.ranked.slice(0,8),reason:v.reason,staleProfile:x.staleProfile}}),f=new Map;for(const x of d){if(!x.chosen||!x.expected.expected)continue;const v=f.get(x.expected.expected)??{off:0,total:0,where:new Map};v.total++;const j=a.mets.get(x.chosen.metId).canonical;j!==x.expected.expected&&(v.off++,v.where.set(j,(v.where.get(j)??0)+1)),f.set(x.expected.expected,v)}for(const[x,v]of f)if(v.total>=3&&v.off/v.total>.5){const j=[...v.where.entries()].sort((N,C)=>C[1]-N[1])[0][0];s.add(`Expected ${dn[x]}, but most mapped metabolites are in the ${dn[j]} — check whether the model places this pathway there.`)}const u=new Map(d.filter(x=>x.chosen&&ei(x.status)).map(x=>[x.slot.slot,x.chosen.metId])),p=e.biology.reactions.map(x=>{for(const v of x.sources)for(const j of x.targets){const N=u.get(v),C=u.get(j);if(!N||!C)continue;const w=Tp(t,N,C,x.hints??[],{ec:x.ec});if(w.length)return{spec:x,reactionIds:w[0].reactionIds,mapped:!0}}return{spec:x,reactionIds:[],mapped:!1}}),m=d.filter(x=>x.slot.level==="required"),h=p.filter(x=>x.spec.level==="required"),g=m.filter(x=>ei(x.status)),y={core:m.length,coreMapped:g.length,all:d.length,allMapped:d.filter(x=>ei(x.status)).length,coreReactions:h.length,coreReactionsMapped:h.filter(x=>x.mapped).length},b=d.filter(x=>ei(x.status)),_=b.length?b.some(x=>x.status==="provisional")||d.some(x=>x.status==="ambiguous")?"medium":"high":"low";return{templateId:e.id,templateVersion:e.version,engineVersion:pC,model:{id:t.id,name:t.name,fingerprint:a.fingerprint},context:a.context,notes:[...s],slots:d,reactions:p,coverage:y,quality:_}}function yC(e){const t=new Map,i=new Map;for(const s of e){if(!s.forced)continue;if(s.forced.metId===null){t.set(s.slot.slot,{status:"absent",reason:`Marked as absent from this model (${s.forced.method})`});continue}const o=s.ranked.find(c=>c.metId===s.forced.metId);if(!o)continue;const l=s.forced.method==="user choice"?"Chosen by the user":s.forced.via?`Same compound as ${s.forced.via}, chosen for this model in another compartment`:"Confirmed earlier for this model (mapping profile)",r={...o,method:s.forced.method,evidence:[{channel:"user",ok:!0,text:l},...o.evidence]};t.set(s.slot.slot,{status:"confirmed",chosen:r,reason:s.forced.method==="user choice"?"Chosen by the user":s.forced.via?`Same compound as ${s.forced.via} (other compartment)`:"Confirmed earlier for this model"}),i.set(o.metId,s.slot.slot)}const a=e.filter(s=>!t.has(s.slot.slot)).sort((s,o)=>{var l,r;return(((l=o.ranked[0])==null?void 0:l.score)??0)-(((r=s.ranked[0])==null?void 0:r.score)??0)});for(const s of a){for(const f of s.ranked){const u=i.get(f.metId);u?f.usedBy=u:delete f.usedBy}const o=s.ranked.filter(f=>!f.usedBy),l=o[0],r=o.find(f=>f.metId!==(l==null?void 0:l.metId)),c=s.entity.name;if(!l){t.set(s.slot.slot,{status:"unresolved",reason:s.ranked.length?"The only candidates are already used by other slots":`No metabolite in the model looks like ${c}`});continue}if(!!r&&l.score-r.score<hC&&r.score>=su){t.set(s.slot.slot,{status:"ambiguous",reason:`${l.metId} and ${r.metId} are equally plausible for ${c} — please choose`});continue}if(l.score>=O1)t.set(s.slot.slot,{status:"auto_high",chosen:l,reason:"High confidence"}),i.set(l.metId,s.slot.slot);else if(l.score>=su)t.set(s.slot.slot,{status:"provisional",chosen:l,reason:"Medium confidence — mapped provisionally, please review"}),i.set(l.metId,s.slot.slot);else{const f=s.expected.expected&&Zo(s.expected.expected)&&l.compartmentFactor<=.35;t.set(s.slot.slot,{status:"unresolved",reason:f?`Only an extracellular ${c} was found (${l.metId}); uptake/transport is not pathway chemistry, so the slot stays open`:`Best candidate ${l.metId} has low confidence`})}}return t}function xC(e){const t=new Map,i=(a,s,o)=>{const l=t.get(a)??[];l.some(r=>r.slot===s)||l.push({slot:s,step:o}),t.set(a,l)};for(const a of e.biology.reactions)for(const s of a.sources)for(const o of a.targets)i(s,o,a.name),i(o,s,a.name);return t}function _C(e,t){const i={};for(const a of e.slots)a.chosen&&ei(a.status)&&(i[a.chosen.method]=(i[a.chosen.method]??0)+1);return{format:"gemsmap-template-mapping-report",generated:new Date().toISOString(),template:{id:t.id,name:t.name,version:t.version,author:t.author},engine:{version:e.engineVersion,externalCrossReferences:"none (offline: model annotation, built-in canonical library, names, topology)"},model:{...e.model,context:e.context.summary},summary:{coreNodes:`${e.coverage.coreMapped}/${e.coverage.core}`,allNodes:`${e.coverage.allMapped}/${e.coverage.all}`,coreReactions:`${e.coverage.coreReactionsMapped}/${e.coverage.coreReactions}`,quality:e.quality,highConfidence:e.slots.filter(a=>a.status==="auto_high").length,confirmed:e.slots.filter(a=>a.status==="confirmed").length,provisional:e.slots.filter(a=>a.status==="provisional").length,ambiguous:e.slots.filter(a=>a.status==="ambiguous").length,unresolved:e.slots.filter(a=>a.status==="unresolved").length,absent:e.slots.filter(a=>a.status==="absent").length,methods:i},notes:e.notes,slots:e.slots.map(a=>{var s,o,l,r;return{slot:a.slot.slot,entity:a.entity.id,entityName:a.entity.name,level:a.slot.level,expectedCompartment:a.expected.expected,compartmentFallback:a.expected.usedFallback,status:a.status,reason:a.reason,metaboliteId:a.chosen&&ei(a.status)?a.chosen.metId:null,confidence:((s=a.chosen)==null?void 0:s.confidence)??null,score:((o=a.chosen)==null?void 0:o.score)??null,method:((l=a.chosen)==null?void 0:l.method)??null,userConfirmed:a.status==="confirmed",evidence:((r=a.chosen)==null?void 0:r.evidence.map(c=>`${c.ok===!0?"+":c.ok===!1?"-":"~"} ${c.text}`))??[],candidates:a.candidates.slice(0,5).map(c=>({id:c.metId,score:c.score,confidence:c.confidence,summary:c.summary}))}}),reactions:e.reactions.map(a=>({id:a.spec.id,name:a.spec.name,level:a.spec.level,modelReactions:a.reactionIds,mapped:a.mapped}))}}const Rc=e=>Uw(e);function L1(e,t){var i,a;return{templateId:e.id,templateVersion:e.version,slot:t.slot.slot,entity:t.entity.id,compartment:t.expected.expected,status:t.status,score:(i=t.chosen)==null?void 0:i.score,method:(a=t.chosen)==null?void 0:a.method}}function vC(e){const t=new Set(e.biology.slots.map(d=>d.slot)),i=e.source;if(!i)return{nodes:e.biology.slots.map(d=>({id:d.slot,slot:d.slot,...e.layout.nodes[d.slot]})),reactions:e.biology.reactions.map(d=>{var f,u,p,m;return{reaction:d.id,sources:d.sources,targets:d.targets,routing:((u=(f=e.layout.reactions)==null?void 0:f[d.id])==null?void 0:u.routing)??"straight",bend:(m=(p=e.layout.reactions)==null?void 0:p[d.id])==null?void 0:m.bend}}),groups:(e.layout.groups??[]).map(d=>({title:d.title,kind:"pathway",nodes:d.slots})),texts:[],cofactors:[]};const a=new Map(i.biology.metabolites.map(d=>[d.id,d])),s=new Map(i.biology.entities.map(d=>[d.id,d])),o=i.layout.nodes.filter(d=>d.attach).map(d=>{const f=a.get(d.metabolite),u=f&&s.get(f.entity);return{id:d.id,reaction:d.attach.reaction,side:d.attach.side,x:d.x,y:d.y,label:(f==null?void 0:f.label)||(u==null?void 0:u.short)||(u==null?void 0:u.name)||"?"}}),l=i.layout.nodes.filter(d=>!d.attach&&t.has(d.metabolite)).map(d=>({id:d.id,slot:d.metabolite,x:d.x,y:d.y,labelPos:d.label_pos,shape:d.shape,r:d.r,fill:d.fill})),r=new Set(l.map(d=>d.id)),c=i.layout.ports.map(d=>{const f=i.biology.connectors.find(u=>u.id===d.connector);return{x:d.x,y:d.y,text:f?`${f.direction==="in"?"← from":"→"} ${f.target.pathway}`:"→",size:10,weight:400,italic:!0,kind:"text"}});return{nodes:l,reactions:i.layout.reactions.filter(d=>d.sources.every(f=>r.has(f))&&d.targets.every(f=>r.has(f))).map(d=>({reaction:d.reaction,sources:d.sources,targets:d.targets,routing:d.routing,bend:d.bend,labelOffset:d.label_offset,labelAngle:d.label_angle,labelFlip:d.label_flip})),groups:i.layout.groups.map(d=>({title:d.title,kind:d.kind,nodes:d.nodes.filter(f=>r.has(f)),subtitle:d.subtitle,padding:d.padding,fill:d.fill,stroke:d.stroke,dashed:d.dashed})),texts:[...i.layout.labels.map(({id:d,...f})=>f),...c],cofactors:o}}function _f(e,t,i,a,s,o,l){var N;const r=vC(t),c=[...r.nodes.map(C=>C.x),...r.texts.map(C=>C.x)],d=[...r.nodes.map(C=>C.y),...r.texts.map(C=>C.y)],f={x:Math.min(...c),y:Math.min(...d)},u=(C,w)=>({x:l(a.x+C-f.x),y:l(a.y+w-f.y)}),p={...e,nodes:{...e.nodes},reactions:{...e.reactions},groups:{...e.groups},texts:{...e.texts}},m=new Map(i==null?void 0:i.slots.map(C=>[C.slot.slot,C])),h=new Map(t.biology.slots.map(C=>[C.slot,C])),g=new Map;for(const C of r.nodes){const w=h.get(C.slot),k=o("n");g.set(C.id,k);const P=Is(t,w.entity),H=m.get(w.slot);p.nodes[k]={id:k,...u(C.x,C.y),labelPos:C.labelPos,role:w.role,...C.shape?{shape:C.shape}:{},...C.r?{r:C.r}:{},...C.fill?{fill:C.fill}:{},label:w.label??(P==null?void 0:P.short)??w.slot,metaboliteId:H&&H.chosen&&ei(H.status)?H.chosen.metId:void 0,template:H?L1(t,H):{templateId:t.id,templateVersion:t.version,slot:w.slot,entity:w.entity,compartment:null,status:"unresolved"}}}const y=new Map(i==null?void 0:i.reactions.map(C=>[C.spec.id,C])),b=new Map(t.biology.reactions.map(C=>[C.id,C])),_=new Map;let x=0;for(const C of r.reactions){const w=b.get(C.reaction);if(!w)continue;const k=o("r");_.set(w.id,k);const P={id:k,sources:C.sources.map(H=>g.get(H)),targets:C.targets.map(H=>g.get(H)),label:w.name,hints:w.hints,ec:w.ec,routing:C.routing??"straight",bend:C.bend,labelOffset:C.labelOffset,labelAngle:C.labelAngle,labelFlip:C.labelFlip};s&&((N=y.get(w.id))!=null&&N.mapped)&&Cs(P,p.nodes,s)&&x++,p.reactions[k]=P}for(const C of r.groups){const w=o("g"),k=C.kind==="compartment";p.groups[w]={id:w,kind:C.kind,title:C.title,subtitle:C.subtitle,nodeIds:C.nodes.map(P=>g.get(P)).filter(Boolean),padding:C.padding??(k?40:24),fill:C.fill??(k?"#f4f6fb":"none"),stroke:C.stroke??(k?"#b9c2d6":"none"),dashed:C.dashed??k}}const v=[],j=[];for(const C of r.texts){const w=o("t");v.push(w),p.texts[w]={id:w,...C,...u(C.x,C.y)}}for(const C of r.cofactors){const w=_.get(C.reaction);if(!w)continue;const k=o("n");j.push(k),p.nodes[k]={id:k,...u(C.x,C.y),label:C.label,shape:"label",attach:{glyph:w,side:C.side}}}return{doc:p,nodeIds:[...g.values()],cofactorIds:j,textIds:v,reactionsBound:x}}function jC(e,t){var f;const i=new Map;for(const u of Object.values(e.nodes))u.template&&i.set(u.template.templateId,[...i.get(u.template.templateId)??[],u.id]);if(!i.size)return{doc:e,mapped:0,total:0,review:0};const a={...e.nodes},s=new Set,o=la(oa(t).fingerprint);let l=0,r=0,c=0;for(const[u,p]of i){const m=Rc(u);if(!m)continue;const h={},g=new Map;for(const _ of p){const x=a[_].template,v=(f=M1(m,x.slot))==null?void 0:f.slot;v&&(g.set(_,v),x.status==="confirmed"&&a[_].metaboliteId&&t.metabolites[a[_].metaboliteId]&&(h[v]=a[_].metaboliteId),x.status==="absent"&&(h[v]=null))}const y=Zp(m,t,{profile:o,overrides:h}),b=new Map(y.slots.map(_=>[_.slot.slot,_]));for(const _ of p){const x=a[_],v=b.get(g.get(_)??"");if(!v)continue;r++;const j=v.chosen&&ei(v.status)?v.chosen.metId:void 0;j&&l++,(v.status==="provisional"||v.status==="ambiguous")&&c++,j!==x.metaboliteId&&s.add(_),a[_]={...x,metaboliteId:j,template:L1(m,v)}}}const d={...e.reactions};for(const u of Object.values(d)){if(![...u.sources,...u.targets].some(m=>s.has(m))&&u.reactionId&&t.reactions[u.reactionId]||![...u.sources,...u.targets].some(m=>{var h;return(h=a[m])==null?void 0:h.template}))continue;const p={...u,reactionId:void 0,lumped:void 0,reversedToModel:void 0};Cs(p,a,t),d[u.id]=p}return{doc:{...e,nodes:a,reactions:d},mapped:l,total:r,review:c}}const vf=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function NC(e,t){if(!t)return null;const i=e.replace(/^M_/,""),a=vf(t),s=vf(t.replace(/^C_/i,""));for(const o of[new RegExp(`^(.+?)_(?:${a}|${s})$`),new RegExp(`^(.+?)\\[(?:${a}|${s})\\]$`),new RegExp(`^(.+?)\\((?:${a}|${s})\\)$`)]){const l=i.match(o);if(l&&l[1])return l[1]}return null}function jf(e){return(e??"").toLowerCase().replace(/\s*[[(][^\])]*[\])]\s*$/,"").replace(/[^a-z0-9]+/g,"")}const wC=(e,t)=>!e||!t||e===t;function T1(e){const t=new Map;for(const a of e){const s=NC(a.id,a.compartment),o=jf(a.name),l=s!=null?`id:${s}`:o?`name:${o}`:null;if(!l)continue;const r=t.get(l);r?r.push(a):t.set(l,[a])}const i=new Map;for(const a of t.values()){if(a.length<2||new Set(a.map(l=>l.compartment)).size!==a.length)continue;const o=a.map(l=>jf(l.name));if(o.every(l=>wC(l,o.find(Boolean)??"")))for(const l of a)i.set(l.id,a.filter(r=>r!==l).map(r=>r.id))}return i}const Nf=new WeakMap,wf=new WeakMap;function CC(e,t){let i=Nf.get(e);return i||(i=T1(Object.values(e.metabolites)),Nf.set(e,i)),i.get(t)??[]}function Qp(e,t){var o,l;let i=wf.get(e);i||(i=R1(e),wf.set(e,i));const a=new Map,s=new Set;for(const r of CC(e,t)){const c=(l=i.get(((o=e.metabolites[r])==null?void 0:o.compartment)??""))==null?void 0:l.canonical;!c||c==="UNKNOWN"||(a.has(c)?s.add(c):a.set(c,r))}for(const r of s)a.delete(r);return a}function F1(e,t,i){const a={...e.entries},s=[],o=new Date().toISOString();for(const[l,r]of Qp(t,i.metaboliteId)){if(l===i.compartment)continue;const c=Pc(i.entity,l);a[c]||(a[c]={entity:i.entity,compartment:l,metaboliteId:r,templateId:i.templateId,templateVersion:i.templateVersion,confirmedAt:o,via:i.metaboliteId},s.push({compartment:l,metaboliteId:r}))}return{profile:s.length?{...e,updated:o,entries:a}:e,added:s}}const X1=(e,t)=>(e==null?void 0:e.label)||(t==null?void 0:t.short)||(t==null?void 0:t.name)||(e==null?void 0:e.id)||"?",K1=e=>e?`${e.direction==="in"?"← from":"→"} ${e.target.pathway||"pathway"}`:"→ pathway",ou=e=>!e||/^M\d+$/.test(e)||e==="New metabolite";function kC(e){var a,s;const t=new Map;for(const o of e.biology.metabolites)o.compartment&&t.set(o.compartment,(t.get(o.compartment)??0)+1);return((a=[...t.entries()].sort((o,l)=>l[1]-o[1])[0])==null?void 0:a[0])??((s=e.biology.compartments[0])==null?void 0:s.id)??"cytosol"}const z1={pathway:{padding:26,fill:"none",stroke:"none",dashed:!1},compartment:{padding:40,fill:"#f4f6fb",stroke:"#b9c2d6",dashed:!0}};function MC(e){const t=$p();t.legend={...t.legend,visible:!1};const i=new Map(e.biology.metabolites.map(o=>[o.id,o])),a=new Map(e.biology.entities.map(o=>[o.id,o]));for(const o of e.layout.nodes){const l=i.get(o.metabolite),r=l&&a.get(l.entity);t.nodes[o.id]={id:o.id,x:o.x,y:o.y,labelPos:o.label_pos,...o.shape?{shape:o.shape}:{},...o.r?{r:o.r}:{},...o.fill?{fill:o.fill}:{},label:X1(l,r),role:l==null?void 0:l.role,design:{kind:"metabolite",id:o.metabolite,status:(r==null?void 0:r.identity.status)??"unresolved",conflict:!!(r!=null&&r.identity.conflict)},...o.attach?{attach:{glyph:`rg_${o.attach.reaction}`,side:o.attach.side},shape:"label"}:{}}}for(const o of e.layout.ports){const l=e.biology.connectors.find(r=>r.id===o.connector);if(t.nodes[o.id]={id:o.id,x:o.x,y:o.y,shape:"label",label:K1(l),design:{kind:"port",id:o.connector}},t.nodes[o.from]){const r=(l==null?void 0:l.direction)!=="in";t.reactions[`lnk_${o.id}`]={id:`lnk_${o.id}`,sources:[r?o.from:o.id],targets:[r?o.id:o.from],routing:"straight",role:"exchange",design:{kind:"link",id:o.connector}}}}const s=new Map(e.biology.reactions.map(o=>[o.id,o]));for(const o of e.layout.reactions){const l=s.get(o.reaction);if(!l||![...o.sources,...o.targets].every(c=>t.nodes[c]))continue;const r=`rg_${o.reaction}`;t.reactions[r]={id:r,sources:o.sources,targets:o.targets,routing:o.routing,...o.bend!=null?{bend:o.bend}:{},...o.label_offset?{labelOffset:o.label_offset}:{},...o.label_angle!=null?{labelAngle:o.label_angle}:{},...o.label_flip?{labelFlip:!0}:{},label:l.name,ec:l.ec,design:{kind:"reaction",id:l.id,status:l.identity.status,reversible:l.reversible}}}for(const o of e.layout.groups){const l=z1[o.kind];t.groups[o.id]={id:o.id,kind:o.kind,title:o.title,...o.subtitle?{subtitle:o.subtitle}:{},nodeIds:o.nodes.filter(r=>t.nodes[r]),padding:o.padding??l.padding,fill:o.fill??l.fill,stroke:o.stroke??l.stroke,dashed:o.dashed??l.dashed}}for(const o of e.layout.labels)t.texts[o.id]={...o};return t}function Jp(e,t){var c,d,f,u;const i=[],a=[];for(const p of Object.values(t.nodes)){if(((c=p.design)==null?void 0:c.kind)!=="metabolite")continue;const m=p.attach&&((d=t.reactions[p.attach.glyph])==null?void 0:d.design);i.push({id:p.id,metabolite:p.design.id,x:p.x,y:p.y,...p.labelPos?{label_pos:p.labelPos}:{},...p.fill&&!m?{fill:p.fill}:{},...p.shape&&p.shape!=="circle"&&!m?{shape:p.shape}:{},...p.r?{r:p.r}:{},...(m==null?void 0:m.kind)==="reaction"?{attach:{reaction:m.id,side:p.attach.side}}:{}})}const s=new Map(i.filter(p=>!p.attach).map(p=>[p.id,p.metabolite]));for(const p of Object.values(t.nodes)){if(((f=p.design)==null?void 0:f.kind)!=="port")continue;const m=e.biology.connectors.find(b=>b.id===p.design.id),h=Object.values(t.reactions).find(b=>{var _;return((_=b.design)==null?void 0:_.kind)==="link"&&(b.sources.includes(p.id)||b.targets.includes(p.id))}),g=h?[...h.sources,...h.targets].find(b=>b!==p.id&&s.has(b)):void 0,y=(u=i.find(b=>b.metabolite===(m==null?void 0:m.metabolite)))==null?void 0:u.id;(g??y)&&a.push({id:p.id,connector:p.design.id,x:p.x,y:p.y,from:g??y})}const o=Object.values(t.reactions).filter(p=>{var m;return((m=p.design)==null?void 0:m.kind)==="reaction"}).map(p=>({reaction:p.design.id,sources:p.sources,targets:p.targets,routing:p.routing,...p.bend!=null?{bend:p.bend}:{},...p.labelOffset?{label_offset:p.labelOffset}:{},...p.labelAngle!=null?{label_angle:p.labelAngle}:{},...p.labelFlip?{label_flip:!0}:{}})),l=Object.values(t.groups).map(p=>{const m=z1[p.kind];return{id:p.id,kind:p.kind,title:p.title,...p.subtitle?{subtitle:p.subtitle}:{},nodes:p.nodeIds.filter(h=>s.has(h)),...p.padding!==m.padding?{padding:p.padding}:{},...p.fill!==m.fill?{fill:p.fill}:{},...p.stroke!==m.stroke?{stroke:p.stroke}:{},...p.dashed!==m.dashed?{dashed:p.dashed}:{}}}),r=Object.values(t.texts).map(p=>({id:p.id,x:p.x,y:p.y,text:p.text,size:p.size,weight:p.weight,...p.italic?{italic:!0}:{},...p.color?{color:p.color}:{},kind:p.kind,...p.rotate?{rotate:p.rotate}:{}}));return{...e,layout:{nodes:i,ports:a,reactions:o,groups:l,labels:r}}}const EC=(e,t)=>e.length===t.length&&e.every((i,a)=>i.metabolite===t[a].metabolite&&i.coefficient===t[a].coefficient&&i.main===t[a].main);function GC(e,t,i){var v,j,N,C,w,k,P,H,G,M;const a=new Map(e.biology.entities.map(A=>[A.id,A])),s=new Map(e.biology.metabolites.map(A=>[A.id,A])),o=new Map(e.biology.reactions.map(A=>[A.id,A])),l=new Map(e.biology.connectors.map(A=>[A.id,A]));let r=!1;const c={...t.nodes},d={...t.reactions};let f=!1;const u=kC(e),p=new Set;for(const A of Object.values(t.nodes)){if(A.attach&&((j=(v=t.reactions[A.attach.glyph])==null?void 0:v.design)==null?void 0:j.kind)!=="reaction"){delete c[A.id],f=!0;continue}if(((N=A.design)==null?void 0:N.kind)==="port"){let L=l.get(A.design.id);if(!L||p.has(L.id)){const D=qi(l.keys(),Zt.connector);L={...L??{metabolite:"",direction:"out",target:{pathway:""}},id:D},l.set(D,L),c[A.id]={...A,design:{kind:"port",id:D}},r=f=!0}p.add(L.id);continue}if(((C=A.design)==null?void 0:C.kind)==="metabolite"&&s.has(A.design.id))continue;const X=qi(a.keys(),Zt.entity),I=A.label&&!/^M\d+$/.test(A.label)?A.label:"New metabolite";a.set(X,{id:X,name:I,synonyms:[],identifiers:{},identity:{status:"unresolved"}});const K=qi(s.keys(),Zt.metabolite);s.set(K,{id:K,entity:X,compartment:u,level:"required",...A.label?{label:A.label}:{}}),c[A.id]={...A,design:{kind:"metabolite",id:K,status:"unresolved"}},r=f=!0}const m=A=>{var X,I;return((I=(X=c[A])==null?void 0:X.design)==null?void 0:I.kind)==="metabolite"&&!c[A].attach?c[A].design.id:void 0},h=A=>{var X,I;return((I=(X=c[A])==null?void 0:X.design)==null?void 0:I.kind)==="port"},g=new Set;for(const A of Object.values(t.reactions)){const X=[...A.sources,...A.targets],I=X.find(h);if(I){const J=c[I].design.id,Pe=l.get(J),ye=X.map(m).find(Boolean),_e=A.targets.includes(I)?"out":"in";Pe&&(ye&&Pe.metabolite!==ye||Pe.direction!==_e)&&(l.set(J,{...Pe,metabolite:ye??Pe.metabolite,direction:_e}),r=!0),(((w=A.design)==null?void 0:w.kind)!=="link"||A.design.id!==J||A.role!=="exchange")&&(d[A.id]={...A,role:"exchange",design:{kind:"link",id:J}},f=!0);continue}const K=[...new Set(A.sources.map(m).filter(J=>!!J))],L=[...new Set(A.targets.map(m).filter(J=>!!J))].filter(J=>!K.includes(J));let D=((k=A.design)==null?void 0:k.kind)==="reaction"?o.get(A.design.id):void 0;if(!D||g.has(D.id)){const J=qi(o.keys(),Zt.reaction);D=D?{...structuredClone(D),id:J,aliases:void 0}:{id:J,name:A.label||`R${o.size+1}`,participants:[],reversible:null,ec:[],identifiers:{},level:"required",identity:{status:"unresolved"}},o.set(J,D),r=!0}g.add(D.id);const F=D.participants,U=F.filter(J=>J.main&&J.coefficient<0).map(J=>J.metabolite),z=F.filter(J=>J.main&&J.coefficient>0).map(J=>J.metabolite),O=U.length>0&&z.length>0&&U.every(J=>L.includes(J))&&z.every(J=>K.includes(J))&&!U.some(J=>K.includes(J)),Z=(J,Pe)=>{const ye=F.find(_e=>_e.main&&_e.metabolite===J);return ye?Pe*Math.abs(ye.coefficient):Pe},oe=[...K.map(J=>({metabolite:J,coefficient:Z(J,-1),main:!0})),...F.filter(J=>!J.main&&J.coefficient<0!==O).map(J=>({...J,coefficient:O?-J.coefficient:J.coefficient})),...L.map(J=>({metabolite:J,coefficient:Z(J,1),main:!0})),...F.filter(J=>!J.main&&J.coefficient>0!==O).map(J=>({...J,coefficient:O?-J.coefficient:J.coefficient}))].filter((J,Pe,ye)=>J.main||!ye.slice(0,Pe).some(_e=>_e.metabolite===J.metabolite&&Math.sign(_e.coefficient)===Math.sign(J.coefficient)));EC(F,oe)||(D={...D,participants:oe},o.set(D.id,D),r=!0);const he=D.identity.status;(((P=A.design)==null?void 0:P.kind)!=="reaction"||A.design.id!==D.id||A.design.status!==he||A.label!==D.name||A.role==="exchange"||A.design.reversible!==D.reversible)&&(d[A.id]={...A,label:D.name,ec:D.ec,role:void 0,design:{kind:"reaction",id:D.id,status:he,reversible:D.reversible}},f=!0)}for(const A of[...o.keys()])g.has(A)||(o.delete(A),r=!0);const y=new Set(Object.values((i==null?void 0:i.nodes)??{}).filter(A=>{var X;return((X=A.design)==null?void 0:X.kind)==="port"}).map(A=>A.design.id));for(const A of[...l.keys()])!p.has(A)&&y.has(A)&&(l.delete(A),r=!0);const b=new Set;for(const A of Object.values(c))((H=A.design)==null?void 0:H.kind)==="metabolite"&&b.add(A.design.id);for(const A of o.values())for(const X of A.participants)b.add(X.metabolite);for(const A of l.values())b.add(A.metabolite);for(const A of[...s.keys()])b.has(A)||(s.delete(A),r=!0);const _=new Set;for(const A of s.values()){_.add(A.entity);for(const X of A.alternatives??[])_.add(X)}for(const A of[...a.keys()])_.has(A)||(a.delete(A),r=!0);for(const A of Object.values(c))if(((G=A.design)==null?void 0:G.kind)==="metabolite"){const X=s.get(A.design.id),I=X&&a.get(X.entity),K=X1(X,I),L=(I==null?void 0:I.identity.status)??"unresolved",D=!!(I!=null&&I.identity.conflict);(A.label!==K||A.design.status!==L||!!A.design.conflict!==D||A.role!==(X==null?void 0:X.role))&&(c[A.id]={...A,label:K,role:X==null?void 0:X.role,design:{...A.design,status:L,conflict:D}},f=!0)}else if(((M=A.design)==null?void 0:M.kind)==="port"){const X=K1(l.get(A.design.id));(A.label!==X||A.shape!=="label")&&(c[A.id]={...A,label:X,shape:"label"},f=!0)}return{file:r?{...e,biology:{...e.biology,entities:[...a.values()],metabolites:[...s.values()],reactions:[...o.values()],connectors:[...l.values()]}}:e,doc:f?{...t,nodes:c,reactions:d}:t}}const It=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Wt=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Te=(e,t)=>({x:e.x*t,y:e.y*t}),U1=e=>Math.hypot(e.x,e.y),_a=e=>{const t=U1(e)||1;return{x:e.x/t,y:e.y/t}},Cf=e=>({x:e.reduce((t,i)=>t+i.x,0)/e.length,y:e.reduce((t,i)=>t+i.y,0)/e.length}),De=e=>+e.toFixed(2),Oi=e=>Math.atan2(e.y,e.x);function q1(e,t,i,a=0,s=0){const o=e.sources.map(y=>t[y]).filter(Boolean),l=e.targets.map(y=>t[y]).filter(Boolean);if(!o.length||!l.length)return null;const r=3,c=Cf(o),d=Cf(l),f=_a(It(d,c)),u=e.labelFlip?{x:f.y,y:-f.x}:{x:-f.y,y:f.x},p=U1(It(d,c));if(o.length===1&&l.length===1){const y=o[0],b=l[0];if(e.routing==="orthogonal"&&Math.abs(y.x-b.x)>1&&Math.abs(y.y-b.y)>1){const X=Math.abs(b.y-y.y)>=Math.abs(b.x-y.x)?{x:y.x,y:b.y}:{x:b.x,y:y.y},I=_a(It(X,y)),K=_a(It(b,X)),L=i(y.id,I)+r,D=i(b.id,Te(K,-1))+r,F=Wt(y,Te(I,L+a)),U=It(b,Te(K,D+s));return{segments:[{d:`M${De(F.x)},${De(F.y)} L${De(X.x)},${De(X.y)} L${De(U.x)},${De(U.y)}`,side:"both",startTip:{...Wt(y,Te(I,L)),angle:Oi(Te(I,-1))},endTip:{...It(b,Te(K,D)),angle:Oi(K)}}],mid:X,normal:u,dir:f}}const _=e.routing==="curved"?e.bend??p*.15:e.bend??0,x=Wt(Te(Wt(y,b),.5),Te(u,_*2)),v=_a(It(Math.abs(_)>.01?x:b,y)),j=_a(It(b,Math.abs(_)>.01?x:y)),N=i(y.id,v)+r,C=i(b.id,Te(j,-1))+r,w=Wt(y,Te(v,N+a)),k=It(b,Te(j,C+s)),P=Wt(y,Te(v,N)),H=It(b,Te(j,C)),G=Math.abs(_)>.01?`M${De(w.x)},${De(w.y)} Q${De(x.x)},${De(x.y)} ${De(k.x)},${De(k.y)}`:`M${De(w.x)},${De(w.y)} L${De(k.x)},${De(k.y)}`,M=Math.abs(_)>.01?Wt(Te(Wt(y,b),.25),Te(x,.5)):Te(Wt(y,b),.5);return{segments:[{d:G,side:"both",startTip:{...P,angle:Oi(Te(v,-1))},endTip:{...H,angle:Oi(j)}}],mid:M,normal:u,dir:f}}const m=Wt(Te(Wt(c,d),.5),Te(u,e.bend??0)),h=Math.max(12,p*.28),g=[];for(const y of o){const b=It(m,Te(f,h)),_=_a(It(b,y)),x=i(y.id,_)+r,v=Wt(y,Te(_,x+a)),j=Wt(y,Te(_,x));g.push({d:`M${De(v.x)},${De(v.y)} Q${De(b.x)},${De(b.y)} ${De(m.x)},${De(m.y)}`,side:"source",startTip:{...j,angle:Oi(Te(_,-1))},endTip:{...m,angle:Oi(f)}})}for(const y of l){const b=Wt(m,Te(f,h)),_=_a(It(y,b)),x=i(y.id,Te(_,-1))+r,v=It(y,Te(_,x+s)),j=It(y,Te(_,x));g.push({d:`M${De(m.x)},${De(m.y)} Q${De(b.x)},${De(b.y)} ${De(v.x)},${De(v.y)}`,side:"target",startTip:{...m,angle:Oi(Te(f,-1))},endTip:{...j,angle:Oi(_)}})}return{segments:g,mid:m,normal:u,dir:f}}function kf(e,t){const i=4.5+t*2,a=2.6+t*1.1,s=Math.cos(e.angle),o=Math.sin(e.angle),l=e.x-s*i,r=e.y-o*i;return`M${De(e.x)},${De(e.y)} L${De(l-o*a)},${De(r+s*a)} L${De(l+o*a)},${De(r-s*a)} Z`}const V1=e=>4.5+e*2;function SC(e,t,i,a){const s=i+4;switch(t){case"left":return{x:e.x-s,y:e.y+a*.35,anchor:"end"};case"top":return{x:e.x,y:e.y-s-1,anchor:"middle"};case"bottom":return{x:e.x,y:e.y+s+a*.8,anchor:"middle"};case"center":return{x:e.x,y:e.y+a*.35,anchor:"middle"};default:return{x:e.x+s,y:e.y+a*.35,anchor:"start"}}}function W1(e,t){if(e.box)return{...e.box};const i=e.nodeIds.map(r=>t[r]).filter(Boolean);if(!i.length)return null;const a=Math.min(...i.map(r=>r.x))-e.padding,s=Math.min(...i.map(r=>r.y))-e.padding,o=Math.max(...i.map(r=>r.x))+e.padding+20,l=Math.max(...i.map(r=>r.y))+e.padding;return{x:a,y:s-14,w:o-a,h:l-s+14}}function lu(e,t){return Object.values(t).filter(i=>i.x>=e.x&&i.x<=e.x+e.w&&i.y>=e.y&&i.y<=e.y+e.h).map(i=>i.id)}function ru(e,t){return e.box?lu(e.box,t):e.nodeIds.filter(i=>t[i])}function Mf(e,t){var i;return((i=q1(e,t,()=>0))==null?void 0:i.mid)??null}function Sd(e,t){let i=null;const a=new Map;for(const s of Object.values(t.nodes)){if(!s.attach)continue;const o=e.nodes[s.id];if(!o||o.x!==s.x||o.y!==s.y)continue;const l=e.reactions[s.attach.glyph],r=t.reactions[s.attach.glyph];if(!l||!r||l===r&&[...r.sources,...r.targets].every(d=>e.nodes[d]===t.nodes[d]))continue;if(!a.has(r.id)){const d=Mf(l,e.nodes),f=Mf(r,t.nodes);a.set(r.id,d&&f?{x:f.x-d.x,y:f.y-d.y}:null)}const c=a.get(r.id);!c||Math.abs(c.x)<1e-6&&Math.abs(c.y)<1e-6||(i??(i={...t.nodes}),i[s.id]={...s,x:+(s.x+c.x).toFixed(2),y:+(s.y+c.y).toFixed(2)})}return i?{...t,nodes:i}:t}const Qo=[{id:"blue-red",name:"Blue – Red",kind:"diverging",colorblindSafe:!0,stops:["#2166ac","#4393c3","#92c5de","#d1e5f0","#f7f7f7","#fddbc7","#f4a582","#d6604d","#b2182b"]},{id:"cool-warm",name:"Cool – Warm",kind:"diverging",colorblindSafe:!0,stops:["#3b4cc0","#6788ee","#9abbff","#c9d7f0","#edd1c2","#f7a889","#e26952","#b40426"]},{id:"purple-orange",name:"Purple – Orange",kind:"diverging",colorblindSafe:!0,stops:["#542788","#8073ac","#b2abd2","#d8daeb","#f7f7f7","#fee0b6","#fdb863","#e08214","#b35806"]},{id:"green-purple",name:"Green – Purple",kind:"diverging",colorblindSafe:!0,stops:["#1b7837","#5aae61","#a6dba0","#d9f0d3","#f7f7f7","#e7d4e8","#c2a5cf","#9970ab","#762a83"]},{id:"viridis",name:"Viridis",kind:"sequential",colorblindSafe:!0,stops:["#440154","#472d7b","#3b528b","#2c728e","#21918c","#28ae80","#5ec962","#addc30","#fde725"]},{id:"plasma",name:"Plasma",kind:"sequential",colorblindSafe:!0,stops:["#0d0887","#46039f","#7201a8","#9c179e","#bd3786","#d8576b","#ed7953","#fb9f3a","#fdca26","#f0f921"]},{id:"blues",name:"Blues",kind:"sequential",colorblindSafe:!0,stops:["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"]},{id:"reds",name:"Reds",kind:"sequential",colorblindSafe:!0,stops:["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"]},{id:"greys",name:"Grayscale",kind:"sequential",colorblindSafe:!0,stops:["#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"]}],Ur=["#e8505b","#a05a5a","#5b6ee1","#2a2f8f","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#999999"];function za(e){return Qo.find(t=>t.id===e)??Qo[0]}function cu(e){const t=e.replace("#",""),i=parseInt(t.length===3?t.split("").map(a=>a+a).join(""):t,16);return[i>>16&255,i>>8&255,i&255]}const Ad=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");function Bs(e,t){const a=Math.max(0,Math.min(1,Number.isFinite(t)?t:.5))*(e.stops.length-1),s=Math.min(e.stops.length-2,Math.floor(a)),o=a-s,l=cu(e.stops[s]),r=cu(e.stops[s+1]);return"#"+Ad(l[0]+(r[0]-l[0])*o)+Ad(l[1]+(r[1]-l[1])*o)+Ad(l[2]+(r[2]-l[2])*o)}function Ef(e,t){const[i,a,s]=cu(e);return`rgba(${i},${a},${s},${t})`}function Gf(e,t,i){const a=new Map,s=new Map;for(const d of Object.values(e.reactions)){for(const f of d.sources)a.has(f)||a.set(f,[]),a.get(f).push(d);for(const f of d.targets)s.has(f)||s.set(f,[]),s.get(f).push(d)}const o=(d,f,u,p)=>{const m=new Set([d]),h=[d];for(;h.length;){const g=h.shift();if(g!==p)for(const y of f.get(g)??[])for(const b of u(y))m.has(b)||(m.add(b),h.push(b))}return m},l=o(t,a,d=>d.targets,i),r=o(i,s,d=>d.sources,t),c=new Set([...l].filter(d=>r.has(d)));return!c.has(t)||!c.has(i)?[]:Object.values(e.reactions).filter(d=>d.sources.some(f=>c.has(f))&&d.targets.some(f=>c.has(f))&&!d.targets.includes(t)&&!d.sources.includes(i)).map(d=>d.id)}function Sf(e,t,i){var X;const a=t.map(I=>e.reactions[I]).filter(Boolean);if(!a.length)return null;const s=new Set(a.map(I=>I.id)),o=new Set(a.flatMap(I=>[...I.sources,...I.targets])),l=new Set(a.flatMap(I=>I.sources)),r=new Set(a.flatMap(I=>I.targets)),c=new Set;for(const I of Object.values(e.reactions))if(!s.has(I.id))for(const K of[...I.sources,...I.targets])c.add(K);for(const I of Object.values(e.plots))I.anchor.kind==="node"&&c.add(I.anchor.id);let d=(i==null?void 0:i.sources)??[...o].filter(I=>l.has(I)&&!r.has(I)),f=(i==null?void 0:i.targets)??[...o].filter(I=>r.has(I)&&!l.has(I)),u;(!d.length||!f.length)&&(d=[a[0].sources[0]],f=[a[a.length-1].targets[0]],u="Could not detect clear start/end metabolites — used the first and last arrow.");const p=new Set([...d,...f]),m=[...o].filter(I=>{var K;return!p.has(I)&&!c.has(I)&&!((K=e.nodes[I])!=null&&K.locked)}),h=new Set(m),g=new Set(d),y=new Set(f),b=a.every(I=>I.sources.every(K=>g.has(K))&&I.targets.every(K=>y.has(K))),_=!b&&m.every(I=>a.filter(K=>K.targets.includes(I)).length===1&&a.filter(K=>K.sources.includes(I)).length===1),x=b?"parallel":_?"series":"network",v=[];for(const I of a){const K=I.sources.some(D=>y.has(D))||I.targets.some(D=>g.has(D))?-1:1,L=I.sources.some(D=>g.has(D))||I.targets.some(D=>g.has(D));if(I.collapsed)for(const D of I.collapsed.members)v.push({reactionId:D.reactionId,sign:D.sign*K,entry:L&&D.entry});else if(I.reactionId){const D=K*(I.reversedToModel?-1:1);for(const F of I.lumped??[I.reactionId])v.push({reactionId:F,sign:D,entry:L&&F===(((X=I.lumped)==null?void 0:X[0])??I.reactionId)})}}const j=Object.values(e.plots).filter(I=>I.anchor.kind==="reaction"?s.has(I.anchor.id):h.has(I.anchor.id)),N={};for(const I of Object.values(e.groups))for(const K of I.nodeIds)h.has(K)&&(N[K]??(N[K]=[])).push(I.id);const C=e.nodes[d[0]],w="entry",k=ke("r"),P={id:k,sources:d,targets:f,routing:"straight",collapsed:{members:v,aggregate:w,topology:x,showBadge:!0,hidden:{nodes:m.map(I=>e.nodes[I]),reactions:a,plots:j,groupOf:N},anchor:{x:(C==null?void 0:C.x)??0,y:(C==null?void 0:C.y)??0}}},H={...e.nodes};m.forEach(I=>delete H[I]);const G={...e.reactions};a.forEach(I=>delete G[I.id]),G[k]=P;const M={...e.plots};j.forEach(I=>delete M[I.id]);const A=Object.fromEntries(Object.entries(e.groups).map(([I,K])=>[I,{...K,nodeIds:K.nodeIds.filter(L=>!h.has(L))}]));return{doc:{...e,nodes:H,reactions:G,plots:M,groups:A},id:k,topology:x,count:v.length,warning:u}}function AC(e,t){var p;const i=e.reactions[t],a=i==null?void 0:i.collapsed;if(!a)return null;const s=e.nodes[i.sources[0]],o=s?s.x-a.anchor.x:0,l=s?s.y-a.anchor.y:0,r={...e.nodes};for(const m of a.hidden.nodes)r[m.id]||(r[m.id]={...m,x:m.x+o,y:m.y+l});const c={...e.reactions};delete c[t];for(const m of a.hidden.reactions)c[m.id]=m;const d={...e.plots};for(const m of a.hidden.plots)d[m.id]=m;const f=(p=a.hidden.reactions[0])==null?void 0:p.id;for(const m of Object.values(d))m.anchor.kind==="reaction"&&m.anchor.id===t&&(f?d[m.id]={...m,anchor:{kind:"reaction",id:f}}:delete d[m.id]);const u={...e.groups};for(const[m,h]of Object.entries(a.hidden.groupOf))for(const g of h)u[g]&&!u[g].nodeIds.includes(m)&&(u[g]={...u[g],nodeIds:[...u[g].nodeIds,m]});return{doc:{...e,nodes:r,reactions:c,plots:d,groups:u},restored:a.hidden.reactions.map(m=>m.id)}}const Ne=(e,t)=>`${e}:${t}`,Oe=e=>{const t=e.indexOf(":");return[e.slice(0,t),e.slice(t+1)]},Ol=e=>({doc:e.doc,mappings:e.mappings,style:e.style,datasets:e.datasets,conditions:e.conditions,model:e.model,design:e.design});let Dd=null,DC=0;const Pd=()=>{const e=$p();return{...e,legend:{...e.legend,visible:!1}}};function Af(e,t,i,a){const s={x:Math.min(...t.nodes.map(c=>c.x)),y:Math.min(...t.nodes.map(c=>c.y))},o=new Map,l=[],r={...e,nodes:{...e.nodes},reactions:{...e.reactions},groups:{...e.groups},texts:{...e.texts}};for(const c of t.nodes){const d=ke("n");o.set(c.key,d),r.nodes[d]={id:d,x:a(i.x+c.x-s.x),y:a(i.y+c.y-s.y),label:c.label,hints:c.hints,labelPos:c.labelPos,role:c.role}}for(const c of t.reactions){const d=ke("r");r.reactions[d]={id:d,sources:c.sources.map(f=>o.get(f)),targets:c.targets.map(f=>o.get(f)),label:c.label,hints:c.hints,routing:c.routing??"straight",bend:c.bend,role:c.role}}for(const c of t.groups??[]){const d=ke("g");r.groups[d]={id:d,kind:c.kind,title:c.title,nodeIds:c.keys.map(f=>o.get(f)).filter(Boolean),padding:24,fill:"none",stroke:"none",dashed:!1}}for(const c of t.texts??[]){const d=ke("t");l.push(d),r.texts[d]={id:d,...c,x:i.x+c.x-s.x,y:i.y+c.y-s.y}}return{doc:r,ids:o,textIds:l}}function PC(e,t){const i=m=>e(h=>{const g=m(h);g.doc&&g.doc!==h.doc&&(g.doc=Sd(h.doc,g.doc));const y={...g,past:[...h.past,Ol(h)].slice(-150),future:[]},b=g.design!==void 0?g.design:h.design;if(b&&(g.doc||g.design)){const _=GC(b,g.doc??h.doc,h.doc);y.doc=_.doc,y.design=_.file}return y}),a=m=>i(h=>({doc:m(h.doc,h)})),s=m=>e({toast:{text:m,id:++DC}}),o=m=>t().selection.filter(h=>h.startsWith(m+":")).map(h=>Oe(h)[1]),l=()=>{var g;const m=t(),h=new globalThis.Set;for(const y of m.selection){const[b,_]=Oe(y);if(b==="node")h.add(_);else if(b==="group")(g=m.doc.groups[_])==null||g.nodeIds.forEach(x=>h.add(x));else if(b==="reaction"){const x=m.doc.reactions[_];x==null||x.sources.concat(x.targets).forEach(v=>h.add(v))}}return[...h].filter(y=>m.doc.nodes[y]&&!m.doc.nodes[y].locked)},r=m=>{const h=t().canvas;return h.snap?Math.round(m/h.gridSize)*h.gridSize:m},c=(m,h=!0)=>a(g=>{const y={...g.nodes};for(const[b,_]of Object.entries(m))y[b]&&(y[b]={...y[b],x:h?r(_.x):_.x,y:h?r(_.y):_.y});return{...g,nodes:y}}),d=m=>{const h=t().doc,g=new globalThis.Set(m),y=[];for(const b of Object.values(h.reactions)){const _=b.sources.find(x=>g.has(x));if(_)for(const x of b.targets)g.has(x)&&y.push([_,x])}return{nodes:m.map(b=>({id:b,x:h.nodes[b].x,y:h.nodes[b].y})),edges:y}},f=(m,h)=>{const g=[...h],y=m.map(b=>{const _=g.find(j=>j.name.toLowerCase()===b.toLowerCase()||j.id===b);if(_)return _.id;const x=Number(b.replace(/[^\d.]/g,"")),v={id:b,name:b,color:Ur[g.length%Ur.length],time:/\d/.test(b)&&Number.isFinite(x)?x:void 0};return g.push(v),v.id});return{conditions:g,ids:y}},u=(m,h,g)=>{const y=t(),b=y.doc,_={...b.nodes},x={...b.reactions},v=new Map;for(const P of Object.values(_))P.metaboliteId&&v.set(P.metaboliteId,P.id);const j=_[m],N=y.layoutSpacing,C=new Map,w=new Map([[j.metaboliteId,0]]),k=[];for(const P of h){const H=g==="down"?P.from:P.to,G=g==="down"?P.to:P.from,M=(w.get(H)??0)+1;if(!v.has(G)){const K=C.get(M)??0;C.set(M,K+1);const L=ke("n"),D=K===0?0:(K%2?1:-1)*Math.ceil(K/2)*N*1.2;_[L]={id:L,x:r(j.x+D),y:r(j.y+(g==="down"?1:-1)*M*N),metaboliteId:G},v.set(G,L),w.set(G,M),k.push(L)}const A=v.get(P.from),X=v.get(P.to),I=Object.values(x).find(K=>K.reactionId===P.reactionId&&!!K.reversedToModel===P.reversed);if(I)(!I.sources.includes(A)||!I.targets.includes(X))&&(x[I.id]={...I,sources:I.sources.includes(A)?I.sources:[...I.sources,A],targets:I.targets.includes(X)?I.targets:[...I.targets,X]});else{const K=ke("r");x[K]={id:K,reactionId:P.reactionId,sources:[A],targets:[X],routing:"straight",reversedToModel:P.reversed}}}return i(P=>({doc:{...P.doc,nodes:_,reactions:x},selection:[m,...k].map(H=>Ne("node",H))})),k.length},p={commit:i,toast:s,undo:()=>e(m=>m.past.length?{...m.past[m.past.length-1],past:m.past.slice(0,-1),future:[Ol(m),...m.future]}:{}),redo:()=>e(m=>m.future.length?{...m.future[0],future:m.future.slice(1),past:[...m.past,Ol(m)]}:{}),beginGesture:()=>e(m=>({past:[...m.past,Ol(m)].slice(-150),future:[]})),live:m=>e(h=>({doc:Sd(h.doc,m(h.doc))})),select:(m,h=!1)=>e(g=>({selection:h?Array.from(new globalThis.Set([...g.selection,...m])):m})),toggleSelect:m=>e(h=>({selection:h.selection.includes(m)?h.selection.filter(g=>g!==m):[...h.selection,m]})),clearSelection:()=>e({selection:[]}),selectAll:()=>e(m=>{const h=(g,y)=>Object.entries(g).filter(([,b])=>!b.locked).map(([b])=>Ne(y,b));return{selection:[...h(m.doc.nodes,"node"),...h(m.doc.reactions,"reaction"),...h(m.doc.texts,"text"),...h(m.doc.plots,"plot")]}}),selectedIds:o,selectedNodeIds:l,addNode:(m,h={})=>{const g=ke("n");return a(y=>({...y,nodes:{...y.nodes,[g]:{id:g,x:r(m.x),y:r(m.y),...h}}})),e({selection:[Ne("node",g)]}),g},addReaction:(m,h,g={},y=!0)=>{const b=ke("r"),_=t(),x={id:b,sources:m,targets:h,routing:"straight",...g};return!x.reactionId&&_.model&&y&&Cs(x,_.doc.nodes,_.model),a(v=>({...v,reactions:{...v.reactions,[b]:x}})),e({selection:[Ne("reaction",b)]}),b},requestConnection:(m,h)=>e({dialog:{kind:"reaction",sources:[m],targets:[h]}}),addModelReaction:(m,h)=>{var k;const g=t(),y=(k=g.model)==null?void 0:k.reactions[m];if(!y)return;const{substrates:b,products:_}=ws(y,g.model.metabolites),x={...g.doc.nodes},v=h??{x:(g.viewport.w/2-g.camera.x)/g.camera.k,y:(g.viewport.h/2-g.camera.y)/g.camera.k},j=(P,H)=>P.map((G,M)=>{const A=ke("n");return x[A]={id:A,x:r(v.x+(M-(P.length-1)/2)*80),y:r(H),metaboliteId:G},A}),N=j(b,v.y-30),C=j(_,v.y+30),w=ke("r");i(P=>({doc:{...P.doc,nodes:x,reactions:{...P.doc.reactions,[w]:{id:w,reactionId:m,sources:N,targets:C,routing:"straight"}}},selection:[Ne("reaction",w)]}))},addModelReactions:(m,h="vertical",g=!1)=>{var I;const y=t(),b=y.model;if(!b)return{added:0,skipped:m.length,boundary:0};const _=new globalThis.Set;for(const K of Object.values(y.doc.reactions))for(const L of[K.reactionId,...K.lumped??[],...((I=K.collapsed)==null?void 0:I.members.map(D=>D.reactionId))??[]])L&&_.add(L);const x=m.filter(K=>b.reactions[K]&&!_.has(K)),v=Pd(),j=new Map,N=Math.max(2,Math.ceil(Math.sqrt(x.length*2)));let C=0;const w=K=>{const L=j.get(K);if(L)return L;const D=ke("n"),F=C++;return v.nodes[D]={id:D,x:F%N*y.layoutSpacing*1.4,y:Math.floor(F/N)*y.layoutSpacing,metaboliteId:K},j.set(K,D),D};let k=0,P=0;for(const K of x){const L=b.reactions[K],{substrates:D,products:F}=ws(L,b.metabolites);if(!D.length||!F.length){P++;continue}const U=D.map(w),z=F.map(w),O=ke("r");v.reactions[O]={id:O,reactionId:K,sources:U,targets:z,routing:"straight"},k++}const H={added:k,skipped:m.length-k-P,boundary:P};if(!k)return H;const G=Object.keys(v.nodes);if(h!=="none"&&G.length>=2){const K=[];for(const D of Object.values(v.reactions))for(const F of D.targets)K.push([D.sources[0],F]);const L=Zm(h,G.map(D=>({id:D,x:v.nodes[D].x,y:v.nodes[D].y})),K,{spacing:y.layoutSpacing});for(const[D,F]of Object.entries(L))v.nodes[D]={...v.nodes[D],x:F.x,y:F.y}}const M=k===1?Object.values(v.reactions)[0].reactionId:`${k} reactions`;if(g)return p.beginPlacing({kind:"reactions",name:M,preview:v}),H;const A={x:(y.viewport.w/2-y.camera.x)/y.camera.k,y:(y.viewport.h/3-y.camera.y)/y.camera.k},X=wa(v)??{x:0,y:0,w:0,h:0};return p.insertBlock(v,{x:r(A.x-(X.x+X.w/2)),y:r(A.y-(X.y+X.h/2))}),H},insertBlock:(m,h)=>{const g={...t().doc.nodes};for(const y of Object.values(m.nodes))g[y.id]={...y,x:r(y.x+h.x),y:r(y.y+h.y)};i(y=>({doc:{...y.doc,nodes:g,reactions:{...y.doc.reactions,...m.reactions}},selection:Object.keys(m.nodes).map(b=>Ne("node",b))}))},addModelMetabolites:m=>{const h=t();if(!h.model)return 0;const g=new globalThis.Set(Object.values(h.doc.nodes).map(j=>j.metaboliteId)),y=m.filter(j=>h.model.metabolites[j]&&!g.has(j)),b={x:(h.viewport.w/2-h.camera.x)/h.camera.k,y:(h.viewport.h/3-h.camera.y)/h.camera.k},_=Math.max(1,Math.ceil(Math.sqrt(y.length))),x={...h.doc.nodes},v=y.map((j,N)=>{const C=ke("n");return x[C]={id:C,x:r(b.x+N%_*h.layoutSpacing*1.4),y:r(b.y+Math.floor(N/_)*h.layoutSpacing),metaboliteId:j},C});return v.length&&i(j=>({doc:{...j.doc,nodes:x},selection:v.map(N=>Ne("node",N))})),v.length},addMetaboliteFromModel:(m,h)=>{const g=t(),y=h??{x:(g.viewport.w/2-g.camera.x)/g.camera.k,y:(g.viewport.h/2-g.camera.y)/g.camera.k};return p.addNode(y,{metaboliteId:m})},addText:(m,h={})=>{const g=ke("t");return a(y=>({...y,texts:{...y.texts,[g]:{id:g,x:r(m.x),y:r(m.y),text:"Text",size:12,weight:400,kind:"text",...h}}})),e({selection:[Ne("text",g)],tool:"select"}),g},addPlot:(m,h="density")=>{const g=t();if(!Ta(g.doc,m))return;const b=ke("p"),_=Object.values(g.doc.plots).filter(x=>x.anchor.id===m.id).length;a(x=>({...x,plots:{...x.plots,[b]:{id:b,anchor:m,type:h,dx:60,dy:-45+_*100,w:140,h:90,showConnector:!0,showAxis:!0}}})),e({selection:[Ne("plot",b)]})},addPlotsForSelection:m=>{const h=o("reaction");if(!h.length)return s("Select one or more reactions first");for(const g of h)p.addPlot({kind:"reaction",id:g},m)},updateNode:(m,h)=>a(g=>({...g,nodes:{...g.nodes,[m]:{...g.nodes[m],...h}}})),updateReaction:(m,h)=>a(g=>({...g,reactions:{...g.reactions,[m]:{...g.reactions[m],...h}}})),updatePlot:(m,h)=>a(g=>({...g,plots:{...g.plots,[m]:{...g.plots[m],...h}}})),updateText:(m,h)=>a(g=>({...g,texts:{...g.texts,[m]:{...g.texts[m],...h}}})),updateGroup:(m,h)=>a(g=>({...g,groups:{...g.groups,[m]:{...g.groups[m],...h}}})),updateNodes:(m,h)=>a(g=>{const y={...g.nodes};for(const b of m)y[b]={...y[b],...h};return{...g,nodes:y}}),updateReactions:(m,h)=>a(g=>{const y={...g.reactions};for(const b of m)y[b]={...y[b],...h};return{...g,reactions:y}}),reverseReaction:m=>a(h=>{const g=h.reactions[m];return{...h,reactions:{...h.reactions,[m]:{...g,sources:g.targets,targets:g.sources,reversedToModel:g.reactionId?!g.reversedToModel:void 0}}}}),bindNode:(m,h)=>{var _;const g=t();if((_=g.doc.nodes[m])!=null&&_.template)return p.setTemplateMapping(m,h);const y={...g.doc.nodes,[m]:{...g.doc.nodes[m],metaboliteId:h}},b={...g.doc.reactions};if(g.model){for(const x of Object.values(b))if(!x.reactionId&&(x.sources.includes(m)||x.targets.includes(m))){const v={...x};Cs(v,y,g.model)&&(b[x.id]=v)}}i(x=>({doc:{...x.doc,nodes:y,reactions:b}}))},unbindNode:m=>a(h=>{const g=h.nodes[m],y=g.metaboliteId?Array.from(new globalThis.Set([bt(g.metaboliteId),...g.hints??[]])):g.hints;return{...h,nodes:{...h.nodes,[m]:{...g,metaboliteId:void 0,hints:y,label:g.label??(g.metaboliteId?bt(g.metaboliteId):void 0)}}}}),autoBindAll:()=>{const m=t();if(!m.model)return s("Load a GEM first (Model tab → Import)");const h=jC(m.doc,m.model),g=tu(h.doc,m.model);i(()=>({doc:g.doc})),s(`Bound ${g.nodes}/${g.totalNodes} slots and ${g.reactions}/${g.totalReactions} reactions to ${m.model.name}`+(h.total?` · template nodes: ${h.mapped}/${h.total} mapped${h.review?`, ${h.review} to review`:""}`:""))},deleteSelection:()=>{const m=t();if(!m.selection.length)return;const h={node:new globalThis.Set,reaction:new globalThis.Set,plot:new globalThis.Set,text:new globalThis.Set,group:new globalThis.Set};for(const g of m.selection){const[y,b]=Oe(g);y!=="legend"&&h[y].add(b)}i(g=>{const y=g.doc,b={...y.nodes};h.node.forEach(N=>{var C;(C=b[N])!=null&&C.locked||delete b[N]});const _={};for(const N of Object.values(y.reactions)){if(h.reaction.has(N.id))continue;const C=N.sources.filter(k=>b[k]),w=N.targets.filter(k=>b[k]);C.length&&w.length&&(_[N.id]=C.length===N.sources.length&&w.length===N.targets.length?N:{...N,sources:C,targets:w})}for(const N of Object.values(b))N.attach&&!_[N.attach.glyph]&&!N.locked&&delete b[N.id];const x={};for(const N of Object.values(y.plots))h.plot.has(N.id)||(N.anchor.kind==="reaction"?_[N.anchor.id]:b[N.anchor.id])&&(x[N.id]=N);const v={...y.texts};h.text.forEach(N=>delete v[N]);const j={};for(const N of Object.values(y.groups)){if(h.group.has(N.id))continue;const C=N.nodeIds.filter(w=>b[w]);C.length&&(j[N.id]={...N,nodeIds:C})}return{doc:{...y,nodes:b,reactions:_,plots:x,texts:v,groups:j},selection:[]}})},copy:()=>{const m=t(),h=new globalThis.Set(o("node"));Dd={nodes:[...h].map(g=>m.doc.nodes[g]),reactions:Object.values(m.doc.reactions).filter(g=>g.sources.every(y=>h.has(y))&&g.targets.every(y=>h.has(y))),texts:o("text").map(g=>m.doc.texts[g]),plots:Object.values(m.doc.plots).filter(g=>m.selection.includes(Ne("plot",g.id)))}},paste:(m=30)=>{if(!Dd)return;const h=Dd,g=new Map;i(y=>{const b=y.doc,_={...b.nodes},x={...b.reactions},v={...b.texts},j={...b.plots},N=[];for(const C of h.nodes){const w=ke("n");g.set(C.id,w),_[w]={...C,id:w,x:C.x+m,y:C.y+m},N.push(Ne("node",w))}for(const C of h.reactions){const w=ke("r");g.set(C.id,w),x[w]={...C,id:w,sources:C.sources.map(k=>g.get(k)),targets:C.targets.map(k=>g.get(k))}}for(const C of h.nodes){const w=g.get(C.id);if(!_[w].attach)continue;const k=g.get(_[w].attach.glyph);_[w]=k?{..._[w],attach:{..._[w].attach,glyph:k}}:{..._[w],attach:void 0}}for(const C of h.texts){const w=ke("t");v[w]={...C,id:w,x:C.x+m,y:C.y+m},N.push(Ne("text",w))}for(const C of h.plots){const w=g.get(C.anchor.id);if(w){const k=ke("p");j[k]={...C,id:k,anchor:{...C.anchor,id:w}}}}return{doc:{...b,nodes:_,reactions:x,texts:v,plots:j},selection:N}})},duplicate:()=>{p.copy(),p.paste(40)},toggleLock:()=>{const m=t().selection.filter(h=>!h.startsWith("legend:"));if(!m.length)return s("Select something to lock");i(h=>{const g=h.doc,y={...g,nodes:{...g.nodes},reactions:{...g.reactions},texts:{...g.texts},plots:{...g.plots},groups:{...g.groups}};for(const b of m){const[_,x]=Oe(b),v=_==="node"?y.nodes:_==="reaction"?y.reactions:_==="text"?y.texts:_==="plot"?y.plots:_==="group"?y.groups:null;v&&v[x]&&(v[x]={...v[x],locked:!0})}return{doc:y,selection:[]}}),s(`Locked ${m.length} item(s) — they are now skipped by clicks and box selection. Hold the mouse 3 s on one (or right-click) to unlock.`)},isLocked:m=>{const[h,g]=Oe(m),y=t().doc,b=h==="node"?y.nodes[g]:h==="reaction"?y.reactions[g]:h==="text"?y.texts[g]:h==="plot"?y.plots[g]:h==="group"?y.groups[g]:void 0;return!!(b!=null&&b.locked)},unlock:m=>{const[h,g]=Oe(m);i(y=>{const b=y.doc,_=v=>v[g]?{...v,[g]:{...v[g],locked:!1}}:v;return{doc:h==="node"?{...b,nodes:_(b.nodes)}:h==="reaction"?{...b,reactions:_(b.reactions)}:h==="text"?{...b,texts:_(b.texts)}:h==="plot"?{...b,plots:_(b.plots)}:h==="group"?{...b,groups:_(b.groups)}:b,selection:[m]}}),s("Unlocked")},moveFrom:(m,h,g)=>e(y=>{var C;const b=y.doc,_={...b.nodes},x={...b.texts},v={...b.plots},j={...b.groups};let N=b.legend;for(const[w,k]of Object.entries(m)){const[P,H]=Oe(w);P==="node"&&_[H]?_[H]={..._[H],x:k.x+h,y:k.y+g}:P==="text"&&x[H]?x[H]={...x[H],x:k.x+h,y:k.y+g}:P==="plot"&&v[H]?v[H]={...v[H],dx:k.x+h,dy:k.y+g}:P==="legend"?N={...N,x:k.x+h,y:k.y+g,auto:!1}:P==="group"&&((C=j[H])!=null&&C.box)&&(j[H]={...j[H],box:{...j[H].box,x:k.x+h,y:k.y+g}})}return{doc:Sd(b,{...b,nodes:_,texts:x,plots:v,legend:N,groups:j})}}),nudge:(m,h)=>{const g=l(),y=o("text");!g.length&&!y.length||a(b=>{const _={...b.nodes},x={...b.texts};for(const v of g)_[v]={..._[v],x:_[v].x+m,y:_[v].y+h};for(const v of y)x[v]={...x[v],x:x[v].x+m,y:x[v].y+h};return{...b,nodes:_,texts:x}})},layoutSelection:(m,h={})=>{const g=l();if(g.length<2)return s("Select at least two metabolites");const{nodes:y,edges:b}=d(g);c(Zm(m,y,b,{spacing:t().layoutSpacing,...h}),m!=="circle")},alignSelection:m=>{const h=l();h.length>1&&c(pN(m,d(h).nodes),!1)},distributeSelection:(m,h=!1)=>{const g=l();(g.length>2||h&&g.length>1)&&c(hN(m,d(g).nodes,h?t().layoutSpacing:void 0),!1)},tidySelection:()=>{const m=l();if(m.length<2)return s("Select at least two metabolites");const{nodes:h,edges:g}=d(m),y=fN(h,g,t().layoutSpacing,t().canvas.gridSize);c(y.pos,!1),s(`Tidy: detected ${y.detected}`)},groupSelection:(m="pathway",h)=>{const g=l();if(!g.length&&m!=="compartment")return s("Select metabolites to group");const y=t(),b=ke("g"),_=m==="pathway"?26:40;let x;if(m==="compartment")if(g.length){const j=g.map(w=>y.doc.nodes[w]).filter(Boolean),N=Math.min(...j.map(w=>w.x))-_,C=Math.min(...j.map(w=>w.y))-_-14;x={x:N,y:C,w:Math.max(...j.map(w=>w.x))+_+20-N,h:Math.max(...j.map(w=>w.y))+_-C}}else{const j={x:(y.viewport.w/2-y.camera.x)/y.camera.k,y:(y.viewport.h/2-y.camera.y)/y.camera.k};x={x:r(j.x-200),y:r(j.y-140),w:400,h:280}}const v={id:b,kind:m,title:h??(m==="pathway"?"Pathway":"Cytosol"),nodeIds:x?lu(x,y.doc.nodes):g,padding:_,fill:m==="pathway"?"none":"#f4f6fb",stroke:m==="pathway"?"none":"#b9c2d6",dashed:m==="compartment",box:x};a(j=>({...j,groups:{...j.groups,[b]:v}})),e({selection:[Ne("group",b)]}),m==="compartment"&&s("Compartment: drag its handles to resize — metabolites inside the frame belong to it")},syncGroupMembers:()=>{const m=t().doc;let h=!1;const g={...m.groups};for(const y of Object.values(m.groups)){if(!y.box)continue;const b=lu(y.box,m.nodes);(b.length!==y.nodeIds.length||b.some((_,x)=>_!==y.nodeIds[x]))&&(g[y.id]={...y,nodeIds:b},h=!0)}h&&e(y=>({doc:{...y.doc,groups:g}}))},fitGroupToMembers:m=>i(h=>{const g=h.doc.groups[m];if(!(g!=null&&g.box))return{};const{box:y,...b}=g;return{doc:{...h.doc,groups:{...h.doc.groups,[m]:{...b,nodeIds:ru(g,h.doc.nodes)}}}}}),ungroup:()=>{const m=o("group");if(!m.length)return;const h=m.flatMap(g=>ru(t().doc.groups[g],t().doc.nodes));a(g=>{const y={...g.groups};return m.forEach(b=>delete y[b]),{...g,groups:y}}),e({selection:h.map(g=>Ne("node",g))})},instantiateTemplate:(m,h)=>{const g=t();if(!h)return p.beginPlacing({kind:"template",name:m.name,template:m,preview:Af(Pd(),m,{x:0,y:0},v=>v).doc});const y=Af(g.doc,m,h,r);let b=y.doc;const _=y.ids;let x=`Inserted “${m.name}” — ${m.nodes.length} slots`;if(g.model){const v=tu(b,g.model,new globalThis.Set(_.values()));b=v.doc,x+=` · bound ${v.nodes}/${v.totalNodes} metabolites, ${v.reactions}/${v.totalReactions} reactions`}else x+=" · load a GEM to bind them";i(()=>({doc:b,selection:[...[..._.values()].map(v=>Ne("node",v)),...y.textIds.map(v=>Ne("text",v))]})),s(x)},beginPlacing:m=>{e({placing:m,dialog:null,contextMenu:null,tool:"select"}),s(`Click on the canvas to place “${m.name}” · Esc cancels`)},placeAt:m=>{const h=t().placing;if(!h)return;const g=wa(h.preview)??{x:0,y:0,w:0,h:0},y={x:r(m.x-(g.x+g.w/2)),y:r(m.y-(g.y+g.h/2))};e({placing:null}),h.kind==="pathway"?p.instantiatePathway(h.spec,h.mapping,y):h.kind==="reactions"?(p.insertBlock(h.preview,y),s(`Placed ${h.name} · metabolites are new copies (drag one onto another to merge)`)):p.instantiateTemplate(h.template,y)},cancelPlacing:()=>{t().placing&&(e({placing:null}),s("Insertion cancelled"))},instantiatePathway:(m,h,g)=>{const y=t();if(!g){const x=_f(Pd(),m,h,{x:0,y:0},y.model,ke,v=>v).doc;return p.beginPlacing({kind:"pathway",name:m.name,spec:m,mapping:h,preview:x})}const b=_f(y.doc,m,h,g,y.model,ke,r);if(i(()=>({doc:b.doc,selection:[...b.nodeIds,...b.cofactorIds].map(x=>Ne("node",x)).concat(b.textIds.map(x=>Ne("text",x)))})),!h)return s(`Inserted “${m.name}” — ${m.biology.slots.length} slots · load a GEM to map them`);const _=h.slots.filter(x=>x.status==="ambiguous"||x.status==="unresolved").length;s(`Inserted “${m.name}” — ${h.coverage.allMapped}/${h.coverage.all} metabolites, ${b.reactionsBound}/${m.biology.reactions.length} reactions mapped`+(_?` · ${_} open slot${_>1?"s":""} (click one to resolve)`:""))},setTemplateMapping:(m,h)=>{const g=t(),y=g.doc.nodes[m];if(!(y!=null&&y.template)||!g.model)return;const b=y.template,_=h?"confirmed":h===null?"absent":"unresolved",x={...g.doc.nodes,[m]:{...y,metaboliteId:h??void 0,template:{...b,status:_,method:h?"user choice":void 0,score:void 0}}},v=new globalThis.Set([m]),j=[];if(h){const H=Qp(g.model,h);for(const G of Object.values(x)){const M=G.template;if(G.id===m||!M||M.entity!==b.entity||M.compartment===b.compartment||M.status==="confirmed"||M.status==="auto_high"||M.status==="absent")continue;const A=H.get(M.compartment);A&&(x[G.id]={...G,metaboliteId:A,template:{...M,status:"confirmed",method:`same compound as ${h}`,score:void 0}},v.add(G.id),j.push(A))}}const N={...g.doc.reactions};for(const H of Object.values(N)){if(![...H.sources,...H.targets].some(M=>v.has(M)))continue;const G={...H,reactionId:void 0,lumped:void 0,reversedToModel:void 0};Cs(G,x,g.model),N[H.id]=G}i(H=>({doc:{...H.doc,nodes:x,reactions:N}}));const C=oa(g.model),w=la(C.fingerprint),k=b.compartment;if(h===void 0)w&&bo(mC(w,b.entity,k));else{const H={entity:b.entity,compartment:k,metaboliteId:h,templateId:b.templateId,templateVersion:b.templateVersion};let G=au(w,{fingerprint:C.fingerprint,id:g.model.id,name:g.model.name},H);h&&(G=F1(G,g.model,{...H,metaboliteId:h}).profile),bo(G)}const P=y.label??b.slot;s(h?`${P} → ${h} (saved for ${g.model.name})${j.length?` · also ${j.join(", ")} (same compound, other compartment${j.length>1?"s":""})`:""}`:h===null?`${P} marked as absent from ${g.model.name}`:`${P}: mapping cleared`)},confirmProvisional:()=>{var _;const m=t();if(!m.model)return;const h=oa(m.model);let g=la(h.fingerprint);const y={...m.doc.nodes};let b=0;for(const x of Object.values(y))((_=x.template)==null?void 0:_.status)!=="provisional"||!x.metaboliteId||(y[x.id]={...x,template:{...x.template,status:"confirmed"}},g=au(g,{fingerprint:h.fingerprint,id:m.model.id,name:m.model.name},{entity:x.template.entity,compartment:x.template.compartment,metaboliteId:x.metaboliteId,templateId:x.template.templateId,templateVersion:x.template.templateVersion}),b++);if(!b)return s("No provisional mappings to confirm");i(x=>({doc:{...x.doc,nodes:y}})),g&&bo(g),s(`Confirmed ${b} provisional mapping${b>1?"s":""}`)},openTemplate:(m,h)=>{const g=t(),y=m.spec??Rc(m.id);if(!y)return p.instantiateTemplate(m,h);if(!g.model)return p.instantiatePathway(y,null,h);e({dialog:{kind:"templateMapping",templateId:y.id,at:h}})},saveSelectionAsTemplate:m=>{const h=t(),g=l();if(!g.length)return s("Select the part of the map to save");const y=Kw(m,h.doc,g,h.model),b=[...h.userTemplates,y];lf(b),e({userTemplates:b}),s(`Saved template “${m}” — reusable with any model`)},deleteUserTemplate:m=>{const h=t().userTemplates.filter(g=>g.id!==m);lf(h),e({userTemplates:h})},expandNode:(m,h,g)=>{const y=t(),b=y.doc.nodes[m];if(!y.model||!(b!=null&&b.metaboliteId))return s("Bind this node to a model metabolite first");const _=yN(y.model,b.metaboliteId,h,g);if(!_.length)return s("No non-currency neighbours in that direction");const x=u(m,_,h);s(`Added ${x} metabolites · ${_.length} reactions`)},findPath:(m,h,g=!1)=>{var x;const y=t();if(!y.model)return s("Load a GEM first");const b=xN(y.model,m,h,{allowCurrency:g});if(!b)return s("No route found (currency metabolites excluded)");let _=(x=Object.values(y.doc.nodes).find(v=>v.metaboliteId===m))==null?void 0:x.id;_||(_=p.addMetaboliteFromModel(m)),u(_,b,"down"),s(`Path: ${b.length} reactions — ${b.map(v=>v.reactionId).join(" → ")}`)},addConnectedReaction:(m,h)=>{const g=t(),y=g.model,b=g.doc.nodes[m],_=y==null?void 0:y.reactions[h];if(!y||!_||!(b!=null&&b.metaboliteId))return;const x=Object.values(g.doc.reactions).find(z=>{var O,Z;return z.reactionId===h||((O=z.lumped)==null?void 0:O.includes(h))||((Z=z.collapsed)==null?void 0:Z.members.some(oe=>oe.reactionId===h))});if(x)return e({selection:[Ne("reaction",x.id)]}),s(`${h} is already on the canvas${x.collapsed?" (inside a collapsed arrow)":""}`);const v=ws(_,y.metabolites),j=b.metaboliteId,N=(_.stoichiometry[j]??0)<0,C=4,w=1,k=(N?v.products:v.substrates).filter(z=>z!==j),P=(N?v.substrates:v.products).filter(z=>z!==j),H=k.slice(0,C),G=P.slice(0,w),M={...g.doc.nodes},A=g.layoutSpacing,X=N?1:-1,I=(z,O,Z)=>{const oe=ke("n");return M[oe]={id:oe,x:r(O),y:r(Z),metaboliteId:z},oe},K=H.map((z,O)=>I(z,b.x+(O-(H.length-1)/2)*A*1.4,b.y+X*A*1.4)),L=G.map((z,O)=>I(z,b.x-A*1.4*(O+1),b.y));if(!K.length)return s(`${h} has no other non-currency participant to draw`);const D=ke("r"),F=N?{id:D,reactionId:h,sources:[m,...L],targets:K,routing:"straight"}:{id:D,reactionId:h,sources:K,targets:[m,...L],routing:"straight"};i(z=>({doc:{...z.doc,nodes:M,reactions:{...z.doc.reactions,[D]:F}},selection:[Ne("reaction",D)]}));const U=k.length-H.length+P.length-G.length;s(`Added ${h}${U>0?` — ${U} more participant(s) hidden; choose them in the Inspector`:""}`)},setParticipant:(m,h,g)=>{var C;const y=t(),b=y.doc.reactions[m],_=b!=null&&b.reactionId?(C=y.model)==null?void 0:C.reactions[b.reactionId]:void 0;if(!b||!_)return;const x=_.stoichiometry[h]??0,j=(b.reversedToModel?x>0:x<0)?"sources":"targets",N={...y.doc.nodes};if(g){const w=b[j].map(M=>N[M]).filter(Boolean),k=w.reduce((M,A)=>M+A.x,0)/(w.length||1),P=w.reduce((M,A)=>M+A.y,0)/(w.length||1),H=ke("n");N[H]={id:H,x:r(k+(w.length%2?1:-1)*Math.ceil((w.length+1)/2)*70),y:r(P),metaboliteId:h};const G=H;i(M=>({doc:{...M.doc,nodes:N,reactions:{...M.doc.reactions,[m]:{...b,[j]:[...b[j],G]}}}}))}else{const w=b[j].find(P=>{var H;return((H=N[P])==null?void 0:H.metaboliteId)===h});if(!w)return;if(b[j].length===1)return s("An arrow needs at least one metabolite on each side");!(Object.values(y.doc.reactions).some(P=>P.id!==m&&(P.sources.includes(w)||P.targets.includes(w)))||Object.values(y.doc.plots).some(P=>P.anchor.id===w))&&!N[w].locked&&delete N[w],i(P=>({doc:{...P.doc,nodes:N,reactions:{...P.doc.reactions,[m]:{...b,[j]:b[j].filter(H=>H!==w)}}}}))}},mergeNodes:(m,h)=>{const g=t(),y=g.doc.nodes[m],b=g.doc.nodes[h];if(!y||!b||m===h)return;const _=x=>Array.from(new globalThis.Set(x.map(v=>v===m?h:v)));i(x=>{const v=x.doc,j={...v.nodes};delete j[m];const N={};for(const k of Object.values(v.reactions)){if(!k.sources.includes(m)&&!k.targets.includes(m)){N[k.id]=k;continue}const P=_(k.sources),H=_(k.targets).filter(G=>!P.includes(G));P.length&&H.length&&(N[k.id]={...k,sources:P,targets:H})}const C=Object.fromEntries(Object.entries(v.plots).map(([k,P])=>[k,P.anchor.kind==="node"&&P.anchor.id===m?{...P,anchor:{...P.anchor,id:h}}:P])),w=Object.fromEntries(Object.entries(v.groups).map(([k,P])=>[k,P.nodeIds.includes(m)?{...P,nodeIds:_(P.nodeIds)}:P]));return{doc:{...v,nodes:j,reactions:N,plots:C,groups:w},selection:[Ne("node",h)]}}),s(`Merged into ${b.label||b.metaboliteId||"node"}`)},mergeDuplicates:m=>{const h=t(),g=Object.values(h.doc.reactions).filter(j=>j.reactionId===m&&!j.collapsed);if(g.length<2)return;const[y,...b]=g,_=j=>!!j.reversedToModel!=!!y.reversedToModel,x=new globalThis.Set(y.sources),v=new globalThis.Set(y.targets);for(const j of b)(_(j)?j.targets:j.sources).forEach(N=>x.add(N)),(_(j)?j.sources:j.targets).forEach(N=>v.add(N));i(j=>{const N={...j.doc.reactions,[y.id]:{...y,sources:[...x],targets:[...v]}};b.forEach(w=>delete N[w.id]);const C={};for(const[w,k]of Object.entries(j.doc.plots))C[w]=b.some(P=>P.id===k.anchor.id)?{...k,anchor:{kind:"reaction",id:y.id}}:k;return{doc:{...j.doc,reactions:N,plots:C},selection:[Ne("reaction",y.id)]}}),s(`Merged ${g.length} arrows of ${m} into one`)},applyRoute:(m,h,g,y={})=>{const b=t(),_=b.doc.nodes[m],x=b.doc.nodes[h];if(!_||!x||!g.length)return;let v={...b.doc,nodes:{...b.doc.nodes},reactions:{...b.doc.reactions},plots:{...b.doc.plots}};const j=y.replaceGlyph?v.reactions[y.replaceGlyph]:void 0;j&&delete v.reactions[j.id];const N=new Map;N.set(g[0].from,m),N.set(g[g.length-1].to,h);const C=g.length,w=[];g.forEach((P,H)=>{if(!N.has(P.to)){const M=(H+1)/C,A=ke("n");v.nodes[A]={id:A,x:r(_.x+(x.x-_.x)*M),y:r(_.y+(x.y-_.y)*M),metaboliteId:P.to},N.set(P.to,A)}const G=ke("r");v.reactions[G]={id:G,reactionId:P.reactionId,sources:[N.get(P.from)],targets:[N.get(P.to)],routing:"straight",reversedToModel:P.reversed},w.push(G)});let k=w[0];if(y.collapse&&w.length>1){const P=Sf(v,w,{sources:[m],targets:[h]});P&&(v=P.doc,k=P.id,j!=null&&j.label&&(v.reactions[P.id]={...v.reactions[P.id],label:j.label}))}if(j)for(const P of Object.values(v.plots))P.anchor.id===j.id&&(v.plots[P.id]={...P,anchor:{kind:"reaction",id:k}});i(()=>({doc:v,selection:[Ne("reaction",k)]})),s(`Inserted ${C} reaction${C>1?"s":""}: ${g.map(P=>P.reactionId).join(" → ")}${y.collapse&&C>1?" (collapsed)":""}`)},collapseSelection:()=>{const m=t();let h=o("reaction");const g=o("node");let y;if(g.length===2){const[_,x]=g;let v=Gf(m.doc,_,x);y={sources:[_],targets:[x]},v.length||(v=Gf(m.doc,x,_),y={sources:[x],targets:[_]}),v.length?h=v:y=void 0}if(!h.length)return s("Select arrows to collapse, or two metabolites with arrows between them");const b=Sf(m.doc,h,y);b&&(i(()=>({doc:b.doc,selection:[Ne("reaction",b.id)]})),s(b.warning??`Collapsed ${h.length} arrow(s) · ${b.count} reactions (${b.topology}). Flux = net flux entering the segment. Expand anytime.`))},expandGlyph:m=>{const h=AC(t().doc,m);h&&i(()=>({doc:h.doc,selection:h.restored.map(g=>Ne("reaction",g))}))},importModel:m=>{const h=ef(m),g=Jm(h),y=Object.values(h.metabolites),b=y.filter(j=>/__\d+__|^[A-Z]\d{4,}|^MAM\d|^s_\d{4}/.test(j.id)||j.id.length>16).length,_=y.length>0&&b/y.length>.5;i(j=>({model:h,style:_?{...j.style,metaboliteLabel:"name"}:j.style})),_&&setTimeout(()=>s("Metabolite IDs look like database accessions — labels switched to names (Inspector → Labels)"),4300),e({validation:g,leftTab:"model"});const x=t(),v=Object.values(x.doc.nodes).some(j=>!j.metaboliteId||!h.metabolites[j.metaboliteId]);s(`Loaded ${h.name}: ${Object.keys(h.metabolites).length} metabolites, ${Object.keys(h.reactions).length} reactions${v?" — click “Auto-bind” to attach your map":""}`),x.datasets.length&&s("Tip: re-import datasets to re-match IDs against the new model")},importDataset:(m,h)=>{const g=t(),y=lN(h,g.model),{conditions:b,ids:_}=f(y.columns,g.conditions),x=rN(m.replace(/\.(csv|tsv|txt)$/i,""),y,g.model,w=>_[y.columns.indexOf(w)]),v=[...g.mappings],j=(w,k)=>v.some(P=>P.target===w&&P.property===k&&P.enabled);x.kind==="flux"||x.kind==="fva"?(j("reaction","width")||v.push({id:ke("m"),datasetId:x.id,target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0}),j("reaction","color")||v.push({id:ke("m"),datasetId:x.id,target:"reaction",property:"color",scale:"linear",magnitude:!0,enabled:!0})):(x.kind==="metabolite"||x.kind==="turnover")&&(j("metabolite","radius")||v.push({id:ke("m"),datasetId:x.id,target:"metabolite",property:"radius",scale:"sqrt",magnitude:!0,enabled:!0}));const N={...g.view};b.some(w=>w.id===N.activeCondition)||(N.activeCondition=_[0]),b.some(w=>w.id===N.reference)||(N.reference=_[0]),i(()=>({datasets:[...g.datasets,x],conditions:b,mappings:v})),e({view:N,leftTab:"data"});const C=Math.round((x.matchedFraction??1)*100);return s(`${x.name}: ${y.kind} · ${x.columns.length} conditions · ${C}% IDs matched`),x.unmatched.length&&e({dialog:{kind:"importReport",datasetId:x.id}}),x},remapDatasetId:(m,h,g)=>i(y=>({datasets:y.datasets.map(b=>b.id===m?cN(b,h,g):b)})),updateDataset:(m,h)=>i(g=>({datasets:g.datasets.map(y=>y.id===m?{...y,...h}:y)})),removeDataset:m=>{i(y=>{const b=y.datasets.filter(v=>v.id!==m),_=new globalThis.Set(b.flatMap(v=>v.columns)),x=y.conditions.filter(v=>_.has(v.id));return{datasets:b,conditions:x,mappings:y.mappings.filter(v=>v.datasetId!==m)}});const h=t(),g=h.conditions.map(y=>y.id);(!g.includes(h.view.activeCondition)||!g.includes(h.view.reference))&&e({view:{...h.view,activeCondition:g.includes(h.view.activeCondition)?h.view.activeCondition:g[0]??"",reference:g.includes(h.view.reference)?h.view.reference:g[0]??""}})},moveCondition:(m,h)=>i(g=>{const y=g.conditions.findIndex(x=>x.id===m);if(y<0)return{};const b=[...g.conditions],[_]=b.splice(y,1);return b.splice(Math.max(0,Math.min(b.length,h)),0,_),{conditions:b}}),updateCondition:(m,h)=>i(g=>({conditions:g.conditions.map(y=>y.id===m?{...y,...h}:y)})),addMapping:m=>i(h=>({mappings:[...h.mappings,{...m,id:ke("m")}]})),updateMapping:(m,h)=>i(g=>({mappings:g.mappings.map(y=>y.id===m?{...y,...h}:y)})),removeMapping:m=>i(h=>({mappings:h.mappings.filter(g=>g.id!==m)})),setView:m=>e(h=>({view:{...h.view,...m}})),stepCondition:m=>{const h=t();if(!h.conditions.length)return;const g=h.conditions.findIndex(b=>b.id===h.view.activeCondition),y=h.conditions.length;e({view:{...h.view,activeCondition:h.conditions[(g+m+y)%y].id}})},saveView:m=>e(h=>({savedViews:[...h.savedViews,{id:ke("v"),name:m,view:h.view,mappings:h.mappings}]})),applySavedView:m=>{e({view:m.view}),i(()=>({mappings:m.mappings}))},deleteSavedView:m=>e(h=>({savedViews:h.savedViews.filter(g=>g.id!==m)})),setStyle:m=>i(h=>({style:{...h.style,...m}})),setCanvas:m=>e(h=>({canvas:{...h.canvas,...m}})),setAnimation:m=>e(h=>({animation:{...h.animation,...m}})),setCamera:m=>e(h=>({camera:{...h.camera,...m}})),zoomBy:(m,h)=>e(g=>{const y=Math.max(.05,Math.min(8,g.camera.k*m)),b=h??{x:g.viewport.w/2,y:g.viewport.h/2};return{camera:{k:y,x:b.x-(b.x-g.camera.x)/g.camera.k*y,y:b.y-(b.y-g.camera.y)/g.camera.k*y}}}),fitTo:(m,h=2)=>e(g=>{if(!m)return{};const y=Math.min(60,g.viewport.w/8,g.viewport.h/8),b=Math.max(.05,Math.min(h,(g.viewport.w-y*2)/Math.max(m.w,1),(g.viewport.h-y*2)/Math.max(m.h,1)));return{camera:{k:b,x:g.viewport.w/2-(m.x+m.w/2)*b,y:g.viewport.h/2-(m.y+m.h/2)*b}}}),fitAll:()=>p.fitTo(wa(t().doc)),fitSelection:()=>{const m=l();p.fitTo(m.length?wa(t().doc,m):wa(t().doc))},focusNode:m=>{const h=t().doc.nodes[m];h&&(e({selection:[Ne("node",m)]}),p.fitTo({x:h.x-150,y:h.y-100,w:300,h:200},1.6))},loadProject:m=>{const h=Yo();e({...h,...m,style:{...h.style,...m.style},canvas:{...h.canvas,...m.canvas},animation:{...h.animation,...m.animation,playing:!1},doc:{...h.doc,...m.doc},model:m.model?ef(m.model):null,selection:[],past:[],future:[],dialog:null,design:null,validation:m.model?Jm(m.model):[]}),m.mappingProfile&&uC(m.mappingProfile),setTimeout(()=>p.fitAll(),0)},newProject:()=>p.loadProject(Yo()),toProjectFile:()=>{const m=t(),h=m.model&&Object.values(m.doc.nodes).some(g=>g.template)?la(oa(m.model).fingerprint):null;return{format:Hp,version:1,name:m.name,model:m.model&&jN(m.model),mappingProfile:h,datasets:m.datasets,conditions:m.conditions,doc:m.doc,mappings:m.mappings,view:m.view,savedViews:m.savedViews,style:m.style,canvas:m.canvas,animation:{...m.animation,playing:!1}}}};return p}const R=Ts()((e,t)=>({...Yo(),selection:[],camera:{x:300,y:80,k:1},viewport:{w:1200,h:800},tool:"select",past:[],future:[],dialog:null,placing:null,contextMenu:null,paletteOpen:!1,toast:null,leftTab:"elements",hideZeroReactions:!1,leftOpen:!0,rightOpen:!0,userTemplates:zw(),validation:[],layoutSpacing:60,design:null,actions:PC(e,t)})),V=()=>R.getState().actions,Y1=Object.freeze(Object.defineProperty({__proto__:null,A:V,key:Ne,parseKey:Oe,useStore:R},Symbol.toStringTag,{value:"Module"})),Ja="Helvetica, Arial, sans-serif",Ot={nature:{name:"Nature clean",background:"#ffffff",nodeFill:"#111111",nodeStroke:"#111111",slotStroke:"#8a8f98",edge:"#3a3a3a",edgeMuted:"#c4c7cc",metLabel:"#111111",rxnLabel:"#2b3fb8",text:"#111111",plotAxis:"#555555",groupFill:"#f6f7f9",groupStroke:"#d4d7dd",font:Ja,nodeStrokeWidth:0},cell:{name:"Cell graphical",background:"#ffffff",nodeFill:"#ffffff",nodeStroke:"#1f2937",slotStroke:"#94a3b8",edge:"#374151",edgeMuted:"#cbd5e1",metLabel:"#1f2937",rxnLabel:"#7c3aed",text:"#111827",plotAxis:"#6b7280",groupFill:"#fef9ef",groupStroke:"#f1d9a6",font:Ja,nodeStrokeWidth:1.8},minimal:{name:"Minimal",background:"#ffffff",nodeFill:"#6b7280",nodeStroke:"#6b7280",slotStroke:"#9ca3af",edge:"#9ca3af",edgeMuted:"#e5e7eb",metLabel:"#374151",rxnLabel:"#6b7280",text:"#374151",plotAxis:"#9ca3af",groupFill:"#fafafa",groupStroke:"#e5e7eb",font:Ja,nodeStrokeWidth:0},presentation:{name:"Presentation",background:"#ffffff",nodeFill:"#0f172a",nodeStroke:"#0f172a",slotStroke:"#64748b",edge:"#1e293b",edgeMuted:"#cbd5e1",metLabel:"#0f172a",rxnLabel:"#2563eb",text:"#0f172a",plotAxis:"#475569",groupFill:"#f1f5f9",groupStroke:"#cbd5e1",font:Ja,nodeStrokeWidth:0},dark:{name:"Dark",background:"#0f1115",nodeFill:"#e5e7eb",nodeStroke:"#e5e7eb",slotStroke:"#6b7280",edge:"#cbd5e1",edgeMuted:"#374151",metLabel:"#f3f4f6",rxnLabel:"#93c5fd",text:"#f3f4f6",plotAxis:"#9ca3af",groupFill:"#171a21",groupStroke:"#2a2f3a",font:Ja,nodeStrokeWidth:0},grayscale:{name:"Print grayscale",background:"#ffffff",nodeFill:"#000000",nodeStroke:"#000000",slotStroke:"#808080",edge:"#333333",edgeMuted:"#bbbbbb",metLabel:"#000000",rxnLabel:"#444444",text:"#000000",plotAxis:"#555555",groupFill:"#f4f4f4",groupStroke:"#cccccc",font:Ja,nodeStrokeWidth:0}},du=[{id:"auto",name:"Fit content",w:0,h:0},{id:"single",name:"Single column (89 mm)",w:89,h:0},{id:"onehalf",name:"1.5 column (120 mm)",w:120,h:0},{id:"double",name:"Double column (183 mm)",w:183,h:0},{id:"fullpage",name:"Full page (183 × 247 mm)",w:183,h:247},{id:"a4",name:"A4 (210 × 297 mm)",w:210,h:297},{id:"slide",name:"16:9 slide (338.7 × 190.5 mm)",w:338.7,h:190.5}];function mu(e){const t=document.querySelector(".canvas-svg");if(!t)return null;const i=e.getBoundingClientRect();if(!i.width&&!i.height)return null;const a=t.getBoundingClientRect(),s=R.getState().camera;return{x:(i.left-a.left-s.x)/s.k,y:(i.top-a.top-s.y)/s.k,w:i.width/s.k,h:i.height/s.k}}const Df=(e,t)=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y;function RC(e){var i;const t=R.getState();if(e==="view"){const a=(i=document.querySelector(".canvas-svg"))==null?void 0:i.getBoundingClientRect(),s=(a==null?void 0:a.width)||t.viewport.w,o=(a==null?void 0:a.height)||t.viewport.h;return{x:-t.camera.x/t.camera.k,y:-t.camera.y/t.camera.k,w:s/t.camera.k,h:o/t.camera.k}}if(e==="selection"){let a=null;for(const s of t.selection){const o=document.querySelector(`#scene-root [data-sel="${CSS.escape(s)}"]`),l=o&&mu(o);l&&(a=a?{x:Math.min(a.x,l.x),y:Math.min(a.y,l.y),w:Math.max(a.x+a.w,l.x+l.w)-Math.min(a.x,l.x),h:Math.max(a.y+a.h,l.y+l.h)-Math.min(a.y,l.y)}:l)}if(!a)throw new Error("Select something to export the selection");return a}return null}const Pf="http://www.w3.org/2000/svg",Rf=72/25.4;function Ic(e){const t=document.getElementById("scene-root");if(!t)throw new Error("Nothing to export");const i=t.cloneNode(!0),a=RC(e.area);if(a){const m=t.firstElementChild,h=i.firstElementChild;if(m&&h){const g=Array.from(m.children),y=Array.from(h.children);g.forEach((b,_)=>{const x=y[_];if(x)if(b.id){const v=Array.from(b.children),j=Array.from(x.children);v.forEach((N,C)=>{var k;const w=mu(N);(!w||!Df(w,a))&&((k=j[C])==null||k.remove())})}else{const v=mu(b);(!v||!Df(v,a))&&x.remove()}})}}i.querySelectorAll(".ui-only").forEach(m=>m.remove()),i.querySelectorAll("*").forEach(m=>{var g;for(const y of Array.from(m.attributes))(y.name.startsWith("data-")||y.name==="class")&&m.removeAttribute(y.name);const h=m.style;h&&(h.removeProperty("transition"),(g=m.getAttribute("style"))!=null&&g.trim()||m.removeAttribute("style"))}),i.removeAttribute("id");const s=document.createElementNS(Pf,"svg");s.setAttribute("style","position:absolute;left:-99999px;top:0;width:10px;height:10px"),s.appendChild(i),document.body.appendChild(s);const o=i.getBBox();document.body.removeChild(s);const l=e.margin,r=e.area==="view"&&a?{...a}:a?{x:a.x-l,y:a.y-l,w:a.w+2*l,h:a.h+2*l}:{x:o.x-l,y:o.y-l,w:o.width+2*l,h:o.height+2*l};if(!r.w||!r.h)throw new Error("Nothing to export in this area");let c=r.w/Rf,d=r.h/Rf;if(e.widthMm>0){const m=e.widthMm/c;c*=m,d*=m}if(e.heightMm>0&&e.widthMm>0&&d>e.heightMm){const m=e.heightMm/d;c*=m,d*=m}const f=Ot[R.getState().style.preset],u=e.background==="white"?`<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${f.background}"/>`:"";return{svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
58
|
+
<svg xmlns="${Pf}" version="1.1" width="${c.toFixed(2)}mm" height="${d.toFixed(2)}mm" viewBox="${r.x.toFixed(2)} ${r.y.toFixed(2)} ${r.w.toFixed(2)} ${r.h.toFixed(2)}" font-family="${f.font}">
|
|
59
|
+
<title>${e0(R.getState().name)}</title>
|
|
60
|
+
${u}
|
|
61
|
+
`+new XMLSerializer().serializeToString(i).replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"/g,"")+`
|
|
62
|
+
</svg>`,wMm:c,hMm:d}}const e0=e=>e.replace(/[<>&"]/g,t=>({"<":"<",">":">","&":"&",'"':"""})[t]);function Di(e,t,i="application/octet-stream"){const a=typeof t=="string"?new Blob([t],{type:i}):t,s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),2e3)}const Z1=()=>R.getState().name.replace(/[^\w.-]+/g,"_")||"figure";async function Q1(e){const{svg:t,wMm:i,hMm:a}=Ic(e),s=Z1();if(e.format==="svg")return Di(`${s}.svg`,t,"image/svg+xml"),`${s}.svg · ${i.toFixed(0)} × ${a.toFixed(0)} mm`;if(e.format==="pdf"){const c=window.open("","_blank");if(!c)throw new Error("Pop-up blocked — allow pop-ups to print to PDF");return c.document.write(`<!doctype html><title>${e0(s)}</title><style>@page{size:${i.toFixed(2)}mm ${a.toFixed(2)}mm;margin:0}html,body{margin:0}svg{display:block}</style>${t.replace(/^<\?xml[^>]*>/,"")}<script>setTimeout(()=>print(),300)<\/script>`),c.document.close(),"Opened print dialog — choose “Save as PDF” (vector)"}const{blob:o,pxW:l,pxH:r}=await t0(t,i,a,e.dpi);return Di(`${s}_${e.dpi}dpi.png`,o),`${s}_${e.dpi}dpi.png · ${l} × ${r} px`}function J1(e,t,i,a){const s=window.open("","_blank");if(!s)throw new Error("Pop-up blocked — allow pop-ups to print to PDF");s.document.write(`<!doctype html><title>${e0(t)}</title><style>@page{size:${i.toFixed(2)}mm ${a.toFixed(2)}mm;margin:0}html,body{margin:0}svg{display:block}</style>${e.replace(/^<\?xml[^>]*>/,"")}<script>setTimeout(()=>print(),300)<\/script>`),s.document.close()}async function t0(e,t,i,a){const s=Math.round(t/25.4*a),o=Math.round(i/25.4*a),l=new Image,r=URL.createObjectURL(new Blob([e],{type:"image/svg+xml"}));await new Promise((u,p)=>{l.onload=()=>u(),l.onerror=()=>p(new Error("Rasterisation failed")),l.src=r});const c=document.createElement("canvas");c.width=s,c.height=o,c.getContext("2d").drawImage(l,0,0,s,o),URL.revokeObjectURL(r);const f=await new Promise(u=>c.toBlob(p=>u(p),"image/png"));return{blob:await IC(f,a),pxW:s,pxH:o}}async function IC(e,t){const i=new Uint8Array(await e.arrayBuffer()),a=Math.round(t/.0254),s=new Uint8Array(21),o=new DataView(s.buffer);o.setUint32(0,9),s.set([112,72,89,115],4),o.setUint32(8,a),o.setUint32(12,a),s[16]=1,o.setUint32(17,BC(s.subarray(4,17)));const l=33,r=new Uint8Array(i.length+21);return r.set(i.subarray(0,l),0),r.set(s,l),r.set(i.subarray(l),l+21),new Blob([r],{type:"image/png"})}let $l=null;function BC(e){if(!$l){$l=[];for(let i=0;i<256;i++){let a=i;for(let s=0;s<8;s++)a=a&1?3988292384^a>>>1:a>>>1;$l.push(a>>>0)}}let t=4294967295;for(const i of e)t=$l[(t^i)&255]^t>>>8;return(t^4294967295)>>>0}function Bc(){const e=R.getState().actions.toProjectFile();Di(`${Z1()}${Wo}`,JSON.stringify(e),"application/json")}const so="gemsmap.autosave",dr="autosave.model",HC=2e6,ex=5*60*1e3;let If=null,uu=!1,Bf=!1;function tx(){const e=R.getState();if(e.design)return;if(!Bf){Bf=!0;try{const s=localStorage.getItem(so);s&&localStorage.setItem(`${so}.previous`,s)}catch{}Cc(dr).then(s=>{s&&Xr(`${dr}.previous`,s)})}const t={...e.actions.toProjectFile(),_savedAt:Date.now()},i=t.model?JSON.stringify(t.model):"";let a;i.length>HC?(If!==e.model&&(If=e.model,Xr(dr,i)),a=JSON.stringify({...t,model:null,_modelInIdb:t.model.id})):a=JSON.stringify(t);try{localStorage.setItem(so,a)}catch{try{localStorage.setItem(so,JSON.stringify({...t,model:null,_modelDropped:!0}))}catch{}}uu=!1}function nx(){R.subscribe((e,t)=>{e.design||e.doc===t.doc&&e.mappings===t.mappings&&e.datasets===t.datasets&&e.model===t.model&&e.style===t.style&&e.view===t.view&&e.name===t.name||(uu=!0)}),window.setInterval(()=>{uu&&tx()},ex)}function ix(){try{const e=localStorage.getItem(so);return e?JSON.parse(e):null}catch{return null}}async function ax(){const e=await Cc(dr);try{return e?JSON.parse(e):null}catch{return null}}const OC=Object.freeze(Object.defineProperty({__proto__:null,AUTOSAVE_EVERY_MS:ex,buildSvg:Ic,download:Di,exportFigure:Q1,loadAutosave:ix,loadAutosavedModel:ax,printSvgAsPdf:J1,saveProjectFile:Bc,saveTempSession:tx,startAutosave:nx,svgToPng:t0},Symbol.toStringTag,{value:"Module"})),$C="modulepreload",LC=function(e){return"/"+e},Hf={},ra=function(t,i,a){let s=Promise.resolve();if(i&&i.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),r=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.allSettled(i.map(c=>{if(c=LC(c),c in Hf)return;Hf[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const u=document.createElement("link");if(u.rel=d?"stylesheet":$C,d||(u.as="script"),u.crossOrigin="",u.href=c,r&&u.setAttribute("nonce",r),document.head.appendChild(u),d)return new Promise((p,m)=>{u.addEventListener("load",p),u.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(l){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=l,window.dispatchEvent(r),!r.defaultPrevented)throw l}return s.then(l=>{for(const r of l||[])r.status==="rejected"&&o(r.reason);return t().catch(o)})},Rd={},n0=(Rd==null?void 0:Rd.VITE_COBRA_API)??"/api";class On extends Error{constructor(t){super(t.message?`${t.title}: ${t.message}`:t.title),this.info=t}}async function Fe(e,t={}){let i;try{i=await fetch(n0+e,t)}catch(a){throw a.name==="AbortError"?new On({title:"Simulation cancelled",message:"",hints:[],status:499,detail:{cancelled:!0}}):new On({title:"COBRApy backend unreachable",message:a.message,hints:["Start GEMsMAP: run gemsmap in a terminal and keep it open","Development checkout: npm run backend (it listens on http://127.0.0.1:8765)"],status:0})}if(!i.ok){let a={title:`Backend error ${i.status}`,message:i.statusText,hints:[],status:i.status};try{const s=await i.json();s!=null&&s.error?a={...s.error,status:i.status}:s!=null&&s.detail&&(a.message=typeof s.detail=="string"?s.detail:JSON.stringify(s.detail))}catch{}throw(i.status===502||i.status===504)&&(a={title:"COBRApy backend unreachable",message:"The Vite proxy could not reach the backend.",hints:["Development checkout: start the backend with npm run backend"],status:i.status}),new On(a)}return i.json()}const Bt=(e,t)=>({method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});async function Of(e,t){var o;const i=await fetch(n0+e,Bt("POST",t));if(!i.ok){let l={title:`Export failed (${i.status})`,message:"",hints:[]};try{const r=await i.json();r!=null&&r.error&&(l=r.error)}catch{}throw new On(l)}const s=((o=(i.headers.get("Content-Disposition")??"").match(/filename="([^"]+)"/))==null?void 0:o[1])??"export";return{blob:await i.blob(),filename:s}}const Se={health:()=>Fe("/health"),examples:()=>Fe("/examples"),importModel:e=>{const t=new FormData;return t.append("file",e),Fe("/models/import",{method:"POST",body:t})},importExample:e=>Fe(`/models/examples/${e}`,{method:"POST"}),getModel:e=>Fe(`/models/${e}`),medium:(e,t)=>Fe(`/models/${e}/medium/query`,Bt("POST",{state:t})),setMedium:(e,t,i)=>Fe(`/models/${e}/medium`,Bt("PUT",{state:t,medium:i})),mediumPreset:(e,t,i,a={})=>Fe(`/models/${e}/medium/preset`,Bt("POST",{state:t,preset:i,...a})),simulate:(e,t,i,a,s={})=>Fe(`/models/${e}/simulate/${t}`,{...Bt("POST",{state:i,params:a,name:s.name,jobId:s.jobId}),signal:s.signal}),checkEdits:(e,t)=>Fe(`/models/${e}/edits/check`,Bt("POST",{ops:t})),commitEdits:(e,t,i)=>Fe(`/models/${e}/edits`,Bt("POST",{ops:t,label:i})),editHistory:e=>Fe(`/models/${e}/edits`),undoEdit:e=>Fe(`/models/${e}/edits/undo`,{method:"POST"}),redoEdit:e=>Fe(`/models/${e}/edits/redo`,{method:"POST"}),discardEdits:e=>Fe(`/models/${e}/edits/discard`,{method:"POST"}),editPatch:async e=>{var i,a;const t=await fetch(`${n0}/models/${e}/edits/patch`);if(!t.ok)throw new On({title:`Patch export failed (${t.status})`,message:"",hints:[]});return{blob:await t.blob(),filename:((a=(i=t.headers.get("Content-Disposition"))==null?void 0:i.match(/filename="([^"]+)"/))==null?void 0:a[1])??"model_patch.json"}},validateModel:e=>Fe(`/models/${e}/validate`),identityCompounds:(e,t=12)=>Fe(`/identity/compounds?q=${encodeURIComponent(e)}&limit=${t}`),job:e=>Fe(`/jobs/${e}`),cancelJob:(e,t=!1)=>Fe(`/jobs/${e}/cancel`,Bt("POST",{keep:t})),compare:(e,t,i,a)=>Fe("/results/compare",Bt("POST",{a:e,b:t,zeroTolerance:i,pseudocount:a})),explainTurnover:(e,t,i,a,s)=>Fe(`/models/${e}/explain-turnover`,Bt("POST",{metabolite:t,fluxesA:i,fluxesB:a,zeroTolerance:s})),derive:(e,t)=>Fe(`/models/${e}/derive`,Bt("POST",{fluxes:t})),exportResult:(e,t,i)=>Of("/results/export",{result:e,format:t,table:i}),exportModel:(e,t,i)=>Of(`/models/${e}/export`,{state:t,format:i}),metabolites:e=>Fe(`/models/${e}/metabolites`),annotation:(e,t=!0)=>Fe(`/models/${e}/annotation${t?"":"?full=false"}`),analyzeAnnotation:(e,t)=>Fe(`/models/${e}/annotation/analyze`,Bt("POST",t)),applyAnnotation:(e,t)=>Fe(`/models/${e}/annotation/apply`,Bt("POST",{items:t})),rejectAnnotation:(e,t)=>Fe(`/models/${e}/annotation/reject`,Bt("POST",{ids:t})),revertAnnotation:(e,t)=>Fe(`/models/${e}/annotation/revert`,Bt("POST",{ids:t}))};function i0(e,t){const i=URL.createObjectURL(e),a=document.createElement("a");a.href=i,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(i),2e3)}const yt="mmol gDW⁻¹ h⁻¹";function W(e,t=4){if(e==null||Number.isNaN(e))return"—";if(!Number.isFinite(e))return e>0?"∞":"−∞";if(e===0)return"0";const i=Math.abs(e);return i>=1e5||i<1e-4?e.toExponential(2).replace("-","−"):Number(e.toPrecision(t+2)).toString().replace("-","−")}const sx=(e,t,i)=>e==null||t==null?null:Math.abs(t-e)<i?0:t-e,rt=(e,t)=>e==null?t==="lower"?"−∞":"∞":W(e),Ua=e=>`[${rt(e[0],"lower")}, ${rt(e[1],"upper")}]`;function Pi(e){if(!e||!Object.keys(e.coefficients).length)return"none";const t=Object.entries(e.coefficients).map(([i,a],s)=>`${a<0?"− ":s?"+ ":""}${W(Math.abs(a),3)} × ${i}`);return`${e.direction==="max"?"max":"min"} ${t.join(" ")}`}const ox={optimal:"Optimal",infeasible:"Infeasible",unbounded:"Unbounded",infeasible_or_unbounded:"Infeasible or unbounded",undefined:"Undefined",error:"Error"},Qt={fba:{label:"FBA",short:"FBA",blurb:"Find an optimal flux distribution.",more:"Linear programming: maximizes (or minimizes) the objective subject to steady-state mass balance (S·v = 0) and reaction bounds. Many flux distributions can share the same optimum; FBA returns one of them."},pfba:{label:"pFBA",short:"pFBA",blurb:"Optimal solution that minimizes total flux.",more:"Parsimonious FBA: first finds the optimal objective, then fixes it (or a fraction of it) and minimizes the sum of absolute fluxes. Gives a more unique, enzyme-economical flux distribution."},loopless:{label:"Loopless FBA",short:"Loopless",blurb:"Avoid thermodynamically infeasible internal loops.",more:"CycleFreeFlux (COBRApy loopless_solution): removes internal cycles from an optimal FBA solution while preserving exchange fluxes and the objective value."},fva:{label:"FVA",short:"FVA",blurb:"Feasible flux range of each reaction.",more:"Flux variability analysis: for each reaction independently, the minimum and maximum flux compatible with the constraints and a fraction of the optimal objective. The intervals are not a joint flux distribution — the midpoint is not a solution."},sampling:{label:"Flux sampling",short:"Sampling",blurb:"Distribution of feasible flux states.",more:"COBRApy hit-and-run sampling (OptGP or ACHR): draws flux vectors uniformly from the space allowed by the constraints, optionally with the objective kept above a fraction of the optimum. Each reaction gets a distribution (mean, median, 95% interval) instead of one value. Samples that fail COBRApy's validation are dropped. Slower than FBA: start with a few hundred samples."}};function lx(e){return{exchange:"Exchange",demand:"Demand",sink:"Sink",transport:"Transport",internal:"Internal"}[e]}const rx=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function cx(e){return e.map(t=>t.map(i=>{const a=i==null?"":String(i);return/[",\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}).join(",")).join(`
|
|
63
|
+
`)}const TC="gemsmap-lab",Jo="sessions";async function dx(){return await Fu,new Promise((e,t)=>{const i=indexedDB.open(TC,1);i.onupgradeneeded=()=>i.result.createObjectStore(Jo),i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})}async function FC(e){try{const t=await dx();return await new Promise((i,a)=>{const s=t.transaction(Jo,"readonly").objectStore(Jo).get(e);s.onsuccess=()=>i(s.result),s.onerror=()=>a(s.error)})}catch{return}}async function XC(e,t){try{const i=await dx();await new Promise((a,s)=>{const o=i.transaction(Jo,"readwrite");o.objectStore(Jo).put(t,e),o.oncomplete=()=>a(),o.onerror=()=>s(o.error)})}catch(i){console.warn("[COBRAGUI] could not persist session",i)}}function yo(e,t){try{const i=localStorage.getItem(e);return i==null?t:{...t,...JSON.parse(i)}}catch{return t}}function qr(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const KC=()=>`imp_${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`,xo=e=>e.replace(/\.[^.]+$/,""),ut=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()===""||/^(na|nan|null|none)$/i.test(e.trim()))return null;const t=Number(e.trim().replace("−","-"));return Number.isFinite(t)?t:null},zC=["fba","pfba","loopless","fva","sampling"],UC={fba:"fba",pfba:"pfba","loopless fba":"loopless",loopless:"loopless",fva:"fva"};function pu(e){return/"cobragui-result"|"last_fluxes"|"last_fva_min"|"reactionFluxes"/.test(e)}function Ca(e){return{model:{id:"",modelId:"",name:"",filename:"",checksum:"",format:"",...e.model},state:{id:null,name:"not recorded (imported)"},method:e.method,methodLabel:e.label,solver:"not recorded",cobraVersion:"",objective:{coefficients:e.objective??{},direction:"max"},objectiveIsModelDefault:!1,medium:{},boundChanges:[],parameters:{},timestamp:new Date().toISOString(),elapsedSeconds:0,solverStatusRaw:"not recorded (imported file)",message:null,tolerance:null}}function bs(e,t,i,a,s,o){return{id:KC(),name:i,modelId:"",modelStateId:null,method:a,solverStatus:"optimal",objectiveValue:null,reactionFluxes:null,fva:null,metaboliteTurnover:null,exchanges:null,diagnostics:[],metadata:s,createdAt:Date.now(),origin:{kind:"imported",file:e,format:t,importedAt:Date.now(),notes:o}}}function ui(e){if(!e||typeof e!="object")return null;const t={};for(const[i,a]of Object.entries(e))t[i]=ut(a);return t}function qC(e,t){let i;try{i=JSON.parse(t)}catch(l){throw new Error(`Not valid JSON: ${l.message}`)}const a=Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.results)?i.results:[i],s=[],o=[];a.forEach((l,r)=>{if(!l||typeof l!="object")throw new Error(`Entry ${r+1} is not an object`);const c=l,d=a.length>1?`${xo(e)} #${r+1}`:xo(e);if(c.format==="cobragui-result"||"metadata"in c&&("reactionFluxes"in c||"fva"in c)){const f=c.metadata,u=zC.includes(c.method)?c.method:"fba",p=bs(e,"json",String(c.name||d),u,f?{...Ca({method:u,label:u.toUpperCase()}),...f}:Ca({method:u,label:u.toUpperCase()}),[]);p.solverStatus=c.solverStatus||"optimal",p.objectiveValue=ut(c.objectiveValue),p.reactionFluxes=ui(c.reactionFluxes),p.metaboliteTurnover=ui(c.metaboliteTurnover),p.exchanges=c.exchanges??null,p.diagnostics=Array.isArray(c.diagnostics)?c.diagnostics:[],p.stateSnapshot=c.stateSnapshot??void 0;const m=c.samples;if(m&&typeof m=="object"&&m.summary){const h={};for(const[y,b]of Object.entries(m.reactions??{}))h[y]=(Array.isArray(b)?b:[]).map(ut).filter(_=>_!=null);const g={};for(const[y,b]of Object.entries(m.summary))g[y]={mean:ut(b.mean),sd:ut(b.sd),median:ut(b.median),q025:ut(b.q025),q25:ut(b.q25),q75:ut(b.q75),q975:ut(b.q975),min:ut(b.min),max:ut(b.max)};p.samples={reactions:h,constant:ui(m.constant)??{},summary:g}}if(c.fva&&typeof c.fva=="object"){p.fva={};for(const[h,g]of Object.entries(c.fva))p.fva[h]={minimum:ut(g==null?void 0:g.minimum),maximum:ut(g==null?void 0:g.maximum)}}s.push(p)}else if("last_fluxes"in c||"last_fva_min"in c){const f={filename:typeof c.model_file=="string"?c.model_file:""},u=ui(c.objective)??{},p=ui(c.last_fva_min),m=ui(c.last_fva_max);if(p&&m){const h="The legacy GEM Explorer stored FVA midpoints as fluxes; they were ignored — only the min/max intervals were imported.",g=bs(e,"legacy-json",`${d} (FVA)`,"fva",Ca({method:"fva",label:"FVA (legacy GEM Explorer)",model:f,objective:u}),[h]);g.fva={};for(const y of new Set([...Object.keys(p),...Object.keys(m)]))g.fva[y]={minimum:p[y]??null,maximum:m[y]??null};o.push(h),s.push(g)}else{const h=bs(e,"legacy-json",d,"fba",Ca({method:"fba",label:"Flux distribution (legacy GEM Explorer)",model:f,objective:u}),[]);h.reactionFluxes=ui(c.last_fluxes);const g=ui(c.met_throughput);g&&Object.keys(g).length&&(h.metaboliteTurnover=g),s.push(h)}}else{const f=Object.values(c);if(f.length&&f.every(u=>typeof u=="number"||u===null)){const u=bs(e,"json",d,"fba",Ca({method:"fba",label:"Imported flux table"}),[]);u.reactionFluxes=ui(c),s.push(u)}else throw new Error("Unrecognized JSON. Expected a result exported by COBRAGUI, a legacy GEM Explorer export, or {reaction_id: flux}.")}});for(const l of s)if(!l.reactionFluxes&&!l.fva&&!l.samples)throw new Error(`“${l.name}” contains no reaction fluxes, FVA intervals or flux samples`);return{results:s,notes:o}}function VC(e){var o,l,r,c,d,f;const t=u=>{var p,m;return(m=(p=e.match(new RegExp(`^#\\s*${u}:\\s*(.*)$`,"mi")))==null?void 0:p[1])==null?void 0:m.trim()},i=t("method"),a=(o=i==null?void 0:i.split(/\s{2,}|\s+solver:/)[0])==null?void 0:o.trim(),s=t("model");return{name:t("result"),method:a?UC[a.toLowerCase()]:void 0,methodLabel:a,status:(l=i==null?void 0:i.match(/status:\s*(\w+)/))==null?void 0:l[1],solver:(r=i==null?void 0:i.match(/solver:\s*(\S+)/))==null?void 0:r[1],filename:s==null?void 0:s.replace(/\s*\(sha256.*$/,""),checksum:(c=s==null?void 0:s.match(/sha256\s+([0-9a-f]+)/))==null?void 0:c[1],state:t("state"),objectiveValue:ut((f=(d=t("objective"))==null?void 0:d.match(/value:\s*(\S+)/))==null?void 0:f[1])}}const WC=/^(.*?)[\s_.-]*(minimum|maximum|min|max|lower|upper|lb|ub)$/i;function YC(e,t){var y;const i=y1(t);if(i.length<2)throw new Error("The table needs a header row and at least one data row.");const[a,...s]=i,o=a[0].toLowerCase(),l=/\.tsv$/i.test(e)||(y=t.split(`
|
|
64
|
+
`).find(b=>b&&!b.startsWith("#")))!=null&&y.includes(" ")?"tsv":"csv";if(/metab|compound|species/.test(o))throw new Error("This is a metabolite table (e.g. turnover). Import a reaction flux or FVA table.");const r=a.map(b=>b.trim().toLowerCase());if(r.includes("uptake")&&r.includes("secretion"))throw new Error("This is an exchange table. Import the reaction flux table instead.");const c=VC(t),d=[],f={filename:c.filename??"",checksum:c.checksum??""},u=b=>s.filter(_=>ut(_[b])!=null).length>=Math.max(1,s.length*.5),p=new Map;a.forEach((b,_)=>{if(_===0)return;const x=b.trim().match(WC);if(!x)return;const v=x[1]||"",j=p.get(v)??{};/^(min|minimum|lower|lb)$/i.test(x[2])?j.lo=_:j.hi=_,p.set(v,j)});const m=[...p.entries()].filter(([,b])=>b.lo!=null&&b.hi!=null),h=[];if(m.length){for(const[b,_]of m){const x=b?`${c.name??xo(e)} · ${b}`:c.name??xo(e),v=bs(e,l,x,"fva",Ca({method:"fva",label:c.methodLabel??"FVA (imported table)",model:f}),[]);v.fva={};for(const j of s){const N=ut(j[_.lo]),C=ut(j[_.hi]);j[0]&&(v.fva[j[0]]={minimum:N==null||C==null?N:Math.min(N,C),maximum:N==null||C==null?C:Math.max(N,C)})}h.push(v)}return{results:h,notes:d}}const g=a.map((b,_)=>_).slice(1).filter(b=>!/^(range|width|name|subsystem|equation|gpr|genes?)$/i.test(a[b].trim())&&u(b));if(!g.length)throw new Error("No numeric flux column found.");for(const b of g){const _=a[b].trim(),x=g.length===1,v=x?c.name??(/^(flux|fluxes|value|v)$/i.test(_)?xo(e):_):_,j=x&&c.method?c.method:"fba",N=bs(e,l,v,j,Ca({method:j,label:x&&c.methodLabel?c.methodLabel:"Imported flux table",model:f}),[]);x&&(c.status&&(N.solverStatus=c.status),N.objectiveValue=c.objectiveValue,c.solver&&(N.metadata.solver=c.solver),c.state&&(N.metadata.state={id:null,name:c.state})),N.reactionFluxes={};for(const C of s)C[0]&&(N.reactionFluxes[C[0]]=ut(C[b]));h.push(N)}return g.length>1&&d.push(`${g.length} numeric columns → ${g.length} results (${g.map(b=>a[b]).join(", ")})`),{results:h,notes:d}}function mx(e,t){return/\.json$/i.test(e)||t.trimStart().startsWith("{")||t.trimStart().startsWith("[")?qC(e,t):YC(e,t)}function ga(e){return Array.isArray?Array.isArray(e):px(e)==="[object Array]"}function ZC(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function hu(e){return e==null?"":ZC(e)}function Dt(e){return typeof e=="string"}function mr(e){return typeof e=="number"}function QC(e){return e===!0||e===!1||JC(e)&&px(e)=="[object Boolean]"}function ux(e){return typeof e=="object"}function JC(e){return ux(e)&&e!==null}function rn(e){return e!=null}function Ll(e){return!e.trim().length}function px(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const e3="Incorrect 'index' type",fu="Invalid doc index: must be a non-negative integer within the bounds of the docs array",t3=e=>`Invalid value for key ${e}`,n3=e=>`Pattern length exceeds max of ${e}.`,i3=e=>`Missing ${e} property in key`,a3=e=>`Property 'weight' in key '${e}' must be a positive integer`,s3="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",$f=Object.prototype.hasOwnProperty;var o3=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(i=>{const a=hx(i);this._keys.push(a),this._keyMap[a.id]=a,t+=a.weight}),this._keys.forEach(i=>{i.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function hx(e){let t=null,i=null,a=null,s=1,o=null;if(Dt(e)||ga(e))a=e,t=Lf(e),i=ur(e);else{if(!$f.call(e,"name"))throw new Error(i3("name"));const l=e.name;if(a=l,$f.call(e,"weight")&&e.weight!==void 0&&(s=e.weight,s<=0))throw new Error(a3(ur(l)));t=Lf(l),i=ur(l),o=e.getFn??null}return{path:t,id:i,weight:s,src:a,getFn:o}}function Lf(e){return ga(e)?e:e.split(".")}function ur(e){return ga(e)?e.join("."):e}function l3(e,t){const i=[];let a=!1;const s=(o,l,r,c)=>{if(rn(o))if(!l[r])i.push(c!==void 0?{v:o,i:c}:o);else{const d=o[l[r]];if(!rn(d))return;if(r===l.length-1&&(Dt(d)||mr(d)||QC(d)||typeof d=="bigint"))i.push(c!==void 0?{v:hu(d),i:c}:hu(d));else if(ga(d)){a=!0;for(let f=0,u=d.length;f<u;f+=1)s(d[f],l,r+1,f)}else l.length&&s(d,l,r+1,c)}};return s(e,Dt(t)?t.split("."):t,0),a?i:i[0]}const r3={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},c3={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},d3={location:0,threshold:.6,distance:100},m3={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:l3,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},be=Object.freeze({...c3,...r3,...d3,...m3});function u3(e){return e>=9&&e<=13||e===32||e===160}function p3(e=1,t=3){const i=new Map,a=Math.pow(10,t);return{get(s){let o=0,l=!1;for(let c=0;c<s.length;c++)u3(s.charCodeAt(c))?l=!1:l||(o++,l=!0);if(o===0&&(o=1),i.has(o))return i.get(o);const r=Math.round(a/Math.pow(o,.5*e))/a;return i.set(o,r),r},clear(){i.clear()}}}var a0=class{constructor({getFn:e=be.getFn,fieldNormWeight:t=be.fieldNormWeight}={}){this.norm=p3(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,i)=>{this._keysMap[t.id]=i})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(Dt(this.docs[0]))for(let i=0;i<e;i++){const a=this._createStringRecord(this.docs[i],i);a&&(this.records[t++]=a)}else for(let i=0;i<e;i++)this.records[t++]=this._createObjectRecord(this.docs[i],i);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(fu);if(Dt(e)){const a=this._createStringRecord(e,t);return a&&this.records.push(a),a}const i=this._createObjectRecord(e,t);return this.records.push(i),i}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(fu);for(let t=0,i=this.records.length;t<i;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,i=this.records.length;t<i;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const a of e)Number.isInteger(a)&&a>=0&&t.add(a);if(t.size===0)return;this.records=this.records.filter(a=>!t.has(a.i));const i=Array.from(t).sort((a,s)=>a-s);for(const a of this.records){let s=0,o=i.length;for(;s<o;){const l=s+o>>>1;i[l]<a.i?s=l+1:o=l}a.i-=s}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!rn(e)||Ll(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const i={i:t,$:{}};for(let a=0,s=this.keys.length;a<s;a++){const o=this.keys[a],l=o.getFn?o.getFn(e):this.getFn(e,o.path);if(rn(l)){if(ga(l)){const r=[];for(let c=0,d=l.length;c<d;c+=1){const f=l[c];if(rn(f)){if(Dt(f)){if(!Ll(f)){const u={v:f,i:c,n:this.norm.get(f)};r.push(u)}}else if(rn(f.v)){const u=Dt(f.v)?f.v:hu(f.v);if(!Ll(u)){const p={v:u,i:f.i,n:this.norm.get(u)};r.push(p)}}}}i.$[a]=r}else if(Dt(l)&&!Ll(l)){const r={v:l,n:this.norm.get(l)};i.$[a]=r}}}return i}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function fx(e,t,{getFn:i=be.getFn,fieldNormWeight:a=be.fieldNormWeight}={}){const s=new a0({getFn:i,fieldNormWeight:a});return s.setKeys(e.map(hx)),s.setSources(t),s.create(),s}function h3(e,{getFn:t=be.getFn,fieldNormWeight:i=be.fieldNormWeight}={}){const{keys:a,records:s}=e,o=new a0({getFn:t,fieldNormWeight:i});return o.setKeys(a),o.setIndexRecords(s),o}function f3(e=[],t=be.minMatchCharLength){const i=[];let a=-1,s=-1,o=0;for(let l=e.length;o<l;o+=1){const r=e[o];r&&a===-1?a=o:!r&&a!==-1&&(s=o-1,s-a+1>=t&&i.push([a,s]),a=-1)}return e[o-1]&&o-a>=t&&i.push([a,o-1]),i}function g3(e,t,i,{location:a=be.location,distance:s=be.distance,threshold:o=be.threshold,findAllMatches:l=be.findAllMatches,minMatchCharLength:r=be.minMatchCharLength,includeMatches:c=be.includeMatches,ignoreLocation:d=be.ignoreLocation}={}){if(t.length>32)throw new Error(n3(32));const f=t.length,u=e.length,p=Math.max(0,Math.min(a,u));let m=o,h=p;const g=(k,P)=>{const H=k/f;if(d)return H;const G=Math.abs(p-P);return s?H+G/s:G?1:H},y=r>1||c,b=y?Array(u):[];let _;for(;(_=e.indexOf(t,h))>-1;){const k=g(0,_);if(m=Math.min(k,m),h=_+f,y){let P=0;for(;P<f;)b[_+P]=1,P+=1}}h=-1;let x=[],v=1,j=0,N=f+u;const C=1<<f-1;for(let k=0;k<f;k+=1){let P=0,H=N;for(;P<H;)g(k,p+H)<=m?P=H:N=H,H=Math.floor((N-P)/2+P);N=H;let G=Math.max(1,p-H+1);const M=l?u:Math.min(p+H,u)+f,A=Array(M+2);A[M+1]=(1<<k)-1;for(let X=M;X>=G;X-=1){const I=X-1,K=i[e[I]];if(A[X]=(A[X+1]<<1|1)&K,k&&(A[X]|=(x[X+1]|x[X])<<1|1|x[X+1]),A[X]&C&&(v=g(k,I),v<=m)){if(m=v,h=I,j=k,h<=p)break;G=Math.max(1,2*p-h)}}if(g(k+1,p)>m)break;x=A}if(y&&h>=0){const k=Math.min(u-1,h+f-1+j);for(let P=h;P<=k;P+=1)i[e[P]]&&(b[P]=1)}const w={isMatch:h>=0,score:Math.max(.001,v)};if(y){const k=f3(b,r);k.length?c&&(w.indices=k):w.isMatch=!1}return w}function b3(e){const t={};for(let i=0,a=e.length;i<a;i+=1){const s=e.charAt(i);t[s]=(t[s]||0)|1<<a-i-1}return t}function s0(e){if(e.length<=1)return e;e.sort((i,a)=>i[0]-a[0]||i[1]-a[1]);const t=[e[0]];for(let i=1,a=e.length;i<a;i+=1){const s=t[t.length-1],o=e[i];o[0]<=s[1]+1?s[1]=Math.max(s[1],o[1]):t.push(o)}return t}const gx={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},y3=new RegExp("["+Object.keys(gx).join("")+"]","g"),el=typeof String.prototype.normalize=="function"?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(y3,t=>gx[t]):e=>e;var o0=class{constructor(e,{location:t=be.location,threshold:i=be.threshold,distance:a=be.distance,includeMatches:s=be.includeMatches,findAllMatches:o=be.findAllMatches,minMatchCharLength:l=be.minMatchCharLength,isCaseSensitive:r=be.isCaseSensitive,ignoreDiacritics:c=be.ignoreDiacritics,ignoreLocation:d=be.ignoreLocation}={}){if(this.options={location:t,threshold:i,distance:a,includeMatches:s,findAllMatches:o,minMatchCharLength:l,isCaseSensitive:r,ignoreDiacritics:c,ignoreLocation:d},e=r?e:e.toLowerCase(),e=c?el(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(p,m)=>{this.chunks.push({pattern:p,alphabet:b3(p),startIndex:m})},u=this.pattern.length;if(u>32){let p=0;const m=u%32,h=u-m;for(;p<h;)f(this.pattern.substr(p,32),p),p+=32;if(m){const g=u-32;f(this.pattern.substr(g),g)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:i,includeMatches:a}=this.options;if(e=t?e:e.toLowerCase(),e=i?el(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return a&&(h.indices=[[0,e.length-1]]),h}const{location:s,distance:o,threshold:l,findAllMatches:r,minMatchCharLength:c,ignoreLocation:d}=this.options,f=[];let u=0,p=!1;this.chunks.forEach(({pattern:h,alphabet:g,startIndex:y})=>{const{isMatch:b,score:_,indices:x}=g3(e,h,g,{location:s+y,distance:o,threshold:l,findAllMatches:r,minMatchCharLength:c,includeMatches:a,ignoreLocation:d});b&&(p=!0),u+=_,b&&x&&f.push(...x)});const m={isMatch:p,score:p?u/this.chunks.length:1};return p&&a&&(m.indices=s0(f)),m}};const x3=new Set(["fuzzy","include"]);function _3(e){return e.startsWith("inverse")}const gu=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const i=t===e;return{isMatch:i,score:i?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let i=0,a;const s=[],o=e.length;for(;(a=t.indexOf(e,i))>-1;)i=a+o,s.push([a,i-1]);const l=!!s.length;return{isMatch:l,score:l?0:1,indices:s}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const i=t.startsWith(e);return{isMatch:i,score:i?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const i=!t.startsWith(e);return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const i=!t.endsWith(e);return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const i=t.endsWith(e);return{isMatch:i,score:i?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const i=t.indexOf(e)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const i=new o0(e,{location:t.location??be.location,threshold:t.threshold??be.threshold,distance:t.distance??be.distance,includeMatches:t.includeMatches??be.includeMatches,findAllMatches:t.findAllMatches??be.findAllMatches,minMatchCharLength:t.minMatchCharLength??be.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??be.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??be.ignoreDiacritics,ignoreLocation:t.ignoreLocation??be.ignoreLocation});return{type:"fuzzy",search(a){return i.searchIn(a)}}}}],Tf=gu.length,v3="\0",j3="|";function N3(e){const t=[],i=e.length;let a=0;for(;a<i;){for(;a<i&&e[a]===" ";)a++;if(a>=i)break;let s=a;for(;s<i&&e[s]!==" "&&e[s]!=='"';)s++;if(s<i&&e[s]==='"'){for(s++;s<i;){if(e[s]==='"'){const o=s+1;if(o>=i||e[o]===" "){s++;break}if(e[o]==="$"&&(o+1>=i||e[o+1]===" ")){s+=2;break}}s++}t.push(e.substring(a,s)),a=s}else{for(;s<i&&e[s]!==" ";)s++;t.push(e.substring(a,s)),a=s}}return t}function Ff(e,t){const i=e.match(t);return i?i[1]:null}function w3(e,t={}){return e.replace(/\\\|/g,v3).split(j3).map(i=>{const a=N3(i.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),s=[];for(let o=0,l=a.length;o<l;o+=1){const r=a[o];let c=!1,d=-1;for(;!c&&++d<Tf;){const f=gu[d],u=Ff(r,f.multiRegex);u&&(s.push(f.create(u,t)),c=!0)}if(!c)for(d=-1;++d<Tf;){const f=gu[d],u=Ff(r,f.singleRegex);if(u){s.push(f.create(u,t));break}}}return s})}var C3=class{constructor(e,{isCaseSensitive:t=be.isCaseSensitive,ignoreDiacritics:i=be.ignoreDiacritics,includeMatches:a=be.includeMatches,minMatchCharLength:s=be.minMatchCharLength,ignoreLocation:o=be.ignoreLocation,findAllMatches:l=be.findAllMatches,location:r=be.location,threshold:c=be.threshold,distance:d=be.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:i,includeMatches:a,minMatchCharLength:s,findAllMatches:l,ignoreLocation:o,location:r,threshold:c,distance:d},e=t?e:e.toLowerCase(),e=i?el(e):e,this.pattern=e,this.query=w3(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:a,ignoreDiacritics:s}=this.options;e=a?e:e.toLowerCase(),e=s?el(e):e;let o=0;const l=[];let r=0,c=!1;for(let d=0,f=t.length;d<f;d+=1){const u=t[d];l.length=0,o=0,c=!1;for(let p=0,m=u.length;p<m;p+=1){const h=u[p],{isMatch:g,indices:y,score:b}=h.search(e);if(g)o+=1,r+=b,_3(h.type)&&(c=!0),i&&(x3.has(h.type)?l.push(...y):l.push(y));else{r=0,o=0,l.length=0,c=!1;break}}if(o){const p={isMatch:!0,score:r/o};return c&&(p.hasInverse=!0),i&&(p.indices=s0(l)),p}}return{isMatch:!1,score:1}}};const bu=[];function l0(...e){bu.push(...e)}function Vr(e,t){for(let i=0,a=bu.length;i<a;i+=1){const s=bu[i];if(s.condition(e,t))return new s(e,t)}return new o0(e,t)}const Wr={AND:"$and",OR:"$or"},yu={PATH:"$path",PATTERN:"$val"},xu=e=>!!(e[Wr.AND]||e[Wr.OR]),k3=e=>!!e[yu.PATH],M3=e=>!ga(e)&&ux(e)&&!xu(e),Xf=e=>({[Wr.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function bx(e,t,{auto:i=!0}={}){const a=s=>{if(Dt(s)){const c={keyId:null,pattern:s};return i&&(c.searcher=Vr(s,t)),c}const o=Object.keys(s),l=k3(s);if(!l&&o.length>1&&!xu(s))return a(Xf(s));if(M3(s)){const c=l?s[yu.PATH]:o[0],d=l?s[yu.PATTERN]:s[c];if(!Dt(d))throw new Error(t3(c));const f={keyId:ur(c),pattern:d};return i&&(f.searcher=Vr(d,t)),f}const r={children:[],operator:o[0]};return o.forEach(c=>{const d=s[c];ga(d)&&d.forEach(f=>{r.children.push(a(f))})}),r};return xu(e)||(e=Xf(e)),a(e)}function _u(e,{ignoreFieldNorm:t=be.ignoreFieldNorm}){let i=1;return e.forEach(({key:a,norm:s,score:o})=>{const l=a?a.weight:null;i*=Math.pow(o===0&&l?Number.EPSILON:o,(l||1)*(t?1:s))}),i}function E3(e,{ignoreFieldNorm:t=be.ignoreFieldNorm}){e.forEach(i=>{i.score=_u(i.matches,{ignoreFieldNorm:t})})}var G3=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){const t=this.heap;for(;e>0;){const i=e-1>>1;if(this.comparator(t[e],t[i])<=0)break;const a=t[e];t[e]=t[i],t[i]=a,e=i}}_sinkDown(e){const t=this.heap,i=t.length;let a=e;do{e=a;const s=2*e+1,o=2*e+2;if(s<i&&this.comparator(t[s],t[a])>0&&(a=s),o<i&&this.comparator(t[o],t[a])>0&&(a=o),a!==e){const l=t[e];t[e]=t[a],t[a]=l}}while(a!==e)}};function S3(e){const t=[];return e.matches.forEach(i=>{if(!rn(i.indices)||!i.indices.length)return;const a={indices:i.indices,value:i.value};i.key&&(a.key=i.key.id),i.idx>-1&&(a.refIndex=i.idx),t.push(a)}),t}function A3(e,t,{includeMatches:i=be.includeMatches,includeScore:a=be.includeScore}={}){return e.map(s=>{const{idx:o}=s,l={item:t[o],refIndex:o};return i&&(l.matches=S3(s)),a&&(l.score=s.score),l})}const D3=/[\p{L}\p{M}\p{N}_]+/gu,Kf=new WeakSet;function P3(e){Kf.has(e)||(Kf.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function R3(e){if(typeof e=="function"){let t=!1;return i=>{const a=e(i);if(!t&&(t=!0,!Array.isArray(a)||a.some(s=>typeof s!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(a)?"array containing non-strings":typeof a}.`);return a}}return e instanceof RegExp?(e.global||P3(e),t=>t.match(e)||[]):t=>t.match(D3)||[]}function vu({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:i}={}){const a=R3(i);return{tokenize(s){return e||(s=s.toLowerCase()),t&&(s=el(s)),a(s)}}}var I3=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=vu({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const i=this.analyzer.tokenize(e),{df:a,fieldCount:s}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const o of i){this.termSearchers.push(new o0(o,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const l=a.get(o)||0,r=Math.log(1+(s-l+.5)/(l+.5));this.idfWeights.push(r)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let i=0,a=0,s=0,o=0;const l=this.combineAll&&!this.useMask?new Set:null;for(let d=0;d<this.termSearchers.length;d++){const f=this.termSearchers[d].searchIn(e),u=this.idfWeights[d];a+=u,f.isMatch&&(s++,i+=u*(1-f.score),f.indices&&t.push(...f.indices),this.combineAll&&(this.useMask?o|=1<<d:l.add(d)))}if(s===0)return{isMatch:!1,score:1};const r=a>0?1-i/a:0,c={isMatch:!0,score:Math.max(.001,r)};return this.options.includeMatches&&t.length&&(c.indices=s0(t)),this.combineAll&&(this.useMask?c.matchedMask=o:c.matchedTerms=l,c.termCount=this.numTerms),c}};function Id(e,t,i,a){const s=a.tokenize(t);if(!s.length)return;e.fieldCount++,e.docFieldCount.set(i,(e.docFieldCount.get(i)||0)+1);const o=new Set(s);let l=e.docTermFieldHits.get(i);l||(l=new Map,e.docTermFieldHits.set(i,l));for(const r of o)l.set(r,(l.get(r)||0)+1),e.df.set(r,(e.df.get(r)||0)+1)}function yx(e,t,i,a){const{i:s,v:o,$:l}=t;if(o!==void 0){Id(e,o,s,a);return}if(l)for(let r=0;r<i;r++){const c=l[r];if(c)if(Array.isArray(c))for(const d of c)Id(e,d.v,s,a);else Id(e,c.v,s,a)}}function B3(e,t,i){const a={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const s of e)yx(a,s,t,i);return a}function H3(e,t,i,a){yx(e,t,i,a)}function O3(e,t){const i=e.docFieldCount.get(t);if(i===void 0)return;e.fieldCount-=i,e.docFieldCount.delete(t);const a=e.docTermFieldHits.get(t);if(a){for(const[s,o]of a){const l=(e.df.get(s)||0)-o;l<=0?e.df.delete(s):e.df.set(s,l)}e.docTermFieldHits.delete(t)}}function zf(e,t){if(t.length===0)return;const i=Array.from(new Set(t)).sort((r,c)=>r-c);for(const r of i)O3(e,r);const a=r=>{let c=0,d=i.length;for(;c<d;){const f=c+d>>>1;i[f]<r?c=f+1:d=f}return r-c},s=i[0],o=new Map;for(const[r,c]of e.docFieldCount)o.set(r>s?a(r):r,c);e.docFieldCount=o;const l=new Map;for(const[r,c]of e.docTermFieldHits)l.set(r>s?a(r):r,c);e.docTermFieldHits=l}var ba=class{constructor(e,t,i){this.options={...be,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new o3(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,i),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=Vr(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof a0))throw new Error(e3);if(this._myIndex=t||fx(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const i=vu({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=B3(this._myIndex.records,this._myIndex.keys.length,i)}this._invalidateSearcherCache()}add(e){if(!rn(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const i=vu({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});H3(this._invertedIndex,t,this._myIndex.keys.length,i)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],i=[];for(let a=0,s=this._docs.length;a<s;a+=1)e(this._docs[a],a)&&(t.push(this._docs[a]),i.push(a));if(i.length){this._invertedIndex&&zf(this._invertedIndex,i);const a=new Set(i);this._docs=this._docs.filter((s,o)=>!a.has(o)),this._myIndex.removeAll(i),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(fu);this._invertedIndex&&zf(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){const{limit:i=-1}=t||{},{includeMatches:a,includeScore:s,shouldSort:o,sortFn:l,ignoreFieldNorm:r}=this.options;if(Dt(e)&&!e.trim()){let p=this._docs.map((m,h)=>({item:m,refIndex:h}));return mr(i)&&i>-1&&(p=p.slice(0,i)),p}const c=o&&mr(i)&&i>0&&Dt(e),d=l,f=(p,m)=>d(p,m)||p.idx-m.idx;let u;if(c){const p=new G3(i,f);Dt(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:r}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:r}),u=p.extractSorted()}else u=Dt(e)?Dt(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),E3(u,{ignoreFieldNorm:r}),o&&u.sort(Dt(e)?f:d),mr(i)&&i>-1&&(u=u.slice(0,i));return A3(u,this._docs,{includeMatches:a,includeScore:s})}_searchStringList(e,{heap:t,ignoreFieldNorm:i}={}){const a=this._getSearcher(e),s=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,l=t?null:[];return o.forEach(({v:r,i:c,n:d})=>{if(!rn(r))return;const f=a.searchIn(r);if(f.isMatch){const u={score:f.score,value:r,norm:d,indices:f.indices};s&&(u.matchedMask=f.matchedMask,u.matchedTerms=f.matchedTerms,u.termCount=f.termCount);const p=[u];if(!s||this._coversAllTokens(p)){const m={item:r,idx:c,matches:p};t?(m.score=_u(m.matches,{ignoreFieldNorm:i}),t.insert(m)):l.push(m)}}}),l}_searchLogical(e){const t=bx(e,this.options),i=this._normalizedKeys(),a=(r,c,d)=>{if(!("children"in r)){const{keyId:m,searcher:h}=r;let g;return m===null?(g=[],i.forEach((y,b)=>{g.push(...this._findMatches({key:y,value:c[b],searcher:h}))})):g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(c,m),searcher:h}),g&&g.length?[{idx:d,item:c,matches:g}]:[]}const{children:f,operator:u}=r,p=[];for(let m=0,h=f.length;m<h;m+=1){const g=f[m],y=a(g,c,d);if(y.length)p.push(...y);else if(u===Wr.AND)return[]}return p},s=this._myIndex.records,o=new Map,l=[];return s.forEach(({$:r,i:c})=>{if(rn(r)){const d=a(t,r,c);d.length&&(o.has(c)||(o.set(c,{idx:c,item:r,matches:[]}),l.push(o.get(c))),d.forEach(({matches:f})=>{o.get(c).matches.push(...f)}))}}),l}_searchObjectList(e,{heap:t,ignoreFieldNorm:i}={}){const a=this._getSearcher(e),s=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,l=this._normalizedKeys(),r=t?null:[];return o.forEach(({$:c,i:d})=>{if(!rn(c))return;const f=[];let u=!1,p=!1;if(l.forEach((m,h)=>{const g=this._findMatches({key:m,value:c[h],searcher:a});g.length?(f.push(...g),g[0].hasInverse&&(p=!0)):u=!0}),!(p&&u)&&f.length&&(!s||this._coversAllTokens(f))){const m={idx:d,item:c,matches:f};t?(m.score=_u(m.matches,{ignoreFieldNorm:i}),t.insert(m)):r.push(m)}}),r}_findMatches({key:e,value:t,searcher:i}){if(!rn(t))return[];const a=[];if(ga(t))t.forEach(({v:s,i:o,n:l})=>{if(!rn(s))return;const r=i.searchIn(s);if(r.isMatch){const c={score:r.score,key:e,value:s,idx:o,norm:l,indices:r.indices,hasInverse:r.hasInverse};r.termCount!==void 0&&(c.matchedMask=r.matchedMask,c.matchedTerms=r.matchedTerms,c.termCount=r.termCount),a.push(c)}});else{const{v:s,n:o}=t,l=i.searchIn(s);if(l.isMatch){const r={score:l.score,key:e,value:s,norm:o,indices:l.indices,hasInverse:l.hasInverse};l.termCount!==void 0&&(r.matchedMask=l.matchedMask,r.matchedTerms=l.matchedTerms,r.termCount=l.termCount),a.push(r)}}return a}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let a=0;for(let s=0;s<e.length;s++)a|=e[s].matchedMask||0;return a===2**t-1}const i=new Set;for(let a=0;a<e.length;a++){const s=e[a].matchedTerms;if(s)for(const o of s)i.add(o)}return i.size===t}};ba.version="7.5.0";ba.createIndex=fx;ba.parseIndex=h3;ba.config=be;ba.match=function(e,t,i){if(i&&i.useTokenSearch)throw new Error(s3);return Vr(e,{...be,...i}).searchIn(t)};ba.parseQuery=bx;l0(C3);l0(I3);ba.use=function(...e){e.forEach(t=>l0(t))};var Hc=ba;const $3=/[\s_\-,;:()[\]{}|/]+/g,mn=e=>e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase(),Uf=e=>mn(e).replace($3," ").trim(),Bd=e=>e?Object.entries(e).map(([t,i])=>`${t} ${Array.isArray(i)?i.join(" "):i}`).join(" "):"";class ju{constructor(t,i){this.entries=[],this.fuse={};const a=(s,o,l,r,c)=>{const d=c.filter(Boolean).map(f=>mn(String(f))).join(" ");this.entries.push({kind:s,id:o,name:l,detail:r,idN:mn(o),nameN:mn(l),hay:`${d} ${Uf(d)}`})};for(const s of t.metabolites)a("metabolite",s.id,s.name||s.id,[s.formula,t.compartments[s.compartment]??s.compartment].filter(Boolean).join(" · "),[s.id,s.name,s.formula,s.compartment,t.compartments[s.compartment],s.charge!=null?String(s.charge):"",Bd(s.annotation)]);for(const s of t.reactions){const o=Object.keys(s.stoichiometry).map(r=>{var c;return((c=i.met.get(r))==null?void 0:c.name)??""}).join(" "),l=s.genes.map(r=>{var c;return((c=i.gene.get(r))==null?void 0:c.name)??""}).join(" ");a("reaction",s.id,s.name||s.id,s.subsystem??s.equation,[s.id,s.name,s.equation,o,s.subsystem,s.gpr,l,s.ec.join(" "),Bd(s.annotation)])}for(const s of t.genes)a("gene",s.id,s.name||s.id,`${s.reactions.length} reaction${s.reactions.length===1?"":"s"}`,[s.id,s.name,s.reactions.join(" "),Bd(s.annotation)])}search(t,i,a=50){const s=mn(t).trim();if(!s)return[];const o=Uf(s).split(" ").filter(Boolean),l=[];for(const r of this.entries){if(i&&!i.includes(r.kind)||!r.hay.includes(s)&&!o.every(d=>r.hay.includes(d)))continue;let c;r.idN===s?c=100:r.nameN===s?c=92:r.idN.startsWith(s)?c=80:r.nameN.startsWith(s)?c=72:r.idN.includes(s)?c=55:r.nameN.includes(s)?c=48:c=20,l.push({kind:r.kind,id:r.id,name:r.name,detail:r.detail,score:c-r.idN.length*.01})}return l.sort((r,c)=>c.score-r.score),l.length?l.slice(0,a):this.fuzzy(s,i,a)}matchIds(t,i){if(!t.trim())return null;const a=this.search(t,[i],1e9);return new Map(a.map(s=>[s.id,s.score]))}fuzzy(t,i,a){const s=[];for(const o of i??["metabolite","reaction","gene"]){let l=this.fuse[o];l||(l=new Hc(this.entries.filter(r=>r.kind===o),{keys:[{name:"idN",weight:2},{name:"nameN",weight:1.5}],threshold:.32,ignoreLocation:!0,includeScore:!0}),this.fuse[o]=l);for(const r of l.search(t,{limit:a}))s.push({kind:o,id:r.item.id,name:r.item.name,detail:r.item.detail,score:10*(1-(r.score??1))})}return s.sort((o,l)=>l.score-o.score).slice(0,a)}}function Nu(e){const t=new Map(e.metabolites.map(r=>[r.id,r])),i=new Map(e.reactions.map(r=>[r.id,r])),a=new Map(e.genes.map(r=>[r.id,r])),s=new Map,o=new Map;let l=0;for(const r of e.reactions){for(const c of Object.keys(r.stoichiometry)){const d=s.get(c);d?d.push(r.id):s.set(c,[r.id])}if(r.subsystem){const c=o.get(r.subsystem);c?c.push(r.id):o.set(r.subsystem,[r.id])}for(const c of[r.lb,r.ub])c!=null&&Math.abs(c)>l&&(l=Math.abs(c))}return{met:t,rxn:i,gene:a,metRxns:s,subsystems:o,maxBound:l||1e3}}const pi=e=>ra(()=>Promise.resolve().then(()=>Y1),void 0).then(t=>t.A().toast(e)),$i=e=>e instanceof On?e.info:{title:"Unexpected error",message:(e==null?void 0:e.message)??String(e),hints:[]},fi=e=>(e==null?void 0:e.edits)??null;let Tl=null;const Xe={async check(e){const t=S.getState().model;if(!t)return null;try{return await Se.checkEdits(t.id,e)}catch(i){return{errors:[$i(i).title+($i(i).message?`: ${$i(i).message}`:"")],warnings:[],info:[],items:[]}}},async commit(e,t){var a,s;const i=S.getState().model;if(!i)return{ok:!1,error:{title:"No model loaded",message:"",hints:[]}};try{const o=await Se.commitEdits(i.id,e,t);if(o.history.count===((a=fi(i))==null?void 0:a.count)&&!o.delta.reactions.upsert.length&&!o.delta.metabolites.upsert.length)return pi("No change"),{ok:!0,report:o.report};Xe.apply(o),S.setState(r=>({undoOrder:[...r.undoOrder,"model"],redoOrder:[]}));const l=o.history.items[o.history.items.length-1];return l&&pi(l.label),{ok:!0,report:o.report}}catch(o){const l=$i(o);return{ok:!1,error:l,report:(s=l.detail)!=null&&s.errors?l.detail:void 0}}},async undo(){var t,i;const e=S.getState().model;if(!e||!((t=fi(e))!=null&&t.count))return!1;try{const a=(i=fi(e).items[fi(e).items.length-1])==null?void 0:i.label;return Xe.apply(await Se.undoEdit(e.id)),pi(`Undone: ${a}`),!0}catch(a){return pi($i(a).title),!1}},async redo(){var t,i;const e=S.getState().model;if(!e||!((t=fi(e))!=null&&t.redo.length))return!1;try{const a=(i=fi(e).redo[0])==null?void 0:i.label;return Xe.apply(await Se.redoEdit(e.id)),pi(`Redone: ${a}`),!0}catch(a){return pi($i(a).title),!1}},async discard(){const e=S.getState().model;if(e)try{Xe.apply(await Se.discardEdits(e.id)),S.setState(t=>({undoOrder:t.undoOrder.filter(i=>i!=="model"),redoOrder:t.redoOrder.filter(i=>i!=="model")})),pi("Model edits discarded — the model is the imported file again")}catch(t){pi($i(t).title)}},async exportPatch(){const e=S.getState().model;if(e)try{const{blob:t,filename:i}=await Se.editPatch(e.id),a=document.createElement("a");a.href=URL.createObjectURL(t),a.download=i,a.click(),setTimeout(()=>URL.revokeObjectURL(a.href),2e3)}catch(t){pi($i(t).title)}},apply(e){const t=S.getState(),i=t.model;if(!i)return;const a=e.delta,s=(b,_,x)=>{const v=new Set(x),j=new Map(_.map(w=>[w.id,w])),N=b.filter(w=>!v.has(w.id)).map(w=>j.get(w.id)??w),C=new Set(N.map(w=>w.id));for(const w of _)C.has(w.id)||N.push(w);return N},o={...i,reactions:s(i.reactions,a.reactions.upsert,a.reactions.remove),metabolites:s(i.metabolites,a.metabolites.upsert,a.metabolites.remove),genes:s(i.genes,a.genes.upsert,a.genes.remove),summary:a.summary,compartments:a.compartments,warnings:a.warnings,medium:a.medium,edits:e.history},l=Nu(o),r=e.renamed.reactions,c=e.renamed.metabolites,d=b=>b in r?r[b]:b,f=b=>{if(!Object.keys(r).length)return b;const _={};for(const[v,j]of Object.entries(b.bounds)){const N=d(v);N&&(_[N]=j)}let x=b.objective;if(x){const v={};for(const[j,N]of Object.entries(x.coefficients)){const C=d(j);C&&(v[C]=N)}x=Object.keys(v).length?{...x,coefficients:v}:null}return{...b,bounds:_,objective:x}},u=b=>{const _=b.kind==="reaction"?r:b.kind==="metabolite"?c:null;return!_||!(b.id in _)?b:_[b.id]?{...b,id:_[b.id]}:null},p=[];let m=t.nav.index;t.nav.stack.forEach((b,_)=>{const x=u(b);x?p.push(x):_<=t.nav.index&&m--});const h=t.favorites.map(b=>{const[_,...x]=b.split(":"),v=u({kind:_,id:x.join(":")});return v?`${v.kind}:${v.id}`:null}).filter(b=>!!b),g=t.states.flatMap(b=>Object.keys(b.bounds).filter(_=>_ in r&&!r[_]).map(_=>`${b.name}: ${_}`));S.setState({model:o,index:l,searchIndex:new ju(o,l),states:t.states.map(f),selection:{reactions:t.selection.reactions.map(d).filter(b=>!!b),metabolites:t.selection.metabolites.map(b=>b in c?c[b]:b).filter(b=>!!b),genes:t.selection.genes.filter(b=>l.gene.has(b))},nav:{stack:p,index:Math.max(-1,Math.min(p.length-1,m))},favorites:h});const y=e.history;g.length&&B.log("warn",`Bound overrides of removed reactions dropped from the states (${g.slice(0,6).join(", ")}${g.length>6?"…":""})`),B.log("info",`Model structure: ${o.summary.reactions} reactions, ${o.summary.metabolites} metabolites · ${y.count} edit${y.count===1?"":"s"}`)},guardUnsaved(e){const t=fi(S.getState().model);return t!=null&&t.dirty?(Tl=e,S.setState({dialog:{kind:"unsaved-edits"}}),!0):!1},continuePending(){const e=Tl;Tl=null,e==null||e()},dropPending(){Tl=null}},wu="gemsmap-lab-settings",Fl="gemsmap-lab-last",xx="gemsmap-lab-figure",qf={zeroTolerance:1e-9,pseudocount:null,reactionColumns:["id","name","equation","lb","ub","flux","fvaMin","fvaMax"],defaultMethod:"pfba",showCofactorsInNetwork:!1},ti=e=>`${e}_${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`,Oc=e=>`${e.kind}:${e.id}`,_x=[{id:"v-active",name:"Active reactions",tab:"reactions",query:"",hideZero:!0,rxnFilters:{},metFilters:{},sort:{key:"absFlux",dir:"desc"},builtin:!0},{id:"v-high",name:"High-flux reactions",tab:"reactions",query:"",hideZero:!0,rxnFilters:{absFluxGt:1},metFilters:{},sort:{key:"absFlux",dir:"desc"},builtin:!0},{id:"v-exch",name:"Exchanges",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["exchange"]},metFilters:{},sort:{key:"flux",dir:"asc"},builtin:!0},{id:"v-transport",name:"Transport",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["transport"]},metFilters:{},sort:null,builtin:!0},{id:"v-modified",name:"Modified bounds",tab:"reactions",query:"",hideZero:!1,rxnFilters:{modifiedOnly:!0},metFilters:{},sort:null,builtin:!0}];function Cu(e="Base model"){return{id:ti("st"),name:e,createdAt:Date.now(),bounds:{},objective:null,changes:[],undo:[],redo:[]}}const pr=()=>{const e=Cu();return{states:[e],activeStateId:e.id,results:[],activeResultId:null,activeFvaId:null,favorites:[],savedViews:[],mediumPresets:[]}},Yr=e=>({bounds:e.bounds,objective:e.objective,changes:e.changes,mediumLabel:e.mediumLabel}),Vf=(e,t)=>e[0]===t[0]&&e[1]===t[1],S=Ts()(()=>({...pr(),workspace:(()=>{try{return localStorage.getItem("gemsmap-workspace")==="map"?"map":"lab"}catch{return"lab"}})(),backend:{status:"checking"},busy:null,importError:null,model:null,index:null,searchIndex:null,running:null,lastRun:null,section:"overview",explorerTab:"reactions",query:"",hideZero:!1,rxnFilters:{},metFilters:{},sort:{reactions:null,metabolites:null,genes:null},selection:{reactions:[],metabolites:[],genes:[]},nav:{stack:[],index:-1},inspectorOpen:!0,settings:yo(wu,qf),compare:{aId:null,bId:null,metric:"log2fc",result:null,loading:!1,error:null},explain:null,objectiveEditorOpen:!1,log:[],logOpen:!1,contextMenu:null,dialog:null,annotation:null,annotationError:null,undoOrder:[],redoOrder:[],simParams:{fractionOfOptimum:1,loopless:!1,reactions:null,pfbaFactor:null,processes:1,samples:500,sampler:"optgp",thinning:100,seed:null,objectiveFraction:null},method:yo(wu,qf).defaultMethod,subsys:{selected:[],metric:"total",mode:"combined",scale:"shared",showZero:!1,sort:"magnitude",hideInactive:!0,view:"list",wide:!1,level:"reactions",series:[],fig:yo(xx,{widthMm:183,fontPt:7,labels:"id",values:!1,divPalette:"blue-red",seqPalette:"blues",maxRows:25,title:null,caption:!0})}})),se=S.setState,je=S.getState,ee={activeState:(e=je())=>e.states.find(t=>t.id===e.activeStateId)??e.states[0],stateSpec:e=>({id:e.id,name:e.name,bounds:e.bounds,objective:e.objective}),originalBounds:e=>[e.lb,e.ub],bounds:(e,t)=>e.bounds[t.id]??[t.lb,t.ub],objective:(e,t=je())=>{var i;return e.objective??((i=t.model)==null?void 0:i.summary.objective)??{coefficients:{},direction:"max"}},result:(e,t=je())=>e?t.results.find(i=>i.id===e)??null:null,fluxResult:(e=je())=>ee.result(e.activeResultId,e),fvaResult:(e=je())=>ee.result(e.activeFvaId,e),isZero:(e,t=je())=>e==null||Math.abs(e)<t.settings.zeroTolerance,rname:e=>{var t,i;return((i=(t=je().index)==null?void 0:t.rxn.get(e))==null?void 0:i.name)||e},mname:e=>{var t,i;return((i=(t=je().index)==null?void 0:t.met.get(e))==null?void 0:i.name)||e},uptakeOf:(e,t)=>{const a=(e.boundaryCoefficient??-1)<0?t[0]==null?1/0:-t[0]:t[1]==null?1/0:t[1];return Math.max(0,a)}};function ze(e,t){se(i=>({log:[...i.log.slice(-400),{time:Date.now(),level:e,text:t}]}))}const bn=e=>ra(()=>Promise.resolve().then(()=>Y1),void 0).then(t=>t.A().toast(e));function Vn(e){return e instanceof On?e.info:{title:"Unexpected error",message:(e==null?void 0:e.message)??String(e),hints:[]}}let Hd=null;function L3(){je().model&&(Hd&&clearTimeout(Hd),Hd=setTimeout(()=>{const t=je();if(!t.model)return;const i={states:t.states.map(a=>({...a,undo:a.undo.slice(-30),redo:a.redo.slice(-30)})),activeStateId:t.activeStateId,results:t.results,activeResultId:t.activeResultId,activeFvaId:t.activeFvaId,favorites:t.favorites,savedViews:t.savedViews,mediumPresets:t.mediumPresets};XC(`session:${t.model.checksum}`,i)},700))}S.subscribe((e,t)=>{if((e.states!==t.states||e.results!==t.results||e.favorites!==t.favorites||e.savedViews!==t.savedViews||e.mediumPresets!==t.mediumPresets||e.activeStateId!==t.activeStateId||e.activeResultId!==t.activeResultId||e.activeFvaId!==t.activeFvaId)&&L3(),e.settings!==t.settings&&qr(wu,e.settings),e.subsys.fig!==t.subsys.fig&&qr(xx,{...e.subsys.fig,title:null}),e.workspace!==t.workspace)try{localStorage.setItem("gemsmap-workspace",e.workspace)}catch{}});let Li=0,es=null;function ts(e){const t=je().states;se(i=>({states:i.states.map(a=>{if(a.id!==i.activeStateId)return a;const s=e(Yr(a),a);return s?{...a,...s,undo:[...a.undo,Yr(a)].slice(-100),redo:[]}:a})})),je().states!==t&&se(i=>({undoOrder:[...i.undoOrder,"state"].slice(-200),redoOrder:i.redoOrder.filter(a=>a!=="state")}))}function ku(e,t,i,a,s){return{id:ti("chg"),time:Date.now(),kind:e,target:t,before:i,after:a,note:s}}function Xl(e,t,i,a){const s=je().index;if(!s)return null;const o={...e.bounds},l=[];for(const[r,c]of Object.entries(t)){const d=s.rxn.get(r);if(!d)continue;const f=o[r]??[d.lb,d.ub];if(Vf(f,c))continue;Vf(c,[d.lb,d.ub])?delete o[r]:o[r]=c;const u=[];f[0]!==c[0]&&u.push([`LB ${rt(f[0],"lower")}`,`${rt(c[0],"lower")}`]),f[1]!==c[1]&&u.push([`UB ${rt(f[1],"upper")}`,`${rt(c[1],"upper")}`]);for(const[p,m]of u)l.push(ku(i,r,p,m,a))}return l.length?{...e,bounds:o,changes:[...e.changes,...l]}:null}const B={log:ze,async checkBackend(e=!1){e||se({backend:{status:"checking"}});try{const t=await Se.health();return se({backend:{status:"online",health:t}}),!0}catch{return se({backend:{status:"offline"}}),!1}},async boot(){let e=await B.checkBackend();for(;!e;)await new Promise(t=>setTimeout(t,3e3)),e=await B.checkBackend(!0)},lastModel(){const e=yo(Fl,{});return e.modelId?{modelId:e.modelId,name:e.name}:null},async restoreLast(){if(je().model)return;const e=yo(Fl,{});if(e.modelId){se({busy:"Restoring last model…"});try{const t=++Li,i=await Se.getModel(e.modelId);t===Li&&await B.setModel(i,!0,t)}catch(t){ze("warn",`Could not restore last model: ${Vn(t).message}`)}finally{se({busy:null})}}},async importFile(e,t=!1){if(!(!t&&Xe.guardUnsaved(()=>B.importFile(e,!0)))){se({busy:`Importing ${e.name}… (COBRApy is reading and validating the model)`,importError:null}),ze("info",`Import started: ${e.name} (${(e.size/1e6).toFixed(1)} MB)`);try{const i=++Li,a=await Se.importModel(e);i===Li&&await B.setModel(a,!1,i)}catch(i){const a=Vn(i);se({importError:a}),ze("error",`Import failed: ${a.title} ${a.message}`)}finally{se({busy:null})}}},async importExample(e,t=!1){if(!(!t&&Xe.guardUnsaved(()=>B.importExample(e,!0)))){se({busy:"Loading example model…",importError:null});try{const i=++Li,a=await Se.importExample(e);i===Li&&await B.setModel(a,!1,i)}catch(i){se({importError:Vn(i)})}finally{se({busy:null})}}},async setModel(e,t=!1,i=++Li){var c,d;const a=Nu(e),s=new ju(e,a),o=await FC(`session:${e.checksum}`);if(i!==Li)return;const l=(c=o==null?void 0:o.states)!=null&&c.length?{...pr(),...o}:pr();se({model:e,index:a,searchIndex:s,...l,section:t?je().section:"overview",selection:{reactions:[],metabolites:[],genes:[]},nav:{stack:[],index:-1},query:"",rxnFilters:{},metFilters:{},compare:{...je().compare,aId:null,bId:null,result:null,error:null},explain:null,lastRun:null,subsys:{...je().subsys,selected:[],series:[]},annotation:null,annotationError:null,undoOrder:[],redoOrder:[]}),qr(Fl,{modelId:e.id,name:e.name||e.filename});const r=e.warnings.filter(f=>f.level!=="info").length;ze("info",`Model ${t?"restored":"imported"}: ${e.filename} — ${e.summary.reactions} reactions, ${e.summary.metabolites} metabolites, ${e.summary.genes} genes`),t||(ze("info",`Validation completed: ${e.warnings.length} notes${r?` (${r} warnings)`:""}`),bn(`Model imported: ${e.name}`)),(d=o==null?void 0:o.states)!=null&&d.length&&ze("info",`Session restored: ${l.states.length} states, ${l.results.length} results`)},async importResults(e){var l;const t=je();if(!t.model||!t.index)return bn("Load a model first: imported results are compared by reaction id against it");const i=t.model,a=t.index,s=[];let o=0;for(const r of e)try{const{results:c,notes:d}=mx(r.name,await r.text());for(const f of d)ze("info",`${r.name}: ${f}`);for(const f of c){const u=Object.keys(f.reactionFluxes??f.fva??((l=f.samples)==null?void 0:l.summary)??{}),p=u.filter(g=>a.rxn.has(g)).length,m=f.metadata.model.checksum,h=!!m&&i.checksum.startsWith(m);if(m&&!h&&o++,f.modelId=i.id,f.origin={...f.origin,matched:p,total:u.length},f.reactionFluxes&&(!f.metaboliteTurnover||!f.exchanges)&&(!m||h)&&u.length&&p/u.length>=.95)try{const g=await Se.derive(i.id,f.reactionFluxes);f.metaboliteTurnover||(f.metaboliteTurnover=g.metaboliteTurnover),f.exchanges||(f.exchanges=g.exchanges),f.origin.derivedWith=i.filename}catch(g){ze("warn",`${f.name}: turnover not derived — ${Vn(g).message}`)}s.push(f),ze("info",`Imported “${f.name}” from ${r.name}: ${p}/${u.length} reaction ids in ${i.filename}${f.origin.derivedWith?" · turnover/exchanges derived with this model":""}`)}}catch(c){const d=c.message;ze("error",`Could not import ${r.name}: ${d}`),bn(`Could not import ${r.name}: ${d}`)}s.length&&(se(r=>({results:[...r.results,...s],lastRun:{resultId:s[s.length-1].id},section:"results"})),bn(`Imported ${s.length} result${s.length>1?"s":""}${o?` · ${o} from another model (compared by reaction id)`:""}`))},closeModel(e=!1){!e&&Xe.guardUnsaved(()=>B.closeModel(!0))||(qr(Fl,{}),se({model:null,index:null,searchIndex:null,...pr(),section:"overview",nav:{stack:[],index:-1}}))},setActiveState(e){var t;se({activeStateId:e}),ze("info",`Active state: ${(t=je().states.find(i=>i.id===e))==null?void 0:t.name}`)},newState(e){const t=Cu(e??`State ${je().states.length+1}`);return se(i=>({states:[...i.states,t],activeStateId:t.id})),t.id},duplicateState(e){const t=je().states.find(a=>a.id===(e??je().activeStateId));if(!t)return;const i={...t,id:ti("st"),name:`${t.name} copy`,createdAt:Date.now(),parentId:t.id,undo:[],redo:[]};return se(a=>({states:[...a.states,i],activeStateId:i.id})),ze("info",`State duplicated: ${t.name} → ${i.name}`),i.id},renameState(e,t){t.trim()&&se(i=>({states:i.states.map(a=>a.id===e?{...a,name:t.trim()}:a)}))},deleteState(e){const t=je();if(t.states.length<=1)return bn("A model needs at least one state");const i=t.states.filter(a=>a.id!==e);se({states:i,activeStateId:t.activeStateId===e?i[0].id:t.activeStateId})},stateFromResult(e){const t=ee.result(e);if(!(t!=null&&t.stateSnapshot))return bn("This result has no stored configuration");const i={...Cu(`${t.metadata.state.name} (from ${t.metadata.methodLabel})`),bounds:{...t.stateSnapshot.bounds},objective:t.stateSnapshot.objective};se(a=>({states:[...a.states,i],activeStateId:i.id})),bn(`Created state “${i.name}” from the result's exact configuration`)},setBounds(e,t,i){if(t[0]!=null&&t[1]!=null&&t[0]>t[1])return bn(`Lower bound (${W(t[0])}) must not exceed upper bound (${W(t[1])})`);ts(a=>Xl(a,{[e]:t},"bounds",i))},setBoundsBulk(e,t){ts(i=>{const a=Xl(i,e,"bulk",t);return a&&ze("info",`${t}: ${Object.keys(e).length} reactions`),a})},resetBounds(e){const t=je().index;if(!t)return;const i={};for(const a of e){const s=t.rxn.get(a);s&&(i[a]=[s.lb,s.ub])}ts(a=>Xl(a,i,e.length>1?"bulk":"bounds","Reset to model file"))},blockReactions(e){const t={};for(const i of e)t[i]=[0,0];e.length===1?B.setBounds(e[0],[0,0],"Blocked"):B.setBoundsBulk(t,"Blocked reactions")},allowReversible(e){var i;const t=((i=je().index)==null?void 0:i.maxBound)??1e3;B.setBounds(e,[-t,t],"Allowed reversible")},setObjective(e){var r;const t=je(),i=ee.activeState(t),a=Pi(ee.objective(i,t)),s=(r=t.model)==null?void 0:r.summary.objective,o=e&&s&&JSON.stringify(e)===JSON.stringify(s)?null:e,l=Pi(o??s);a!==l&&(ts(c=>({...c,objective:o,changes:[...c.changes,ku("objective","Objective",a,l)]})),ze("info",`Objective changed: ${l}`))},setObjectiveReaction(e){B.setObjective({coefficients:{[e]:1},direction:ee.objective(ee.activeState()).direction}),bn(`Objective: maximize ${e}`)},applyMediumBounds(e,t,i){ts(a=>{const s=Xl(a,e,"medium",i);return s?{...s,mediumLabel:t}:null}),ze("info",`Medium modified: ${i}`)},undo(){var o,l;const e=je(),t=!!ee.activeState(e).undo.length,i=!!((l=(o=e.model)==null?void 0:o.edits)!=null&&l.count),a=e.undoOrder[e.undoOrder.length-1],s=a==="model"&&i?"model":a==="state"&&t||t?"state":i?"model":null;if(s){if(se(r=>({undoOrder:r.undoOrder.slice(0,-1),redoOrder:[...r.redoOrder,s]})),s==="model"){Xe.undo();return}se(r=>({states:r.states.map(c=>c.id===r.activeStateId&&c.undo.length?{...c,...c.undo[c.undo.length-1],undo:c.undo.slice(0,-1),redo:[Yr(c),...c.redo]}:c)}))}},redo(){var o,l;const e=je(),t=!!ee.activeState(e).redo.length,i=!!((l=(o=e.model)==null?void 0:o.edits)!=null&&l.redo.length),a=e.redoOrder[e.redoOrder.length-1],s=a==="model"&&i?"model":a==="state"&&t||t?"state":i?"model":null;if(s){if(se(r=>({redoOrder:r.redoOrder.slice(0,-1),undoOrder:[...r.undoOrder,s]})),s==="model"){Xe.redo();return}se(r=>({states:r.states.map(c=>c.id===r.activeStateId&&c.redo.length?{...c,...c.redo[0],redo:c.redo.slice(1),undo:[...c.undo,Yr(c)]}:c)}))}},resetState(){ts(e=>Object.keys(e.bounds).length||e.objective?{bounds:{},objective:null,mediumLabel:void 0,changes:[...e.changes,ku("reset","Model","modified","model file")]}:null),ze("info","State reset to the model file")},async simulate(e=je().method,t={}){var d;const i=je();if(!i.model||i.running)return;const a=ee.activeState(i),s={...i.simParams,...t},o=ee.stateSpec(a),l=ti("job"),r=new AbortController;es=r,se({running:{method:e,startedAt:Date.now(),stateName:a.name,jobId:l},method:e,lastRun:null}),ze("info",`${e.toUpperCase()} started on “${a.name}”${e==="fva"&&s.reactions?` (${s.reactions.length} reactions)`:""}`);const c=e==="fva"||e==="sampling"?setInterval(async()=>{try{const f=await Se.job(l);se(u=>{var p;return((p=u.running)==null?void 0:p.jobId)===l&&f.total?{running:{...u.running,progress:{done:f.done,total:f.total,phase:f.phase}}}:{}})}catch{}},500):null;try{const u={...await Se.simulate(i.model.id,e,o,s,{jobId:l,signal:r.signal}),modelStateId:a.id,stateSnapshot:JSON.parse(JSON.stringify(o)),createdAt:Date.now()},p=u.solverStatus==="optimal";return se(m=>({results:[...m.results,u],activeResultId:p&&u.method!=="fva"&&u.method!=="sampling"?u.id:m.activeResultId,activeFvaId:p&&u.method==="fva"?u.id:m.activeFvaId,lastRun:{resultId:u.id,method:e}})),ze(p?"info":"warn",`Solver ${u.solverStatus} — ${u.name}${p?` · objective ${W(u.objectiveValue)}`:""} (${u.metadata.elapsedSeconds.toFixed(2)} s)`),u.metadata.partial&&ze("warn",`FVA stopped early: intervals kept for ${u.metadata.partial.done} of ${u.metadata.partial.total} reactions`),p&&ze("info","Result saved"),u}catch(f){const u=Vn(f);(d=u.detail)!=null&&d.cancelled?(se({lastRun:{cancelled:!0,method:e}}),ze("warn",`${e.toUpperCase()} cancelled — nothing was saved`)):(se({lastRun:{error:u,method:e}}),ze("error",`${e.toUpperCase()} failed: ${u.title} ${u.message}`))}finally{c&&clearInterval(c),es===r&&(es=null),se(f=>{var u;return((u=f.running)==null?void 0:u.jobId)===l?{running:null}:{}})}},async cancelRun(e=!1){const t=je().running;if(!(!t||t.stopping)){se({running:{...t,stopping:e?"keep":"discard"}});try{await Se.cancelJob(t.jobId,e)}catch{}e||es==null||es.abort()}},selectResult(e){const t=ee.result(e);if(t){if(t.solverStatus!=="optimal")return se({lastRun:{resultId:e}});t.method==="fva"?se({activeFvaId:e}):t.method!=="sampling"&&se({activeResultId:e})}},renameResult(e,t){t.trim()&&se(i=>({results:i.results.map(a=>a.id===e?{...a,name:t.trim()}:a)}))},deleteResult(e){se(t=>({results:t.results.filter(i=>i.id!==e),activeResultId:t.activeResultId===e?null:t.activeResultId,activeFvaId:t.activeFvaId===e?null:t.activeFvaId,compare:{...t.compare,aId:t.compare.aId===e?null:t.compare.aId,bId:t.compare.bId===e?null:t.compare.bId}}))},async runCompare(){const e=je(),t=ee.result(e.compare.aId),i=ee.result(e.compare.bId);if(!(!t||!i)){se({compare:{...e.compare,loading:!0,error:null},explain:null});try{const a=await Se.compare(t,i,e.settings.zeroTolerance,e.settings.pseudocount);se(s=>({compare:{...s.compare,result:a,loading:!1}})),ze("info",`Compared ${t.name} vs ${i.name}`)}catch(a){se(s=>({compare:{...s.compare,loading:!1,error:Vn(a)}}))}}},async explainTurnover(e){const t=je(),i=ee.result(t.compare.aId),a=ee.result(t.compare.bId);if(!(!t.model||!(i!=null&&i.reactionFluxes)||!(a!=null&&a.reactionFluxes))){se({explain:{metabolite:e,data:null,loading:!0}});try{const s=await Se.explainTurnover(t.model.id,e,i.reactionFluxes,a.reactionFluxes,t.settings.zeroTolerance);se({explain:{metabolite:e,data:s,loading:!1}})}catch(s){se({explain:null}),bn(Vn(s).title)}}},navigate(e){se(t=>{const i=t.nav.stack[t.nav.index];if(i&&i.kind===e.kind&&i.id===e.id)return{inspectorOpen:!0};const a=[...t.nav.stack.slice(0,t.nav.index+1),e].slice(-60);return{nav:{stack:a,index:a.length-1},inspectorOpen:!0}})},back(){se(e=>e.nav.index>0?{nav:{...e.nav,index:e.nav.index-1}}:{})},forward(){se(e=>e.nav.index<e.nav.stack.length-1?{nav:{...e.nav,index:e.nav.index+1}}:{})},goTo(e){se(t=>({nav:{...t.nav,index:Math.max(0,Math.min(t.nav.stack.length-1,e))}}))},current(){const e=je();return e.nav.stack[e.nav.index]??null},setSection(e){se({section:e})},patchMetabolites(e){const t=je().model;if(!t||!e.length)return;const i=new Map(e.map(o=>[o.id,o])),a={...t,metabolites:t.metabolites.map(o=>i.get(o.id)??o)},s=Nu(a);se({model:a,index:s,searchIndex:new ju(a,s)})},async loadAnnotation(){const e=je().model;if(e)try{se({annotation:await Se.annotation(e.id),annotationError:null})}catch(t){se({annotationError:Vn(t)})}},async analyzeAnnotation(e){var i,a,s,o,l;const t=je().model;if(t)try{const r=await Se.analyzeAnnotation(t.id,e);for(se({annotation:{...je().annotation??{analysis:null,curation:{accepted:0,identifiers:0,formulas:0,rejected:0,entries:{},rejectedIds:[]}},job:r},annotationError:null}),ze("info","Metabolite analysis started (MetaNetX)");;){if(await new Promise(d=>setTimeout(d,800)),((i=je().model)==null?void 0:i.id)!==t.id)return;const c=await Se.annotation(t.id,!1);if(se({annotation:{...c,analysis:((a=je().annotation)==null?void 0:a.analysis)??null}}),((s=c.job)==null?void 0:s.state)!=="running"){const d=await Se.annotation(t.id);if(se({annotation:d}),((o=d.job)==null?void 0:o.state)==="error"){se({annotationError:{title:"Metabolite analysis failed",message:d.job.error??"",hints:["Check the internet connection: MetaNetX is queried at rdf.metanetx.org"]}});return}d.curation.accepted&&B.patchMetabolites(await Se.metabolites(t.id));const f=(l=d.analysis)==null?void 0:l.summary;f&&ze("info",`Metabolite analysis: ${f.confident} confident, ${f.doubt} to review, ${f.unmapped} unmapped · ${d.curation.accepted} curated`);return}}}catch(r){se({annotationError:Vn(r)})}},async curate(e,t){const i=je().model;if(i)try{const a=e==="apply"?await Se.applyAnnotation(i.id,t):e==="reject"?await Se.rejectAnnotation(i.id,t):await Se.revertAnnotation(i.id,t);B.patchMetabolites(a.metabolites);const s=je().annotation;s&&se({annotation:{...s,curation:a.curation}})}catch(a){se({annotationError:Vn(a)})}},setTab(e){se({explorerTab:e,section:"explore"})},showInExplorer(e,t,i){e==="reactions"?se({rxnFilters:{ids:{label:i,ids:t}}}):e==="metabolites"&&se({metFilters:{ids:{label:i,ids:t}}}),se({explorerTab:e,section:"explore",query:"",hideZero:!1})},setSort(e,t){se(i=>({sort:{...i.sort,[e]:t}}))},toggleFavorite(e){const t=Oc(e);se(i=>({favorites:i.favorites.includes(t)?i.favorites.filter(a=>a!==t):[...i.favorites,t]}))},saveView(e){const t=je(),i={id:ti("view"),name:e,tab:t.explorerTab,query:t.query,hideZero:t.hideZero,rxnFilters:t.rxnFilters,metFilters:t.metFilters,sort:t.sort[t.explorerTab]};se({savedViews:[...t.savedViews,i]}),bn(`Saved view “${e}”`)},applyView(e){se(t=>({explorerTab:e.tab,section:"explore",query:e.query,hideZero:e.hideZero,rxnFilters:e.rxnFilters,metFilters:e.metFilters,sort:{...t.sort,[e.tab]:e.sort}}))},deleteView(e){se(t=>({savedViews:t.savedViews.filter(i=>i.id!==e)}))},setSelection(e,t){se(i=>({selection:{...i.selection,[e]:t}}))},clearSelection(){se({selection:{reactions:[],metabolites:[],genes:[]}})},setSettings(e){se(t=>({settings:{...t.settings,...e}}))},saveMediumPreset(e,t){se(i=>({mediumPresets:[...i.mediumPresets,{id:ti("med"),name:e,medium:t}]})),bn(`Saved medium preset “${e}”`)},deleteMediumPreset(e){se(t=>({mediumPresets:t.mediumPresets.filter(i=>i.id!==e)}))},setWorkspace(e){se({workspace:e})},setSubsys(e){se(t=>({subsys:{...t.subsys,...e}}))},setFig(e){se(t=>({subsys:{...t.subsys,fig:{...t.subsys.fig,...e}}}))},toggleSubsystem(e){se(t=>({subsys:{...t.subsys,selected:t.subsys.selected.includes(e)?t.subsys.selected.filter(i=>i!==e):[...t.subsys.selected,e]}}))}};function T3(){var i,a;const e=ix();return!e||!Op(e.format)?null:Object.keys(((i=e.doc)==null?void 0:i.nodes)??{}).length+Object.keys(((a=e.doc)==null?void 0:a.reactions)??{}).length?e:null}const F3=e=>{if(!e)return"";const t=new Date(e);return new Date().toDateString()===t.toDateString()?`today ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:t.toLocaleString([],{dateStyle:"short",timeStyle:"short"})};async function Wf(e){if(e._modelInIdb&&!e.model){const t=await ax();if(t){const{_modelInIdb:i,...a}=e;return{...a,model:t}}}return e}function X3(){const[e]=E.useState(T3),[t]=E.useState(()=>B.lastModel()),[i,a]=E.useState(!!e||!!t),[s,o]=E.useState("");if(!i)return null;const l=async()=>{if(e){o("Opening the last session…");try{const d=await Wf(e);R.getState().actions.loadProject(d),R.getState().actions.toast(`Continued “${e.name??"last session"}”`),a(!1)}catch(d){o(`Could not open it: ${d.message}`)}}},r=async()=>{if(e)try{const d=await Wf(e),f=`${String(d.name||"last_session").replace(/[^\w.-]+/g,"_")}_autosave.gemsmap`,u=URL.createObjectURL(new Blob([JSON.stringify(d)],{type:"application/json"})),p=document.createElement("a");p.href=u,p.download=f,document.body.appendChild(p),p.click(),p.remove(),setTimeout(()=>URL.revokeObjectURL(u),2e3),o(`Saved ${f}${d.model?"":" (without its model)"}`)}catch(d){o(`Could not read it: ${d.message}`)}},c=()=>{B.restoreLast(),o(`Reopening ${(t==null?void 0:t.name)??"the last model"} in COBRAGUI…`)};return n.jsxs("div",{className:"start-banner",role:"status",children:[n.jsxs("div",{className:"sb-text",children:[n.jsx("b",{children:"Welcome back."})," ",e?n.jsxs(n.Fragment,{children:["Your last session ",n.jsxs("b",{children:["“",e.name??"Untitled","”"]})," was autosaved",e._savedAt?` (${F3(e._savedAt)})`:"",". "]}):null,"Open a project with ",n.jsx("b",{children:"File → Open project…"}),", or:"]}),n.jsxs("div",{className:"sb-actions",children:[e&&n.jsx("button",{className:"btn small primary",onClick:l,children:"Continue last session"}),e&&n.jsx("button",{className:"btn small",onClick:r,title:"Save the autosaved session as a project file",children:"Download it (.gemsmap)"}),t&&n.jsxs("button",{className:"btn small",onClick:c,title:"COBRAGUI keeps your imported models on the backend",children:["Reopen COBRAGUI model",t.name?`: ${t.name}`:""]}),n.jsx("button",{className:"btn small",onClick:()=>a(!1),children:"Start fresh"})]}),s&&n.jsx("div",{className:"small",children:s}),n.jsx("div",{className:"muted small",children:"The session is autosaved every 5 minutes; save your work as a project (Ctrl S) to keep it for good."})]})}const vi=[.8,.9,1,1.1,1.25,1.5,1.75],vx="gemsmap.uiScale",qe=e=>`${e/16}rem`,Fn=Ts(()=>({scale:1,factor:1,vw:1280}));function K3(){try{const e=Number(localStorage.getItem(vx));return vi.includes(e)?e:1}catch{return 1}}function Mu(e){const t=document.documentElement;t.style.setProperty("--ui-scale",String(e));const i=parseFloat(getComputedStyle(t).fontSize)/16||1;Fn.setState({scale:e,factor:i,vw:window.innerWidth/i})}function $c(e){const t=vi.reduce((i,a)=>Math.abs(a-e)<Math.abs(i-e)?a:i);try{localStorage.setItem(vx,String(t))}catch{}Mu(t)}function tl(e){const t=vi.indexOf(Fn.getState().scale);$c(vi[Math.max(0,Math.min(vi.length-1,(t<0?vi.indexOf(1):t)+e))])}const z3=e=>`${Math.round(e*100)}%`,Zr=e=>e*Fn.getState().factor;function U3(){Mu(K3());let e=0;window.addEventListener("resize",()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>Mu(Fn.getState().scale))})}const jx=[{id:"ui-larger",group:"View",label:"Interface size: larger",hint:"Ctrl Alt +",run:()=>tl(1)},{id:"ui-smaller",group:"View",label:"Interface size: smaller",hint:"Ctrl Alt −",run:()=>tl(-1)},{id:"ui-reset",group:"View",label:"Interface size: 100 %",hint:"Ctrl Alt 0",run:()=>$c(1)}],Od={A:[-90,0],B:[0,0],C:[90,0],D:[-157,77],E:[-75,77],F:[75,77],G:[157,77],H:[0,250]},q3=[["AE","#f3cada"],["CF","#ffbbbc"],["FH","#ffbbbc"],["BF","#9e9bfe"],["AB","#7e7fff"],["EH","#736eeb"],["AD","#4c49f6"],["GH","#4c49f6"],["BC","#1800ad"],["BE","#ff5757"],["CG","#ff3131"],["DH","#f24e50"]],V3=["DE","EF","FG"],W3={r:16,ring:3.4,edge:7,girdle:3.2},Y3={r:24,ring:5,edge:13,girdle:6};function Z3({width:e=26}){const t=e>=96?W3:Y3,i=314+2*t.r,a=250+2*t.r,s=(o,l,r)=>{const[c,d]=Od[o[0]],[f,u]=Od[o[1]];return n.jsx("line",{x1:c,y1:d,x2:f,y2:u,stroke:l,strokeWidth:r,strokeLinecap:"round"},o)};return n.jsxs("svg",{width:qe(e),height:qe(e*a/i),viewBox:`${-157-t.r} ${-t.r} ${i} ${a}`,"aria-hidden":"true",children:[q3.map(([o,l])=>s(o,l,t.edge)),V3.map(o=>s(o,"#000",t.girdle)),Object.entries(Od).map(([o,[l,r]])=>n.jsx("circle",{cx:l,cy:r,r:t.r-t.ring/2,fill:"#262626",stroke:"#000",strokeWidth:t.ring},o))]})}const Yf={select:"M5 3l12 8-5.5 1.2L14 18l-2.2 1-2.6-5.7L5 17z",metabolite:"M12 12m-5 0a5 5 0 1 0 10 0a5 5 0 1 0-10 0",slot:"M12 12m-5 0a5 5 0 1 0 10 0a5 5 0 1 0-10 0",reaction:"M4 12h13M13 7l5 5-5 5",text:"M5 6V4h14v2M12 4v16M9 20h6",pan:"M12 3v18M3 12h18M12 3l-3 3M12 3l3 3M12 21l-3-3M12 21l3-3M3 12l3-3M3 12l3 3M21 12l-3-3M21 12l-3 3",undo:"M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",redo:"M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",grid:"M4 4h16v16H4zM4 10h16M4 15h16M10 4v16M15 4v16",magnet:"M6 4v8a6 6 0 0 0 12 0V4h-4v8a2 2 0 0 1-4 0V4z",fit:"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5",search:"M11 11m-6 0a6 6 0 1 0 12 0a6 6 0 1 0-12 0M20 20l-4.5-4.5",export:"M12 3v12M7 10l5 5 5-5M5 21h14",import:"M12 15V3M7 8l5-5 5 5M5 21h14",vertical:"M12 3v18M8 7l4-4 4 4M8 17l4 4 4-4",horizontal:"M3 12h18M7 8l-4 4 4 4M17 8l4 4-4 4",circle:"M12 12m-8 0a8 8 0 1 0 16 0a8 8 0 1 0-16 0",gridLayout:"M5 5h4v4H5zM15 5h4v4h-4zM5 15h4v4H5zM15 15h4v4h-4z",organic:"M6 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M18 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M10 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M8 7l8 1M7 8l2 8M17 10l-6 7",hier:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M12 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M12 7v10M11 7l-5 10M13 7l5 10",alignLeft:"M4 3v18M8 7h10M8 12h6M8 17h12",alignRight:"M20 3v18M6 7h10M10 12h6M4 17h12",alignTop:"M3 4h18M7 8v10M12 8v6M17 8v12",alignBottom:"M3 20h18M7 6v10M12 10v6M17 4v12",alignCX:"M12 3v18M6 7h12M8 12h8M5 17h14",alignCY:"M3 12h18M7 6v12M12 8v8M17 5v14",distH:"M4 4v16M20 4v16M9 8h2v8H9zM13 8h2v8h-2z",distV:"M4 4h16M4 20h16M8 9h8v2H8zM8 13h8v2H8z",tidy:"M4 6h16M4 12h10M4 18h14M18 14l2 2 3-4",group:"M3 3h7M14 3h7M3 21h7M14 21h7M3 3v7M3 14v7M21 3v7M21 14v7M8 8h8v8H8z",template:"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM16.5 13v7M13 16.5h7",expandDown:"M12 4v12M7 11l5 5 5-5M5 20h14",expandUp:"M12 20V8M7 13l5-5 5 5M5 4h14",plot:"M4 20V4M4 20h16M7 16l4-5 3 3 5-7",path:"M5 19c4 0 3-14 7-14s3 14 7 14",link:"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",swap:"M7 4v16M3 16l4 4 4-4M17 20V4M13 8l4-4 4 4",curve:"M4 18C8 4 16 4 20 18",lock:"M6 11h12v9H6zM8 11V7a4 4 0 0 1 8 0v4",trash:"M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13",play:"M7 4l13 8-13 8z",pause:"M7 4h4v16H7zM13 4h4v16h-4z",stop:"M6 6h12v12H6z",loop:"M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3M18 3v4h-4M6 21v-4h4",chevL:"M15 5l-7 7 7 7",chevR:"M9 5l7 7-7 7",panelL:"M4 4h16v16H4zM9 4v16",panelR:"M4 4h16v16H4zM15 4v16",plus:"M12 5v14M5 12h14",x:"M6 6l12 12M18 6L6 18",eye:"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0-6 0",eyeOff:"M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6 0 10 7 10 7a17 17 0 0 1-3.2 3.9M6.6 6.6C3.8 8.4 2 12 2 12s4 7 10 7a9.7 9.7 0 0 0 4.4-1",sparkle:"M12 3l2 6 6 2-6 2-2 6-2-6-6-2 6-2z",particles:"M4 12h2M9 12h2M14 12h2M19 12h1M17 8l3 4-3 4",help:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0-18 0M9.5 9a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.7M12 17h.01",file:"M6 3h8l4 4v14H6zM14 3v4h4",more:"M6 12h.01M12 12h.01M18 12h.01"};function q({name:e,size:t=16,stroke:i=1.6,fill:a}){const s=Yf[e]??Yf.more,o=a??(e==="metabolite"||e==="play"||e==="stop");return n.jsx("svg",{width:qe(t),height:qe(t),viewBox:"0 0 24 24",fill:o?"currentColor":"none",stroke:"currentColor",strokeWidth:i,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:e==="slot"?"3 2.5":void 0,"aria-hidden":!0,children:n.jsx("path",{d:s})})}const Q3={lab:{file:"cobragui-logo.png",name:"COBRAGUI",about:"a graphical user interface for COBRApy: explore, edit and simulate the GEM"},map:{file:"mapbuilder-logo.png",name:"Map Builder",about:"pathway figures, flux mapping, export"},templates:{file:"templates-logo.png",name:"Templates",about:"model-independent pathway templates (biological identity + layout), reusable with any GEM"}};function Qr({workspace:e}){const t=Q3[e];return n.jsx("img",{className:"ws-logo",src:`/brand/${t.file}`,alt:t.name,title:`${t.name} — ${t.about}`,draggable:!1})}const ji="ds_cobra_flux",Zf="ds_cobra_fva",Eu="ds_cobra_turnover",Jr="ds_cobra_samples",Ci=e=>`sim_${e.id}`;function J3(e){const i={};for(const o of e.metabolites)i[o.id]={id:o.id,name:o.name||o.id,formula:o.formula??void 0,charge:o.charge??void 0,compartment:o.compartment,annotation:o.annotation};const a={};for(const o of e.reactions)a[o.id]={id:o.id,name:o.name||o.id,stoichiometry:{...o.stoichiometry},reversible:o.reversible,lowerBound:o.lb??-1e3,upperBound:o.ub??1e3,subsystem:o.subsystem??void 0,gpr:o.gpr??void 0,genes:o.genes,ec:o.ec.length?o.ec:void 0};const s=Object.fromEntries(e.genes.map(o=>[o.id,{id:o.id,name:o.name||void 0}]));return{id:e.modelId||e.id,name:e.name,metabolites:i,reactions:a,genes:s,compartments:{...e.compartments},source:"cobrapy",checksum:e.checksum}}function Lc(){var i;const e=S.getState().model;if(!e)return!1;const t=R.getState();if(((i=t.model)==null?void 0:i.checksum)===e.checksum)return!0;if(t.model){const a=e.reactions.map(o=>o.id);if(a.filter(o=>t.model.reactions[o]).length/Math.max(1,a.length)>.97)return!0;if(Object.keys(t.doc.nodes).length&&!window.confirm(`The Map Builder currently uses “${t.model.name}”.
|
|
65
|
+
|
|
66
|
+
Replace it with “${e.name}” from COBRAGUI?
|
|
67
|
+
Arrows keep their reaction ids; ids missing from the new model become unbound.`))return!1}return t.actions.importModel(J3(e)),!0}function vn(e,t="vertical",i=!0){if(!e.length||!Lc())return;const a=V().addModelReactions(e,t,i),s=[];if(a.skipped&&s.push(`${a.skipped} already drawn`),a.boundary&&s.push(`${a.boundary} boundary reaction${a.boundary===1?"":"s"} skipped (no metabolite on one side)`),!a.added){V().toast(s.join(" · ")||"Nothing to add");return}i?(B.setWorkspace("map"),V().toast([`Click on the map to place ${a.added===1?e.find(o=>{var l;return(l=R.getState().model)==null?void 0:l.reactions[o]}):`${a.added} reactions`} · Esc cancels`,...s].join(" · "))):V().toast([`${a.added} reaction${a.added===1?"":"s"} added to the map`,...s].join(" · ")),B.log("info",`Add to map: ${a.added} reaction(s)${s.length?`, ${s.join(", ")}`:""}`)}function Fs(e,t=!0){if(!e.length||!Lc())return;const i=V().addModelMetabolites(e);V().toast(i?`${i} metabolite${i===1?"":"s"} added to the map`:"Already on the map"),t&&i&&B.setWorkspace("map")}function Tc(e){const t=R.getState().doc;if(e.kind==="reaction"){const i=Object.values(t.reactions).find(a=>{var s,o;return a.reactionId===e.id||((s=a.lumped)==null?void 0:s.includes(e.id))||((o=a.collapsed)==null?void 0:o.members.some(l=>l.reactionId===e.id))});return i?{glyph:i.id,node:i.sources[0]}:null}if(e.kind==="metabolite"){const i=Object.values(t.nodes).find(a=>a.metaboliteId===e.id);return i?{node:i.id}:null}return null}function ec(e){const t=Tc(e);if(!t)return V().toast(`${e.id} is not on the map yet`);B.setWorkspace("map"),setTimeout(()=>{t.node&&V().focusNode(t.node),t.glyph&&R.setState({selection:[Ne("reaction",t.glyph)]})},30)}function ek(e){var a,s,o;const t=S.getState();if(!t.model)return V().toast("Load the model in COBRAGUI first");if(!(e.kind==="reaction"?(a=t.index)==null?void 0:a.rxn.has(e.id):e.kind==="metabolite"?(s=t.index)==null?void 0:s.met.has(e.id):(o=t.index)==null?void 0:o.gene.has(e.id)))return V().toast(`${e.id} is not in the COBRAGUI model (${t.model.name})`);B.setWorkspace("lab"),t.section==="overview"&&B.setSection("explore"),B.navigate(e)}function tk(e,t){const i=Ci(t);return e.find(s=>s.id===i)?e.map(s=>s.id===i?{...s,name:t.name}:s):[...e,{id:i,name:t.name,color:Ur[e.length%Ur.length]}]}function oo(e,t,i,a,s){return{id:e,name:t,kind:i,target:a,unit:s,visible:!0,columns:[],values:{},unmatched:[],idMap:{},matchedFraction:1}}function _o(e,t,i,a){var c;const s=e.columns.includes(t)?e.columns:[...e.columns,t],o=s.indexOf(t),l=new Set([...Object.keys(e.values),...Object.keys(i),...Object.keys(a??{})]),r={...e,columns:s,values:{}};(a||e.ranges)&&(r.ranges={});for(const d of l){const f=[...e.values[d]??[]];for(;f.length<s.length;)f.push(null);if(f[o]=i[d]??null,r.values[d]=f,r.ranges){const u=[...((c=e.ranges)==null?void 0:c[d])??[]];for(;u.length<s.length;)u.push(null);a&&(u[o]=a[d]??null),r.ranges[d]=u}}return r}function nk(e,t,i){var d,f;const a=i.samples,s=((d=i.metadata.sampling)==null?void 0:d.n)??1,o={};for(const[u,p]of Object.entries(a.summary))o[u]=p.mean;const l=_o(e,t,o),r=l.columns.indexOf(t),c={};for(const u of Object.keys(l.values)){const p=[...((f=e.samples)==null?void 0:f[u])??[]];for(;p.length<l.columns.length;)p.push([]);const m=a.constant[u];p[r]=a.reactions[u]??(m==null?[]:Array(s).fill(m)),c[u]=p}return{...l,samples:c}}function bi(e,t){const i=e.findIndex(a=>a.target===t.target&&a.property===t.property);return i>=0?e.map((a,s)=>s===i?{...a,...t,domain:void 0}:a):[...e,{...t,id:`m_${Math.random().toString(36).slice(2,9)}`}]}function r0(e){const t=R.getState();let i=[...t.datasets],a=[...t.conditions];const s=l=>{i=i.some(r=>r.id===l.id)?i.map(r=>r.id===l.id?l:r):[...i,l]},o=l=>i.find(r=>r.id===l);for(const l of e){a=tk(a,l);const r=Ci(l);if(l.reactionFluxes&&s(_o(o(ji)??oo(ji,"COBRA simulations · flux","flux","reaction",yt),r,l.reactionFluxes)),l.metaboliteTurnover&&s(_o(o(Eu)??oo(Eu,"COBRA simulations · metabolite turnover","turnover","metabolite",yt),r,l.metaboliteTurnover)),l.samples&&s(nk(o(Jr)??{...oo(Jr,"COBRA simulations · flux samples","samples","reaction",yt),samples:{}},r,l)),l.fva){const c={},d={};for(const[f,u]of Object.entries(l.fva))c[f]=u.minimum==null||u.maximum==null?null:[u.minimum,u.maximum],d[f]=null;s(_o(o(Zf)??{...oo(Zf,"COBRA simulations · FVA intervals","fva","reaction",yt),ranges:{}},r,d,c))}}return{datasets:i,conditions:a}}function ik(e,t){const i=R.getState(),{datasets:a,conditions:s}=r0(e);let o=[...i.mappings];const l=(p,m)=>o.some(h=>h.target===p&&h.property===m&&h.enabled),r=e[e.length-1];let c=0;if(r.reactionFluxes){l("reaction","width")||(o=bi(o,{datasetId:ji,target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0})),l("reaction","color")||(o=bi(o,{datasetId:ji,target:"reaction",property:"color",scale:"linear",magnitude:!0,enabled:!0}));const p=Ci(r);o=o.map(m=>{const h=a.find(g=>g.id===m.datasetId);return m.target!=="reaction"||m.datasetId===ji||h!=null&&h.columns.includes(p)||(h==null?void 0:h.kind)==="comparison"?m:(c++,{...m,datasetId:ji,domain:void 0})})}i.actions.commit(()=>({datasets:a,conditions:s,mappings:o})),i.actions.setView({activeCondition:Ci(r),compare:"absolute",reference:i.view.reference&&s.some(p=>p.id===i.view.reference)?i.view.reference:Ci(e[0])}),R.setState({leftTab:"data"});const d=new Set(e.flatMap(p=>{var m;return Object.keys(p.reactionFluxes??p.fva??((m=p.samples)==null?void 0:m.summary)??{})})),f=i.model?[...d].filter(p=>i.model.reactions[p]).length:null,u=e.filter(p=>p.fva).length;V().toast(`${t}: ${e.length} result${e.length>1?"s":""} added as conditions${f!=null?` · ${f}/${d.size} reaction ids in ${i.model.name}`:" · load a GEM to bind them"}${u?` · ${u} FVA as ranges (use range plots)`:""}${c?` · ${c} reaction mapping${c>1?"s":""} now use the imported fluxes (Ctrl Z to undo)`:""}`)}function ak(e,t){if(!Lc())return;const i=R.getState(),{datasets:a,conditions:s}=r0([e]);let o=[...i.mappings];e.reactionFluxes&&(t.width&&(o=bi(o,{datasetId:ji,target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0})),t.color!=="none"&&(o=bi(o,{datasetId:ji,target:"reaction",property:"color",scale:"linear",magnitude:t.color==="magnitude",enabled:!0}))),e.samples&&(t.width&&(o=bi(o,{datasetId:Jr,target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0})),t.color!=="none"&&(o=bi(o,{datasetId:Jr,target:"reaction",property:"color",scale:"linear",magnitude:t.color==="magnitude",enabled:!0}))),e.metaboliteTurnover&&t.turnoverRadius&&(o=bi(o,{datasetId:Eu,target:"metabolite",property:"radius",scale:"sqrt",magnitude:!0,enabled:!0})),i.actions.commit(()=>({datasets:a,conditions:s,mappings:o})),i.actions.setView({activeCondition:Ci(e),compare:"absolute",reference:i.view.reference&&s.some(r=>r.id===i.view.reference)?i.view.reference:Ci(e)});const l=Object.values(i.doc.reactions).filter(r=>{var c,d,f;return r.reactionId&&(((c=e.reactionFluxes)==null?void 0:c[r.reactionId])!=null||((d=e.fva)==null?void 0:d[r.reactionId])||((f=e.samples)==null?void 0:f.summary[r.reactionId]))}).length;V().toast(`“${e.name}” is now a dataset in the Map Builder${l?` · ${l} arrows bound`:" · add reactions to the map to see it"}${e.samples?" · right-click a reaction → Add linked plot (density or box) to see its distribution":""}`),B.log("info",`Result sent to Map Builder: ${e.name}`),B.setWorkspace("map")}function sk(e,t,i,a,s){if(!Lc()||e.kind!=="flux")return;const o=R.getState(),l=r0([t,i]),r=Ci(i),c={};let d=0,f=0;for(const b of e.reactions)c[b.id]=a==="log2fc"?b.log2fc:b.delta,b.category==="reversal"&&d++,a==="log2fc"&&b.log2fc==null&&b.category!=="both-zero"&&f++;const u=`ds_cmp_${t.id}_${i.id}_${a}`,p=a==="log2fc"?`log₂FC |v| · ${i.name} vs ${t.name}`:`Δ flux · ${i.name} − ${t.name}`,m=_o(oo(u,p,"comparison","reaction",a==="delta"?yt:void 0),r,c),h=[...l.datasets.filter(b=>b.id!==u),m];let g=bi([...o.mappings],{datasetId:u,target:"reaction",property:"color",scale:"linear",magnitude:!1,enabled:!0});s&&(g=bi(g,{datasetId:ji,target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0})),o.actions.commit(()=>({datasets:h,conditions:l.conditions,mappings:g})),o.actions.setView({activeCondition:r,compare:"absolute",reference:Ci(t)});const y=[`Comparison sent: colour = ${a==="log2fc"?"log₂FC |v|":"Δ flux"} (diverging)${s?", width = |flux| in B":""}`];a==="log2fc"&&f&&y.push(`${f} reactions without a defined log₂FC (activation, inactivation or ${d} direction reversals) are drawn neutral`),V().toast(y.join(" · ")),B.log("info",y.join("; ")),B.setWorkspace("map")}const ok={model:".json,.xml,.sbml",data:".csv,.tsv,.txt,.json",project:`${Wo},${qm},.json`,auto:`.json,.xml,.sbml,.csv,.tsv,.txt,${Wo},${qm}`};function $n(e){const t=document.createElement("input");t.type="file",t.accept=ok[e],t.multiple=e==="data"||e==="auto",t.onchange=()=>{for(const i of Array.from(t.files??[]))c0(i,e)},t.click()}async function c0(e,t="auto"){const i=await e.text(),a=e.name.toLowerCase();try{let s=t;if(s==="auto")if(a.endsWith(Wo)||a.endsWith(qm))s="project";else if(/\.(csv|tsv|txt)$/.test(a))s="data";else if(/\.(xml|sbml)$/.test(a))s="model";else{const o=i.slice(0,4e3);s=d1(o)?"project":pu(o)?"data":"model"}if(s==="project"){const o=JSON.parse(i);if(!Op(o.format))throw new Error(`Not a ${Wo} project`);V().loadProject(o),V().toast(`Opened ${o.name}`)}else if(s==="model")V().importModel(j1(e.name,i));else if(/\.json$/i.test(a)||pu(i.slice(0,4e3))){const{results:o,notes:l}=mx(e.name,i);ik(o,e.name),l.length&&setTimeout(()=>V().toast(l.join(" · ")),4300)}else V().importDataset(e.name,i)}catch(s){V().toast(`Could not import ${e.name}: ${s.message}`)}}async function lk(e){const t=await fetch(e);if(!t.ok||(t.headers.get("content-type")??"").includes("text/html"))throw new Error(`${e} is not available — it is a local-only file kept out of the repository (public/${e})`);return t}function jn({value:e,options:t,onChange:i,labels:a,titles:s}){return n.jsx("div",{className:"seg",children:t.map(o=>n.jsx("button",{type:"button",className:e===o?"on":"",title:s==null?void 0:s[o],onClick:()=>i(o),children:(a==null?void 0:a[o])??o},o))})}function pn({checked:e,onChange:t,children:i,title:a}){return n.jsxs("label",{className:`lab-toggle ${e?"on":""}`,title:a,children:[n.jsx("input",{type:"checkbox",checked:e,onChange:s=>t(s.target.checked)}),n.jsx("span",{className:"lab-toggle-box"}),n.jsx("span",{children:i})]})}function Qn({text:e,children:t}){return n.jsx("span",{className:"infotip",title:e,tabIndex:0,children:t??"ⓘ"})}function tc({status:e}){return n.jsxs("span",{className:`status-pill s-${e}`,children:[n.jsx("i",{}),ox[e]??e]})}function ml({info:e,onRetry:t,title:i}){var a;return n.jsxs("div",{className:"error-card",children:[n.jsx("div",{className:"ec-title",children:i??e.title}),e.message&&n.jsx("div",{className:"ec-msg",children:e.message}),((a=e.hints)==null?void 0:a.length)>0&&n.jsxs("div",{className:"ec-hints",children:[n.jsx("div",{className:"muted small",children:"Check:"}),n.jsx("ul",{children:e.hints.map((s,o)=>n.jsx("li",{children:s},o))})]}),n.jsxs("div",{className:"row gap",children:[t&&n.jsx("button",{className:"btn small",onClick:t,children:"Try again"}),e.detail!=null&&n.jsxs("details",{className:"ec-details",children:[n.jsx("summary",{children:"Show details"}),n.jsx("pre",{children:typeof e.detail=="string"?e.detail:JSON.stringify(e.detail,null,1)})]})]})]})}function Xt({r:e,children:t,className:i,title:a}){return n.jsx("button",{type:"button",className:`elink k-${e.kind} ${i??""}`,title:a??e.id,onClick:s=>{s.stopPropagation(),B.navigate(e)},onContextMenu:s=>{s.preventDefault(),s.stopPropagation(),S.setState({contextMenu:{x:s.clientX,y:s.clientY,refs:[e]}})},children:t??e.id})}function rk({r:e,size:t=14}){const i=S(a=>a.favorites.includes(Oc(e)));return n.jsx("button",{type:"button",className:`star ${i?"on":""}`,title:i?"Remove from favorites":"Add to favorites",onClick:a=>{a.stopPropagation(),B.toggleFavorite(e)},children:n.jsx("svg",{width:qe(t),height:qe(t),viewBox:"0 0 24 24",fill:i?"currentColor":"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round",children:n.jsx("path",{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z"})})})}function ck({r:e,names:t=!0}){const i=S(o=>o.index),a=o=>Object.entries(e.stoichiometry).filter(([,l])=>l*o>0),s=o=>o.length===0?n.jsx("span",{className:"muted",children:"∅"}):o.map(([l,r],c)=>{var d,f;return n.jsxs("span",{className:"eq-term",children:[c>0&&n.jsx("span",{className:"eq-plus",children:" + "}),Math.abs(r)!==1&&n.jsxs("span",{className:"eq-coef",children:[W(Math.abs(r),3)," "]}),n.jsx(Xt,{r:{kind:"metabolite",id:l},title:`${l} — ${((d=i==null?void 0:i.met.get(l))==null?void 0:d.name)??""}`,children:t&&((f=i==null?void 0:i.met.get(l))==null?void 0:f.name)||l})]},l)});return n.jsxs("div",{className:"eq",children:[s(a(-1)),n.jsx("span",{className:"eq-arrow",children:e.reversible?" ⇌ ":e.lb!=null&&e.lb<0&&(e.ub??1)<=0?" ← ":" → "}),s(a(1))]})}function Nx({v:e,max:t}){if(e==null)return null;const i=t>0?Math.min(1,Math.abs(e)/t):0;return n.jsx("span",{className:`fluxbar ${e<0?"neg":"pos"}`,children:n.jsx("span",{style:{width:`${i*100}%`}})})}function nl({min:e,max:t,lo:i,hi:a}){if(e==null||t==null||a<=i)return n.jsx("span",{className:"muted",children:"—"});const s=l=>(l-i)/(a-i)*100,o=i<0&&a>0?s(0):null;return n.jsxs("span",{className:"rangebar",title:`${W(e)} … ${W(t)}`,children:[o!=null&&n.jsx("i",{className:"rb-zero",style:{left:`${o}%`}}),n.jsx("span",{className:"rb-span",style:{left:`${s(e)}%`,width:`${Math.max(.8,s(t)-s(e))}%`}})]})}function Xn(e,t=120){const[i,a]=E.useState(e);return E.useEffect(()=>{const s=setTimeout(()=>a(e),t);return()=>clearTimeout(s)},[e,t]),i}function dk(e,t){const i=E.useRef(null);return E.useEffect(()=>{if(!e)return;const a=o=>{var l;(l=i.current)!=null&&l.contains(o.target)||t()},s=o=>{o.key==="Escape"&&t()};return window.addEventListener("pointerdown",a),window.addEventListener("keydown",s),()=>{window.removeEventListener("pointerdown",a),window.removeEventListener("keydown",s)}},[e,t]),i}function Kt({trigger:e,children:t,align:i="left",className:a}){const[s,o]=E.useState(!1),l=dk(s,()=>o(!1));return n.jsxs("div",{className:"pop-wrap",ref:l,children:[e(s,()=>o(!s)),s&&n.jsx("div",{className:`popover ${i} ${a??""}`,children:t(()=>o(!1))})]})}function wn({value:e,onCommit:t,placeholder:i,className:a,allowEmpty:s,title:o,autoFocus:l}){const[r,c]=E.useState(e==null?"":String(e));E.useEffect(()=>c(e==null?"":String(e)),[e]);const d=()=>{const f=r.trim().replace("−","-");if(f===""||/^[-+]?(inf|∞)$/i.test(f)){s?t(null):c(e==null?"":String(e));return}const u=Number(f);Number.isFinite(u)?t(u):c(e==null?"":String(e))};return n.jsx("input",{className:`input num-in ${a??""}`,value:r,placeholder:i,title:o,autoFocus:l,onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&f.target.blur(),f.key==="Escape"&&(c(e==null?"":String(e)),f.target.blur())}})}function ul({title:e,children:t,sub:i}){return n.jsxs("div",{className:"lab-sec-head",children:[n.jsxs("div",{children:[n.jsx("div",{className:"lab-sec-title",children:e}),i&&n.jsx("div",{className:"muted small",children:i})]}),n.jsx("div",{className:"row gap",children:t})]})}const mk=(e,t)=>typeof e=="string"||typeof t=="string"?String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:"base"}):Number(e)-Number(t);function ci({rows:e,cols:t,rowKey:i,rowHeight:a=24,sort:s,onSort:o,selected:l,active:r,onRowClick:c,onRowDoubleClick:d,onContextMenu:f,onKeyNav:u,rowClass:p,empty:m}){const[h,g]=E.useState(null),y=!o,b=y?h:s,_=y?D=>{const F=t.find(O=>O.key===D);if(!(F!=null&&F.sortValue))return;const z=typeof e.map(O=>F.sortValue(O)).find(O=>O!=null&&O!=="")=="string"?"asc":"desc";g(O=>(O==null?void 0:O.key)!==D?{key:D,dir:z}:O.dir===z?{key:D,dir:z==="asc"?"desc":"asc"}:null)}:o,x=E.useMemo(()=>{const D=y&&h?t.find(z=>z.key===h.key):void 0;if(!(D!=null&&D.sortValue))return e;const F=h.dir==="asc"?1:-1,U=D.sortValue;return e.map((z,O)=>({r:z,i:O,v:U(z)})).sort((z,O)=>{const Z=z.v==null||z.v==="",oe=O.v==null||O.v==="";return Z||oe?Z===oe?z.i-O.i:Z?1:-1:F*mk(z.v,O.v)||z.i-O.i}).map(z=>z.r)},[e,t,y,h]),v=D=>D.sortable!==!1&&(y?!!D.sortValue:!!o),j=E.useRef(null),[N,C]=E.useState(0),[w,k]=E.useState(500);E.useLayoutEffect(()=>{const D=j.current;if(!D)return;const F=new ResizeObserver(()=>k(D.clientHeight));return F.observe(D),k(D.clientHeight),()=>F.disconnect()},[]);const P=Fn(D=>D.factor),H=t.map(D=>typeof D.width=="number"?qe(D.width):D.width.replace(/(\d*\.?\d+)px/g,(F,U)=>qe(+U))).join(" "),G=qe(t.reduce((D,F)=>D+(typeof F.width=="number"?F.width:160),0)),M=26*P,A=a*P,X=Math.max(0,Math.floor((N-M)/A)-6),I=Math.min(x.length,Math.ceil((N+w)/A)+6),K=r?x.findIndex(D=>i(D)===r):-1,L=D=>{if(!u||!x.length||D.key!=="ArrowDown"&&D.key!=="ArrowUp")return;D.preventDefault();const F=Math.max(0,Math.min(x.length-1,K+(D.key==="ArrowDown"?1:-1)));u(x[F],F);const U=j.current;if(U){const z=F*A,O=z+A+M;z<U.scrollTop?U.scrollTop=z:O>U.scrollTop+U.clientHeight&&(U.scrollTop=O-U.clientHeight)}};return n.jsx("div",{className:"vt",ref:j,tabIndex:0,onKeyDown:L,onScroll:D=>C(D.currentTarget.scrollTop),children:n.jsxs("div",{className:"vt-inner",style:{minWidth:G},children:[n.jsx("div",{className:"vt-head",style:{gridTemplateColumns:H,height:M},children:t.map(D=>{const F=(b==null?void 0:b.key)===D.key;return n.jsxs("div",{className:`vt-th ${D.align??""} ${v(D)?"sortable":""} ${F?"on":""}`,title:D.title,onClick:()=>v(D)&&(_==null?void 0:_(D.key)),children:[n.jsx("span",{className:"ellipsis",children:D.label}),F&&n.jsx("span",{className:"vt-sort",children:b.dir==="asc"?"↑":"↓"})]},D.key)})}),n.jsx("div",{className:"vt-body",style:{height:x.length*A},children:x.slice(X,I).map((D,F)=>{const U=i(D),z=X+F;return n.jsx("div",{className:`vt-row ${l!=null&&l.has(U)?"sel":""} ${r===U?"active":""} ${(p==null?void 0:p(D))??""}`,style:{top:z*A,height:A,gridTemplateColumns:H},onClick:O=>{O.target.closest("input, select, textarea, button")||c==null||c(D,O,z)},onDoubleClick:O=>{var oe;const Z=(oe=O.target.closest("[data-col]"))==null?void 0:oe.getAttribute("data-col");Z&&(d==null||d(D,Z,O))},onContextMenu:O=>{f&&(O.preventDefault(),f(D,O))},children:t.map(O=>n.jsx("div",{"data-col":O.key,className:`vt-td ${O.align??""}`,children:O.render(D)},O.key))},U)})}),!x.length&&n.jsx("div",{className:"vt-empty",children:m??"No rows"})]})})}function wx(e,t,i,a,s){if(a.shiftKey&&s){const o=e.indexOf(s),l=e.indexOf(i);if(o>=0&&l>=0){const r=e.slice(Math.min(o,l),Math.max(o,l)+1);return Array.from(new Set([...t,...r]))}}return a.ctrlKey||a.metaKey?t.includes(i)?t.filter(o=>o!==i):[...t,i]:[]}const Vi={confident:{label:"Confident",cls:"ok",hint:"All identifiers (or the metabolite ID and the main databases) agree on one MetaNetX chemical"},doubt:{label:"Review",cls:"warn",hint:"Identifiers disagree, the formula conflicts, or only the ID string / the name matched"},unmapped:{label:"Unmapped",cls:"none",hint:"No identifier or exact name known to MetaNetX"},skipped:{label:"Skipped",cls:"none",hint:"Pseudo-metabolite (enzyme, pool, biomass component)"}},uk={preparing:"Preparing",identifiers:"Resolving identifiers",names:"Exact name lookup",compounds:"Fetching compound data",deciding:"Comparing evidence",done:"Done"},pk={"metanetx.chemical":"MetaNetX","kegg.compound":"KEGG",chebi:"ChEBI","bigg.metabolite":"BiGG","seed.compound":"ModelSEED","metacyc.compound":"MetaCyc",hmdb:"HMDB",vmhmetabolite:"VMH","sabiork.compound":"SABIO-RK",lipidmaps:"LIPID MAPS",slm:"SwissLipids","kegg.glycan":"KEGG glycan",inchikey:"InChIKey"},hk=e=>`https://www.metanetx.org/chem_info/${e}`;function Wi(e,t){if(!e)return null;const i=e.entries[t];return i?i.source:e.rejectedIds.includes(t)?"kept":null}function fk(){var l;const e=S(r=>r.model),t=S(r=>r.annotation);E.useEffect(()=>{B.loadAnnotation()},[e.id]);const i=t==null?void 0:t.analysis,a=t==null?void 0:t.curation,s=((l=t==null?void 0:t.job)==null?void 0:l.state)==="running",o=()=>B.setSection("annotation");return n.jsxs("div",{className:"ov-panel ann-card",children:[n.jsxs("div",{className:"row between",children:[n.jsx("div",{className:"insp-sub",children:"Metabolite annotation · MetaNetX"}),i&&n.jsxs("span",{className:"muted small",children:["analysed ",new Date(i.createdAt).toLocaleDateString()]})]}),!i&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"small",children:["Map every metabolite to ",n.jsx("b",{children:"MetaNetX / MNXref"})," through the identifiers already in the model. Missing cross-references (KEGG, ChEBI, BiGG, ModelSEED, MetaCyc, HMDB, InChIKey…) and missing formulas are added to the annotation; uncertain matches wait for your review. The curated model can be exported."]}),n.jsx("div",{children:n.jsxs("button",{className:"btn primary small",onClick:()=>{o(),B.analyzeAnnotation({useNames:!0,autoApply:!0,fillFormulas:!0})},children:[n.jsx(q,{name:"sparkle",size:13})," Analyze metabolites"]})})]}),s&&n.jsx(kx,{}),i&&!s&&n.jsxs(n.Fragment,{children:[n.jsx(Cx,{s:i.summary}),n.jsxs("div",{className:"ann-tiles",children:[n.jsxs("button",{onClick:o,children:[n.jsx("b",{className:"ok",children:i.summary.confident.toLocaleString()}),n.jsx("span",{children:"confident"})]}),n.jsxs("button",{onClick:o,children:[n.jsx("b",{className:"warn-text",children:i.summary.doubt.toLocaleString()}),n.jsx("span",{children:"to review"})]}),n.jsxs("button",{onClick:o,children:[n.jsx("b",{children:i.summary.unmapped.toLocaleString()}),n.jsx("span",{children:"unmapped"})]}),n.jsxs("button",{onClick:o,children:[n.jsx("b",{children:((a==null?void 0:a.accepted)??0).toLocaleString()}),n.jsxs("span",{children:["curated · +",((a==null?void 0:a.identifiers)??0).toLocaleString()," IDs",a!=null&&a.formulas?` · ${a.formulas} formulas`:""]})]})]}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:o,children:"Open metabolite analysis"}),((a==null?void 0:a.accepted)??0)>0&&n.jsxs("button",{className:"btn small",onClick:()=>S.setState({dialog:{kind:"export-model"}}),children:[n.jsx(q,{name:"export",size:13})," Export curated model"]})]})]})]})}function Cx({s:e}){const t=i=>`${100*i/Math.max(1,e.total)}%`;return n.jsxs("div",{className:"ann-bar",title:`${e.confident} confident · ${e.doubt} to review · ${e.unmapped} unmapped · ${e.skipped} skipped`,children:[n.jsx("i",{className:"ok",style:{width:t(e.confident)}}),n.jsx("i",{className:"warn",style:{width:t(e.doubt)}}),n.jsx("i",{className:"none",style:{width:t(e.unmapped)}}),n.jsx("i",{className:"skip",style:{width:t(e.skipped)}})]})}function kx(){const e=S(i=>{var a;return(a=i.annotation)==null?void 0:a.job});if(!e)return null;const t=e.total?Math.round(100*e.done/e.total):0;return n.jsxs("div",{className:"ann-progress",children:[n.jsxs("div",{className:"row between small",children:[n.jsxs("span",{children:[n.jsx("span",{className:"spinner sm"})," ",uk[e.phase]??e.phase,"…"]}),n.jsx("span",{className:"muted",children:e.total?`${e.done.toLocaleString()} / ${e.total.toLocaleString()}`:""})]}),n.jsx("div",{className:"ann-bar",children:n.jsx("i",{className:"accent",style:{width:`${t}%`}})}),n.jsx("div",{className:"muted small",children:"Queries MetaNetX in batches; everything is cached locally, so a second run is instant."})]})}function gk(){var j;const e=S(N=>N.model),t=S(N=>N.annotation),i=S(N=>N.annotationError),[a,s]=E.useState({useNames:!0,autoApply:!0,fillFormulas:!0}),[o,l]=E.useState("review"),[r,c]=E.useState(""),d=Xn(r).trim().toLowerCase(),[f,u]=E.useState(null);E.useEffect(()=>{t||B.loadAnnotation()},[e.id,t]);const p=t==null?void 0:t.analysis,m=t==null?void 0:t.curation,h=((j=t==null?void 0:t.job)==null?void 0:j.state)==="running",g=E.useMemo(()=>p?p.items.filter(N=>{var w;const C=Wi(m,N.id);return o==="review"&&!(N.status==="doubt"&&!C)||o==="confident"&&N.status!=="confident"||o==="unmapped"&&N.status!=="unmapped"||o==="curated"&&!(C==="auto"||C==="user")?!1:!d||N.id.toLowerCase().includes(d)||N.name.toLowerCase().includes(d)||(((w=N.proposal)==null?void 0:w.mnx)??"").toLowerCase().includes(d)}):[],[p,m,o,d]),y=(p==null?void 0:p.items.find(N=>N.id===f))??null,b=E.useMemo(()=>p?T1(p.items):new Map,[p]),_=E.useMemo(()=>new Map(((p==null?void 0:p.items)??[]).map(N=>[N.id,N])),[p]),x=p?p.items.filter(N=>N.status==="doubt"&&!Wi(m,N.id)).length:0,v=[{key:"status",label:"Status",width:74,sortValue:N=>Vi[N.status].label,render:N=>n.jsx("span",{className:`ann-st ${Vi[N.status].cls}`,title:Vi[N.status].hint,children:Vi[N.status].label})},{key:"id",label:"Metabolite",width:"minmax(110px, 1fr)",sortValue:N=>N.id,render:N=>n.jsx("span",{className:"mono ellipsis",title:N.id,children:N.id})},{key:"name",label:"Name",width:"minmax(140px, 2fr)",sortValue:N=>N.name,render:N=>n.jsx("span",{className:"ellipsis",title:N.name,children:N.name})},{key:"comp",label:"Comp.",width:64,sortValue:N=>N.compartment,render:N=>{const C=b.get(N.id);return n.jsxs("span",{className:"muted",title:C?`Same compound in: ${C.join(", ")}`:void 0,children:[N.compartment,C&&n.jsxs("span",{className:"ann-sib",children:[" +",C.length]})]})}},{key:"mnx",label:"MetaNetX",width:"minmax(150px, 2fr)",sortValue:N=>{var C;return(C=N.proposal)==null?void 0:C.mnx},render:N=>{var C,w;return N.proposal?n.jsxs("span",{className:"ellipsis",title:((C=N.candidates[0])==null?void 0:C.name)??"",children:[n.jsx("span",{className:"mono",children:N.proposal.mnx})," ",n.jsx("span",{className:"muted",children:(w=N.candidates.find(k=>k.mnx===N.proposal.mnx))==null?void 0:w.name})]}):n.jsx("span",{className:"muted",children:"—"})}},{key:"add",label:"+IDs",width:48,align:"right",sortValue:N=>N.proposal?Object.values(N.proposal.add).reduce((C,w)=>C+w.length,0):null,render:N=>n.jsx("span",{className:"mono",children:N.proposal?Object.values(N.proposal.add).reduce((C,w)=>C+w.length,0):""}),title:"Cross-references that would be added"},{key:"dec",label:"Model",width:92,sortValue:N=>Wi(m,N.id),render:N=>{const C=Wi(m,N.id);return C==="auto"||C==="user"?n.jsxs("span",{className:"ok small",children:["✓ curated",C==="auto"?" (auto)":""]}):C==="kept"?n.jsx("span",{className:"muted small",children:"kept original"}):n.jsx("span",{className:"muted small",children:"—"})}}];return n.jsxs("div",{className:"lab-page ann-page",children:[n.jsx(ul,{title:"Metabolite analysis",sub:"Cross-references from MetaNetX / MNXref, from the identifiers already in the model. Uncertain matches are never applied without you.",children:m&&m.accepted>0&&n.jsxs("button",{className:"btn small",onClick:()=>S.setState({dialog:{kind:"export-model"}}),children:[n.jsx(q,{name:"export",size:13})," Export curated model"]})}),n.jsxs("div",{className:"ov-panel ann-run",children:[n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("button",{className:"btn primary",disabled:h,onClick:()=>B.analyzeAnnotation(a),children:[n.jsx(q,{name:"sparkle",size:14})," ",p?"Analyze again":"Analyze metabolites"]}),n.jsx(pn,{checked:a.autoApply,onChange:N=>s({...a,autoApply:N}),title:"Add the cross-references of confident matches to the model right away (each one can be undone)",children:"Apply confident matches"}),n.jsx(pn,{checked:a.fillFormulas,onChange:N=>s({...a,fillFormulas:N}),title:"Only for metabolites without a formula; MetaNetX formula and charge (pH 7.3)",children:"Fill missing formulas"}),n.jsx(pn,{checked:a.useNames,onChange:N=>s({...a,useNames:N}),title:"For metabolites without any identifier: exact MetaNetX name match, always left for review",children:"Suggest by exact name"}),n.jsx("span",{className:"grow"}),p&&n.jsxs("span",{className:"muted small",title:p.source.bigg?`BiGG tables: ${p.source.bigg.metabolites.toLocaleString()} universal metabolites${p.source.bigg.installed?`, installed ${p.source.bigg.installed}`:""}. MetaNetX decides; BiGG adds its IDs and curated cross-references.`:"BiGG tables not installed (npm run bigg:data): MetaNetX only",children:[p.summary.total.toLocaleString()," metabolites · ",p.seconds,"s · ",p.source.service,p.status==="partial"?" · partial (MetaNetX unreachable for some queries)":""]})]}),h&&n.jsx(kx,{}),p&&!h&&n.jsx(Cx,{s:p.summary}),m&&m.accepted>0&&n.jsxs("div",{className:"row gap small",children:[n.jsxs("span",{children:[n.jsx("b",{children:m.accepted.toLocaleString()})," metabolites curated · ",n.jsxs("b",{children:["+",m.identifiers.toLocaleString()]})," cross-references",m.formulas?n.jsxs(n.Fragment,{children:[" · ",n.jsx("b",{children:m.formulas})," formulas filled"]}):null,". Included in exports; the original file is unchanged."]}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"link small",onClick:()=>{confirm(`Undo all ${m.accepted} curated metabolites?`)&&B.curate("revert",null)},children:"Revert all"})]})]}),i&&n.jsx(ml,{info:i}),!p&&!h&&n.jsxs("div",{className:"note small",children:["Nothing analysed yet for this model. The analysis needs an internet connection to ",n.jsx("span",{className:"mono",children:"rdf.metanetx.org"})," the first time; results are cached."]}),p&&n.jsxs("div",{className:"ann-split",children:[n.jsxs("div",{className:"ann-list",children:[n.jsxs("div",{className:"row gap",children:[n.jsx(jn,{value:o,options:["review","confident","unmapped","curated","all"],onChange:l,labels:{review:`Needs review (${x})`,confident:`Confident (${p.summary.confident})`,unmapped:`Unmapped (${p.summary.unmapped})`,curated:`Curated (${(m==null?void 0:m.accepted)??0})`,all:"All"}}),n.jsx("input",{className:"input",style:{width:qe(200)},placeholder:"Filter id, name, MNX…",value:r,onChange:N=>c(N.target.value)})]}),n.jsx("div",{className:"ann-table",children:n.jsx(ci,{rows:g,cols:v,rowKey:N=>N.id,active:f,onRowClick:N=>u(N.id),onKeyNav:N=>u(N.id),empty:n.jsx("div",{className:"muted small pad",children:o==="review"?"Nothing left to review.":"No metabolites in this view."})})})]}),n.jsx("div",{className:"ann-detail",children:y?n.jsx(bk,{it:y,cur:m,siblings:(b.get(y.id)??[]).map(N=>_.get(N)).filter(Boolean)},y.id):n.jsx("div",{className:"muted small pad",children:"Select a metabolite to see the evidence and decide."})})]})]})}function Qf(e,t,i){var o;const a=Wi(t,e.id),s=(o=t==null?void 0:t.entries[e.id])==null?void 0:o.mnx;return(a==="auto"||a==="user")&&s&&s!==i?`curated as ${s}`:e.status==="confident"&&e.proposal&&e.proposal.mnx!==i?`its own identifiers point to ${e.proposal.mnx}`:null}function bk({it:e,cur:t,siblings:i}){var v,j,N,C,w;const a=Wi(t,e.id),s=(v=t==null?void 0:t.entries[e.id])==null?void 0:v.mnx,[o,l]=E.useState(s??((j=e.proposal)==null?void 0:j.mnx)??((N=e.candidates[0])==null?void 0:N.mnx)),r=e.candidates.find(k=>k.mnx===o),[c,d]=E.useState(!0),[f,u]=E.useState({}),p=k=>f[k.id]??!Qf(k,t,o),m=i.filter(p),h=()=>r&&B.curate("apply",[{id:e.id,mnx:r.mnx,fillFormula:c},...m.map(k=>({id:k.id,mnx:r.mnx,fillFormula:c,like:e.id}))]),g=()=>B.curate("reject",[e.id,...m.map(k=>k.id)]),y=()=>B.curate("revert",[e.id,...m.filter(k=>{const P=Wi(t,k.id);return P==="auto"||P==="user"}).map(k=>k.id)]),b=m.length?` (+${m.length})`:"",_=!e.formula&&!!(r!=null&&r.formula),x=o===((C=e.proposal)==null?void 0:C.mnx)?(w=e.proposal)==null?void 0:w.add:void 0;return n.jsxs("div",{className:"ann-det",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:`ann-st ${Vi[e.status].cls}`,children:Vi[e.status].label}),n.jsx("button",{className:"link small",onClick:()=>B.navigate({kind:"metabolite",id:e.id}),children:"Open in explorer"})]}),n.jsx("div",{className:"insp-title",children:e.name||e.id}),n.jsxs("div",{className:"mono muted small",children:[e.id," · ",e.compartment,e.formula?` · ${e.formula}`:" · no formula",e.charge!=null?` · charge ${e.charge}`:""]}),n.jsx("div",{className:"small",children:e.reason}),e.inputs.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"insp-sub",children:"Identifiers in the model"}),n.jsx("div",{className:"ann-inputs",children:e.inputs.map((k,P)=>n.jsxs("div",{className:"small",children:[n.jsx("span",{className:"mono",children:k.xref}),k.source==="id"?n.jsx("span",{className:"muted",children:" (from the ID)"}):k.source==="bigg"?n.jsx("span",{className:"muted",children:" (bridge)"}):null," → ",k.mnx.length?k.mnx.map(H=>n.jsxs("span",{className:`mono ${H===o?"strong":"muted"}`,children:[H," "]},H)):n.jsx("span",{className:"muted",children:"not in MetaNetX"})]},P))})]}),e.candidates.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"insp-sub",children:"MetaNetX candidates"}),e.candidates.map(k=>n.jsx(yk,{c:k,on:k.mnx===o,onPick:()=>l(k.mnx)},k.mnx))]}),r&&n.jsxs("div",{children:[n.jsx("div",{className:"insp-sub",children:a==="auto"||a==="user"?"Added to the model":"Will be added"}),x?n.jsxs("div",{className:"ann-add",children:[Object.entries(x).map(([k,P])=>n.jsxs("div",{className:"small",children:[n.jsx("span",{className:"ann-ns",children:pk[k]??k})," ",P.map(H=>n.jsx("span",{className:"mono chip-id",children:H},H))]},k)),!Object.keys(x).length&&n.jsx("div",{className:"muted small",children:"The model already has every cross-reference MetaNetX knows for this chemical."})]}):n.jsxs("div",{className:"muted small",children:["The cross-references of ",r.mnx," are added when you apply it (existing ones are never duplicated or removed)."]}),_&&n.jsxs(pn,{checked:c,onChange:d,title:"MetaNetX formula and charge (pH 7.3)",children:["Also set formula ",r.formula,r.charge!=null?` (charge ${r.charge})`:""]})]}),i.length>0&&n.jsxs("div",{className:"ann-sibs",children:[n.jsxs("div",{className:"insp-sub",children:["Same compound in other compartments · ",i.length]}),n.jsx("div",{className:"muted small",children:"Checked ones get the same decision (the identity of a compound does not depend on its compartment)."}),i.map(k=>{var G;const P=Qf(k,t,o),H=Wi(t,k.id);return n.jsxs("label",{className:`ann-sib-row ${P?"conflict":""}`,children:[n.jsx("input",{type:"checkbox",checked:p(k),onChange:M=>u(A=>({...A,[k.id]:M.target.checked}))}),n.jsx("span",{className:"mono",children:k.id}),n.jsx("span",{className:"muted",children:k.compartment}),n.jsx("span",{className:`ann-st ${Vi[k.status].cls}`,children:Vi[k.status].label}),n.jsx("span",{className:"muted small ellipsis",children:P?`⚠ ${P}`:H==="auto"||H==="user"?`curated · ${(G=t==null?void 0:t.entries[k.id])==null?void 0:G.mnx}`:H==="kept"?"kept original":""})]},k.id)})]}),n.jsxs("div",{className:"row gap wrap",children:[r&&n.jsxs("button",{className:"btn primary small",onClick:h,title:m.length?`Also for ${m.map(k=>k.id).join(", ")}`:void 0,children:[a==="auto"||a==="user"?s===r.mnx?"Re-apply":`Use ${r.mnx} instead`:`Apply ${r.mnx}`,b]}),a!=="kept"&&n.jsxs("button",{className:"btn small",onClick:g,title:`Leave ${m.length?"these metabolites":"this metabolite"} as in the model file`,children:["Keep original",b]}),(a==="auto"||a==="user")&&n.jsxs("button",{className:"btn small",onClick:y,children:["Undo",b]})]})]})}function yk({c:e,on:t,onPick:i}){return n.jsxs("label",{className:`ann-cand ${t?"on":""}`,children:[n.jsx("input",{type:"radio",checked:t,onChange:i}),n.jsxs("div",{className:"grow",children:[n.jsxs("div",{children:[n.jsx("a",{className:"mono",href:hk(e.mnx),target:"_blank",rel:"noreferrer",children:e.mnx})," ",e.name??n.jsx("span",{className:"muted",children:"(no name)"})]}),n.jsxs("div",{className:"muted small",children:[e.formula?n.jsxs(n.Fragment,{children:[e.formula,e.charge!=null?` (${e.charge>0?"+":""}${e.charge})`:""," "]}):"no structure ",e.formulaCheck==="match"&&n.jsx("span",{className:"ok",children:"✓ formula"}),e.formulaCheck==="conflict"&&n.jsx("span",{className:"warn-text",children:"✗ formula differs"}),e.nameMatch&&n.jsx("span",{className:"ok",children:" ✓ name"}),e.bigg&&e.bigg.length>0&&n.jsxs("span",{title:"BiGG universal metabolite (local BiGG tables)",children:[" · BiGG ",n.jsx("span",{className:"mono",children:e.bigg.join(", ")})]})]}),e.fromBigg&&n.jsx("div",{className:"muted small",children:"described by the local BiGG tables only — MetaNetX gave no data"}),n.jsxs("div",{className:"muted small",children:["via ",e.via.slice(0,5).join(", "),e.via.length>5?` +${e.via.length-5}`:""]})]})]})}const Mx="__none__",ct=e=>e===Mx?"No subsystem":/\s/.test(e)||!/_/.test(e)?e:e.replace(/^S_/,"").replace(/__/g,", ").replace(/_/g," ").replace(/ ,/g,",").trim()||e;function Ex(e){const t=new Map(e.subsystems),i=[...e.rxn.values()].filter(a=>!a.subsystem).map(a=>a.id);return i.length&&t.set(Mx,i),t}function xk(e,t,i){var s;const a=[];for(const[o,l]of Ex(e)){let r=0,c=0;for(const d of l)if(t.fva){const f=t.fva[d];if(!f||f.minimum==null||f.maximum==null)continue;const u=f.maximum-f.minimum;u>=i&&(r+=u,c++)}else{const f=(s=t.reactionFluxes)==null?void 0:s[d];f!=null&&Math.abs(f)>=i&&(r+=Math.abs(f),c++)}a.push({key:o,rids:l,total:r,active:c,mean:c?r/c:null})}return a}const Kl=(e,t)=>t==="total"?e.total:t==="active"?e.active:e.mean??0;function _k(e,t,i){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const[o,l]of Ex(e)){let r=0,c=0;const d={changed:0,activated:0,inactivated:0,reversal:0};for(const m of l){const h=a.get(m);h&&(r+=Math.abs(h.a??0),c+=Math.abs(h.b??0),(h.category==="changed"||h.category==="activated"||h.category==="inactivated"||h.category==="reversal")&&d[h.category]++)}const f=r<i,u=c<i,p=f&&u?"both-zero":f?"activated":u?"inactivated":"changed";s.push({key:o,rids:l,totalA:r,totalB:c,delta:c-r,log2:!f&&!u?Math.log2(c/r):null,state:p,counts:d})}return s}const Gx="gemsmap-panel-widths",vk=.22,jk=.4;function Jf(){try{return JSON.parse(localStorage.getItem(Gx)??"{}")}catch{return{}}}function Kn(e,t,i=140,a=720,s){const o=Fn(h=>h.vw),[l,r]=E.useState(()=>{const h=Jf()[e];return typeof h=="number"?h:null}),[c,d]=E.useState(null),f=E.useCallback(h=>Math.round(Math.max(i,Math.min(a,o*jk,h))),[i,a,o]),u=E.useCallback(h=>{const g=Jf();h==null?delete g[e]:g[e]=h;try{localStorage.setItem(Gx,JSON.stringify(g))}catch{}},[e]),p=s!=null&&s.narrow&&o<s.narrow[0]?s.narrow[1]:Math.min(t,o*vk),m=c??f(l??p);return{width:m,css:qe(m),set:h=>d(f(h)),commit:h=>{const g=f(h);d(null),r(g),u(g)},reset:()=>{d(null),r(null),u(null)}}}function zn({panel:e,edge:t}){const i=a=>{if(a.button!==0)return;a.preventDefault(),a.stopPropagation();const s=a.clientX,o=e.width,l=Fn.getState().factor;let r=o;document.body.classList.add("resizing-col");const c=f=>{const u=(f.clientX-s)/l;r=o+(t==="right"?u:-u),e.set(r)},d=()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",d),document.body.classList.remove("resizing-col"),e.commit(r)};window.addEventListener("pointermove",c),window.addEventListener("pointerup",d)};return n.jsx("div",{className:`resize-handle ${t}`,onPointerDown:i,onDoubleClick:e.reset,title:"Arraste para redimensionar · duplo clique para voltar ao tamanho padrão",role:"separator","aria-orientation":"vertical"})}const d0="#2a78d6",Sx="#e34948",Ax="#b45309",Ga=["#2a78d6","#eb6834","#1baf7a","#eda100","#e87ba4","#008300","#4a3aa7","#e34948"],Js="#b8b8b4",Lt="#111111",ai="#555555",Nk="#e3e3e0",vo="#8a8a86",Dx="#f1f1ef",wk="Helvetica, Arial, sans-serif",$d=72/25.4,Ia=(e,t)=>e.length*t*.56;function si(e,t,i){if(Ia(e,i)<=t)return e;const a=Math.max(1,Math.floor(t/(i*.56))-1);return e.slice(0,a)+"…"}const Xs=e=>{if(e===0)return"0";const t=Math.abs(e);return t>=1e4||t<.001?e.toExponential(0):String(+e.toPrecision(3))};function Ck(e){const t=parseInt(e.slice(1),16),i=[t>>16&255,t>>8&255,t&255].map(a=>{const s=a/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return .2126*i[0]+.7152*i[1]+.0722*i[2]}const Px=e=>Ck(e)>.36?Lt:"#ffffff",ki=(e,t)=>e.flux?e.flux[t]??null:null,nc=(e,t)=>!!e.flux&&t in e.flux,m0=(e,t,i)=>{let a=0;for(const s of t.all)if(e.fva){const o=e.fva[s];o&&o.minimum!=null&&o.maximum!=null&&o.maximum-o.minimum>=i&&(a+=o.maximum-o.minimum)}else{const o=ki(e,s);o!=null&&Math.abs(o)>=i&&(a+=Math.abs(o))}return a};function Rx(e,t,i,a){e=Math.min(0,e),t=Math.max(0,t),t-e<1e-12&&(t=e+1);const s=(t-e)/5,o=Math.pow(10,Math.floor(Math.log10(s))),l=[1,2,2.5,5,10].map(u=>u*o).find(u=>u>=s),r=Math.floor(e/l+1e-9)*l,c=Math.ceil(t/l-1e-9)*l,d=[];for(let u=r;u<=c+l*1e-6;u+=l)d.push(+u.toPrecision(12));return{sx:u=>i+(u-r)/(c-r)*(a-i),ticks:d}}function Ix({sx:e,ticks:t,y:i,top:a,fs:s,title:o,x0:l,x1:r}){return n.jsxs("g",{children:[t.map(c=>n.jsx("line",{x1:e(c),x2:e(c),y1:a,y2:i,stroke:c===0?vo:Nk,strokeWidth:c===0?.6:.4},"g"+c)),n.jsx("line",{x1:l,x2:r,y1:i,y2:i,stroke:vo,strokeWidth:.5}),t.map(c=>n.jsxs("g",{children:[n.jsx("line",{x1:e(c),x2:e(c),y1:i,y2:i+2,stroke:vo,strokeWidth:.5}),n.jsx("text",{x:e(c),y:i+2+s,fontSize:s-1,textAnchor:"middle",fill:ai,children:Xs(c)})]},"t"+c)),n.jsx("text",{x:(l+r)/2,y:i+4+s*2.1,fontSize:s,textAnchor:"middle",fill:Lt,children:o})]})}function eg(e,t,i,a,s,o){var H;const l=t.fontPt,r=e.series.length,c=!!((H=e.series[0])!=null&&H.fva),d=G=>t.labels==="name"&&e.rxnName(G)||G,f=a.flatMap(G=>G.rids),u=Math.min(i*.36,Math.max(40,...f.map(G=>Ia(d(G),l-.5)))+6),p=u+4,m=i-6;let h=0,g=0;for(const G of e.series)for(const M of f)if(G.fva){const A=G.fva[M];A&&(h=Math.min(h,A.minimum??0),g=Math.max(g,A.maximum??0))}else{const A=ki(G,M)??0;h=Math.min(h,A),g=Math.max(g,A)}o&&([h,g]=o);const{sx:y,ticks:b}=Rx(h,g,p,m),_=Math.max(2.4,Math.min(l*.95,l*1.6/r)),x=Math.max(l*1.3,r*_+(r-1)*.6+3),v=l*1.7,j=[],N=[];let C=0;for(const G of a)s&&(j.push(n.jsx("text",{x:0,y:C+l*1.15,fontSize:l,fontWeight:700,fill:Lt,children:si(ct(G.key),i,l)},"h"+G.key)),C+=v),G.rids.length||(j.push(n.jsx("text",{x:p,y:C+l,fontSize:l-1,fill:ai,fontStyle:"italic",children:c?"no variable reaction":"no reaction carries flux"},"e"+G.key)),C+=x),G.rids.forEach((M,A)=>{const X=C+x/2;A%2===1&&N.push(n.jsx("rect",{x:0,y:C,width:i,height:x,fill:"#f7f7f5"},"z"+G.key+M)),j.push(n.jsxs("text",{x:u,y:X+l*.33,fontSize:l-.5,textAnchor:"end",fill:Lt,children:[si(d(M),u-2,l-.5),n.jsx("title",{children:`${M} — ${e.rxnName(M)}`})]},"l"+G.key+M)),e.series.forEach((I,K)=>{const L=X-(r*_+(r-1)*.6)/2+K*(_+.6);if(I.fva){const O=I.fva[M];if(!O||O.minimum==null||O.maximum==null)return;const Z=y(O.minimum),oe=y(O.maximum);j.push(n.jsxs("g",{stroke:Ax,strokeWidth:1,children:[n.jsx("line",{x1:Z,x2:Math.max(oe,Z+.6),y1:L+_/2,y2:L+_/2,strokeWidth:Math.max(1.2,_*.6)}),n.jsx("line",{x1:Z,x2:Z,y1:L,y2:L+_}),n.jsx("line",{x1:oe,x2:oe,y1:L,y2:L+_}),n.jsx("title",{children:`${M}: [${W(O.minimum)}, ${W(O.maximum)}]`})]},"f"+G.key+M+K));return}const D=ki(I,M);if(!nc(I,M)){j.push(n.jsxs("text",{x:y(0)+2,y:L+_*.85,fontSize:Math.min(l-2,_+1),fill:ai,children:["n/a",n.jsx("title",{children:`${M} is not in ${I.name}`})]},"n"+G.key+M+K));return}if(D==null||Math.abs(D)<e.tol)return;const F=y(Math.min(0,D)),U=y(Math.max(0,D)),z=r===1?D>0?d0:Sx:I.color;j.push(n.jsx("rect",{x:F,y:L,width:Math.max(.4,U-F),height:_,fill:z,children:n.jsx("title",{children:`${M} · ${I.name}: ${W(D)} ${yt}`})},"b"+G.key+M+K)),t.values&&r===1&&j.push(n.jsx("text",{x:D>0?U+1.5:F-1.5,y:L+_*.8,fontSize:l-1.5,textAnchor:D>0?"start":"end",fill:ai,children:Xs(D)},"v"+G.key+M))}),C+=x}),(a.length>1||s)&&(C+=l*.5);const w=0,k=C+2,P=c?`Feasible flux range (${yt})`:`Flux (${yt})`;return{w:i,h:k+l*2.8,body:n.jsxs("g",{children:[N,n.jsx(Ix,{sx:y,ticks:b,y:k,top:w,fs:l,title:P,x0:p,x1:m}),j]})}}function kk(e,t,i){var b;const a=t.fontPt,s=e.series.length,o=!!((b=e.series[0])!=null&&b.fva),l=e.groups.map(_=>ct(_.key)),r=Math.min(i*.4,Math.max(40,...l.map(_=>Ia(_,a-.5)))+6),c=r+4,d=i-(t.values?30:8),f=e.groups.map(_=>e.series.map(x=>m0(x,_,e.tol))),{sx:u,ticks:p}=Rx(0,Math.max(0,...f.flat()),c,d),m=Math.max(2.4,Math.min(a*1.1,a*2/s)),h=s*m+(s-1)*.6+a*.6,g=[];e.groups.forEach((_,x)=>{const j=x*h+h/2;g.push(n.jsxs("text",{x:r,y:j+a*.33,fontSize:a-.5,textAnchor:"end",fill:Lt,children:[si(l[x],r-2,a-.5),n.jsx("title",{children:l[x]})]},"l"+_.key)),e.series.forEach((N,C)=>{const w=f[x][C],k=j-(s*m+(s-1)*.6)/2+C*(m+.6);g.push(n.jsx("rect",{x:u(0),y:k,width:Math.max(.4,u(w)-u(0)),height:m,fill:s===1?o?Ax:d0:N.color,children:n.jsx("title",{children:`${l[x]} · ${N.name}: ${W(w)}`})},"b"+_.key+C)),t.values&&g.push(n.jsx("text",{x:u(w)+1.5,y:k+m*.8,fontSize:a-1.5,fill:ai,children:Xs(w)},"v"+_.key+C))})});const y=e.groups.length*h+2;return{w:i,h:y+a*2.8,body:n.jsxs("g",{children:[n.jsx(Ix,{sx:u,ticks:p,y,top:0,fs:a,title:o?`Σ FVA width per subsystem (${yt})`:`Σ |flux| per subsystem (${yt})`,x0:c,x1:d}),g]})}}function Gu({cs:e,x:t,y:i,w:a,fs:s,title:o}){const l=`cb-${e.paletteId}-${Math.round(e.lo*1e6)}-${Math.round(e.hi*1e6)}`,r=za(e.paletteId),c=e.diverging?[e.lo,0,e.hi]:[e.lo,(e.lo+e.hi)/2,e.hi];return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("linearGradient",{id:l,x1:"0",x2:"1",y1:"0",y2:"0",children:(e.diverging?[...r.stops].reverse():r.stops).map((d,f)=>n.jsx("stop",{offset:f/(r.stops.length-1),stopColor:d},f))})}),n.jsx("text",{x:t,y:i-2,fontSize:s-1,fill:Lt,children:o}),n.jsx("rect",{x:t,y:i,width:a,height:s*.9,fill:`url(#${l})`,stroke:vo,strokeWidth:.3}),c.map((d,f)=>n.jsxs("g",{children:[n.jsx("line",{x1:t+f/2*a,x2:t+f/2*a,y1:i+s*.9,y2:i+s*.9+1.5,stroke:vo,strokeWidth:.4}),n.jsx("text",{x:t+f/2*a,y:i+s*.9+1.5+s-1,fontSize:s-1.5,textAnchor:"middle",fill:ai,children:Xs(d)})]},f))]})}function Ld(e,t,i,a,s,o,l){const r=t.fontPt,c=e.series.length,d=G=>t.labels==="name"&&e.rxnName(G)||G,f=[],u=[];if(a==="subsystems")for(const G of s)f.push({key:G.key,label:ct(G.key),vals:e.series.map(M=>m0(M,G,e.tol))});else for(const G of s)for(const M of G.rids)f.push({key:G.key+M,label:d(M),group:G.key,vals:e.series.map(A=>{if(!nc(A,M))return null;const X=ki(A,M)??0;return Math.abs(X)<e.tol?0:X})});const p=f.flatMap(G=>G.vals).filter(G=>G!=null),m=l??Bx(p,a,t),h=Math.min(i*.4,Math.max(36,...f.map(G=>Ia(G.label,r-.5)))+6),g=e.series.map(G=>G.name),y=Math.max(14,Math.min(64,(i-h-10)/c)),b=g.some(G=>Ia(G,r-.5)>y-2),_=b?Math.min(90,Math.max(...g.map(G=>Ia(G,r-.5))))*.72+r:r*1.6,x=Math.max(r*1.25,7),v=.8,j=[];let N=_;g.forEach((G,M)=>{const A=h+4+M*y+y/2;j.push(b?n.jsxs("text",{x:A,y:_-3,fontSize:r-.5,fill:Lt,transform:`rotate(-40 ${A} ${_-3})`,children:[si(G,120,r-.5),n.jsx("title",{children:G})]},"c"+M):n.jsx("text",{x:A,y:_-4,fontSize:r-.5,textAnchor:"middle",fill:Lt,children:G},"c"+M))});let C;for(const G of f)a==="reactions"&&G.group!==C&&(s.length>1||o)&&(u.push({y:N,label:ct(G.group)}),N+=r*1.6,C=G.group),j.push(n.jsx("text",{x:h,y:N+x/2+r*.33,fontSize:r-.5,textAnchor:"end",fill:Lt,children:si(G.label,h-2,r-.5)},"l"+G.key)),G.vals.forEach((M,A)=>{const X=h+4+A*y,I=M==null?Dx:m.color(M);j.push(n.jsxs("g",{children:[n.jsx("rect",{x:X,y:N,width:y-v,height:x-v,fill:I}),M==null&&n.jsx("line",{x1:X+2,x2:X+y-v-2,y1:N+x-v-2,y2:N+2,stroke:"#c9c9c5",strokeWidth:.5}),t.values&&M!=null&&n.jsx("text",{x:X+(y-v)/2,y:N+x/2+(r-1.5)*.35,fontSize:r-1.5,textAnchor:"middle",fill:Px(I),children:Xs(M)}),n.jsx("title",{children:`${G.label} · ${e.series[A].name}: ${M==null?"not in this result":W(M)}`})]},"k"+G.key+A))}),N+=x;u.forEach((G,M)=>j.push(n.jsx("text",{x:0,y:G.y+r*1.15,fontSize:r,fontWeight:700,fill:Lt,children:si(G.label,i,r)},"h"+M))),f.length||(j.push(n.jsx("text",{x:h,y:N+r,fontSize:r-1,fontStyle:"italic",fill:ai,children:"no reaction carries flux"},"empty")),N+=r*1.5);const w=h+4+c*y;let k=N+4;const P=Math.min(110,i*.3),H=a==="subsystems"?"Σ |flux|":"Flux";return l||(i-w-12>=P?j.push(n.jsx(Gu,{cs:m,x:w+12,y:_+r,w:P,fs:r,title:H},"cb")):(j.push(n.jsx(Gu,{cs:m,x:h+4,y:k+r,w:P,fs:r,title:H},"cb")),k+=r*3.4)),{w:i,h:k,body:n.jsx("g",{children:j})}}function Bx(e,t,i){if(t==="subsystems"||e.every(o=>o>=0)){const o=za(i.seqPalette),l=Math.max(1e-12,...e);return{color:r=>Bs(o,r/l),lo:0,hi:l,diverging:!1,paletteId:o.id}}const a=za(i.divPalette),s=Math.max(1e-12,...e.map(Math.abs));return{color:o=>Bs(a,.5-o/(2*s)),lo:-s,hi:s,diverging:!0,paletteId:a.id}}function tg(e,t,i,a,s,o){const l=o-s>Math.PI?1:0,r=(c,d)=>`${(e+c*Math.sin(d)).toFixed(2)},${(t-c*Math.cos(d)).toFixed(2)}`;return o-s>=Math.PI*2-1e-6?`M${r(a,0)}A${a},${a} 0 1 1 ${r(a,Math.PI)}A${a},${a} 0 1 1 ${r(a,0)}M${r(i,0)}A${i},${i} 0 1 0 ${r(i,Math.PI)}A${i},${i} 0 1 0 ${r(i,0)}Z`:`M${r(a,s)}A${a},${a} 0 ${l} 1 ${r(a,o)}L${r(i,o)}A${i},${i} 0 ${l} 0 ${r(i,s)}Z`}function ng({slices:e,cx:t,cy:i,r:a,fs:s,title:o,values:l,center:r}){const c=e.reduce((u,p)=>u+p.value,0),d=a*.58;let f=0;return n.jsxs("g",{children:[n.jsxs("text",{x:t,y:i-a-4,fontSize:s,textAnchor:"middle",fill:Lt,fontWeight:600,children:[si(o,a*2.6,s),n.jsx("title",{children:o})]}),c<=0?n.jsx("path",{d:tg(t,i,d,a,0,Math.PI*2),fill:Dx,fillRule:"evenodd"}):e.filter(u=>u.value>0).map(u=>{const p=f,m=f+u.value/c*Math.PI*2;f=m;const h=(p+m)/2,g=u.value/c;return n.jsxs("g",{children:[n.jsx("path",{d:tg(t,i,d,a,p,m),fill:u.color,fillRule:"evenodd",stroke:"#ffffff",strokeWidth:e.length>1?.8:0}),l&&g>=.06&&n.jsxs("text",{x:t+(a+d)/2*Math.sin(h),y:i-(a+d)/2*Math.cos(h)+(s-1.5)*.35,fontSize:s-1.5,textAnchor:"middle",fill:Px(u.color),children:[Math.round(g*100),"%"]}),n.jsx("title",{children:`${u.label}: ${W(u.value)} (${(g*100).toFixed(1)} %)`})]},u.key)}),n.jsx("text",{x:t,y:i+s*.1,fontSize:s-1,textAnchor:"middle",fill:ai,children:c<=0?"no flux":r}),c>0&&n.jsx("text",{x:t,y:i+s*1.1,fontSize:s-2,textAnchor:"middle",fill:ai,children:"Σ|v|"})]})}function Su({items:e,x:t,y:i,w:a,fs:s}){const o=[];let l=t,r=i;const c=s*1.45;for(const d of e){const f=Math.min(Ia(d.label,s-.5),a*.6)+s*1.6;l+f>t+a&&l>t&&(l=t,r+=c),o.push(n.jsxs("g",{children:[n.jsx("rect",{x:l,y:r-s*.75,width:s*.8,height:s*.8,rx:1,fill:d.color}),n.jsx("text",{x:l+s*1.1,y:r,fontSize:s-.5,fill:Lt,children:si(d.label,a*.6,s-.5)})]},d.label+l+r)),l+=f+s*.8}return{node:n.jsx("g",{children:o}),h:r-i+c}}function Mk(e,t,i,a){const s=t.fontPt,o=e.series.length,l=[];let r=0;const c=d=>Xs(d.reduce((f,u)=>f+u.value,0));if(a==="subsystems"){const d=e.groups.map((m,h)=>({key:m.key,label:ct(m.key),color:h<7||e.groups.length<=8?Ga[h]:Js})),f=Math.max(28,Math.min(70,i/Math.min(o,4)*.36)),u=Math.max(1,Math.floor(i/(f*2.7)));e.series.forEach((m,h)=>{const g=h%u,y=Math.floor(h/u),b=i/Math.min(o,u)*(g+.5),_=y*(f*2+s*3)+f+s*1.6;let x=e.groups.map((v,j)=>({...d[j],value:m0(m,v,e.tol)}));x.length>8&&(x=[...x.slice(0,7),{key:"__other",label:"Other",color:Js,value:x.slice(7).reduce((v,j)=>v+j.value,0)}]),l.push(n.jsx(ng,{slices:x,cx:b,cy:_,r:f,fs:s,title:m.name,values:t.values,center:c(x)},m.id))}),r=Math.ceil(o/u)*(f*2+s*3)+s*.6;const p=Su({items:d.length>8?[...d.slice(0,7),{key:"__other",label:"Other",color:Js}]:d,x:0,y:r+s,w:i,fs:s});l.push(n.jsx("g",{children:p.node},"leg")),r+=p.h+s}else{const d=Math.max(24,Math.min(54,i*.62/Math.max(1,o)*.36));for(const f of e.groups){const u=x=>Math.max(...e.series.map(v=>Math.abs(ki(v,x)??0))),p=f.all.filter(x=>u(x)>=e.tol).sort((x,v)=>u(v)-u(x)),m=p.length>8?p.slice(0,7):p,h=p.slice(m.length);l.push(n.jsx("text",{x:0,y:r+s*1.15,fontSize:s,fontWeight:700,fill:Lt,children:si(ct(f.key),i,s)},"h"+f.key)),r+=s*3;const g=[...m.map((x,v)=>({label:t.labels==="name"&&e.rxnName(x)||x,color:Ga[v]})),...h.length?[{label:`Other (${h.length})`,color:Js}]:[]],y=o*d*2.6;e.series.forEach((x,v)=>{const j=[...m.map((N,C)=>({key:N,label:N,color:Ga[C],value:Math.abs(ki(x,N)??0)})),...h.length?[{key:"__other",label:`Other (${h.length} reactions)`,color:Js,value:h.reduce((N,C)=>N+Math.abs(ki(x,C)??0),0)}]:[]];l.push(n.jsx(ng,{slices:j,cx:d*1.3+v*d*2.6,cy:r+d+s*.8,r:d,fs:s,title:x.name,values:t.values,center:c(j)},f.key+x.id))});const b=Math.min(y+s,i*.62),_=Su({items:g,x:b,y:r+s,w:i-b,fs:s});l.push(n.jsx("g",{children:_.node},"lg"+f.key)),r+=Math.max(d*2+s*1.6,_.h+s)+s}}return{w:i,h:r,body:n.jsx("g",{children:l})}}function Ek(e,t,i){const a=i.length>1&&e>=360?2:1,s=t*2,o=(e-s*(a-1))/a,l=[];let r=0;for(let c=0;c<i.length;c+=a){const d=i.slice(c,c+a).map(u=>({p:u,b:u.build(o)})),f=Math.max(...d.map(u=>u.b.h));d.forEach(({p:u,b:p},m)=>{l.push(n.jsxs("g",{transform:`translate(${(m*(o+s)).toFixed(2)},${r.toFixed(2)})`,children:[n.jsx("text",{x:-t*.5,y:t*1.15,fontSize:t+1.5,fontWeight:700,fill:Lt,textAnchor:"end",children:String.fromCharCode(97+c+m)}),p.body]},u.key))}),r+=f+s}return{w:e,h:r-s,body:n.jsx("g",{children:l})}}function Gk(e,t,i,a){return E.useMemo(()=>{var _;const s=a.fontPt,o=s*1.4,l=a.widthMm,r=l*$d,c=r-o*2-(e.mode==="separate"&&i==="reactions"&&t!=="pie"?s:0),d=!!((_=e.series[0])!=null&&_.fva);let f;if(t==="pie")f=Mk(e,a,c,i);else if(i==="subsystems")f=t==="bars"?kk(e,a,c):Ld(e,a,c,"subsystems",e.groups,!1,null);else if(e.mode==="separate"){let x=null,v=null;if(e.scale==="shared"){const N=e.groups.flatMap(w=>w.rids),C=e.series.flatMap(w=>N.flatMap(k=>{var P,H;return w.fva?[((P=w.fva[k])==null?void 0:P.minimum)??0,((H=w.fva[k])==null?void 0:H.maximum)??0]:[ki(w,k)??0]}));x=[Math.min(0,...C),Math.max(0,...C)],t==="heatmap"&&(v=Bx(e.series.flatMap(w=>N.filter(k=>nc(w,k)).map(k=>ki(w,k)??0)),"reactions",a))}const j=Ek(c,s,e.groups.map(N=>({key:N.key,build:C=>t==="bars"?eg(e,a,C,[N],!0,x):Ld(e,a,C,"reactions",[N],!0,v)})));if(v){const N=n.jsx(Gu,{cs:v,x:0,y:j.h+s*2,w:Math.min(110,c*.3),fs:s,title:"Flux (all panels)"});f={w:j.w,h:j.h+s*5,body:n.jsxs("g",{children:[j.body,N]})}}else f=j;f={...f,body:n.jsx("g",{transform:`translate(${s},0)`,children:f.body})}}else f=t==="bars"?eg(e,a,c,e.groups,e.groups.length>1,null):Ld(e,a,c,"reactions",e.groups,!1,null);const u=a.title??e.autoTitle;let p=o;const m=[];u&&(m.push(n.jsx("text",{x:o,y:p+s*1.3,fontSize:s+2,fontWeight:700,fill:Lt,children:si(u,c,s+2)},"title")),p+=s*2.4);const h=e.series.length>1&&t!=="pie"?e.series.map(x=>({label:x.name,color:x.color})):t==="bars"&&i==="reactions"&&!d?[{label:"flux as written",color:d0},{label:"reverse direction",color:Sx}]:[];if(h.length&&t!=="heatmap"){const x=Su({items:h,x:o,y:p+s,w:c,fs:s});m.push(n.jsx("g",{children:x.node},"legend")),p+=x.h+s*.4}m.push(n.jsx("g",{transform:`translate(${o.toFixed(2)},${p.toFixed(2)})`,children:f.body},"core")),p+=f.h+s*.6;const g=[];if(a.caption){t==="pie"?g.push(i==="subsystems"?"Slices: share of Σ|flux| among the shown subsystems (descriptive; not a mass balance).":"Slices: share of each reaction in the subsystem’s Σ|flux| (descriptive; not a mass balance)."):i==="subsystems"?g.push(`Σ|flux|: sum of absolute fluxes over the reactions annotated with each subsystem${d?" (FVA: sum of interval widths)":""}.`):d?g.push("Bars: FVA feasible intervals [min, max]; no midpoint is shown."):g.push("Sign: positive = flux in the written direction of the reaction, negative = reverse.");const x=e.groups.filter(v=>v.rids.length<v.all.length).length;i==="reactions"&&t!=="pie"&&x&&g.push("Only reactions passing the current filters are shown (zero-flux hidden or the per-subsystem limit)."),e.series.some(v=>v.flux&&e.groups.some(j=>j.rids.some(N=>!nc(v,N))))&&g.push("n/a / hatched: reaction not present in that result.")}g.forEach((x,v)=>m.push(n.jsx("text",{x:o,y:p+s*(v+1)*1.25,fontSize:s-1.5,fill:ai,children:x},"note"+v))),p+=g.length?s*(g.length*1.25+.8):0;const y=p+o*.6;return{node:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:`${l}mm`,height:`${(y/$d).toFixed(2)}mm`,viewBox:`0 0 ${r.toFixed(2)} ${y.toFixed(2)}`,fontFamily:wk,children:[n.jsx("rect",{x:0,y:0,width:r,height:y,fill:"#ffffff"}),m]}),wMm:l,hMm:y/$d,title:u||e.autoTitle}},[e,t,i,a])}function Sk({supports:e,exportRef:t,fileBase:i,size:a}){const s=S(u=>u.subsys),o=s.fig,[l,r]=E.useState(""),c=()=>{var p;const u=(p=t.current)==null?void 0:p.querySelector("svg");if(!u)throw new Error("Nothing to export");return`<?xml version="1.0" encoding="UTF-8"?>
|
|
68
|
+
`+new XMLSerializer().serializeToString(u)},d=i.replace(/[^\w.-]+/g,"_").slice(0,80)||"subsystems",f=async u=>{try{const p=c();if(u==="svg")Di(`${d}.svg`,p,"image/svg+xml"),r(`${d}.svg · ${a.wMm.toFixed(0)} × ${a.hMm.toFixed(0)} mm`);else if(u==="pdf")J1(p,d,a.wMm,a.hMm),r("Print dialog opened — choose “Save as PDF” (vector)");else{const m=u==="png300"?300:600,{blob:h,pxW:g,pxH:y}=await t0(p,a.wMm,a.hMm,m);Di(`${d}_${m}dpi.png`,h),r(`${d}_${m}dpi.png · ${g} × ${y} px`)}}catch(p){r(p.message)}};return n.jsxs("div",{className:"fig-bar",children:[n.jsxs("div",{className:"fig-row",children:[n.jsx(jn,{value:s.level,options:["reactions","subsystems"],onChange:u=>B.setSubsys({level:u}),labels:{reactions:"Reactions",subsystems:"Subsystem totals"},titles:{reactions:"One row / slice per reaction of the open subsystems",subsystems:"One row / slice per subsystem (Σ|flux|) — the global picture"}}),n.jsxs("label",{className:"fig-field",children:["Width",n.jsx("select",{className:"input tiny",value:o.widthMm,onChange:u=>B.setFig({widthMm:+u.target.value}),children:du.filter(u=>u.w>0&&u.w<=200).map(u=>n.jsx("option",{value:u.w,children:u.name},u.id))})]}),n.jsxs("label",{className:"fig-field",children:["Font",n.jsx("select",{className:"input tiny",value:o.fontPt,onChange:u=>B.setFig({fontPt:+u.target.value}),children:[6,7,8,9,10,12].map(u=>n.jsxs("option",{value:u,children:[u," pt"]},u))})]}),n.jsx(jn,{value:o.labels,options:["id","name"],onChange:u=>B.setFig({labels:u}),labels:{id:"IDs",name:"Names"}}),n.jsx(pn,{checked:o.values,onChange:u=>B.setFig({values:u}),children:"Values"}),n.jsx(pn,{checked:o.caption,onChange:u=>B.setFig({caption:u}),children:"Notes"})]}),n.jsxs("div",{className:"fig-row",children:[s.view==="heatmap"&&e.heatmap&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"fig-field",children:["Signed",n.jsx("select",{className:"input tiny",value:o.divPalette,onChange:u=>B.setFig({divPalette:u.target.value}),children:Qo.filter(u=>u.kind==="diverging").map(u=>n.jsx("option",{value:u.id,children:u.name},u.id))})]}),n.jsxs("label",{className:"fig-field",children:["Totals",n.jsx("select",{className:"input tiny",value:o.seqPalette,onChange:u=>B.setFig({seqPalette:u.target.value}),children:Qo.filter(u=>u.kind==="sequential").map(u=>n.jsx("option",{value:u.id,children:u.name},u.id))})]})]}),s.level==="reactions"&&s.view!=="pie"&&n.jsxs("label",{className:"fig-field",title:"Largest reactions per subsystem drawn in the figure",children:["Max rows",n.jsx("input",{className:"input tiny num",type:"number",min:3,max:300,value:o.maxRows,onChange:u=>B.setFig({maxRows:Math.max(3,Math.min(300,+u.target.value||25))})})]}),n.jsxs("label",{className:"fig-field grow",children:["Title",n.jsx("input",{className:"input tiny",placeholder:"automatic — type to replace, a space for none",value:o.title??"",onChange:u=>B.setFig({title:u.target.value===""?null:u.target.value.trim()===""?"":u.target.value})})]}),n.jsxs("span",{className:"fig-save",children:[n.jsx("span",{className:"muted small",children:"Save"}),n.jsx("button",{className:"btn small",onClick:()=>f("svg"),title:"Vector, editable (Illustrator, Inkscape)",children:"SVG"}),n.jsx("button",{className:"btn small",onClick:()=>f("pdf"),title:"Vector PDF through the print dialog",children:"PDF"}),n.jsx("button",{className:"btn small",onClick:()=>f("png300"),children:"PNG 300 dpi"}),n.jsx("button",{className:"btn small primary",onClick:()=>f("png600"),title:"High resolution raster for journals",children:"PNG 600 dpi"})]})]}),(l||e.reason)&&n.jsx("div",{className:"muted small",children:l||e.reason})]})}function Hx({inp:e,view:t,level:i}){var r,c;const a=S(d=>d.subsys.fig),s=E.useRef(null),o=Gk(e,t,i,a),l=`${o.title}_${t}`;return n.jsxs("div",{className:"fig-wrap",children:[n.jsx(Sk,{supports:{pie:!((r=e.series[0])!=null&&r.fva),heatmap:!((c=e.series[0])!=null&&c.fva)},exportRef:s,fileBase:l,size:{wMm:o.wMm,hMm:o.hMm}}),n.jsx("div",{className:"fig-paper-scroll",children:n.jsx("div",{className:"fig-paper",ref:s,style:{width:`min(100%, ${(o.wMm*3.78*1.25).toFixed(0)}px)`},children:o.node})}),n.jsxs("div",{className:"muted small fig-size",children:[o.wMm.toFixed(0)," × ",o.hMm.toFixed(0)," mm at ",a.fontPt," pt · hover a mark for its value"]})]})}const Au="#2a78d6",Ox="#e34948",jo="#86b6ef",No="#1c5cab",ig=40;function $x(){const[e,t]=E.useState(null),i=s=>({onMouseMove:o=>t({x:o.clientX,y:o.clientY,body:s}),onMouseLeave:()=>t(null)}),a=e?n.jsx("div",{className:"ss-tip",style:{left:Math.min(e.x+14,window.innerWidth-Zr(260)),top:e.y+14},children:e.body}):null;return{on:i,node:a}}function Lx({legend:e,isFva:t}){const i=S(s=>s.subsys),a=i.view!=="list";return n.jsxs("div",{className:"ss-controls",children:[a&&n.jsx("button",{className:`btn small ${i.wide?"on":""}`,onClick:()=>B.setSubsys({wide:!i.wide}),title:i.wide?"Show the subsystem list":"Hide the subsystem list: the figure gets the full width",children:n.jsx(q,{name:i.wide?"panelR":"panelL",size:12})}),n.jsx(jn,{value:i.view,options:["list","bars","heatmap","pie"],onChange:s=>B.setSubsys({view:s}),labels:{list:"List",bars:"Bars",heatmap:"Heatmap",pie:"Donut"},titles:{list:"Interactive rows: click a reaction to inspect it",bars:"Publication figure: bar chart",heatmap:t?"Not available for FVA (intervals have no single value)":"Publication figure: heatmap (rows × results)",pie:t?"Not available for FVA (intervals are not amounts)":"Publication figure: donut of shares of Σ|flux|"}}),n.jsx("span",{className:"ss-sep"}),!(a&&i.level==="subsystems")&&i.view!=="pie"&&n.jsx(jn,{value:i.mode,options:["combined","separate"],onChange:s=>B.setSubsys({mode:s}),labels:{combined:"Together",separate:"Separate"},titles:{combined:"One chart, one scale: compare magnitudes across subsystems",separate:"One panel per subsystem (small multiples)"}}),i.mode==="separate"&&!(a&&(i.level==="subsystems"||i.view==="pie"))&&n.jsx(jn,{value:i.scale,options:["shared","independent"],onChange:s=>B.setSubsys({scale:s}),labels:{shared:"Shared scale",independent:"Own scale"},titles:{shared:"Bar lengths comparable across panels",independent:"Each panel scaled to its own largest flux — reveals the pattern inside small subsystems"}}),n.jsx(jn,{value:i.sort,options:["magnitude","name"],onChange:s=>B.setSubsys({sort:s}),labels:{magnitude:"Sort |flux|",name:"Sort ID"}}),n.jsx(pn,{checked:i.showZero,onChange:s=>B.setSubsys({showZero:s}),children:"Zero-flux reactions"}),n.jsx("span",{className:"grow"}),!a&&n.jsx("div",{className:"ss-legend",children:e})]})}function Sa({color:e,label:t,round:i}){return n.jsxs("span",{className:"ss-sw",children:[n.jsx("i",{style:{background:e,borderRadius:i?"50%":2}}),t]})}function Tx({k:e,summary:t,n:i}){return n.jsxs("div",{className:"ss-group-head",children:[n.jsxs("div",{className:"ss-group-title",children:[n.jsx("button",{className:"ss-group-name ellipsis",title:`Inspect ${ct(e)}`,onClick:()=>B.navigate({kind:"subsystem",id:e}),children:ct(e)}),n.jsx("span",{className:"muted small",children:t})]}),n.jsx("button",{className:"icon-btn tiny",title:`Add the ${i} reactions to the map`,onClick:()=>vn(S.getState().index.subsystems.get(e)??[],"hierarchical"),children:n.jsx(q,{name:"plus",size:11})}),n.jsx("button",{className:"icon-btn tiny",title:"Remove from selection",onClick:()=>B.toggleSubsystem(e),children:n.jsx(q,{name:"x",size:11})})]})}function Fx({items:e,render:t}){const[i,a]=E.useState(!1);return n.jsxs(n.Fragment,{children:[(i?e:e.slice(0,ig)).map(t),e.length>ig&&n.jsx("button",{className:"link small ss-more",onClick:()=>a(!i),children:i?"Show fewer":`Show all ${e.length} reactions`})]})}function Ak({v:e,max:t,tol:i}){if(e==null)return n.jsx("span",{className:"ss-div",children:n.jsx("i",{className:"ss-zero"})});const a=t>0?Math.min(1,Math.abs(e)/t)*50:0,s=Math.abs(e)<i;return n.jsxs("span",{className:"ss-div",children:[n.jsx("i",{className:"ss-zero"}),!s&&n.jsx("span",{className:`ss-bar ${e>0?"pos":"neg"}`,style:{width:`${a}%`,background:e>0?Au:Ox,...e>0?{left:"50%"}:{right:"50%"}}})]})}function Dk({r:e}){const t=S(g=>g.index),i=S(g=>g.settings.zeroTolerance),a=S(g=>g.subsys),[s,o]=E.useState(""),l=$x(),r=Kn("lab-subsys-overview",340,240,640),c=!!e.fva,d=E.useMemo(()=>xk(t,e,i),[t,e,i]),f=c?{total:"Σ FVA width",active:"Variable reactions",mean:"Mean FVA width"}:{total:"Σ |flux|",active:"Active reactions",mean:"Mean |flux| (active)"},u=E.useMemo(()=>{const g=mn(s.trim());return d.filter(y=>(!a.hideInactive||y.active>0)&&(!g||mn(ct(y.key)).includes(g))).sort((y,b)=>Kl(b,a.metric)-Kl(y,a.metric)||y.key.localeCompare(b.key))},[d,a.hideInactive,a.metric,s]),p=Math.max(1e-12,...u.map(g=>Kl(g,a.metric))),m=d.filter(g=>g.active>0).length,h=a.selected.filter(g=>d.some(y=>y.key===g));return n.jsxs("div",{className:"ss-layout",children:[n.jsxs("div",{className:"ss-overview",style:{width:r.css,display:a.wide&&a.view!=="list"&&h.length?"none":void 0},children:[n.jsx(zn,{panel:r,edge:"right"}),n.jsxs("div",{className:"ss-ov-head",children:[n.jsxs("div",{className:"search-box",children:[n.jsx(q,{name:"search",size:13}),n.jsx("input",{placeholder:"Filter subsystems…",value:s,onChange:g=>o(g.target.value)})]}),n.jsx("div",{className:"row gap wrap",children:n.jsx(jn,{value:a.metric,options:["total","active","mean"],onChange:g=>B.setSubsys({metric:g}),labels:f})}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx(pn,{checked:a.hideInactive,onChange:g=>B.setSubsys({hideInactive:g}),children:"Hide inactive"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"link small",onClick:()=>B.setSubsys({selected:u.slice(0,5).map(g=>g.key)}),children:"Top 5"}),h.length>0&&n.jsx("button",{className:"link small",onClick:()=>B.setSubsys({selected:[]}),children:"Clear"})]}),n.jsxs("div",{className:"muted small",children:[m," of ",d.length," subsystems ",c?"variable":"carry flux"," · descriptive sums over annotated reactions",a.metric!=="active"&&!c?` (${yt})`:""]})]}),n.jsxs("div",{className:"ss-ov-list",children:[u.map(g=>{const y=Kl(g,a.metric),b=a.selected.includes(g.key);return n.jsxs("button",{className:`ss-ov-row ${b?"on":""}`,onClick:()=>B.toggleSubsystem(g.key),...l.on(n.jsx(Pk,{s:g,isFva:c})),children:[n.jsx("input",{type:"checkbox",readOnly:!0,checked:b,tabIndex:-1}),n.jsx("span",{className:"ss-ov-name ellipsis",title:g.key,children:ct(g.key)}),n.jsx("span",{className:"ss-ov-track",children:n.jsx("span",{style:{width:`${y/p*100}%`,background:Au,opacity:g.active?1:.3}})}),n.jsx("span",{className:"ss-ov-val mono",children:a.metric==="active"?y:W(y)}),n.jsxs("span",{className:"ss-ov-n mono muted",children:[g.active,"/",g.rids.length]})]},g.key)}),!u.length&&n.jsx("div",{className:"muted small pad",children:"No subsystem matches."})]})]}),n.jsxs("div",{className:"ss-detail",children:[n.jsx(Lx,{isFva:c,legend:c?n.jsx(Sa,{color:"#b45309",label:"feasible interval"}):n.jsxs(n.Fragment,{children:[n.jsx(Sa,{color:Au,label:"forward (as written)"}),n.jsx(Sa,{color:Ox,label:"reverse"})]})}),a.view!=="list"&&h.length>0?n.jsx(Ok,{r:e,keys:h,stats:d}):h.length?n.jsx(Rk,{r:e,keys:h,stats:d,tip:l.on}):n.jsxs("div",{className:"ss-empty",children:[n.jsx("div",{className:"empty-title",children:"Pick subsystems to open"}),n.jsx("p",{className:"muted",children:"Click subsystems on the left to see the flux through each of their reactions — together on one scale, or side by side."}),n.jsx("button",{className:"btn primary small",onClick:()=>B.setSubsys({selected:u.slice(0,5).map(g=>g.key)}),children:"Open the top 5"})]})]}),l.node]})}function Pk({s:e,isFva:t}){return n.jsxs(n.Fragment,{children:[n.jsx("b",{children:ct(e.key)}),n.jsxs("div",{children:[t?"Σ FVA width":"Σ |flux|",": ",n.jsx("span",{className:"mono",children:W(e.total)})]}),n.jsxs("div",{children:[t?"Variable":"Active",": ",n.jsxs("span",{className:"mono",children:[e.active," / ",e.rids.length]})," reactions"]}),e.mean!=null&&n.jsxs("div",{children:["Mean over ",t?"variable":"active",": ",n.jsx("span",{className:"mono",children:W(e.mean)})]}),n.jsxs("div",{className:"muted",children:["Click to ",S.getState().subsys.selected.includes(e.key)?"close":"open"," its reactions"]})]})}function Rk({r:e,keys:t,stats:i,tip:a}){const s=S(h=>h.index),o=S(h=>h.settings.zeroTolerance),l=S(h=>h.subsys),r=!!e.fva,c=t.map(h=>{const g=i.find(_=>_.key===h);let y=g.rids;l.showZero||(y=y.filter(_=>{var x;return r?(()=>{const v=e.fva[_];return v&&(Math.abs(v.minimum??0)>=o||Math.abs(v.maximum??0)>=o)})():Math.abs(((x=e.reactionFluxes)==null?void 0:x[_])??0)>=o}));const b=_=>{var x,v,j;return r?Math.max(Math.abs(((x=e.fva[_])==null?void 0:x.minimum)??0),Math.abs(((v=e.fva[_])==null?void 0:v.maximum)??0)):Math.abs(((j=e.reactionFluxes)==null?void 0:j[_])??0)};return y=[...y].sort(l.sort==="name"?(_,x)=>_.localeCompare(x):(_,x)=>b(x)-b(_)),{st:g,rids:y,max:Math.max(1e-12,...y.map(b))}}),d=Math.max(1e-12,...c.map(h=>h.max)),f=r?Math.min(0,...c.flatMap(h=>h.rids.map(g=>{var y;return((y=e.fva[g])==null?void 0:y.minimum)??0}))):0,u=r?Math.max(0,...c.flatMap(h=>h.rids.map(g=>{var y;return((y=e.fva[g])==null?void 0:y.maximum)??0}))):0,p=(h,g,y,b)=>{var j,N;const _=s.rxn.get(h),x=(j=e.reactionFluxes)==null?void 0:j[h],v=(N=e.fva)==null?void 0:N[h];return n.jsxs("div",{className:"ss-row",onClick:()=>B.navigate({kind:"reaction",id:h}),...a(r?n.jsxs(n.Fragment,{children:[n.jsx("b",{className:"mono",children:h}),n.jsx("div",{children:_==null?void 0:_.name}),n.jsxs("div",{children:["FVA: ",n.jsxs("span",{className:"mono",children:["[",W(v==null?void 0:v.minimum),", ",W(v==null?void 0:v.maximum),"]"]})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("b",{className:"mono",children:h}),n.jsx("div",{children:_==null?void 0:_.name}),n.jsxs("div",{children:["Flux: ",n.jsx("span",{className:"mono",children:W(x)})," ",yt]}),n.jsx("div",{className:"muted",children:x==null||Math.abs(x)<o?"no flux":x>0?"runs as written":"runs in reverse of the written direction"})]})),children:[n.jsx("span",{className:"mono ss-id ellipsis",children:h}),n.jsx("span",{className:"ss-name ellipsis",children:_==null?void 0:_.name}),r?n.jsx("span",{className:"ss-div",children:n.jsx(nl,{min:(v==null?void 0:v.minimum)??null,max:(v==null?void 0:v.maximum)??null,lo:y,hi:b})}):n.jsx(Ak,{v:x,max:g,tol:o}),n.jsx("span",{className:"mono ss-val",children:W(r?((v==null?void 0:v.maximum)??0)-((v==null?void 0:v.minimum)??0):x)})]},h)},m=(h,g,y,b)=>n.jsxs(n.Fragment,{children:[n.jsx(Tx,{k:h.st.key,n:h.st.rids.length,summary:n.jsxs(n.Fragment,{children:[r?"Σ width":"Σ|v|"," ",n.jsx("span",{className:"mono",children:W(h.st.total)})," · ",h.st.active,"/",h.st.rids.length," ",r?"variable":"active"]})}),h.rids.length?n.jsx(Fx,{items:h.rids,render:_=>p(_,g,y,b)}):n.jsxs("div",{className:"muted small ss-none",children:["No ",r?"variable":"active"," reaction",l.showZero?"":" — turn on “Zero-flux reactions” to list all","."]})]});return l.mode==="combined"?n.jsxs("div",{className:"ss-combined",children:[n.jsx(ic,{max:d,isFva:r,lo:f,hi:u}),c.map(h=>n.jsx("div",{className:"ss-group",children:m(h,d,f,u)},h.st.key))]}):n.jsx("div",{className:"ss-grid",children:c.map(h=>{const g=l.scale==="shared"?d:h.max,y=r&&l.scale==="independent"?Math.min(0,...h.rids.map(_=>{var x;return((x=e.fva[_])==null?void 0:x.minimum)??0})):f,b=r&&l.scale==="independent"?Math.max(0,...h.rids.map(_=>{var x;return((x=e.fva[_])==null?void 0:x.maximum)??0})):u;return n.jsxs("div",{className:"ss-card",children:[m(h,g,y,b),n.jsx(ic,{max:g,isFva:r,lo:y,hi:b})]},h.st.key)})})}function ic({max:e,isFva:t,lo:i,hi:a}){return n.jsx("div",{className:"ss-scale mono",children:t?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:W(i)}),n.jsx("span",{children:"0"}),n.jsx("span",{children:W(a)})]}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:["−",W(e)]}),n.jsx("span",{children:"0"}),n.jsxs("span",{children:["+",W(e)]})]})})}function Ik(){const e=S(g=>g.compare.result),t=S(g=>g.index),i=S(g=>g.settings.zeroTolerance),a=S(g=>g.subsys),[s,o]=E.useState(""),[l,r]=E.useState("absDelta"),c=$x(),d=Kn("lab-subsys-compare-overview",420,300,720),f=e.reactions,u=E.useMemo(()=>_k(t,f,i),[t,f,i]),p=E.useMemo(()=>{const g=mn(s.trim()),y=u.filter(_=>(!a.hideInactive||_.state!=="both-zero")&&(!g||mn(ct(_.key)).includes(g))),b=_=>l==="absDelta"?-Math.abs(_.delta):l==="log2"?-Math.abs(_.log2??(_.state==="changed"?0:1/0)):l==="totalB"?-_.totalB:0;return y.sort((_,x)=>b(_)-b(x)||ct(_.key).localeCompare(ct(x.key)))},[u,a.hideInactive,s,l]),m=Math.max(1e-12,...p.map(g=>Math.max(g.totalA,g.totalB))),h=a.selected.filter(g=>u.some(y=>y.key===g));return n.jsxs("div",{className:"ss-layout cmp",children:[n.jsxs("div",{className:"ss-overview",style:{width:d.css,display:a.wide&&a.view!=="list"&&h.length?"none":void 0},children:[n.jsx(zn,{panel:d,edge:"right"}),n.jsxs("div",{className:"ss-ov-head",children:[n.jsxs("div",{className:"search-box",children:[n.jsx(q,{name:"search",size:13}),n.jsx("input",{placeholder:"Filter subsystems…",value:s,onChange:g=>o(g.target.value)})]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("select",{className:"input tiny",value:l,onChange:g=>r(g.target.value),children:[n.jsx("option",{value:"absDelta",children:"Sort: largest |Δ Σ|v||"}),n.jsx("option",{value:"log2",children:"Sort: largest |log₂ ratio|"}),n.jsx("option",{value:"totalB",children:"Sort: Σ|v| in B"}),n.jsx("option",{value:"name",children:"Sort: name"})]}),n.jsx(pn,{checked:a.hideInactive,onChange:g=>B.setSubsys({hideInactive:g}),children:"Hide zero in both"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"link small",onClick:()=>B.setSubsys({selected:p.slice(0,5).map(g=>g.key)}),children:"Top 5"}),h.length>0&&n.jsx("button",{className:"link small",onClick:()=>B.setSubsys({selected:[]}),children:"Clear"})]}),n.jsxs("div",{className:"ss-legend",children:[n.jsx(Sa,{color:jo,label:`A · ${e.a.name}`,round:!0}),n.jsx(Sa,{color:No,label:`B · ${e.b.name}`,round:!0})]}),n.jsx("div",{className:"muted small",children:"Σ|flux| per subsystem in A and B (descriptive sums). Reaction counts use the comparison categories."})]}),n.jsx("div",{className:"ss-ov-list",children:p.map(g=>{const y=a.selected.includes(g.key),b=g.totalA/m*100,_=g.totalB/m*100;return n.jsxs("button",{className:`ss-ov-row cmp ${y?"on":""}`,onClick:()=>B.toggleSubsystem(g.key),...c.on(n.jsx(Bk,{s:g})),children:[n.jsx("input",{type:"checkbox",readOnly:!0,checked:y,tabIndex:-1}),n.jsx("span",{className:"ss-ov-name ellipsis",title:g.key,children:ct(g.key)}),n.jsxs("span",{className:"ss-dumbbell",children:[n.jsx("i",{className:"ss-db-line",style:{left:`${Math.min(b,_)}%`,width:`${Math.abs(_-b)}%`}}),n.jsx("i",{className:"ss-db-dot",style:{left:`${b}%`,background:jo}}),n.jsx("i",{className:"ss-db-dot",style:{left:`${_}%`,background:No}})]}),n.jsxs("span",{className:`ss-ov-val mono ${g.delta>i?"up":g.delta<-i?"down":""}`,children:[g.delta>0?"+":"",W(g.delta)]}),n.jsxs("span",{className:"ss-badges",children:[g.counts.reversal>0&&n.jsxs("span",{className:"cat c-reversal",title:"direction reversals",children:["⇄",g.counts.reversal]}),g.counts.activated>0&&n.jsxs("span",{className:"cat c-activated",title:"activated from zero",children:["+",g.counts.activated]}),g.counts.inactivated>0&&n.jsxs("span",{className:"cat c-inactivated",title:"inactivated to zero",children:["−",g.counts.inactivated]})]})]},g.key)})})]}),n.jsxs("div",{className:"ss-detail",children:[n.jsx(Lx,{legend:n.jsxs(n.Fragment,{children:[n.jsx(Sa,{color:jo,label:"A"}),n.jsx(Sa,{color:No,label:"B"}),n.jsx("span",{className:"muted small",children:"right of 0 = as written · left = reverse"})]})}),a.view!=="list"&&h.length>0?n.jsx($k,{keys:h,stats:u}):h.length?n.jsx(Hk,{keys:h,stats:u,rows:f,tip:c.on}):n.jsxs("div",{className:"ss-empty",children:[n.jsx("div",{className:"empty-title",children:"Which subsystems changed?"}),n.jsx("p",{className:"muted",children:"The left list ranks subsystems by how much their total flux moved between A and B. Open some to compare their reactions one by one."}),n.jsx("button",{className:"btn primary small",onClick:()=>B.setSubsys({selected:p.slice(0,5).map(g=>g.key)}),children:"Open the 5 largest changes"})]})]}),c.node]})}function Bk({s:e}){return n.jsxs(n.Fragment,{children:[n.jsx("b",{children:ct(e.key)}),n.jsxs("div",{children:["Σ|v|: ",n.jsxs("span",{className:"mono",children:[W(e.totalA)," → ",W(e.totalB)]})," (Δ ",n.jsx("span",{className:"mono",children:W(e.delta)}),")"]}),n.jsx("div",{children:e.state==="activated"?"Inactive in A":e.state==="inactivated"?"Inactive in B":e.log2!=null?n.jsxs(n.Fragment,{children:["log₂ ratio ",n.jsx("span",{className:"mono",children:W(e.log2,3)})]}):"Zero in both"}),n.jsxs("div",{className:"muted",children:[e.counts.changed," changed · ",e.counts.activated," activated · ",e.counts.inactivated," inactivated · ",e.counts.reversal," reversed"]})]})}function Hk({keys:e,stats:t,rows:i,tip:a}){const s=S(p=>p.index),o=S(p=>p.settings.zeroTolerance),l=S(p=>p.subsys),r=E.useMemo(()=>new Map(i.map(p=>[p.id,p])),[i]),c=e.map(p=>{const m=t.find(g=>g.key===p);let h=m.rids.map(g=>r.get(g)).filter(g=>!!g);return l.showZero||(h=h.filter(g=>g.category!=="both-zero")),h.sort(l.sort==="name"?(g,y)=>g.id.localeCompare(y.id):(g,y)=>(y.absDelta??0)-(g.absDelta??0)),{st:m,list:h,max:Math.max(1e-12,...h.map(g=>Math.max(Math.abs(g.a??0),Math.abs(g.b??0))))}}),d=Math.max(1e-12,...c.map(p=>p.max)),f=(p,m)=>{var h,g;return n.jsxs("div",{className:`ss-row cmp ${p.category==="reversal"?"rev":""}`,onClick:()=>B.navigate({kind:"reaction",id:p.id}),...a(n.jsxs(n.Fragment,{children:[n.jsx("b",{className:"mono",children:p.id}),n.jsx("div",{children:(h=s.rxn.get(p.id))==null?void 0:h.name}),n.jsxs("div",{children:["A ",n.jsx("span",{className:"mono",children:W(p.a)})," → B ",n.jsx("span",{className:"mono",children:W(p.b)})]}),n.jsx("div",{children:p.category==="reversal"?"Direction reversal — no fold change":p.log2fc!=null?n.jsxs(n.Fragment,{children:["log₂FC |v| ",n.jsx("span",{className:"mono",children:W(p.log2fc,3)})]}):p.category})]})),children:[n.jsx("span",{className:"mono ss-id ellipsis",children:p.id}),n.jsx("span",{className:"ss-name ellipsis",children:(g=s.rxn.get(p.id))==null?void 0:g.name}),n.jsxs("span",{className:"ss-pair",children:[n.jsx(ag,{v:p.a,max:m,color:jo,tol:o}),n.jsx(ag,{v:p.b,max:m,color:No,tol:o})]}),n.jsxs("span",{className:`mono ss-val ${(p.delta??0)>o?"up":(p.delta??0)<-o?"down":""}`,children:[(p.delta??0)>0?"+":"",W(p.delta)]}),n.jsx("span",{className:"ss-cat",children:p.category==="reversal"?n.jsx("span",{className:"cat c-reversal",children:"⇄"}):p.category==="activated"?n.jsx("span",{className:"cat c-activated",children:"0→"}):p.category==="inactivated"?n.jsx("span",{className:"cat c-inactivated",children:"→0"}):null})]},p.id)},u=(p,m)=>n.jsxs(n.Fragment,{children:[n.jsx(Tx,{k:p.st.key,n:p.st.rids.length,summary:n.jsxs(n.Fragment,{children:["Σ|v| ",n.jsxs("span",{className:"mono",children:[W(p.st.totalA)," → ",W(p.st.totalB)]}),p.st.counts.reversal?` · ${p.st.counts.reversal} reversed`:""]})}),p.list.length?n.jsx(Fx,{items:p.list,render:h=>f(h,m)}):n.jsx("div",{className:"muted small ss-none",children:"No reaction carries flux in A or B."})]});return l.mode==="combined"?n.jsxs("div",{className:"ss-combined",children:[n.jsx(ic,{max:d,isFva:!1,lo:0,hi:0}),c.map(p=>n.jsx("div",{className:"ss-group",children:u(p,d)},p.st.key))]}):n.jsx("div",{className:"ss-grid",children:c.map(p=>{const m=l.scale==="shared"?d:p.max;return n.jsxs("div",{className:"ss-card",children:[u(p,m),n.jsx(ic,{max:m,isFva:!1,lo:0,hi:0})]},p.st.key)})})}function ag({v:e,max:t,color:i,tol:a}){const s=e==null||Math.abs(e)<a?0:Math.min(1,Math.abs(e)/t)*50;return n.jsxs("span",{className:"ss-div thin",children:[n.jsx("i",{className:"ss-zero"}),s>0&&n.jsx("span",{className:`ss-bar ${e>0?"pos":"neg"}`,style:{width:`${s}%`,background:i,...e>0?{left:"50%"}:{right:"50%"}}})]})}function Xx(e,t,i,a,s){const o=l=>Math.max(0,...i.map(r=>{var c,d,f;return r.fva?Math.max(Math.abs(((c=r.fva[l])==null?void 0:c.minimum)??0),Math.abs(((d=r.fva[l])==null?void 0:d.maximum)??0)):Math.abs(((f=r.flux)==null?void 0:f[l])??0)}));return e.map(l=>{const r=t(l);let c=s.showZero?r:r.filter(d=>o(d)>=a);return c=[...c].sort(s.sort==="name"?(d,f)=>d.localeCompare(f):(d,f)=>o(f)-o(d)).slice(0,s.fig.maxRows),{key:l,all:r,rids:c}})}const ac=(e,t,i=e.name)=>({id:e.id,name:i,color:t,flux:e.reactionFluxes,fva:e.fva});function Ok({r:e,keys:t,stats:i}){const a=S(p=>p.index),s=S(p=>p.settings.zeroTolerance),o=S(p=>p.subsys),l=S(p=>p.results),r=!!e.fva,c=l.filter(p=>p.id!==e.id&&p.solverStatus==="optimal"&&!!p.reactionFluxes&&!r),d=o.series.map(p=>c.find(m=>m.id===p)).filter(p=>!!p),f=E.useMemo(()=>{const p=[ac(e,Ga[0]),...d.map((h,g)=>ac(h,Ga[(g+1)%Ga.length]))];return{series:p,groups:Xx(t,h=>{var g;return((g=i.find(y=>y.key===h))==null?void 0:g.rids)??[]},p,s,o),tol:s,mode:o.mode,scale:o.scale,autoTitle:p.length>1?`${t.length===1?ct(t[0]):"Subsystem fluxes"} — ${p.length} results`:`${t.length===1?ct(t[0]):"Subsystem fluxes"} — ${e.name}`,rxnName:h=>{var g;return((g=a.rxn.get(h))==null?void 0:g.name)??""}}},[e,d.map(p=>p.id).join(),t.join(),i,s,o.mode,o.scale,o.showZero,o.sort,o.fig.maxRows,a]),u=r&&o.view!=="bars"?"bars":o.view;return n.jsxs("div",{className:"ss-figure",children:[r&&o.view!=="bars"&&n.jsx("div",{className:"note small",children:"FVA results are drawn as intervals only — heatmaps and donuts need one value per reaction, so the bar (interval) figure is shown."}),!r&&n.jsxs("div",{className:"fig-series",children:[n.jsx("span",{className:"muted small",children:"Results in the figure"}),f.series.map((p,m)=>n.jsxs("span",{className:"fig-chip",children:[n.jsx("i",{style:{background:p.color}}),p.name,m>0&&n.jsx("button",{className:"icon-btn tiny",title:"Remove",onClick:()=>B.setSubsys({series:o.series.filter(h=>h!==p.id)}),children:n.jsx(q,{name:"x",size:9})})]},p.id)),c.length>d.length&&f.series.length<Ga.length&&n.jsxs("select",{className:"input tiny",value:"",onChange:p=>p.target.value&&B.setSubsys({series:[...o.series,p.target.value]}),children:[n.jsx("option",{value:"",children:"+ Add a result…"}),c.filter(p=>!o.series.includes(p.id)).map(p=>n.jsxs("option",{value:p.id,children:[p.name,p.origin?" (imported)":""]},p.id))]}),f.series.length>1&&n.jsx("span",{className:"muted small",children:"compared by reaction id · values as stored in each result"})]}),n.jsx(Hx,{inp:f,view:u,level:o.level})]})}function $k({keys:e,stats:t}){const i=S(c=>c.index),a=S(c=>c.settings.zeroTolerance),s=S(c=>c.subsys),o=S(c=>ee.result(c.compare.aId,c)),l=S(c=>ee.result(c.compare.bId,c)),r=E.useMemo(()=>{if(!o||!l)return null;const c=[ac(o,jo,`A · ${o.name}`),ac(l,No,`B · ${l.name}`)];return{series:c,groups:Xx(e,f=>{var u;return((u=t.find(p=>p.key===f))==null?void 0:u.rids)??[]},c,a,s),tol:a,mode:s.mode,scale:s.scale,autoTitle:`${e.length===1?ct(e[0]):"Subsystem fluxes"} — ${o.name} vs ${l.name}`,rxnName:f=>{var u;return((u=i.rxn.get(f))==null?void 0:u.name)??""}}},[o,l,e.join(),t,a,s.mode,s.scale,s.showZero,s.sort,s.fig.maxRows,i]);return r?n.jsx("div",{className:"ss-figure",children:n.jsx(Hx,{inp:r,view:s.view,level:s.level})}):n.jsx("div",{className:"muted small pad",children:"Pick results A and B."})}const sg=[{key:"id",label:"Reaction"},{key:"name",label:"Name"},{key:"equation",label:"Equation"},{key:"lb",label:"LB"},{key:"ub",label:"UB"},{key:"flux",label:"Flux"},{key:"fvaMin",label:"FVA min"},{key:"fvaMax",label:"FVA max"},{key:"fvaRange",label:"FVA range"},{key:"subsystem",label:"Subsystem"},{key:"type",label:"Type"},{key:"reversible",label:"Reversible"},{key:"genes",label:"Genes"},{key:"ec",label:"EC"},{key:"objective",label:"Obj. coef."}],og=[{key:"absFlux",dir:"desc",label:"|Flux| ↓"},{key:"absFlux",dir:"asc",label:"|Flux| ↑"},{key:"flux",dir:"desc",label:"Flux ↓"},{key:"flux",dir:"asc",label:"Flux ↑"},{key:"fvaWidth",dir:"desc",label:"FVA width ↓"},{key:"fvaWidth",dir:"asc",label:"FVA width ↑"},{key:"id",dir:"asc",label:"ID"},{key:"name",dir:"asc",label:"Name"},{key:"lb",dir:"asc",label:"Lower bound"},{key:"ub",dir:"desc",label:"Upper bound"},{key:"subsystem",dir:"asc",label:"Subsystem"}];function sc(e,t){var i;return(i=e.boundsSource)!=null&&i.stateSnapshot?e.boundsSource.stateSnapshot.bounds[t.id]??[t.lb,t.ub]:ee.bounds(e.st,t)}function Kx(e,t,i){var o,l,r,c;const a=(l=(o=i.flux)==null?void 0:o.reactionFluxes)==null?void 0:l[t.id],s=(c=(r=i.fva)==null?void 0:r.fva)==null?void 0:c[t.id];switch(e){case"id":return t.id.toLowerCase();case"name":return(t.name||t.id).toLowerCase();case"equation":return t.equation;case"lb":return sc(i,t)[0]??-1/0;case"ub":return sc(i,t)[1]??1/0;case"flux":return a??null;case"absFlux":return a==null?null:Math.abs(a);case"fvaMin":return(s==null?void 0:s.minimum)??null;case"fvaMax":return(s==null?void 0:s.maximum)??null;case"fvaRange":case"fvaWidth":return(s==null?void 0:s.minimum)==null||(s==null?void 0:s.maximum)==null?null:s.maximum-s.minimum;case"subsystem":return(t.subsystem??"~").toLowerCase();case"type":return t.type;case"reversible":return t.reversible?1:0;case"genes":return t.genes.length;case"ec":return t.ec[0]??"~";case"objective":return ee.objective(i.st).coefficients[t.id]??0;default:return null}}function oi(e,t,i){if(!t)return e;const a=t.dir==="asc"?1:-1,s=e.map(o=>[i(t.key,o),o]);return s.sort((o,l)=>{const r=o[0],c=l[0];return r==null&&c==null?0:r==null?1:c==null?-1:(r<c?-1:r>c?1:0)*a}),s.map(o=>o[1])}function Lk(e,t,i,a){var c,d,f;const s=(c=a.flux)==null?void 0:c.reactionFluxes,o=(d=t.subsystems)!=null&&d.length?new Set(t.subsystems):null,l=(f=t.compartments)!=null&&f.length?new Set(t.compartments):null,r=t.ids?new Set(t.ids.ids):null;return e.filter(u=>{var m,h,g;if(r&&!r.has(u.id))return!1;const p=s==null?void 0:s[u.id];if(i){if(s){if(p==null||Math.abs(p)<a.tol)return!1}else if((m=a.fva)!=null&&m.fva){const y=a.fva.fva[u.id];if(!y||Math.abs(y.minimum??0)<a.tol&&Math.abs(y.maximum??0)<a.tol)return!1}}if(t.absFluxGt!=null&&(p==null||Math.abs(p)<=t.absFluxGt)||t.absFluxLt!=null&&(p==null||Math.abs(p)>=t.absFluxLt))return!1;if(t.reversibility){const y=sc(a,u),b=(y[0]==null||y[0]<0)&&(y[1]==null||y[1]>0),_=y[0]===0&&y[1]===0;if(t.reversibility==="blocked"?!_:t.reversibility==="reversible"?!b:b||_)return!1}return!(t.modifiedOnly&&!a.st.bounds[u.id]||(h=t.types)!=null&&h.length&&!t.types.includes(u.type)||(g=t.hideTypes)!=null&&g.length&&t.hideTypes.includes(u.type)||t.genes==="with"&&!u.genes.length||t.genes==="without"&&u.genes.length||o&&!o.has(u.subsystem??"")||l&&!u.compartments.some(y=>l.has(y))||t.favoritesOnly&&!a.favorites.has(`reaction:${u.id}`))})}function zx(e,t,i){const a=S(l=>ee.activeState(l)),s=S(l=>l.favorites),o=S(l=>l.settings.zeroTolerance);return E.useMemo(()=>({st:a,flux:e,fva:t,boundsSource:i,favorites:new Set(s),tol:o}),[a,e,t,i,s,o])}function Ux({rows:e,ctx:t,columns:i,sort:a,onSort:s,editable:o=!0}){const l=S(x=>x.selection.reactions),r=S(x=>x.nav.stack[x.nav.index]),[c,d]=E.useState(null),[f,u]=E.useState(null),p=E.useMemo(()=>new Set(l),[l]),m=E.useMemo(()=>{var j;let x=0;const v=(j=t.flux)==null?void 0:j.reactionFluxes;if(v)for(const N of Object.values(v))N!=null&&Math.abs(N)>x&&(x=Math.abs(N));return x},[t.flux]),h=E.useMemo(()=>{var j;let x=0,v=0;for(const N of Object.values(((j=t.fva)==null?void 0:j.fva)??{}))N.minimum!=null&&(x=Math.min(x,N.minimum)),N.maximum!=null&&(v=Math.max(v,N.maximum));return[x,v]},[t.fva]),g=(x,v)=>{const j=sc(t,x);if(c&&c.id===x.id&&c.side===v)return n.jsx(wn,{autoFocus:!0,allowEmpty:!0,value:j[v],className:"cell-edit",onCommit:w=>{d(null);const k=v===0?[w,j[1]]:[j[0],w];B.setBounds(x.id,k)}});const N=v===0?x.lb:x.ub,C=j[v]!==N;return n.jsx("span",{className:C?"modified":"",title:C?`Model file: ${rt(N,v?"upper":"lower")} → now ${rt(j[v],v?"upper":"lower")}`:o?"Double-click to edit":void 0,children:rt(j[v],v?"upper":"lower")})},y={sel:{key:"sel",label:n.jsx("input",{type:"checkbox",checked:e.length>0&&e.every(x=>p.has(x.id)),onChange:x=>B.setSelection("reactions",x.target.checked?e.map(v=>v.id):[]),title:"Select all rows"}),width:28,sortable:!1,render:x=>n.jsx("input",{type:"checkbox",checked:p.has(x.id),onClick:v=>v.stopPropagation(),onChange:()=>B.setSelection("reactions",p.has(x.id)?l.filter(v=>v!==x.id):[...l,x.id])})},id:{key:"id",label:"Reaction",width:"minmax(110px, 1fr)",render:x=>n.jsxs("span",{className:"mono strong",children:[t.favorites.has(`reaction:${x.id}`)&&n.jsx("span",{className:"fav-dot",children:"★"}),x.id]})},name:{key:"name",label:"Name",width:"minmax(140px, 1.6fr)",render:x=>n.jsx("span",{className:"ellipsis",title:x.name,children:x.name})},equation:{key:"equation",label:"Equation",width:"minmax(200px, 3fr)",render:x=>n.jsx("span",{className:"ellipsis mono eq-cell",title:x.equationNames,children:x.equation})},lb:{key:"lb",label:"LB",width:70,align:"right",render:x=>g(x,0)},ub:{key:"ub",label:"UB",width:70,align:"right",render:x=>g(x,1)},flux:{key:"flux",label:"Flux",width:110,align:"right",title:"Flux in the active result (mmol gDW⁻¹ h⁻¹). Click again to sort by |flux|",render:x=>{var j;if(!t.flux)return n.jsx("span",{className:"muted",children:"—"});const v=(j=t.flux.reactionFluxes)==null?void 0:j[x.id];return n.jsxs("span",{className:"flux-cell",children:[n.jsx(Nx,{v,max:m}),n.jsx("span",{className:`mono ${v!=null&&Math.abs(v)<t.tol?"zero":""}`,children:W(v)})]})}},fvaMin:{key:"fvaMin",label:"FVA min",width:80,align:"right",render:x=>{var v,j;return n.jsx("span",{className:"mono",children:t.fva?W((j=(v=t.fva.fva)==null?void 0:v[x.id])==null?void 0:j.minimum):"—"})}},fvaMax:{key:"fvaMax",label:"FVA max",width:80,align:"right",render:x=>{var v,j;return n.jsx("span",{className:"mono",children:t.fva?W((j=(v=t.fva.fva)==null?void 0:v[x.id])==null?void 0:j.maximum):"—"})}},fvaRange:{key:"fvaRange",label:"FVA range",width:120,title:"Feasible interval on a shared axis (sort = width)",render:x=>{var j,N;const v=(N=(j=t.fva)==null?void 0:j.fva)==null?void 0:N[x.id];return t.fva?n.jsx(nl,{min:(v==null?void 0:v.minimum)??null,max:(v==null?void 0:v.maximum)??null,lo:h[0],hi:h[1]}):n.jsx("span",{className:"muted",children:"—"})}},subsystem:{key:"subsystem",label:"Subsystem",width:"minmax(110px, 1.2fr)",render:x=>n.jsx("span",{className:"ellipsis muted",children:x.subsystem??""})},type:{key:"type",label:"Type",width:78,render:x=>n.jsx("span",{className:`tag t-${x.type}`,children:lx(x.type)})},reversible:{key:"reversible",label:"Rev.",width:44,align:"center",render:x=>x.reversible?"⇌":"→"},genes:{key:"genes",label:"Genes",width:56,align:"right",render:x=>n.jsx("span",{className:"mono",children:x.genes.length||""})},ec:{key:"ec",label:"EC",width:90,render:x=>n.jsx("span",{className:"mono ellipsis",children:x.ec.join(", ")})},objective:{key:"objective",label:"Obj.",width:52,align:"right",render:x=>{const v=ee.objective(t.st).coefficients[x.id];return v?n.jsx("span",{className:"mono obj",children:W(v,3)}):null}}},b=["sel",...i].map(x=>y[x]).filter(Boolean),_=e.map(x=>x.id);return n.jsx(ci,{rows:e,cols:b,rowKey:x=>x.id,sort:a,onSort:s,selected:p,active:(r==null?void 0:r.kind)==="reaction"?r.id:null,rowClass:x=>t.st.bounds[x.id]?"row-modified":"",onRowClick:(x,v)=>{if(v.shiftKey||v.ctrlKey||v.metaKey){B.setSelection("reactions",wx(_,l,x.id,v,f)),u(x.id);return}u(x.id),B.navigate({kind:"reaction",id:x.id})},onKeyNav:x=>B.navigate({kind:"reaction",id:x.id}),onRowDoubleClick:(x,v)=>{o&&(v==="lb"||v==="ub")&&d({id:x.id,side:v==="lb"?0:1})},onContextMenu:(x,v)=>{const j=p.has(x.id)&&l.length>1?l.map(N=>({kind:"reaction",id:N})):[{kind:"reaction",id:x.id}];S.setState({contextMenu:{x:v.clientX,y:v.clientY,refs:j}})},empty:n.jsx(u0,{})})}function u0(){const e=S(t=>t.query||t.hideZero||Object.keys(t.rxnFilters).length||Object.keys(t.metFilters).length);return n.jsx("div",{className:"muted",children:e?"No rows match the search and filters.":"Nothing to show."})}function Tk(e,t,i,a,s,o){var c;const l=(c=t.compartments)!=null&&c.length?new Set(t.compartments):null,r=t.ids?new Set(t.ids.ids):null;return e.filter(d=>{if(r&&!r.has(d.id)||l&&!l.has(d.compartment))return!1;if(i&&a){const f=a[d.id];if(f==null||Math.abs(f)<s)return!1}return!(t.favoritesOnly&&!o.has(`metabolite:${d.id}`))})}function qx(e,t,i){switch(e){case"id":return t.id.toLowerCase();case"name":return(t.name||t.id).toLowerCase();case"compartment":return t.compartment;case"formula":return t.formula??"~";case"charge":return t.charge;case"reactions":return t.reactionCount;case"turnover":return i?i[t.id]??null:null;default:return null}}function Vx({rows:e,turnover:t,sort:i,onSort:a}){const s=S(g=>{var y;return((y=g.model)==null?void 0:y.compartments)??{}}),o=S(g=>g.selection.metabolites),l=S(g=>g.favorites),r=S(g=>g.settings.zeroTolerance),c=S(g=>g.nav.stack[g.nav.index]),[d,f]=E.useState(null),u=E.useMemo(()=>new Set(o),[o]),p=E.useMemo(()=>Math.max(0,...Object.values(t??{}).map(g=>g??0)),[t]),m=[{key:"sel",label:n.jsx("input",{type:"checkbox",checked:e.length>0&&e.every(g=>u.has(g.id)),onChange:g=>B.setSelection("metabolites",g.target.checked?e.map(y=>y.id):[])}),width:28,sortable:!1,render:g=>n.jsx("input",{type:"checkbox",checked:u.has(g.id),onClick:y=>y.stopPropagation(),onChange:()=>B.setSelection("metabolites",u.has(g.id)?o.filter(y=>y!==g.id):[...o,g.id])})},{key:"id",label:"Metabolite",width:"minmax(110px, 1fr)",render:g=>n.jsxs("span",{className:"mono strong",children:[l.includes(`metabolite:${g.id}`)&&n.jsx("span",{className:"fav-dot",children:"★"}),g.id]})},{key:"name",label:"Name",width:"minmax(160px, 2fr)",render:g=>n.jsx("span",{className:"ellipsis",title:g.name,children:g.name})},{key:"compartment",label:"Compartment",width:120,render:g=>n.jsx("span",{className:"ellipsis muted",children:s[g.compartment]??g.compartment})},{key:"formula",label:"Formula",width:120,render:g=>n.jsx("span",{className:"mono ellipsis",children:g.formula??""})},{key:"charge",label:"Charge",width:56,align:"right",render:g=>n.jsx("span",{className:"mono",children:g.charge??""})},{key:"reactions",label:"Rxns",width:48,align:"right",render:g=>n.jsx("span",{className:"mono muted",children:g.reactionCount})},{key:"turnover",label:n.jsxs("span",{children:["Turnover ",n.jsx(Qn,{text:`Metabolite turnover / throughput — a derived proxy from one flux vector:
|
|
69
|
+
0.5 × Σ |stoichiometric coefficient × reaction flux|.
|
|
70
|
+
It is not a flux carried by the metabolite itself.`})]}),width:130,align:"right",render:g=>{if(!t)return n.jsx("span",{className:"muted",children:"—"});const y=t[g.id];return n.jsxs("span",{className:"flux-cell",children:[n.jsx(Nx,{v:y,max:p}),n.jsx("span",{className:`mono ${y!=null&&Math.abs(y)<r?"zero":""}`,children:W(y)})]})}}],h=e.map(g=>g.id);return n.jsx(ci,{rows:e,cols:m,rowKey:g=>g.id,sort:i,onSort:a,selected:u,active:(c==null?void 0:c.kind)==="metabolite"?c.id:null,onRowClick:(g,y)=>{if(y.shiftKey||y.ctrlKey||y.metaKey){B.setSelection("metabolites",wx(h,o,g.id,y,d)),f(g.id);return}f(g.id),B.navigate({kind:"metabolite",id:g.id})},onKeyNav:g=>B.navigate({kind:"metabolite",id:g.id}),onContextMenu:(g,y)=>{const b=u.has(g.id)&&o.length>1?o.map(_=>({kind:"metabolite",id:_})):[{kind:"metabolite",id:g.id}];S.setState({contextMenu:{x:y.clientX,y:y.clientY,refs:b}})},empty:n.jsx(u0,{})})}function Wx(e,t,i){switch(e){case"id":return t.id.toLowerCase();case"name":return(t.name||"~").toLowerCase();case"reactions":return t.reactions.length;case"active":return i(t);default:return null}}function Yx({rows:e,active:t,sort:i,onSort:a}){const s=S(c=>c.nav.stack[c.nav.index]),o=S(c=>c.favorites),l=S(c=>!!ee.fluxResult(c)),r=[{key:"id",label:"Gene",width:"minmax(120px, 1fr)",render:c=>n.jsxs("span",{className:"mono strong",children:[o.includes(Oc({kind:"gene",id:c.id}))&&n.jsx("span",{className:"fav-dot",children:"★"}),c.id]})},{key:"name",label:"Name",width:"minmax(120px, 1.5fr)",render:c=>n.jsx("span",{className:"ellipsis",children:c.name})},{key:"reactions",label:"Reactions",width:80,align:"right",render:c=>n.jsx("span",{className:"mono",children:c.reactions.length})},{key:"active",label:"Active reactions",width:120,align:"right",title:"Associated reactions carrying non-zero flux in the active result",render:c=>n.jsx("span",{className:"mono",children:l?t(c):"—"})},{key:"rxnlist",label:"Associated reactions",width:"minmax(160px, 3fr)",sortable:!1,render:c=>n.jsx("span",{className:"ellipsis mono muted",children:c.reactions.join(", ")})}];return n.jsx(ci,{rows:e,cols:r,rowKey:c=>c.id,sort:i,onSort:a,active:(s==null?void 0:s.kind)==="gene"?s.id:null,onRowClick:c=>B.navigate({kind:"gene",id:c.id}),onKeyNav:c=>B.navigate({kind:"gene",id:c.id}),onContextMenu:(c,d)=>S.setState({contextMenu:{x:d.clientX,y:d.clientY,refs:[{kind:"gene",id:c.id}]}}),empty:n.jsx(u0,{})})}const p0={changed:"Changed",unchanged:"Unchanged",activated:"Activated from zero",inactivated:"Inactivated to zero",reversal:"Direction reversal","both-zero":"Zero in both",missing:"Only in one result",narrowed:"Narrowed",widened:"Widened",shifted:"Shifted",disjoint:"Disjoint"},lg={delta:"Flux difference (Δ = B − A)",absDelta:"Absolute difference |Δ|",log2fc:"log₂ fold change |B|/|A|",foldchange:"Fold change |B|/|A|"};function Fk(){const e=S(c=>c.results.filter(d=>d.solverStatus==="optimal"&&d.method!=="sampling")),t=S(c=>c.compare),i=S(c=>c.settings),[a,s]=E.useState("results"),o=ee.result(t.aId),l=ee.result(t.bId),r=c=>S.setState(d=>({compare:{...d.compare,...c}}));return E.useEffect(()=>{t.result&&(t.result.a.id!==t.aId||t.result.b.id!==t.bId)&&r({result:null})},[t.aId,t.bId]),n.jsxs("div",{className:"lab-page compare",children:[n.jsx(ul,{title:"Compare",sub:"Direct comparison of in-app results — B is compared against the reference A. No export needed.",children:n.jsx(jn,{value:a,options:["results","states"],onChange:s,labels:{results:"Simulation results",states:"Model states (configuration)"}})}),a==="states"?n.jsx(Wk,{}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"cmp-pick",children:[n.jsxs("label",{children:[n.jsx("span",{className:"cmp-ab",children:"A"}),n.jsx("span",{className:"muted small",children:"reference"}),n.jsxs("select",{className:"input",value:t.aId??"",onChange:c=>r({aId:c.target.value||null}),children:[n.jsx("option",{value:"",children:"Choose a result…"}),e.map(c=>n.jsx("option",{value:c.id,children:c.name},c.id))]})]}),n.jsx("button",{className:"icon-btn",title:"Swap A and B",onClick:()=>r({aId:t.bId,bId:t.aId,result:null}),children:n.jsx(q,{name:"swap",size:15})}),n.jsxs("label",{children:[n.jsx("span",{className:"cmp-ab b",children:"B"}),n.jsx("span",{className:"muted small",children:"compared"}),n.jsxs("select",{className:"input",value:t.bId??"",onChange:c=>r({bId:c.target.value||null}),children:[n.jsx("option",{value:"",children:"Choose a result…"}),e.map(c=>n.jsx("option",{value:c.id,children:c.name},c.id))]})]}),n.jsxs("label",{children:[n.jsx("span",{className:"muted small",children:"Metric"}),n.jsx("select",{className:"input",value:t.metric,onChange:c=>r({metric:c.target.value}),children:Object.keys(lg).map(c=>n.jsx("option",{value:c,children:lg[c]},c))})]}),n.jsxs("div",{className:"cmp-opts",children:[n.jsxs("label",{className:"check small",title:"Pseudocount p: log₂((|B|+p)/(|A|+p)) for rows activated from / inactivated to zero. Off = those rows get no fold change.",children:[n.jsx("input",{type:"checkbox",checked:i.pseudocount!=null,onChange:c=>B.setSettings({pseudocount:c.target.checked?.001:null})})," pseudocount"]}),i.pseudocount!=null&&n.jsx("input",{className:"input tiny num",type:"number",step:"any",min:0,value:i.pseudocount,onChange:c=>B.setSettings({pseudocount:Math.max(1e-12,+c.target.value)})}),n.jsxs("span",{className:"muted small",children:["zero if |v| < ",i.zeroTolerance]})]}),n.jsx("button",{className:"btn primary",disabled:!o||!l||o.id===l.id||t.loading,onClick:()=>B.runCompare(),children:t.loading?"Comparing…":"Compare"})]}),e.length<2&&n.jsx("div",{className:"note",children:"Comparison needs two optimal results. Typical workflow: duplicate the state, change one condition (e.g. oxygen uptake), run the same method again."}),t.error&&n.jsx(ml,{info:t.error}),t.result&&n.jsx(zk,{})]})]})}function Xk(){const e=S(s=>s.compare.result.config),[t,i]=E.useState(!0),a=e.medium.length+e.bounds.length+(e.objective.changed?1:0);return n.jsxs("div",{className:"cfg-diff",children:[n.jsxs("button",{className:"cfg-head",onClick:()=>i(!t),children:[n.jsx("span",{className:"insp-sub",children:"Configuration differences (A → B)"}),n.jsxs("span",{className:"muted small",children:[a?`${a} difference${a>1?"s":""}`:"identical configuration",!e.sameModel&&" · different model files!",e.methods.a!==e.methods.b&&` · methods ${e.methods.a} vs ${e.methods.b}`]}),n.jsx("span",{className:"grow"}),n.jsx("span",{children:t?"▾":"▸"})]}),t&&a>0&&n.jsxs("div",{className:"cfg-body",children:[e.objective.changed&&n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Objective"}),n.jsxs("span",{className:"mono",children:[Pi(e.objective.a)," → ",Pi(e.objective.b)]})]}),e.medium.length>0&&n.jsxs("div",{className:"cfg-group",children:[n.jsx("div",{className:"muted small",children:"Medium (max uptake)"}),e.medium.map(s=>n.jsxs("div",{className:"kv small",children:[n.jsx(Xt,{r:{kind:"reaction",id:s.reaction}}),n.jsxs("span",{className:"mono",children:[W(s.a??0)," → ",W(s.b??0)]})]},s.reaction))]}),e.bounds.length>0&&n.jsxs("div",{className:"cfg-group",children:[n.jsx("div",{className:"muted small",children:"Bounds (vs model file)"}),e.bounds.map(s=>n.jsxs("div",{className:"kv small",children:[n.jsx(Xt,{r:{kind:"reaction",id:s.reaction}}),n.jsxs("span",{className:"mono",children:[s.a?Ua(s.a):"file"," → ",s.b?Ua(s.b):"file"]})]},s.reaction))]})]})]})}function Kk(e,t){return e==="all"?!0:e==="differing"?t!=="both-zero"&&t!=="unchanged"&&t!=="missing":t===e}function zk(){const e=S(r=>r.compare.result),t=S(r=>r.compare.metric),i=S(r=>r.explain),[a,s]=E.useState("reactions"),o=S(r=>{var c;return(((c=r.index)==null?void 0:c.subsystems.size)??0)>0}),l=e.kind==="fva";return n.jsxs("div",{className:"cmp-view",children:[n.jsx(Xk,{}),n.jsxs("div",{className:"cmp-summary",children:[e.objective&&n.jsxs("span",{children:["Objective ",n.jsxs("b",{className:"mono",children:[W(e.objective.a)," → ",W(e.objective.b)]})]}),Object.entries(e.counts).filter(([r])=>r!=="both-zero").map(([r,c])=>n.jsxs("span",{className:`cat-pill c-${r}`,children:[p0[r]??r," · ",c]},r)),n.jsx("span",{className:"grow"}),!l&&n.jsx("button",{className:"btn small primary",onClick:()=>S.setState({dialog:{kind:"visualize-comparison"}}),children:"Visualize comparison"})]}),n.jsxs("div",{className:"ex-tabs",children:[n.jsx("button",{className:a==="reactions"?"on":"",onClick:()=>s("reactions"),children:"Reactions"}),!l&&n.jsx("button",{className:a==="metabolites"?"on":"",onClick:()=>s("metabolites"),children:"Metabolite turnover"}),!l&&n.jsx("button",{className:a==="exchanges"?"on":"",onClick:()=>s("exchanges"),children:"Exchanges"}),!l&&n.jsx("button",{className:a==="subsystems"?"on":"",disabled:!o,title:o?"Compare metabolism at the subsystem level":"This model has no subsystem annotations",onClick:()=>s("subsystems"),children:"Subsystems"})]}),a==="subsystems"&&!l?n.jsx("div",{className:"cmp-body",children:n.jsx(Ik,{})}):n.jsxs("div",{className:"cmp-body",children:[n.jsx("div",{className:"cmp-table",children:l?n.jsx(qk,{}):n.jsx(Uk,{kind:a,metric:t},a)}),i&&a==="metabolites"&&n.jsx(Vk,{})]})]})}function Uk({kind:e,metric:t}){const i=S(j=>j.compare.result),a=S(j=>j.index),s=S(j=>j.explain),[o,l]=E.useState("differing"),[r,c]=E.useState(""),d=Xn(r,100),[f,u]=E.useState(null);E.useEffect(()=>u({key:t==="delta"||t==="absDelta"?"absDelta":"absLog2fc",dir:"desc"}),[t,e]);const p=(e==="reactions"?i.reactions:e==="metabolites"?i.metabolites:i.exchanges)??[],m=j=>{var N,C;return(e==="metabolites"?(N=a.met.get(j))==null?void 0:N.name:(C=a.rxn.get(j))==null?void 0:C.name)??""},h=E.useMemo(()=>{const j=mn(d.trim()),N=p.filter(C=>Kk(o,C.category)&&(!j||mn(`${C.id} ${m(C.id)} ${C.metabolite??""}`).includes(j)));return oi(N,f,(C,w)=>{switch(C){case"id":return w.id.toLowerCase();case"name":return m(w.id).toLowerCase();case"a":return w.a;case"b":return w.b;case"delta":return w.delta;case"absDelta":return w.absDelta;case"log2fc":return w.log2fc;case"absLog2fc":return w.log2fc==null?null:Math.abs(w.log2fc);case"foldChange":return w.foldChange;case"category":return w.category;case"uptakeA":case"uptakeB":case"secretionA":case"secretionB":case"deltaUptake":case"deltaSecretion":return w[C]??null;default:return null}})},[p,o,d,f]),g=j=>u(N=>(N==null?void 0:N.key)===j?N.dir==="desc"?{key:j,dir:"asc"}:null:{key:j,dir:"desc"}),y=j=>{var N;return j.category==="reversal"?n.jsxs("span",{className:"cat c-reversal",title:"The reaction runs in opposite directions in A and B — not summarized by a fold change",children:["⇄ reversal",j.switch?` (${j.switch})`:""]}):j.category==="activated"?n.jsx("span",{className:"cat c-activated",children:"activated from zero"}):j.category==="inactivated"?n.jsx("span",{className:"cat c-inactivated",children:"inactivated to zero"}):n.jsx("span",{className:`cat c-${j.category}`,children:(N=p0[j.category])==null?void 0:N.toLowerCase()})},b=j=>{const N=t==="foldchange"?j.foldChange:j.log2fc;return N==null?n.jsx("span",{className:"muted",title:j.category==="reversal"?"Undefined for a direction reversal":j.category==="activated"||j.category==="inactivated"?"Undefined without a pseudocount (zero in one condition)":"",children:"—"}):n.jsxs("span",{className:`mono ${N>0?"up":N<0?"down":""}`,children:[N>0&&t!=="foldchange"?"+":"",W(N,3),j.pseudocount&&n.jsx("sup",{title:"computed with pseudocount",children:"p"})]})},_=j=>j==null?"—":n.jsxs("span",{className:`mono ${j>0?"up":j<0?"down":""}`,children:[j>0?"+":"",W(j)]}),x=e==="metabolites"?"Turnover":"Flux",v=e==="exchanges"?[{key:"id",label:"Exchange",width:"minmax(110px, 1fr)",render:j=>n.jsx("span",{className:"mono strong",children:j.id})},{key:"name",label:"Compound",width:"minmax(130px, 1.4fr)",render:j=>{var N;return n.jsx("span",{className:"ellipsis",children:((N=a.met.get(j.metabolite??""))==null?void 0:N.name)??""})}},{key:"uptakeA",label:"Uptake A",width:80,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.uptakeA)})},{key:"uptakeB",label:"Uptake B",width:80,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.uptakeB)})},{key:"deltaUptake",label:"Δ uptake",width:84,align:"right",render:j=>_(j.deltaUptake)},{key:"secretionA",label:"Secr. A",width:80,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.secretionA)})},{key:"secretionB",label:"Secr. B",width:80,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.secretionB)})},{key:"deltaSecretion",label:"Δ secr.",width:84,align:"right",render:j=>_(j.deltaSecretion)},{key:"category",label:"Change",width:"minmax(130px, 1fr)",render:y}]:[{key:"id",label:e==="metabolites"?"Metabolite":"Reaction",width:"minmax(110px, 1fr)",render:j=>n.jsx("span",{className:"mono strong",children:j.id})},{key:"name",label:"Name",width:"minmax(140px, 1.6fr)",render:j=>n.jsx("span",{className:"ellipsis",children:m(j.id)})},{key:"a",label:`${x} A`,width:90,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.a)})},{key:"b",label:`${x} B`,width:90,align:"right",render:j=>n.jsx("span",{className:"mono",children:W(j.b)})},{key:"delta",label:"Δ",width:90,align:"right",render:j=>_(j.delta)},{key:t==="foldchange"?"foldChange":"log2fc",label:t==="foldchange"?"FC |v|":"log₂FC |v|",width:92,align:"right",title:"Magnitude ratio |B|/|A|; direction changes are classified separately",render:b},{key:"category",label:"Change",width:"minmax(130px, 1fr)",render:y}];return n.jsxs("div",{className:"rw-table",children:[n.jsxs("div",{className:"ex-toolbar",children:[n.jsxs("div",{className:"search-box ex-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:`Search ${e}…`,value:r,onChange:j=>c(j.target.value)})]}),n.jsxs("select",{className:"input tiny",value:o,onChange:j=>l(j.target.value),children:[n.jsx("option",{value:"differing",children:"Differing only"}),n.jsx("option",{value:"all",children:"All rows"}),n.jsx("option",{value:"changed",children:"Changed (same direction)"}),n.jsx("option",{value:"activated",children:"Activated from zero"}),n.jsx("option",{value:"inactivated",children:"Inactivated to zero"}),e!=="metabolites"&&n.jsx("option",{value:"reversal",children:"Direction reversals only"}),n.jsx("option",{value:"missing",children:"Only in one result (other model)"})]}),n.jsxs("select",{className:"input tiny",value:f?`${f.key}:${f.dir}`:"",onChange:j=>{const[N,C]=j.target.value.split(":");u(N?{key:N,dir:C}:null)},children:[n.jsx("option",{value:"absDelta:desc",children:"|Δ| ↓"}),n.jsx("option",{value:"delta:desc",children:"Δ ↓"}),n.jsx("option",{value:"delta:asc",children:"Δ ↑"}),n.jsx("option",{value:"absLog2fc:desc",children:"|log₂FC| ↓"}),n.jsx("option",{value:"log2fc:desc",children:"log₂FC ↓"}),n.jsx("option",{value:"log2fc:asc",children:"log₂FC ↑"}),e==="exchanges"&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"deltaUptake:desc",children:"Δ uptake ↓"}),n.jsx("option",{value:"deltaSecretion:desc",children:"Δ secretion ↓"})]})]}),e==="metabolites"&&n.jsx("span",{className:"muted small",children:"Click a metabolite: which reactions changed its turnover?"}),n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",children:[h.length," of ",p.length]})]}),n.jsx("div",{className:"ex-table",children:n.jsx(ci,{rows:h,cols:v,rowKey:j=>j.id,sort:f,onSort:g,active:e==="metabolites"?(s==null?void 0:s.metabolite)??null:null,rowClass:j=>j.category==="reversal"?"row-reversal":"",onRowClick:j=>{e==="metabolites"?(B.explainTurnover(j.id),B.navigate({kind:"metabolite",id:j.id})):B.navigate({kind:"reaction",id:j.id})},onContextMenu:(j,N)=>S.setState({contextMenu:{x:N.clientX,y:N.clientY,refs:[{kind:e==="metabolites"?"metabolite":"reaction",id:j.id}]}})})})]})}function qk(){const e=S(f=>f.compare.result),t=S(f=>f.index),[i,a]=E.useState({key:"absDeltaWidth",dir:"desc"}),[s,o]=E.useState(!0),l=e.reactions,r=E.useMemo(()=>[Math.min(0,...l.map(f=>Math.min(f.aMin??0,f.bMin??0))),Math.max(0,...l.map(f=>Math.max(f.aMax??0,f.bMax??0)))],[l]),c=E.useMemo(()=>oi(l.filter(f=>!s||f.category!=="unchanged"&&f.category!=="missing"),i,(f,u)=>f==="id"?u.id:u[f]??null),[l,i,s]),d=[{key:"id",label:"Reaction",width:"minmax(110px, 1fr)",render:f=>{var u;return n.jsx("span",{className:"mono strong",title:(u=t.rxn.get(f.id))==null?void 0:u.name,children:f.id})}},{key:"ia",label:"A interval",width:150,sortable:!1,render:f=>n.jsxs("span",{className:"mono small",children:["[",W(f.aMin),", ",W(f.aMax),"]"]})},{key:"ib",label:"B interval",width:150,sortable:!1,render:f=>n.jsxs("span",{className:"mono small",children:["[",W(f.bMin),", ",W(f.bMax),"]"]})},{key:"bars",label:"A / B",width:"minmax(140px, 1.5fr)",sortable:!1,render:f=>n.jsxs("span",{className:"dual-range",children:[n.jsx(nl,{min:f.aMin??null,max:f.aMax??null,lo:r[0],hi:r[1]}),n.jsx(nl,{min:f.bMin??null,max:f.bMax??null,lo:r[0],hi:r[1]})]})},{key:"deltaWidth",label:"Δ width",width:90,align:"right",render:f=>n.jsx("span",{className:"mono",children:W(f.deltaWidth)})},{key:"category",label:"Change",width:110,render:f=>n.jsx("span",{className:`cat c-${f.category}`,children:p0[f.category]??f.category})}];return n.jsxs("div",{className:"rw-table",children:[n.jsxs("div",{className:"ex-toolbar",children:[n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:s,onChange:f=>o(f.target.checked)})," Hide unchanged"]}),n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",children:[c.length," of ",l.length," · intervals compared reaction by reaction"]})]}),n.jsx("div",{className:"ex-table",children:n.jsx(ci,{rows:c,cols:d,rowKey:f=>f.id,sort:i,onSort:f=>a(u=>(u==null?void 0:u.key)===f&&u.dir==="desc"?{key:f,dir:"asc"}:{key:f,dir:"desc"}),onRowClick:f=>B.navigate({kind:"reaction",id:f.id})})})]})}function Vk(){const e=Kn("lab-explain",330,240,640),t=S(s=>s.explain),i=t.data,a=i?Math.max(1e-12,...i.rows.map(s=>Math.abs(s.delta??0))):1;return n.jsxs("div",{className:"explain",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"left"}),n.jsxs("div",{className:"pane-scroll explain-scroll",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("div",{className:"insp-sub",children:["Why did ",(i==null?void 0:i.name)??t.metabolite," turnover ",i&&(i.delta??0)<0?"decrease":"change","?"]}),n.jsx("button",{className:"icon-btn tiny",onClick:()=>S.setState({explain:null}),children:n.jsx(q,{name:"x",size:11})})]}),i?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mono small",children:[W(i.turnoverA)," → ",W(i.turnoverB)," (Δ ",W(i.delta),")"]}),n.jsxs("div",{className:"note small",children:["Flux contributions to turnover change: 0.5·|S·v| per reaction in A and B. Descriptive, not a causal inference. ",n.jsx(Qn,{text:i.note})]}),n.jsx("div",{className:"explain-rows",children:i.rows.filter(s=>Math.abs(s.delta??0)>1e-12||s.category==="reversal").map(s=>n.jsxs("div",{className:"explain-row",onClick:()=>B.navigate({kind:"reaction",id:s.reaction}),children:[n.jsxs("div",{className:"row between",children:[n.jsx(Xt,{r:{kind:"reaction",id:s.reaction}}),n.jsxs("span",{className:`mono ${(s.delta??0)>0?"up":"down"}`,children:[(s.delta??0)>0?"+":"",W(s.delta)]})]}),n.jsx("div",{className:"contrib-bar",children:n.jsx("span",{className:(s.delta??0)>0?"up":"down",style:{width:`${Math.abs(s.delta??0)/a*100}%`}})}),n.jsxs("div",{className:"muted small",children:[s.roleA," → ",s.roleB,s.category==="reversal"?" · direction reversed":""," · ",s.name]})]},s.reaction))})]}):n.jsx("div",{className:"muted small",children:"Computing…"})]})]})}function Wk(){var b,_;const e=S(x=>x.states),t=S(x=>x.model),i=S(x=>x.index),[a,s]=E.useState((b=e[0])==null?void 0:b.id),[o,l]=E.useState((_=e[e.length-1])==null?void 0:_.id),[r,c]=E.useState(null),d=e.find(x=>x.id===a),f=e.find(x=>x.id===o);if(E.useEffect(()=>{if(!d||!f)return;let x=!0;return Promise.all([Se.medium(t.id,ee.stateSpec(d)),Se.medium(t.id,ee.stateSpec(f))]).then(v=>x&&c(v),()=>x&&c(null)),()=>{x=!1}},[d,f,t.id]),!d||!f)return null;const u=ee.objective(d),p=ee.objective(f),m=Array.from(new Set([...Object.keys(d.bounds),...Object.keys(f.bounds)])).filter(x=>JSON.stringify(ee.bounds(d,i.rxn.get(x)))!==JSON.stringify(ee.bounds(f,i.rxn.get(x)))),h=new Set(t.reactions.filter(x=>x.type==="exchange").map(x=>x.id)),g=r?r[0].rows.map(x=>[x,r[1].rows.find(v=>v.reaction===x.reaction)]).filter(([x,v])=>v&&(x.uptakeMax!==v.uptakeMax||x.uptakeUnbounded!==v.uptakeUnbounded)&&x.kind==="exchange"):[],y=m.filter(x=>!h.has(x));return n.jsxs("div",{className:"state-diff",children:[n.jsxs("div",{className:"cmp-pick",children:[n.jsxs("label",{children:[n.jsx("span",{className:"cmp-ab",children:"A"}),n.jsx("select",{className:"input",value:a,onChange:x=>s(x.target.value),children:e.map(x=>n.jsx("option",{value:x.id,children:x.name},x.id))})]}),n.jsx(q,{name:"chevR",size:14}),n.jsxs("label",{children:[n.jsx("span",{className:"cmp-ab b",children:"B"}),n.jsx("select",{className:"input",value:o,onChange:x=>l(x.target.value),children:e.map(x=>n.jsx("option",{value:x.id,children:x.name},x.id))})]}),n.jsx("span",{className:"muted small",children:"Model/configuration differences — before any simulation."})]}),n.jsxs("div",{className:"cfg-body",children:[n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Objective"}),n.jsx("span",{className:"mono",children:JSON.stringify(u)===JSON.stringify(p)?"unchanged":`${Pi(u)} → ${Pi(p)}`})]}),n.jsxs("div",{className:"cfg-group",children:[n.jsxs("div",{className:"insp-sub",children:["Medium differences · ",g.length]}),!r&&n.jsx("div",{className:"muted small",children:"Reading media…"}),r&&!g.length&&n.jsx("div",{className:"muted small",children:"Same medium."}),g.map(([x,v])=>n.jsxs("div",{className:"kv small",children:[n.jsxs("span",{children:[n.jsx(Xt,{r:{kind:"reaction",id:x.reaction}})," ",n.jsx("span",{className:"muted",children:x.metaboliteName})]}),n.jsxs("span",{className:"mono",children:[x.uptakeUnbounded?"∞":W(x.uptakeMax)," → ",v.uptakeUnbounded?"∞":W(v.uptakeMax)]})]},x.reaction))]}),n.jsxs("div",{className:"cfg-group",children:[n.jsxs("div",{className:"insp-sub",children:["Bounds · ",y.length," reaction",y.length===1?"":"s"," changed"]}),!y.length&&n.jsx("div",{className:"muted small",children:"No other bound differences."}),y.map(x=>{const v=i.rxn.get(x);return n.jsxs("div",{className:"kv small",children:[n.jsx(Xt,{r:{kind:"reaction",id:x}}),n.jsxs("span",{className:"mono",children:[Ua(ee.bounds(d,v))," → ",Ua(ee.bounds(f,v))]})]},x)})]})]})]})}const rg=(e,t)=>{const i=e??-1/0,a=t??1/0;return i<0&&a>0?"both":a<=0&&i<0?"rev":"fwd"},Yk={fwd:"-->",rev:"<--",both:"<=>"},cg={fwd:"→",rev:"←",both:"⇌"},Zk=e=>Math.abs(e)===1?"":`${+Math.abs(e).toPrecision(10)} `;function Qk(e,t,i=a=>a){const a=s=>Object.entries(e).filter(([,o])=>o>0===s).map(([o,l])=>Zk(l)+i(o)).join(" + ");return`${a(!1)} ${Yk[t]} ${a(!0)}`.trim()}const Jk=/\s*(<=>|<->|<-->|-->|->|=>|<--|<-|<=)\s*/;function eM(e){const t={stoich:{},arrow:null,errors:[],warnings:[]},i=e.trim();if(!i)return t;const a=i.match(Jk);if(!a)return t.errors.push("No arrow: use -->, <=> or <--"),t;const s=a[1];t.arrow=s==="<=>"||s==="<->"?"both":s.startsWith("<")?"rev":"fwd";const[o,l]=[i.slice(0,a.index),i.slice(a.index+a[0].length)],r=(c,d)=>{for(const f of c.split(/\s+\+\s+|^\+\s+|\s+\+$/)){const u=f.trim();if(!u)continue;const p=u.match(/^(\d*\.?\d+(?:[eE][-+]?\d+)?)\s+(\S+)$/),[m,h]=p?[+p[1],p[2]]:[1,u];if(/\s/.test(h)){t.errors.push(`“${u}” is not “coefficient metabolite_id”`);continue}if(!(m>0)||!Number.isFinite(m)){t.errors.push(`Invalid coefficient in “${u}”`);continue}t.stoich[h]!=null&&t.warnings.push(`${h} appears twice — the coefficients are combined`),t.stoich[h]=(t.stoich[h]??0)+d*m,t.stoich[h]===0&&(delete t.stoich[h],t.warnings.push(`${h} cancels out (same amount on both sides)`))}};return r(o,-1),r(l,1),t}function dg(e){const t=(e??"").trim();if(!t)return null;const i={},a=/([A-Z][a-z]?)(\d*\.?\d*)/g;let s=0;for(let o=a.exec(t);o;o=a.exec(t)){if(o.index!==s||!o[0])return null;i[o[1]]=(i[o[1]]??0)+(o[2]?+o[2]:1),s=o.index+o[0].length}return s===t.length?i:null}function tM(e,t){const i=Object.keys(e),a=i.filter(r=>{var c;return!dg((c=t(r))==null?void 0:c.formula)}),s=i.filter(r=>{var c;return((c=t(r))==null?void 0:c.charge)==null});let o=null,l=null;if(i.length&&!a.length){const r={};for(const[c,d]of Object.entries(e))for(const[f,u]of Object.entries(dg(t(c).formula)))r[f]=(r[f]??0)+d*u;o=Object.fromEntries(Object.entries(r).filter(([,c])=>Math.abs(c)>1e-6).map(([c,d])=>[c,+d.toFixed(6)]))}return i.length&&!s.length&&(l=+Object.entries(e).reduce((r,[c,d])=>r+d*t(c).charge,0).toFixed(6)),{mass:o,charge:l,missingFormula:a,missingCharge:s}}function nM(e){if(!e.trim())return null;const t=(e.match(/\(|\)|[^\s()]+/g)??[]).map(o=>/^(and|&)$/i.test(o)?"and":/^(or|\|)$/i.test(o)?"or":o);let i=0;const a=()=>{const o=t[i];if(o==null)throw new Error("the rule ends where a gene or “(” was expected");if(o==="("){if(i++,s(),t[i]!==")")throw new Error("a “(” is not closed");i++}else{if(o===")"||o==="and"||o==="or")throw new Error(`unexpected “${o}” where a gene was expected`);i++}},s=()=>{for(a();t[i]==="and"||t[i]==="or";)i++,a()};try{if(s(),i!==t.length)throw new Error(`unexpected “${t[i]}”`)}catch(o){return o.message}return null}const mg=new WeakMap;function Zx(e){var u;const t=mg.get(e);if(t)return t;const i=e.metabolites;let a=0,s=0,o=0;const l=[];for(const p of i){let m=p.id;m.startsWith("M_")&&(o++,m=m.slice(2)),p.compartment&&m.endsWith(`_${p.compartment}`)?(a++,l.push(m.slice(0,-p.compartment.length-1))):p.compartment&&m.endsWith(`[${p.compartment}]`)?(s++,l.push(m.slice(0,-p.compartment.length-2))):l.push(m)}const r=Math.max(1,i.length),c=p=>l.filter(m=>p.test(m)).length/Math.max(1,l.length),d=c(/^cpd\d{5}$/)>.4?"seed":c(/^C\d{5}$/)>.4?"kegg":c(/^MNXM\d+$/i)>.4?"mnx":c(/^[a-z0-9]+(__?[A-Za-z0-9]+)*$/)>.5?"bigg":"other",f={suffix:a/r>.5?"underscore":s/r>.5?"bracket":"none",prefix:o/r>.6?"M_":"",ns:d,example:((u=i.find(p=>p.compartment))==null?void 0:u.id)??""};return mg.set(e,f),f}const iM=e=>e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40)||"met";function aM(e,t,i){const a=o=>{var l;return(l=i==null?void 0:i[o])==null?void 0:l[0]};return(e.ns==="seed"?a("seed.compound"):e.ns==="kegg"?a("kegg.compound"):e.ns==="mnx"?a("metanetx.chemical"):e.ns==="bigg"?a("bigg.metabolite"):void 0)??(e.ns==="bigg"||e.ns==="other"?a("bigg.metabolite"):void 0)??iM(t)}function sM(e,t,i){const a=i?e.suffix==="underscore"?`_${i}`:e.suffix==="bracket"?`[${i}]`:"":"";return`${e.prefix}${t}${a}`}function h0(e,t){if(!t(e))return e;const i=e.match(/^(.*?)(_[A-Za-z0-9]{1,3}|\[[^\]]+\])?$/);for(let a=2;a<1e3;a++){const s=`${i[1]}_${a}${i[2]??""}`;if(!t(s))return s}return`${e}_${Date.now().toString(36)}`}function oM(e,t,i,a,s,o=[]){const l=Zx(e);return h0(sM(l,aM(l,i,s),a),r=>t.met.has(r)||o.includes(r))}const lM={exchange:["EX_","R_EX_","Ex_","EXC_","ex_"],sink:["SK_","R_SK_","SINK_","sink_","Sink_"],demand:["DM_","R_DM_","DEMAND_","demand_"]},rM={exchange:"EX_",sink:"SK_",demand:"DM_"},cM={exchange:"SBO:0000627",demand:"SBO:0000628",sink:"SBO:0000632"};function dM(e,t){const i=e.reactions.filter(o=>o.type===t).map(o=>o.id);let a=rM[t],s=0;for(const o of lM[t]){const l=i.filter(r=>r.startsWith(o)).length;l>s&&(s=l,a=o)}return a}function ug(e,t,i,a){const s=dM(e,i),o=s.startsWith("R_")&&a.startsWith("M_")?a.slice(2):a;return h0(`${s}${o}`,l=>t.rxn.has(l))}function mM(e,t){return(e.metRxns.get(t)??[]).map(i=>e.rxn.get(i)).filter(i=>Object.keys(i.stoichiometry).length===1).map(i=>({id:i.id,kind:i.type}))}function uM(e,t){var s,o;const i={};for(const l of e.reactions)if(l.type==="exchange"&&l.boundaryMetabolite){const r=(s=t.met.get(l.boundaryMetabolite))==null?void 0:s.compartment;r&&(i[r]=(i[r]??0)+1)}return((o=Object.entries(i).sort((l,r)=>r[1]-l[1])[0])==null?void 0:o[0])??Object.keys(e.compartments).find(l=>/^(e|e0|ext|extracellular|C_e)$/i.test(l))??null}const Qx=["metanetx.chemical","kegg.compound","chebi","bigg.metabolite","seed.compound","inchikey","metacyc.compound","hmdb"],Jx=(e,t)=>`${e}:${(e==="chebi"?t.replace(/^chebi:/i,""):t).trim().toLowerCase()}`,pg=new WeakMap;function pM(e){const t=pg.get(e);if(t)return t;const i=new Map;for(const a of e.met.values())for(const[s,o]of Object.entries(a.annotation??{})){const l=s.toLowerCase();if(Qx.includes(l))for(const r of Array.isArray(o)?o:[o]){const c=Jx(l,String(r));i.set(c,[...i.get(c)??[],a.id])}}return pg.set(e,i),i}function hM(e,t){const i=pM(e),a=new Set;for(const[s,o]of Object.entries(t.identifiers??{}))for(const l of o)for(const r of i.get(Jx(s,l))??[])a.add(r);return[...a].sort()}function fM(e){var i;const t={};for(const a of Qx){const s=(i=e.identifiers)==null?void 0:i[a];if(!(s!=null&&s.length))continue;const o=a==="chebi"?s.map(l=>/^chebi:/i.test(l)?l.toUpperCase():`CHEBI:${l}`):s;t[a]=o.length>1?o:o[0]}return t}function Du(e,t){const i=t.filter(a=>a!==e&&Math.abs(a.score-e.score)<.1&&a.score>=.5);return e.score<.9?{level:"review",why:e.match||"partial name match"}:e.structured===!1?{level:"review",why:"no formula or structure in MetaNetX"}:i.length?{level:"review",why:`${i.length+1} candidates match equally well`}:{level:"confident",why:e.match}}function oc({value:e,onChange:t,keyHint:i,multi:a=!0,suggestions:s=[]}){const o=Object.entries(e),[l,r]=E.useState(""),[c,d]=E.useState(""),f=m=>{const h=m.split(",").map(g=>g.trim()).filter(Boolean);return!a||h.length<=1?h[0]??"":h},u=`kv-${i.replace(/\W/g,"")}`,p=()=>{!l.trim()||!c.trim()||(t({...e,[l.trim()]:f(c)}),r(""),d(""))};return n.jsxs("div",{className:"kv-edit",children:[o.map(([m,h])=>n.jsxs("div",{className:"kv-row",children:[n.jsx("span",{className:"mono small kv-key",title:m,children:m}),n.jsx("input",{className:"input tiny",value:Array.isArray(h)?h.join(", "):h,onChange:g=>t({...e,[m]:f(g.target.value)})}),n.jsx("button",{className:"icon-btn tiny",title:"Remove",onClick:()=>{const g={...e};delete g[m],t(g)},children:n.jsx(q,{name:"x",size:10})})]},m)),n.jsxs("div",{className:"kv-row add",children:[n.jsx("input",{className:"input tiny kv-key",placeholder:i,value:l,list:s.length?u:void 0,onChange:m=>r(m.target.value)}),n.jsx("input",{className:"input tiny",placeholder:a?"value (several: comma-separated)":"value",value:c,onChange:m=>d(m.target.value),onKeyDown:m=>{m.key==="Enter"&&p()}}),n.jsx("button",{className:"btn tiny",disabled:!l.trim()||!c.trim(),onClick:p,children:"Add"}),s.length>0&&n.jsx("datalist",{id:u,children:s.map(m=>n.jsx("option",{value:m},m))})]})]})}const gM=["metanetx.chemical","kegg.compound","chebi","bigg.metabolite","seed.compound","metacyc.compound","hmdb","inchikey","sbo"],bM=["ec-code","metanetx.reaction","rhea","kegg.reaction","bigg.reaction","seed.reaction","metacyc.reaction","sbo"];function ft({label:e,children:t,hint:i,wide:a,error:s}){return n.jsxs("label",{className:`ef ${a?"wide":""} ${s?"bad":""}`,children:[n.jsx("span",{className:"ef-label",children:e}),t,s?n.jsx("span",{className:"ef-err",children:s}):i?n.jsx("span",{className:"ef-hint",children:i}):null]})}function f0({report:e,local:t=[],skipWarn:i}){const a=[...t,...(e==null?void 0:e.errors)??[]],s=((e==null?void 0:e.warnings)??[]).filter(r=>!(i!=null&&i(r))),o=(e==null?void 0:e.info)??[];if(!a.length&&!s.length&&!o.length)return null;const l=r=>r.replace(/^(Reaction|Metabolite|Compartment|Delete reaction|Delete metabolite) [^:]*: /,"");return n.jsxs("div",{className:"ed-report",children:[a.map((r,c)=>n.jsxs("div",{className:"ed-msg err",children:[n.jsx("span",{children:"✕"}),l(r)]},"e"+c)),s.map((r,c)=>n.jsxs("div",{className:"ed-msg warn",children:[n.jsx("span",{children:"⚠"}),l(r)]},"w"+c)),o.map((r,c)=>n.jsxs("div",{className:"ed-msg info",children:[n.jsx("span",{children:"i"}),l(r)]},"i"+c))]})}function Mi({title:e,onClose:t,children:i,width:a=720,footer:s}){return n.jsx("div",{className:"modal-backdrop",onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),t())},children:n.jsxs("div",{className:"modal lab-modal ed-modal",style:{width:qe(a)},role:"dialog","aria-label":typeof e=="string"?e:void 0,children:[n.jsxs("div",{className:"modal-head",children:[n.jsx("span",{children:e}),n.jsx("button",{className:"icon-btn",title:"Close (Esc)",onClick:t,children:n.jsx(q,{name:"x",size:14})})]}),n.jsx("div",{className:"modal-body ed-body",children:i}),s&&n.jsx("div",{className:"ed-foot",children:s})]})})}function Pu({mode:e,origId:t,init:i,candidate:a,review:s,context:o,pendingComps:l=[],extraTaken:r=[],onDone:c,onCancel:d,onUseExisting:f}){const u=S(me=>me.model),p=S(me=>me.index),m=t?p.met.get(t):void 0,h=Zx(u),g=a?fM(a):{},[y,b]=E.useState((i==null?void 0:i.name)??(a==null?void 0:a.name)??(m==null?void 0:m.name)??""),[_,x]=E.useState((i==null?void 0:i.compartment)??(m==null?void 0:m.compartment)??""),[v,j]=E.useState((i==null?void 0:i.formula)??(a==null?void 0:a.formula)??(m==null?void 0:m.formula)??""),[N,C]=E.useState((i==null?void 0:i.charge)??(a==null?void 0:a.charge)??(m==null?void 0:m.charge)??null),[w,k]=E.useState((i==null?void 0:i.annotation)??(a?g:(m==null?void 0:m.annotation)??{})),P=m==null?void 0:m.notes,[H,G]=E.useState((i==null?void 0:i.notes)??P??(a!=null&&a.synonyms.length?{synonyms:a.synonyms.slice(0,12).join("; ")}:{})),[M,A]=E.useState(e==="edit"||!!(i!=null&&i.id)),[X,I]=E.useState((i==null?void 0:i.id)??(m==null?void 0:m.id)??""),[K,L]=E.useState(null),[D,F]=E.useState(null),[U,z]=E.useState(!s),[O,Z]=E.useState(null),[oe,he]=E.useState(!1),[J,Pe]=E.useState(null),ye={...u.compartments,...Object.fromEntries(l.map(me=>[me.id,me.name])),...K?{[K.id]:K.name}:{}},_e=E.useMemo(()=>_&&y?oM(u,p,y,_,a==null?void 0:a.identifiers,r):"",[u,p,y,_,a,r]);E.useEffect(()=>{M||I(_e)},[_e,M]);const Ke={id:X.trim(),name:y.trim(),compartment:_,formula:v.trim(),charge:N,annotation:w,notes:H},Mn=()=>[...l.map(me=>({op:"add_compartment",...me})),...K?[{op:"add_compartment",...K}]:[],{op:"put_metabolite",id:t??null,metabolite:Ke}],Ct=JSON.stringify([Ke,K,l]),Un=Xn(Ct,350);E.useEffect(()=>{let me=!0;if(!Ke.id||!Ke.name){Z(null);return}return Xe.check(Mn()).then(Y=>{me&&Z(Y)}),()=>{me=!1}},[Un]);const sn=[];r.includes(Ke.id)&&Ke.id!==t&&sn.push(`ID “${Ke.id}” is already used by another new metabolite of this reaction`);const di=O==null?void 0:O.items.find(me=>me.label.startsWith("Metabolite")),qt=(di==null?void 0:di.duplicates)??[],kt=[...sn,...(O==null?void 0:O.errors)??[]],En=!!Ke.id&&!!Ke.name&&!!Ke.compartment&&U&&!kt.length&&!oe,mi=async()=>{if(!En)return;const me={...Ke,origin:a?"database":"manual",source:a?`${a.name} (${a.sources.join(", ")})`:void 0};if(o==="reaction"){c(me,K??void 0);return}he(!0),Pe(null);const Y=await Xe.commit(Mn(),e==="edit"?void 0:`Added metabolite ${Ke.id}`);he(!1),Y.ok?(c(me,K??void 0),B.navigate({kind:"metabolite",id:Ke.id})):(Pe(Y.error.message||Y.error.title),Y.report&&Z(Y.report))},ya=m?(p.metRxns.get(m.id)??[]).length:0;return n.jsxs("div",{className:"mf",onKeyDown:me=>{me.key==="Enter"&&(me.ctrlKey||me.metaKey)&&mi()},children:[a&&n.jsxs("div",{className:`mf-src ${s?"review":""}`,children:[n.jsxs("div",{className:"row between",children:[n.jsx("b",{children:a.name}),n.jsx("span",{className:`tag ${s?"warn":"ok"}`,children:s?"Needs review":"Confident match"})]}),n.jsxs("div",{className:"small muted",children:["From ",a.sources.join(", ")," · ",a.match,a.note?` · ${a.note}`:""]}),s&&n.jsxs("label",{className:"check small mf-confirm",children:[n.jsx("input",{type:"checkbox",checked:U,onChange:me=>z(me.target.checked)}),n.jsxs("span",{children:["I checked the identity: this is ",n.jsx("b",{children:a.name}),a.formula?n.jsxs(n.Fragment,{children:[" (",a.formula,")"]}):null,". ",n.jsx("span",{className:"muted",children:Du(a,[a]).why===a.match?a.match:""})]})]})]}),n.jsxs("div",{className:"ef-grid",children:[n.jsx(ft,{label:"Name *",children:n.jsx("input",{className:"input",autoFocus:e!=="edit",value:y,onChange:me=>b(me.target.value),placeholder:"L-Malate"})}),n.jsx(ft,{label:"Compartment *",hint:_?void 0:"Only the compartments of the model are listed",children:n.jsxs("select",{className:"input",value:_,onChange:me=>{me.target.value==="__new"?F({id:"",name:""}):x(me.target.value)},children:[n.jsx("option",{value:"",disabled:!0,children:"Choose…"}),Object.entries(ye).map(([me,Y])=>n.jsxs("option",{value:me,children:[Y&&Y!==me?`${Y} [${me}]`:me,(K==null?void 0:K.id)===me||l.some(ae=>ae.id===me)?" (new)":""]},me)),n.jsx("option",{value:"__new",children:"+ New compartment…"})]})}),D&&n.jsxs("div",{className:"mf-newcomp wide",children:[n.jsxs("div",{className:"small",children:[n.jsx("b",{children:"New compartment"})," ",n.jsx("span",{className:"muted",children:"— added to the model with this metabolite. Check the existing ones first: a typo creates a second compartment."})]}),n.jsxs("div",{className:"row gap",children:[n.jsx("input",{className:"input tiny",placeholder:"ID (e.g. x)",value:D.id,onChange:me=>F({...D,id:me.target.value.trim()})}),n.jsx("input",{className:"input tiny grow",placeholder:"Name (e.g. peroxisome)",value:D.name,onChange:me=>F({...D,name:me.target.value})}),n.jsx("button",{className:"btn small",disabled:!D.id||/\s/.test(D.id)||D.id in ye,onClick:()=>{L({id:D.id,name:D.name||D.id}),x(D.id),F(null)},children:"Create compartment"}),n.jsx("button",{className:"btn small",onClick:()=>F(null),children:"Cancel"})]}),D.id in ye&&n.jsxs("div",{className:"ef-err",children:["“",D.id,"” already exists — choose it in the list."]})]}),n.jsx(ft,{label:"Metabolite ID *",wide:!0,hint:M?_e&&_e!==X?n.jsxs("button",{className:"link small",onClick:()=>{A(!1),I(_e)},children:["Use suggestion ",_e]}):void 0:n.jsxs(n.Fragment,{children:["Suggested from the model's convention",h.example?n.jsxs(n.Fragment,{children:[" (e.g. ",n.jsx("span",{className:"mono",children:h.example}),")"]}):null," — edit freely"]}),children:n.jsx("input",{className:"input mono",value:X,onChange:me=>{A(!0),I(me.target.value)},placeholder:h.example||"met_c"})}),e==="edit"&&m&&Ke.id!==m.id&&ya>0&&n.jsxs("div",{className:"note small wide",children:["Renaming updates the ",ya," reaction",ya>1?"s":""," that use ",m.id,": they keep pointing to this metabolite under the new ID."]}),n.jsx(ft,{label:"Formula",children:n.jsx("input",{className:"input mono",value:v,onChange:me=>j(me.target.value),placeholder:"C4H4O5"})}),n.jsx(ft,{label:"Charge",children:n.jsx(wn,{allowEmpty:!0,value:N,onCommit:C,placeholder:"—"})}),(!Ke.formula||N==null)&&n.jsx("div",{className:"muted small wide",children:"Mass/charge balance cannot be fully evaluated without formula and charge."})]}),n.jsxs("details",{className:"mf-more",open:!!a||Object.keys(w).length>0,children:[n.jsxs("summary",{className:"insp-sub",children:["Annotations · ",Object.keys(w).length,a&&n.jsx("span",{className:"muted",children:" (from the database)"})]}),n.jsx(oc,{value:w,onChange:k,keyHint:"key (kegg.compound, chebi…)",suggestions:gM})]}),n.jsxs("details",{className:"mf-more",open:Object.keys(H).length>0,children:[n.jsxs("summary",{className:"insp-sub",children:["Notes · ",Object.keys(H).length]}),n.jsx(oc,{value:H,onChange:me=>G(Object.fromEntries(Object.entries(me).map(([Y,ae])=>[Y,Array.isArray(ae)?ae.join(", "):ae]))),keyHint:"key (e.g. comment)",multi:!1})]}),qt.filter(me=>me.sameCompartment||e!=="edit").length>0&&n.jsxs("div",{className:"mf-dups",children:[n.jsxs("div",{className:"small",children:[n.jsx("b",{children:"Possible existing metabolite detected"})," ",n.jsx("span",{className:"muted",children:"— the model may already have this compound. You decide."})]}),qt.map(me=>n.jsxs("div",{className:"mf-dup",children:[n.jsx("span",{className:"mono",children:me.id}),n.jsx("span",{className:"ellipsis",children:me.name}),n.jsxs("span",{className:"ms-comp",children:["[",u.compartments[me.compartment]??me.compartment,"]"]}),n.jsx("span",{className:"muted small ellipsis",children:me.reasons.join(", ")}),o==="reaction"&&f?n.jsx("button",{className:"btn tiny",onClick:()=>f(me.id),children:"Use this one"}):n.jsx("button",{className:"btn tiny",onClick:()=>{d(),B.navigate({kind:"metabolite",id:me.id})},children:"Open"})]},me.id))]}),n.jsx(f0,{report:O,local:sn,skipWarn:me=>/Possible existing metabolite|without formula and charge/.test(me)}),J&&n.jsxs("div",{className:"ed-msg err",children:[n.jsx("span",{children:"✕"}),J]}),n.jsxs("div",{className:"row end gap mf-actions",children:[n.jsx("button",{className:"btn",onClick:d,children:"Cancel"}),n.jsxs("button",{className:"btn primary",disabled:!En,onClick:mi,title:U?void 0:"Confirm the identity first",children:[oe?n.jsx("span",{className:"spinner sm light"}):n.jsx(q,{name:e==="edit"?"tidy":"plus",size:12}),o==="reaction"?" Add to reaction":e==="edit"?" Save metabolite":" Create metabolite"]})]})]})}const yM=["all","MetaNetX","BiGG","ModelSEED","KEGG/ChEBI"],xM=(e,t)=>{var i,a,s,o,l;return e==="all"?!0:e==="MetaNetX"?!!((i=t.identifiers["metanetx.chemical"])!=null&&i.length):e==="BiGG"?!!((a=t.identifiers["bigg.metabolite"])!=null&&a.length)||t.sources.includes("BiGG"):e==="ModelSEED"?!!((s=t.identifiers["seed.compound"])!=null&&s.length):!!((o=t.identifiers["kegg.compound"])!=null&&o.length||(l=t.identifiers.chebi)!=null&&l.length)},hg={"metanetx.chemical":"MetaNetX","kegg.compound":"KEGG",chebi:"ChEBI","bigg.metabolite":"BiGG","seed.compound":"ModelSEED","metacyc.compound":"MetaCyc",hmdb:"HMDB"};function e_({onPick:e,compartment:t,pending:i=[],initial:a="",autoFocus:s=!0,onClose:o}){const l=S(M=>M.index),r=S(M=>M.model),c=S(M=>M.searchIndex),[d,f]=E.useState(a),[u,p]=E.useState("model"),[m,h]=E.useState("all"),[g,y]=E.useState(0),[b,_]=E.useState(null),x=E.useRef(null),v=Xn(d,120),j=E.useMemo(()=>{const M=v.trim().toLowerCase(),A=i.filter(K=>!M||K.id.toLowerCase().includes(M)||K.name.toLowerCase().includes(M)),I=(M?c.search(v,["metabolite"],60):[]).map(K=>l.met.get(K.id)).filter(Boolean);return I.sort((K,L)=>+(L.compartment===t)-+(K.compartment===t)),{pend:A,rows:I.slice(0,40)}},[v,c,l,t,i]),N=async M=>{if(M.trim()){_({q:M,loading:!0,list:[],sources:{}});try{const A=await Se.identityCompounds(M.trim(),12);_({q:M,loading:!1,list:A.candidates,sources:A.sources})}catch(A){_({q:M,loading:!1,list:[],sources:{},error:A.message})}}},C=Xn(d,450);E.useEffect(()=>{u==="db"&&C.trim()&&C!==(b==null?void 0:b.q)&&N(C)},[u,C]),E.useEffect(()=>y(0),[v,u]);const w=[...j.pend.map(M=>({kind:"pending",id:M.id})),...j.rows.map(M=>({kind:"model",id:M.id}))],k=((b==null?void 0:b.list)??[]).filter(M=>xM(m,M)),P=M=>{if(u==="model"){const A=w[M];A&&e(A)}else{const A=k[M];A&&e({kind:"import",compound:A,review:Du(A,b.list).level==="review"})}},H=M=>{const A=u==="model"?w.length:k.length;M.key==="ArrowDown"?(M.preventDefault(),y(X=>Math.min(A-1,X+1))):M.key==="ArrowUp"?(M.preventDefault(),y(X=>Math.max(0,X-1))):M.key==="Enter"?(M.preventDefault(),P(g)):M.key==="Escape"?(M.stopPropagation(),o==null||o()):M.key==="Tab"&&!M.shiftKey&&d.trim()&&(M.preventDefault(),p(u==="model"?"db":"model"))},G=M=>r.compartments[M]??M;return n.jsxs("div",{className:"ms",onKeyDown:H,children:[n.jsxs("div",{className:"ms-top",children:[n.jsxs("div",{className:"search-box",children:[n.jsx(q,{name:"search",size:13}),n.jsx("input",{ref:x,autoFocus:s,placeholder:"Metabolite name, ID, formula, KEGG / ChEBI / MetaNetX / BiGG id…",value:d,onChange:M=>f(M.target.value)})]}),n.jsxs("div",{className:"ms-tabs",children:[n.jsxs("button",{className:u==="model"?"on":"",onClick:()=>p("model"),children:["In this model ",n.jsx("span",{className:"count",children:w.length})]}),n.jsx("button",{className:u==="db"?"on":"",onClick:()=>{p("db"),d.trim()&&d!==(b==null?void 0:b.q)&&N(d)},title:"KEGG and ChEBI resolved through MetaNetX, plus the local BiGG tables",children:"Databases"})]})]}),u==="model"&&n.jsxs("div",{className:"ms-list",children:[!d.trim()&&!j.pend.length&&n.jsxs("div",{className:"muted small pad",children:["Type to search the ",l.met.size.toLocaleString()," metabolites of the model",t?n.jsxs(n.Fragment,{children:[" — ",n.jsx("b",{children:G(t)})," first"]}):null,"."]}),j.pend.length>0&&n.jsx("div",{className:"ms-label",children:"New in this edit"}),j.pend.map((M,A)=>n.jsxs("button",{className:`ms-row ${g===A?"on":""}`,onMouseEnter:()=>y(A),onClick:()=>e({kind:"pending",id:M.id}),children:[n.jsx("span",{className:"ms-name",children:M.name}),n.jsx("span",{className:"mono small",children:M.id}),n.jsxs("span",{className:"ms-comp",children:["[",G(M.compartment),"]"]}),n.jsx("span",{className:"tag",children:"new"})]},"p"+M.id)),j.rows.length>0&&n.jsx("div",{className:"ms-label",children:"Already in model"}),j.rows.map((M,A)=>{const X=j.pend.length+A;return n.jsxs("button",{className:`ms-row ${g===X?"on":""}`,onMouseEnter:()=>y(X),onClick:()=>e({kind:"model",id:M.id}),title:`${M.id} — ${M.name}${M.formula?` · ${M.formula}`:""} · used by ${M.reactionCount} reactions`,children:[n.jsx("span",{className:"ms-name",children:M.name||M.id}),n.jsx("span",{className:"mono small",children:M.id}),n.jsxs("span",{className:`ms-comp ${M.compartment===t?"same":""}`,children:["[",G(M.compartment),"]"]}),n.jsx("span",{className:"mono small muted",children:M.formula??""})]},M.id)}),d.trim()&&!w.length&&n.jsxs("div",{className:"muted small pad",children:["No metabolite of the model matches “",d,"”."]})]}),u==="db"&&n.jsxs("div",{className:"ms-list",children:[n.jsxs("div",{className:"ms-filters",children:[yM.map(M=>n.jsx("button",{className:`chip-btn ${m===M?"on":""}`,onClick:()=>h(M),children:M==="all"?"All":M},M)),b&&!b.loading&&n.jsx("span",{className:"muted small ms-src",children:Object.entries(b.sources).map(([M,A])=>`${M}: ${A}`).join(" · ")})]}),!d.trim()&&n.jsx("div",{className:"muted small pad",children:"Type a compound name or an identifier (C00149, CHEBI:30797, MNXM98, cpd00130)."}),(b==null?void 0:b.loading)&&n.jsxs("div",{className:"muted small pad",children:[n.jsx("span",{className:"spinner sm"})," Searching KEGG, ChEBI, MetaNetX and BiGG…"]}),(b==null?void 0:b.error)&&n.jsxs("div",{className:"note small",children:["Database search unavailable: ",b.error,". Is the backend running? You can still create the metabolite by hand."]}),b&&!b.loading&&!b.error&&d.trim()&&!k.length&&n.jsxs("div",{className:"muted small pad",children:["No database compound for “",b.q,"”",m!=="all"?` with a ${m} identifier`:"","."]}),k.map((M,A)=>{const X=Du(M,b.list),I=hM(l,M);return n.jsxs("div",{className:`ms-cand ${g===A?"on":""}`,onMouseEnter:()=>y(A),children:[n.jsxs("div",{className:"row between gap",children:[n.jsx("b",{className:"ellipsis",children:M.name}),n.jsx("span",{className:`tag ${X.level==="confident"?"ok":"warn"}`,title:X.why,children:X.level==="confident"?"Confident":"Needs review"})]}),n.jsxs("div",{className:"small",children:[n.jsx("span",{className:"mono",children:M.formula??"no formula"}),M.charge!=null&&n.jsxs(n.Fragment,{children:[" · charge ",n.jsx("span",{className:"mono",children:M.charge})]})," · ",n.jsx("span",{className:"muted",children:M.match})]}),n.jsx("div",{className:"ms-ids",children:Object.entries(M.identifiers).filter(([K])=>hg[K]).map(([K,L])=>n.jsxs("span",{className:"ms-id",children:[n.jsx("span",{className:"muted",children:hg[K]})," ",n.jsxs("span",{className:"mono",children:[L.slice(0,2).join(", "),L.length>2?"…":""]})]},K))}),M.synonyms.length>0&&n.jsxs("div",{className:"muted small ellipsis",title:M.synonyms.join("; "),children:["also: ",M.synonyms.slice(0,5).join("; ")]}),I.length>0&&n.jsxs("div",{className:"ms-exist",children:[n.jsx("span",{children:"Already in model as"}),I.slice(0,6).map(K=>{var L;return n.jsx("button",{className:"link mono",onClick:()=>e({kind:"model",id:K}),title:`Use ${K} (${G(((L=l.met.get(K))==null?void 0:L.compartment)??"")})`,children:K},K)})]}),n.jsx("div",{className:"row end gap",children:n.jsx("button",{className:`btn small ${I.length?"":"primary"}`,onClick:()=>e({kind:"import",compound:M,review:X.level==="review"}),children:I.length?"Add as a new metabolite…":"Add to model…"})})]},(M.mnx??M.name)+A)})]}),n.jsxs("div",{className:"ms-foot",children:[u==="model"?n.jsx("button",{className:"link small",onClick:()=>{p("db"),d.trim()&&N(d)},children:"Not in model? Search external databases →"}):n.jsx("button",{className:"link small",onClick:()=>p("model"),children:"← Back to the model"}),n.jsx("span",{className:"grow"}),n.jsxs("button",{className:"btn small",onClick:()=>e({kind:"create",name:d.trim()}),children:[n.jsx(q,{name:"plus",size:11})," Create new metabolite"]})]})]})}function _M(e,t){if(e!=null&&e.compartments.length)return e.compartments.find(a=>a!=="e")??e.compartments[0];const i=Object.keys(t.compartments);return i.find(a=>/^(c|c0|cytosol|C_c)$/i.test(a))??i[0]??""}function t_(e,t,i,a={}){const s=e?Object.entries(e.stoichiometry).map(([o,l])=>({key:ti("row"),met:o,amount:Math.abs(l),side:l<0?"reactant":"product"})):[];return{id:(e==null?void 0:e.id)??"",name:(e==null?void 0:e.name)??"",subsystem:(e==null?void 0:e.subsystem)??"",lb:e?e.lb:0,ub:e?e.ub:i.maxBound||1e3,gpr:(e==null?void 0:e.gpr)??"",objective:(e==null?void 0:e.objectiveCoefficient)??0,annotation:(e==null?void 0:e.annotation)??{},rows:s,compartment:_M(e,t),notes:(e==null?void 0:e.notes)??{},...a}}const vM=e=>{const t={};for(const i of e)t[i.met]=(t[i.met]??0)+(i.side==="reactant"?-i.amount:i.amount);for(const i of Object.keys(t))t[i]===0&&delete t[i];return t},fg=(e,t,i)=>{const a=e.lb??-1/0,s=e.ub??1/0;return t==="fwd"?{lb:a<0?0:e.lb,ub:s>0?e.ub:i}:t==="rev"?{lb:a<0?e.lb:-i,ub:0}:{lb:a<0?e.lb:-i,ub:s>0?e.ub:i}};function jM({id:e,init:t,onClose:i}){const a=S($=>$.model),s=S($=>$.index),o=S($=>ee.activeState($)),l=e?s.rxn.get(e):void 0,r=s.maxBound||1e3,c=E.useMemo(()=>t_(l,a,s,t),[]),[d,f]=E.useState(c),[u,p]=E.useState((t==null?void 0:t.pending)??[]),[m,h]=E.useState([]),[g,y]=E.useState(null),[b,_]=E.useState(null),[x,v]=E.useState(null),[j,N]=E.useState(!1),[C,w]=E.useState(null),k=$=>f(T=>({...T,...$})),P=$=>s.met.get($)??u.find(T=>T.id===$),H=vM(d.rows),G=rg(d.lb,d.ub),M=Qk(H,G),[A,X]=E.useState(M),[I,K]=E.useState(null),L=E.useRef(!1);E.useEffect(()=>{L.current||X(M)},[M]);const D=($,T)=>{const Q=eM($),ne=Object.keys(Q.stoich).filter(re=>!P(re)),Re=Q.errors[0]??(ne.length?`Unknown metabolite${ne.length>1?"s":""}: ${ne.join(", ")} — add ${ne.length>1?"them":"it"} with “+ Add” first`:null);if(Re){K(T?`Text not applied (${Re}); showing the table's equation.`:Re),T&&X(M);return}K(Q.warnings[0]??null);const ue=new Map(d.rows.map(re=>[`${re.side}:${re.met}`,re.key])),le=Object.entries(Q.stoich).map(([re,ie])=>{const xe=ie<0?"reactant":"product";return{key:ue.get(`${xe}:${re}`)??ti("row"),met:re,amount:Math.abs(ie),side:xe}});f(re=>({...re,rows:le,...Q.arrow&&Q.arrow!==rg(re.lb,re.ub)?fg(re,Q.arrow,r):{}}))},F=[];d.id.trim()?/\s/.test(d.id)?F.push("Reaction ID contains spaces"):d.id!==(l==null?void 0:l.id)&&s.rxn.has(d.id.trim())&&F.push(`Reaction ID “${d.id}” is already used`):F.push("Reaction ID is required"),Object.keys(H).length||F.push("Add at least one metabolite"),d.rows.some($=>!($.amount>0))&&F.push("Amounts must be positive numbers (the side sets the sign)"),d.lb!=null&&d.ub!=null&&d.lb>d.ub&&F.push(`Lower bound ${d.lb} is greater than the upper bound ${d.ub}`);const U=nM(d.gpr);U&&F.push(`Gene rule: ${U}`);const z=d.rows.filter(($,T)=>d.rows.findIndex(Q=>Q.met===$.met)!==T).map($=>$.met),O={id:d.id.trim(),name:d.name.trim(),lb:d.lb,ub:d.ub,subsystem:d.subsystem.trim(),gpr:d.gpr.trim(),metabolites:H,annotation:d.annotation,objective:d.objective,notes:d.notes},Z=u.filter($=>$.id in H),oe=m.filter($=>Z.some(T=>T.compartment===$.id)),he=()=>[...oe.map($=>({op:"add_compartment",...$})),...Z.map($=>({op:"put_metabolite",metabolite:{id:$.id,name:$.name,compartment:$.compartment,formula:$.formula,charge:$.charge,annotation:$.annotation,notes:$.notes}})),{op:"put_reaction",id:(l==null?void 0:l.id)??null,reaction:O}],J=Xn(JSON.stringify([O,Z,oe]),350);E.useEffect(()=>{let $=!0;if(!O.id||!Object.keys(H).length){v(null);return}return Xe.check(he()).then(T=>{$&&v(T)}),()=>{$=!1}},[J]);const Pe=x==null?void 0:x.items.find($=>$.label.startsWith("Reaction")),ye=(Pe==null?void 0:Pe.duplicates)??[],_e=F.length>0||((x==null?void 0:x.errors.length)??0)>0,Ke=JSON.stringify([d,u])!==JSON.stringify([c,(t==null?void 0:t.pending)??[]]),Mn=()=>{(!Ke||window.confirm("Discard the changes to this reaction?"))&&i()},Ct=async()=>{if(_e||j)return;N(!0),w(null);const $=l?void 0:`Added reaction ${O.id}${Z.length?` (+${Z.length} metabolite${Z.length>1?"s":""})`:""}`,T=await Xe.commit(he(),$);N(!1),T.ok?(i(),B.navigate({kind:"reaction",id:O.id})):(w(T.error.message||T.error.title),T.report&&v(T.report))},Un=($,T)=>f(Q=>({...Q,rows:[...Q.rows,{key:ti("row"),met:$,amount:1,side:T}]})),sn=$=>T=>{if(T.kind==="model"||T.kind==="pending"){Un(T.id,$),y(null);return}y(null),_({side:$,picked:T})},di=tM(H,P),qt=Object.values(H).every($=>$<0)||Object.values(H).every($=>$>0),kt=[...new Set(Object.keys(H).map($=>{var T;return(T=P($))==null?void 0:T.compartment}).filter(Boolean))],En=l&&o.bounds[l.id],mi=(d.gpr.match(/[^\s()]+/g)??[]).filter($=>!/^(and|or)$/i.test($)&&!s.gene.has($)),ya=$=>{var T;return((T=P($))==null?void 0:T.name)||$},me=$=>Math.abs($)===1?"":`${W(Math.abs($),4)} `,Y=$=>Object.entries(H).filter(([,T])=>T>0===$).map(([T,Q])=>me(Q)+ya(T)).join(" + ")||"∅",ae=$=>{const T=d.rows.filter(Q=>Q.side===$);return n.jsxs("div",{className:"re-col",children:[n.jsx("div",{className:"re-col-head",children:n.jsxs("span",{className:"insp-sub",children:[$==="reactant"?"Reactants":"Products"," · ",T.length]})}),T.map(Q=>{const ne=P(Q.met),Re=u.some(ue=>ue.id===Q.met);return n.jsxs("div",{className:`re-row ${z.includes(Q.met)?"dup":""}`,children:[n.jsx("input",{className:"input tiny num re-amt",type:"number",min:0,step:"any",value:Number.isFinite(Q.amount)?Q.amount:"",onChange:ue=>f(le=>({...le,rows:le.rows.map(re=>re.key===Q.key?{...re,amount:ue.target.value===""?NaN:+ue.target.value}:re)}))}),n.jsxs("div",{className:"re-met",title:`${Q.met}${ne!=null&&ne.formula?` · ${ne.formula}`:""}${(ne==null?void 0:ne.charge)!=null?` · charge ${ne.charge}`:""}`,children:[n.jsx("span",{className:"ellipsis",children:(ne==null?void 0:ne.name)||Q.met}),n.jsx("span",{className:"mono small muted ellipsis",children:Q.met}),n.jsxs("span",{className:"ms-comp",children:["[",a.compartments[(ne==null?void 0:ne.compartment)??""]??(ne==null?void 0:ne.compartment)??"?","]"]}),Re&&n.jsx("span",{className:"tag",children:"new"})]}),n.jsx("button",{className:"icon-btn tiny",title:`Move to ${$==="reactant"?"products":"reactants"}`,onClick:()=>f(ue=>({...ue,rows:ue.rows.map(le=>le.key===Q.key?{...le,side:$==="reactant"?"product":"reactant"}:le)})),children:n.jsx(q,{name:"swap",size:11})}),n.jsx("button",{className:"icon-btn tiny",title:"Remove",onClick:()=>f(ue=>({...ue,rows:ue.rows.filter(le=>le.key!==Q.key)})),children:n.jsx(q,{name:"x",size:11})})]},Q.key)}),n.jsxs("button",{className:`btn small re-add ${g===$?"on":""}`,onClick:()=>{_(null),y(g===$?null:$)},children:[n.jsx(q,{name:"plus",size:11})," Add ",$]})]})};return n.jsx(Mi,{title:l?n.jsxs(n.Fragment,{children:["Edit reaction ",n.jsx("span",{className:"mono",children:l.id})]}):"New reaction",onClose:Mn,width:1e3,footer:n.jsxs(n.Fragment,{children:[l&&n.jsxs("button",{className:"btn small",onClick:()=>{(!Ke||window.confirm("Discard the changes and delete this reaction?"))&&S.setState({dialog:{kind:"delete-reaction",id:l.id}})},children:[n.jsx(q,{name:"trash",size:11})," Delete reaction…"]}),n.jsx("span",{className:"grow"}),C&&n.jsx("span",{className:"ef-err",children:C}),n.jsx("button",{className:"btn",onClick:Mn,children:"Cancel"}),n.jsxs("button",{className:"btn primary",disabled:_e||j,onClick:Ct,title:_e?"Fix the errors first":"Apply to the model (Ctrl+Enter)",children:[j&&n.jsx("span",{className:"spinner sm light"})," ",l?"Save changes":"Create reaction"]})]}),children:n.jsxs("div",{className:"re",onKeyDown:$=>{$.key==="Enter"&&($.ctrlKey||$.metaKey)&&Ct()},children:[n.jsxs("div",{className:"re-main",children:[n.jsxs("div",{className:"ef-grid",children:[n.jsx(ft,{label:"Reaction ID *",children:n.jsx("input",{className:"input mono",autoFocus:!l,value:d.id,onChange:$=>k({id:$.target.value}),placeholder:"MDH_NEW"})}),n.jsx(ft,{label:"Name",children:n.jsx("input",{className:"input",value:d.name,onChange:$=>k({name:$.target.value}),placeholder:"malate dehydrogenase"})}),n.jsxs(ft,{label:"Subsystem",children:[n.jsx("input",{className:"input",list:"re-subsystems",value:d.subsystem,onChange:$=>k({subsystem:$.target.value})}),n.jsx("datalist",{id:"re-subsystems",children:[...s.subsystems.keys()].sort().map($=>n.jsx("option",{value:$},$))})]}),n.jsx(ft,{label:"Compartment",hint:"Ranks the metabolite search; default for new metabolites",children:n.jsx("select",{className:"input",value:d.compartment,onChange:$=>k({compartment:$.target.value}),children:Object.entries({...a.compartments,...Object.fromEntries(m.map($=>[$.id,$.name]))}).map(([$,T])=>n.jsx("option",{value:$,children:T&&T!==$?`${T} [${$}]`:$},$))})})]}),n.jsxs("div",{className:"re-eq",children:[ae("reactant"),n.jsx("div",{className:"re-arrow",title:G==="both"?"Reversible (lower bound < 0 < upper bound)":G==="fwd"?"Forward only":"Backward only",children:cg[G]}),ae("product")]}),g&&n.jsxs("div",{className:"re-panel",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("span",{className:"small",children:[n.jsxs("b",{children:["Add a ",g]})," ",n.jsx("span",{className:"muted",children:"— model first; databases and new metabolites below"})]}),n.jsx("button",{className:"icon-btn tiny",onClick:()=>y(null),children:n.jsx(q,{name:"x",size:11})})]}),n.jsx(e_,{onPick:sn(g),compartment:d.compartment,pending:u,onClose:()=>y(null)})]}),b&&n.jsxs("div",{className:"re-panel",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("span",{className:"small",children:[n.jsx("b",{children:b.picked.kind==="import"?"Import from database":"Create new metabolite"})," ",n.jsx("span",{className:"muted",children:"— created together with this reaction when you save"})]}),n.jsx("button",{className:"icon-btn tiny",onClick:()=>_(null),children:n.jsx(q,{name:"x",size:11})})]}),n.jsx(Pu,{mode:b.picked.kind==="import"?"import":"create",context:"reaction",candidate:b.picked.kind==="import"?b.picked.compound:void 0,review:b.picked.kind==="import"&&b.picked.review,init:{compartment:d.compartment,...b.picked.kind==="create"?{name:b.picked.name}:{}},pendingComps:m,extraTaken:u.map($=>$.id),onCancel:()=>_(null),onUseExisting:$=>{Un($,b.side),_(null)},onDone:($,T)=>{p(Q=>[...Q,$]),T&&h(Q=>[...Q,T]),Un($.id,b.side),_(null)}})]}),n.jsx(ft,{label:"Equation (text)",wide:!0,hint:I?void 0:"Edit the table or this text — they stay in sync. Arrows: --> irreversible, <=> reversible, <-- backward",error:I,children:n.jsx("input",{className:"input mono",value:A,spellCheck:!1,onFocus:()=>{L.current=!0},onChange:$=>{X($.target.value),D($.target.value,!1)},onBlur:$=>{L.current=!1,D($.target.value,!0)}})}),n.jsxs("div",{className:"ef-grid",children:[n.jsx(ft,{label:"Lower bound",hint:d.lb==null?"empty = −∞":void 0,children:n.jsx(wn,{allowEmpty:!0,value:d.lb,onCommit:$=>k({lb:$}),placeholder:"−∞"})}),n.jsx(ft,{label:"Upper bound",hint:d.ub==null?"empty = ∞":void 0,children:n.jsx(wn,{allowEmpty:!0,value:d.ub,onCommit:$=>k({ub:$}),placeholder:"∞"})}),n.jsx(ft,{label:"Reversibility",children:n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:G==="both",onChange:$=>k(fg(d,$.target.checked?"both":"fwd",r))})," Reversible ",n.jsx("span",{className:"muted small",children:"(lower bound < 0)"})]})}),n.jsx(ft,{label:"Objective coefficient",hint:"In the model file; a state's objective overrides it",children:n.jsx(wn,{value:d.objective,onCommit:$=>k({objective:$??0})})})]}),En&&n.jsxs("div",{className:"note small",children:["State “",o.name,"” overrides this reaction's bounds with ",n.jsxs("span",{className:"mono",children:["[",rt(En[0],"lower"),", ",rt(En[1],"upper"),"]"]}),". The bounds edited here belong to the model itself and apply wherever no state override exists."]}),n.jsx(ft,{label:"Gene rule (GPR)",wide:!0,error:U?`Invalid rule: ${U}`:null,hint:mi.length?n.jsxs(n.Fragment,{children:["New gene",mi.length>1?"s":"",": ",n.jsx("span",{className:"mono",children:mi.slice(0,8).join(", ")})]}):"geneA and (geneB or geneC)",children:n.jsx("input",{className:"input mono",value:d.gpr,onChange:$=>k({gpr:$.target.value}),placeholder:"b1234 and (b5678 or b9012)"})}),n.jsxs("details",{className:"mf-more",open:Object.keys(d.annotation).length>0&&!l,children:[n.jsxs("summary",{className:"insp-sub",children:["Annotations · ",Object.keys(d.annotation).length]}),n.jsx(oc,{value:d.annotation,onChange:$=>k({annotation:$}),keyHint:"key (ec-code, rhea, kegg.reaction…)",suggestions:bM})]}),n.jsxs("details",{className:"mf-more",children:[n.jsxs("summary",{className:"insp-sub",children:["Notes · ",Object.keys(d.notes).length]}),n.jsx(oc,{value:d.notes,onChange:$=>k({notes:Object.fromEntries(Object.entries($).map(([T,Q])=>[T,Array.isArray(Q)?Q.join(", "):Q]))}),keyHint:"key (e.g. comment)",multi:!1})]})]}),n.jsxs("aside",{className:"re-side",children:[n.jsx("div",{className:"insp-sub",children:"Preview"}),n.jsxs("div",{className:"re-preview",children:[n.jsxs("div",{className:"mono",children:[n.jsx("b",{children:O.id||"NEW_REACTION"}),O.name&&n.jsxs("span",{className:"muted",children:[" · ",O.name]})]}),n.jsxs("div",{className:"re-pv-eq",children:[Y(!1),n.jsx("div",{className:"re-pv-arrow",children:cg[G]}),Y(!0)]}),n.jsxs("div",{className:"mono small",children:[rt(d.lb,"lower")," ≤ v ≤ ",rt(d.ub,"upper")]}),d.objective!==0&&n.jsxs("div",{className:"small",children:["Objective coefficient ",n.jsx("span",{className:"mono",children:d.objective})]}),kt.length>1&&n.jsxs("div",{className:"small muted",children:["Transport between ",kt.map($=>a.compartments[$]??$).join(" and ")]}),Z.length>0&&n.jsxs("div",{className:"small",children:["Creates ",Z.length," metabolite",Z.length>1?"s":"",": ",n.jsx("span",{className:"mono",children:Z.map($=>$.id).join(", ")})]})]}),n.jsx(NM,{oneSided:qt,bal:di}),ye.length>0&&n.jsxs("div",{className:"re-dups",children:[n.jsx("div",{className:"small",children:n.jsx("b",{children:"Potential duplicate reaction"})}),ye.map($=>n.jsxs("div",{className:"mf-dup",children:[n.jsx("span",{className:"mono",children:$.id}),n.jsxs("span",{className:"muted small ellipsis",children:[$.reason,$.scaled?" (scaled)":""]}),n.jsx("button",{className:"btn tiny",onClick:()=>{(!Ke||window.confirm("Close the editor and open the existing reaction?"))&&(i(),B.navigate({kind:"reaction",id:$.id}))},children:"Open"})]},$.id))]}),n.jsx(f0,{report:x,local:F,skipWarn:$=>/Potential duplicate reaction|Mass balance|Charge balance/.test($)}),z.length>0&&n.jsxs("div",{className:"ed-msg warn",children:[n.jsx("span",{children:"⚠"}),[...new Set(z)].join(", ")," appears more than once — the amounts are combined."]})]})]})})}function NM({oneSided:e,bal:t}){if(e)return n.jsx("div",{className:"re-bal muted small",children:"Boundary-like reaction (one side empty): mass and charge balance do not apply."});const i=t.missingFormula.length?n.jsxs("span",{className:"muted",children:["Mass balance: cannot be evaluated — no formula for ",n.jsxs("span",{className:"mono",children:[t.missingFormula.slice(0,4).join(", "),t.missingFormula.length>4?"…":""]})]}):t.mass&&Object.keys(t.mass).length?n.jsx("span",{className:"warn-text",children:"Mass balance: ⚠ Unbalanced"}):n.jsx("span",{className:"ok-text",children:"Mass balance: ✓ Balanced"}),a=t.missingCharge.length?n.jsxs("span",{className:"muted",children:["Charge balance: cannot be evaluated — no charge for ",n.jsxs("span",{className:"mono",children:[t.missingCharge.slice(0,4).join(", "),t.missingCharge.length>4?"…":""]})]}):t.charge?n.jsxs("span",{className:"warn-text",children:["Charge imbalance: ",t.charge>0?"+":"",t.charge]}):n.jsx("span",{className:"ok-text",children:"Charge balance: ✓"});return n.jsxs("div",{className:"re-bal",children:[n.jsx("div",{className:"small",children:i}),t.mass&&Object.keys(t.mass).length>0&&n.jsx("div",{className:"re-bal-diff mono small",children:Object.entries(t.mass).map(([s,o])=>n.jsxs("span",{children:[s,": ",o>0?"+":"",+o.toFixed(4)]},s))}),n.jsx("div",{className:"small",children:a}),t.mass&&Object.keys(t.mass).length||t.charge?n.jsx("div",{className:"muted small",children:"Products minus reactants. Unbalanced reactions can still be saved (biomass, lumped and pseudo-reactions are unbalanced by design)."}):null]})}const wM=["reaction-editor","metabolite-editor","boundary","delete-reaction","delete-metabolite","validate-model","unsaved-edits"];function CM({d:e}){const t=()=>S.setState({dialog:null});switch(e.kind){case"reaction-editor":return n.jsx(jM,{id:e.id,init:e.init,onClose:t},e.id??"new");case"metabolite-editor":return n.jsx(kM,{id:e.id,init:e.init,close:t},e.id??JSON.stringify(e.init??{}));case"boundary":return n.jsx(MM,{met:e.metabolite,kind:e.type,close:t},e.metabolite);case"delete-reaction":return n.jsx(EM,{id:e.id,close:t},e.id);case"delete-metabolite":return n.jsx(GM,{id:e.id,close:t},e.id);case"validate-model":return n.jsx(SM,{close:t});case"unsaved-edits":return n.jsx(AM,{close:t});default:return null}}function kM({id:e,init:t,close:i}){const[a,s]=E.useState(e||t?{kind:"create",name:(t==null?void 0:t.name)??""}:null);return e?n.jsx(Mi,{title:n.jsxs(n.Fragment,{children:["Edit metabolite ",n.jsx("span",{className:"mono",children:e})]}),onClose:i,width:640,children:n.jsx(Pu,{mode:"edit",origId:e,context:"standalone",onCancel:i,onDone:i})}):a?n.jsx(Mi,{title:a.kind==="import"?"Import metabolite from database":"Create new metabolite",onClose:i,width:640,children:n.jsx(Pu,{mode:a.kind==="import"?"import":"create",context:"standalone",candidate:a.kind==="import"?a.compound:void 0,review:a.kind==="import"&&a.review,init:{...t,...a.kind==="create"&&a.name?{name:a.name}:{}},onCancel:()=>e||t?i():s(null),onDone:i})}):n.jsxs(Mi,{title:"New metabolite",onClose:i,width:720,children:[n.jsx("div",{className:"muted small",children:"Search first: the model may already have the compound (in another compartment, or under another name)."}),n.jsx(e_,{onClose:i,onPick:o=>{o.kind==="model"||o.kind==="pending"?(i(),B.navigate({kind:"metabolite",id:o.id})):s(o)}})]})}const zl={exchange:{title:"Exchange",what:"Exchange with the environment, normally for extracellular metabolites. Negative flux = uptake, positive = secretion."},demand:{title:"Demand",what:"Removes the metabolite irreversibly from the system (e.g. a product accumulating in the cell)."},sink:{title:"Sink",what:"Artificial production or consumption of the metabolite, depending on the bounds (e.g. a compound supplied by unmodelled metabolism)."}};function ns(e,t,i){return e==="exchange"?[{key:"secretion",label:"Secretion only",lb:0,ub:t,hint:"no uptake"},{key:"limited",label:"Uptake limited",lb:-i,ub:t,hint:`uptake ≤ ${i}`},{key:"both",label:"Uptake + secretion",lb:-t,ub:t,hint:"unlimited uptake"},{key:"closed",label:"Closed",lb:0,ub:0,hint:"no flux"}]:e==="sink"?[{key:"remove",label:"Consume only",lb:0,ub:t,hint:"removes the metabolite"},{key:"supply",label:"Supply only",lb:-t,ub:0,hint:"provides the metabolite"},{key:"both",label:"Both directions",lb:-t,ub:t,hint:"COBRA default sink"}]:[{key:"demand",label:"Remove",lb:0,ub:t,hint:"irreversible"}]}function MM({met:e,kind:t,close:i}){const a=S(O=>O.model),s=S(O=>O.index),o=s.met.get(e),l=s.maxBound||1e3,[r,c]=E.useState(t),[d,f]=E.useState(10),[u,p]=E.useState(ns(t,l,10)[0].key),[m,h]=E.useState(ns(t,l,10)[0].lb),[g,y]=E.useState(ns(t,l,10)[0].ub),[b,_]=E.useState(()=>ug(a,s,t,e)),[x,v]=E.useState(!1),[j,N]=E.useState(null),[C,w]=E.useState(!1),[k,P]=E.useState(null),H=uM(a,s),G=mM(s,e),M=G.filter(O=>O.kind===r),A=G.filter(O=>O.kind!==r),X=r==="exchange"&&!!H&&(o==null?void 0:o.compartment)!==H,I=ns(r,l,d),K=O=>{const Z=ns(r,l,d).find(oe=>oe.key===O);p(O),h(Z.lb),y(Z.ub)};E.useEffect(()=>{const O=ns(r,l,10)[0];p(O.key),h(O.lb),y(O.ub),_(ug(a,s,r,e)),v(!1)},[r]),E.useEffect(()=>{u==="limited"&&h(-d)},[d,u]);const L=`${(o==null?void 0:o.name)||e} ${r==="exchange"?"exchange":r==="sink"?"sink":"demand"}`,D=()=>[{op:"put_reaction",reaction:{id:b.trim(),name:L,lb:m,ub:g,subsystem:"",gpr:"",metabolites:{[e]:-1},annotation:{sbo:cM[r]},objective:0}}],F=Xn(JSON.stringify([b,m,g,r]),250);if(E.useEffect(()=>{let O=!0;return b.trim()&&Xe.check(D()).then(Z=>O&&N(Z)),()=>{O=!1}},[F]),!o)return null;const U=m!=null&&g!=null&&m>g||!b.trim()||s.rxn.has(b.trim()),z=async()=>{w(!0);const O=await Xe.commit(D(),`Added ${r} ${b.trim()} (${m??"−∞"} / ${g??"∞"})`);w(!1),O.ok?(i(),B.navigate({kind:"reaction",id:b.trim()})):P(O.error.message||O.error.title)};return n.jsxs(Mi,{title:n.jsxs(n.Fragment,{children:["Create boundary reaction · ",n.jsx("span",{className:"mono",children:e})]}),onClose:i,width:600,footer:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"grow"}),k&&n.jsx("span",{className:"ef-err",children:k}),n.jsx("button",{className:"btn",onClick:i,children:"Cancel"}),n.jsxs("button",{className:"btn primary",disabled:U||C||M.length>0||X&&!x,onClick:z,children:[C&&n.jsx("span",{className:"spinner sm light"})," Create ",zl[r].title.toLowerCase()]})]}),children:[n.jsx("div",{className:"bd-kinds",children:["exchange","sink","demand"].map(O=>n.jsxs("button",{className:`bd-kind ${r===O?"on":""}`,onClick:()=>c(O),children:[n.jsx("b",{children:zl[O].title}),n.jsx("span",{className:"small muted",children:zl[O].what})]},O))}),n.jsxs("div",{className:"small",children:[n.jsx("b",{children:o.name||e})," ",n.jsx("span",{className:"mono muted",children:e})," · ",a.compartments[o.compartment]??o.compartment]}),M.length>0&&n.jsxs("div",{className:"ed-msg warn bd-exists",children:[n.jsx("span",{children:"⚠"}),n.jsxs("div",{children:[zl[r].title," already exists: ",M.map(O=>n.jsxs("b",{className:"mono",children:[O.id," "]},O.id)),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:()=>{i(),B.navigate({kind:"reaction",id:M[0].id})},children:"Open reaction"}),n.jsx("span",{className:"muted small",children:"Edit its bounds there instead of creating a duplicate."})]})]})]}),A.length>0&&!M.length&&n.jsxs("div",{className:"ed-msg info",children:[n.jsx("span",{children:"i"}),"This metabolite already has a boundary reaction of another kind: ",A.map(O=>`${O.id} (${O.kind})`).join(", "),". A new ",r," adds the same stoichiometry."]}),X&&n.jsxs("label",{className:"ed-msg warn",children:[n.jsx("span",{children:"⚠"}),n.jsxs("span",{children:["This metabolite is in ",a.compartments[o.compartment]??o.compartment,", not in the extracellular compartment (",a.compartments[H]??H,"). Exchange reactions are normally associated with extracellular metabolites. A sink or demand may be what you need.",n.jsxs("span",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:x,onChange:O=>v(O.target.checked)})," Create the exchange anyway"]})]})]}),n.jsx(ft,{label:"Reaction ID",hint:`Follows the model's ${r} prefix`,children:n.jsx("input",{className:"input mono",value:b,onChange:O=>_(O.target.value)})}),n.jsx("div",{className:"insp-sub",children:"Bounds"}),n.jsxs("div",{className:"bd-presets",children:[I.map(O=>n.jsxs("button",{className:`chip-btn ${u===O.key?"on":""}`,onClick:()=>K(O.key),title:`${rt(O.lb,"lower")} / ${rt(O.ub,"upper")}`,children:[O.label," ",n.jsx("span",{className:"muted",children:O.key==="limited"?"":`${O.lb} / ${O.ub}`})]},O.key)),u==="limited"&&n.jsxs("label",{className:"small row gap",children:["max uptake ",n.jsx(wn,{value:d,onCommit:O=>f(Math.abs(O??10)),className:"tiny"})]})]}),n.jsxs("div",{className:"ef-grid",children:[n.jsx(ft,{label:"Lower bound",children:n.jsx(wn,{allowEmpty:!0,value:m,onCommit:O=>{h(O),p("")},placeholder:"−∞"})}),n.jsx(ft,{label:"Upper bound",children:n.jsx(wn,{allowEmpty:!0,value:g,onCommit:O=>{y(O),p("")},placeholder:"∞"})})]}),n.jsxs("div",{className:"re-preview mono small",children:[e," ",m!=null&&m>=0?"-->":g!=null&&g<=0?"<--":"<=>"," ∅ · ",rt(m,"lower")," ≤ v ≤ ",rt(g,"upper"),r==="exchange"&&n.jsxs("div",{className:"muted",children:["uptake allowed: ",m!=null&&m<0?`yes (≤ ${-m})`:m==null?"yes (unlimited)":"no"," · secretion allowed: ",g==null||g>0?"yes":"no"]})]}),n.jsx(f0,{report:j,skipWarn:O=>/Potential duplicate|normally associated with extracellular/.test(O)})]})}function EM({id:e,close:t}){const i=S(d=>d.index),a=S(d=>d.states),s=i.rxn.get(e),[o,l]=E.useState(!1);if(!s)return null;const r=a.filter(d=>d.bounds[e]).map(d=>d.name),c=async()=>{l(!0);const d=await Xe.commit([{op:"delete_reaction",id:e}],`Deleted reaction ${e}`);l(!1),d.ok&&t()};return n.jsxs(Mi,{title:n.jsxs(n.Fragment,{children:["Delete reaction ",n.jsx("span",{className:"mono",children:e}),"?"]}),onClose:t,width:520,footer:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:t,children:"Cancel"}),n.jsxs("button",{className:"btn danger",disabled:o,onClick:c,children:[n.jsx(q,{name:"trash",size:11})," Delete reaction"]})]}),children:[n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Name"}),n.jsx("span",{children:s.name||"—"})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Metabolites"}),n.jsx("span",{children:Object.keys(s.stoichiometry).length})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Genes"}),n.jsx("span",{className:"mono small",children:s.genes.join(", ")||"—"})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Subsystem"}),n.jsx("span",{children:s.subsystem||"—"})]}),n.jsx("div",{className:"mono small muted",children:s.equation}),n.jsxs("div",{className:"note small",children:["Its metabolites are kept, even if no other reaction uses them. Undo (Ctrl+Z) brings the reaction back.",r.length>0&&n.jsxs(n.Fragment,{children:[" Bound overrides in ",r.join(", ")," are dropped."]})]})]})}function GM({id:e,close:t}){const i=S(f=>f.index),a=i.met.get(e),s=i.metRxns.get(e)??[],[o,l]=E.useState(""),[r,c]=E.useState(!1);if(!a)return null;const d=async f=>{c(!0);const u=await Xe.commit([{op:"delete_metabolite",id:e,cascade:f}],f?`Deleted metabolite ${e} and ${s.length} reactions`:`Deleted metabolite ${e}`);c(!1),u.ok&&t()};return n.jsxs(Mi,{title:n.jsxs(n.Fragment,{children:["Delete metabolite ",n.jsx("span",{className:"mono",children:e}),"?"]}),onClose:t,width:560,footer:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:t,children:"Cancel"}),!s.length&&n.jsxs("button",{className:"btn danger",disabled:r,onClick:()=>d(!1),children:[n.jsx(q,{name:"trash",size:11})," Delete metabolite"]})]}),children:[n.jsxs("div",{children:[n.jsx("b",{children:a.name||e})," ",n.jsxs("span",{className:"muted",children:["· ",a.compartment]})]}),s.length?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"ed-msg warn",children:[n.jsx("span",{children:"⚠"}),"This metabolite participates in ",s.length," reaction",s.length>1?"s":"",". It cannot be deleted on its own."]}),n.jsxs("div",{className:"block-list",children:[s.slice(0,10).map(f=>{var u;return n.jsxs("div",{className:"kv small",children:[n.jsx("span",{className:"mono",children:f}),n.jsx("span",{className:"ellipsis",children:(u=i.rxn.get(f))==null?void 0:u.name})]},f)}),s.length>10&&n.jsxs("div",{className:"muted small",children:["…and ",s.length-10," more"]})]}),n.jsxs("details",{className:"bd-danger",children:[n.jsxs("summary",{className:"small",children:["Delete the metabolite ",n.jsxs("b",{children:["and these ",s.length," reactions"]}),"…"]}),n.jsxs("div",{className:"small",children:["This removes ",s.length," reaction",s.length>1?"s":""," from the model (undo restores them). Type ",n.jsx("span",{className:"mono",children:e})," to confirm."]}),n.jsxs("div",{className:"row gap",children:[n.jsx("input",{className:"input tiny mono grow",value:o,onChange:f=>l(f.target.value),placeholder:e}),n.jsxs("button",{className:"btn danger small",disabled:o!==e||r,onClick:()=>d(!0),children:["Delete metabolite and ",s.length," reactions"]})]})]})]}):n.jsx("div",{className:"note small",children:"No reaction uses it. Undo (Ctrl+Z) brings it back."})]})}function SM({close:e}){const t=S(d=>d.model),[i,a]=E.useState(null),[s,o]=E.useState(null),l=()=>{a(null),o(null),Se.validateModel(t.id).then(a,d=>o(d.message))};E.useEffect(l,[t.id,t.summary.reactions,t.summary.metabolites]);const r={error:0,warning:1,info:2},c=E.useMemo(()=>[...(i==null?void 0:i.issues)??[]].sort((d,f)=>r[d.level]-r[f.level]),[i]);return n.jsxs(Mi,{title:"Validate model",onClose:e,width:680,footer:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:l,children:"Run again"}),n.jsx("button",{className:"btn primary",onClick:e,children:"Close"})]}),children:[!i&&!s&&n.jsxs("div",{className:"muted small",children:[n.jsx("span",{className:"spinner sm"})," COBRApy is checking the model…"]}),s&&n.jsxs("div",{className:"ed-msg err",children:[n.jsx("span",{children:"✕"}),s]}),i&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"small",children:[i.reactions.toLocaleString()," reactions · ",i.metabolites.toLocaleString()," metabolites · ",i.edits," structural edit",i.edits===1?"":"s"," · ",c.filter(d=>d.level==="error").length?n.jsxs("b",{className:"warn-text",children:[c.filter(d=>d.level==="error").length," error types"]}):n.jsx("span",{className:"ok-text",children:"no errors"})]}),c.map(d=>n.jsxs("details",{className:`val-item lv-${d.level}`,open:d.level==="error",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`lv lv-${d.level}`,children:d.level})," ",n.jsx("b",{children:d.count.toLocaleString()})," ",d.title]}),d.detail&&n.jsx("div",{className:"muted small",children:d.detail}),n.jsxs("div",{className:"val-ids",children:[d.ids.slice(0,40).map(f=>n.jsx("button",{className:"link mono small",onClick:()=>{e(),B.navigate({kind:d.code.includes("metabolite")||["no-formula","no-charge","unknown-compartment"].includes(d.code)?"metabolite":"reaction",id:f})},children:f},f)),d.ids.length>40&&n.jsxs("span",{className:"muted small",children:["…",d.ids.length-40," more"]})]}),d.ids.length>0&&n.jsx("button",{className:"link small",onClick:()=>{e(),B.showInExplorer(d.code.includes("metabolite")||["no-formula","no-charge","unknown-compartment"].includes(d.code)?"metabolites":"reactions",d.ids,d.title)},children:"Show all in the explorer"})]},d.code)),!c.length&&n.jsx("div",{className:"ok-text",children:"No issue found."})]})]})}function AM({close:e}){const t=fi(S(a=>a.model)),i=()=>{Xe.dropPending(),e()};return n.jsxs(Mi,{title:"You have unsaved model changes",onClose:i,width:540,footer:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn",onClick:i,children:"Cancel"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn danger",onClick:async()=>{e(),await Xe.discard(),Xe.continuePending()},children:"Discard edits"}),n.jsx("button",{className:"btn",onClick:()=>{e(),Xe.continuePending()},title:"The edits stay in COBRAGUI and are re-applied when this model is opened again",children:"Keep for later"}),n.jsx("button",{className:"btn primary",onClick:()=>{Xe.dropPending(),S.setState({dialog:{kind:"export-model"}})},children:"Export model…"})]}),children:[n.jsxs("div",{children:["The working model has ",n.jsx("b",{children:(t==null?void 0:t.count)??0})," structural edit",(t==null?void 0:t.count)===1?"":"s"," that ",(t==null?void 0:t.count)===1?"is":"are"," not in any file yet."]}),n.jsx("ul",{className:"small",children:t==null?void 0:t.items.slice(-6).reverse().map(a=>n.jsx("li",{children:a.label},a.id))}),n.jsxs("div",{className:"muted small",children:[n.jsx("b",{children:"Export model"})," writes a new SBML / JSON / MAT file with the edits. ",n.jsx("b",{children:"Keep for later"})," leaves them in COBRAGUI: they are re-applied when this model is opened again. ",n.jsx("b",{children:"Discard"})," reverts the model to the imported file."]})]})}function Ya(e,t){S.setState({dialog:{kind:"reaction-editor",id:e,init:t},contextMenu:null})}function Ks(e,t){S.setState({dialog:{kind:"metabolite-editor",id:e,init:t},contextMenu:null})}function ks(e,t){S.setState({dialog:{kind:"boundary",metabolite:e,type:t},contextMenu:null})}const DM=["internal","transport","exchange","demand","sink"];function PM(){const e=S(I=>I.model),t=S(I=>I.index),i=S(I=>I.searchIndex),a=S(I=>I.explorerTab),s=S(I=>I.query),o=S(I=>I.hideZero),l=S(I=>I.rxnFilters),r=S(I=>I.metFilters),c=S(I=>I.sort),d=S(I=>I.settings),f=S(I=>I.favorites),u=S(I=>ee.fluxResult(I)),p=S(I=>ee.fvaResult(I)),m=S(I=>I.selection),[h,g]=E.useState(t.subsystems.size>0),y=E.useRef(null),b=Xn(s,110),_=zx(u,p),x=c[a],v=E.useMemo(()=>i.matchIds(b,a==="reactions"?"reaction":a==="metabolites"?"metabolite":"gene"),[i,b,a]),j=I=>v?I.filter(K=>v.has(K.id)).sort((K,L)=>v.get(L.id)-v.get(K.id)):I,N=E.useMemo(()=>{if(a!=="reactions")return[];const I=Lk(j(e.reactions),l,o,_);return oi(I,x,(K,L)=>Kx(K,L,_))},[a,e,v,l,o,_,x]),C=(u==null?void 0:u.metaboliteTurnover)??null,w=E.useMemo(()=>{if(a!=="metabolites")return[];const I=Tk(j(e.metabolites),r,o,C,d.zeroTolerance,new Set(f));return oi(I,x,(K,L)=>qx(K,L,C))},[a,e,v,r,o,C,d.zeroTolerance,f,x]),k=E.useMemo(()=>{const I=u==null?void 0:u.reactionFluxes;return K=>I?K.reactions.filter(L=>Math.abs(I[L]??0)>=d.zeroTolerance).length:null},[u,d.zeroTolerance]),P=E.useMemo(()=>{if(a!=="genes")return[];const I=j(e.genes).filter(K=>!(o&&u)||(k(K)??0)>0);return oi(I,x,(K,L)=>Wx(K,L,k))},[a,e,v,x,k,o,u]),H=I=>{const K=c[a];let L;I==="flux"&&(K==null?void 0:K.key)==="flux"&&K.dir==="desc"?L={key:"absFlux",dir:"desc"}:(K==null?void 0:K.key)===I?L=K.dir==="asc"?{key:I,dir:"desc"}:null:L={key:I,dir:["flux","absFlux","turnover","fvaRange","fvaWidth","active","reactions","genes","ub"].includes(I)?"desc":"asc"},B.setSort(a,L)},G={metabolites:e.metabolites.length,reactions:e.reactions.length,genes:e.genes.length},M=a==="reactions"?N.length:a==="metabolites"?w.length:P.length,A=a==="metabolites"?"Hide zero turnover":a==="genes"?"Only genes with active reactions":u?"Hide zero flux":p?"Hide blocked (FVA)":"Hide zero flux",X=a==="metabolites"?!C:!(u||a==="reactions"&&p);return n.jsxs("div",{className:"explorer",children:[n.jsxs("div",{className:"ex-toolbar",children:[n.jsx("div",{className:"ex-tabs",role:"tablist",children:["metabolites","reactions","genes"].map(I=>n.jsxs("button",{role:"tab",className:a===I?"on":"",onClick:()=>B.setTab(I),title:`${I[0].toUpperCase()} key`,children:[I[0].toUpperCase()+I.slice(1)," ",n.jsx("span",{className:"count",children:G[I].toLocaleString()})]},I))}),n.jsxs("div",{className:"search-box ex-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{ref:y,id:"lab-explorer-search",placeholder:a==="reactions"?"Search id, name, equation, metabolites, genes, subsystem, EC…":a==="metabolites"?"Search id, name, formula, compartment, annotations…":"Search gene id, name, reactions…",value:s,onChange:I=>S.setState({query:I.target.value}),onKeyDown:I=>{I.key==="Escape"&&(S.setState({query:""}),I.target.blur())}}),s?n.jsx("button",{className:"icon-btn tiny",onClick:()=>S.setState({query:""}),children:n.jsx(q,{name:"x",size:11})}):n.jsx("kbd",{children:"F"})]})]}),n.jsxs("div",{className:"ex-toolbar second",children:[n.jsx(pn,{checked:o,onChange:I=>S.setState({hideZero:I}),title:X?"Run a simulation first":`|value| < ${d.zeroTolerance} counts as zero (Settings)`,children:A}),a==="reactions"&&n.jsx(IM,{}),a==="reactions"&&n.jsx(HM,{}),a==="metabolites"&&n.jsx(OM,{}),a==="reactions"&&n.jsx(BM,{}),n.jsx($M,{}),t.subsystems.size>0&&a==="reactions"&&n.jsx("button",{className:`btn small ${h?"on":""}`,onClick:()=>g(!h),children:"Subsystems"}),n.jsx("span",{className:"grow"}),a==="reactions"&&n.jsxs("button",{className:"btn small",onClick:()=>Ya(),title:"Reaction builder",children:[n.jsx(q,{name:"plus",size:11})," Reaction"]}),a==="metabolites"&&n.jsxs("button",{className:"btn small",onClick:()=>Ks(),title:"Search the model and the databases, or create one",children:[n.jsx(q,{name:"plus",size:11})," Metabolite"]}),n.jsx(RM,{}),n.jsxs("span",{className:"muted small nowrap",children:[M.toLocaleString()," of ",G[a].toLocaleString()]})]}),n.jsx(LM,{}),n.jsxs("div",{className:"ex-body",children:[h&&a==="reactions"&&t.subsystems.size>0&&n.jsx(TM,{}),n.jsxs("div",{className:"ex-table",children:[a==="reactions"&&n.jsx(Ux,{rows:N,ctx:_,columns:d.reactionColumns,sort:x,onSort:H}),a==="metabolites"&&n.jsx(Vx,{rows:w,turnover:C,sort:x,onSort:H}),a==="genes"&&n.jsx(Yx,{rows:P,active:k,sort:x,onSort:H})]})]}),a==="reactions"&&m.reactions.length>0&&n.jsx(FM,{rows:N.map(I=>I.id)}),a==="metabolites"&&m.metabolites.length>0&&n.jsx(XM,{})]})}function RM(){const e=S(s=>ee.fluxResult(s)),t=S(s=>ee.fvaResult(s)),i=S(s=>s.activeStateId);if(!e&&!t)return n.jsx("span",{className:"muted small",children:"No simulation yet"});const a=(s,o)=>n.jsxs("button",{className:`result-chip ${s.modelStateId!==i?"other":""}`,onClick:()=>B.setSection("results"),title:s.modelStateId!==i?`From state “${s.metadata.state.name}” (not the active state)`:s.name,children:[n.jsx("i",{className:`m-${s.method}`}),o,": ",s.name,s.modelStateId!==i&&n.jsx("span",{className:"warn-dot",children:"●"})]});return n.jsxs("span",{className:"row gap",children:[e&&a(e,"Flux"),t&&a(t,"FVA")]})}function IM(){var i;const e=S(a=>a.sort.reactions),t=((i=og.find(a=>a.key===(e==null?void 0:e.key)&&a.dir===(e==null?void 0:e.dir)))==null?void 0:i.label)??(e?`${e.key} ${e.dir==="asc"?"↑":"↓"}`:"Relevance");return n.jsx(Kt,{trigger:(a,s)=>n.jsxs("button",{className:`btn small ${a?"on":""}`,onClick:s,children:["Sort: ",t," ▾"]}),children:a=>n.jsxs("div",{className:"menu-list",children:[og.map(s=>n.jsx("button",{className:(e==null?void 0:e.key)===s.key&&e.dir===s.dir?"on":"",onClick:()=>{B.setSort("reactions",{key:s.key,dir:s.dir}),a()},children:s.label},s.key+s.dir)),n.jsx("div",{className:"dd-sep"}),n.jsx("button",{onClick:()=>{B.setSort("reactions",null),a()},children:"Default / relevance"})]})})}function BM(){const e=S(t=>t.settings.reactionColumns);return n.jsx(Kt,{trigger:(t,i)=>n.jsx("button",{className:`btn small ${t?"on":""}`,onClick:i,children:"Columns ▾"}),children:()=>n.jsx("div",{className:"menu-list checks",children:sg.map(t=>n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:e.includes(t.key),disabled:t.key==="id",onChange:i=>B.setSettings({reactionColumns:i.target.checked?sg.map(a=>a.key).filter(a=>a===t.key||e.includes(a)):e.filter(a=>a!==t.key)})})," ",t.label]},t.key))})})}function HM(){const e=S(d=>d.rxnFilters),t=S(d=>d.model),i=S(d=>d.index),[a,s]=E.useState(""),o=d=>S.setState(f=>{const u={...f.rxnFilters,...d};for(const p of Object.keys(u)){const m=u[p];(m==null||Array.isArray(m)&&!m.length||m===!1)&&delete u[p]}return{rxnFilters:u}}),l=(d,f)=>d!=null&&d.includes(f)?d.filter(u=>u!==f):[...d??[],f],r=Object.keys(e).length,c=[...i.subsystems.keys()].sort().filter(d=>d.toLowerCase().includes(a.toLowerCase()));return n.jsx(Kt,{className:"filter-pop",trigger:(d,f)=>n.jsxs("button",{className:`btn small ${d||r?"on":""}`,onClick:f,children:[n.jsx(q,{name:"tidy",size:12})," Filters",r?` · ${r}`:""," ▾"]}),children:()=>n.jsxs("div",{className:"filters",children:[n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Flux (active result)"}),n.jsxs("div",{className:"row gap",children:[n.jsx("span",{className:"small",children:"|flux| >"}),n.jsx("input",{className:"input tiny num",type:"number",step:"any",value:e.absFluxGt??"",onChange:d=>o({absFluxGt:d.target.value===""?void 0:+d.target.value})}),n.jsx("span",{className:"small",children:"|flux| <"}),n.jsx("input",{className:"input tiny num",type:"number",step:"any",value:e.absFluxLt??"",onChange:d=>o({absFluxLt:d.target.value===""?void 0:+d.target.value})})]})]}),n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Bounds"}),n.jsxs("div",{className:"row gap wrap",children:[["reversible","irreversible","blocked"].map(d=>n.jsx("button",{className:`chip-btn ${e.reversibility===d?"on":""}`,onClick:()=>o({reversibility:e.reversibility===d?void 0:d}),children:d},d)),n.jsx("button",{className:`chip-btn ${e.modifiedOnly?"on":""}`,onClick:()=>o({modifiedOnly:!e.modifiedOnly}),children:"modified"})]})]}),n.jsxs("div",{className:"f-group",children:[n.jsxs("div",{className:"f-title",children:["Type ",n.jsx("span",{className:"muted small",children:"(click: only · ⌫ hide)"})]}),n.jsx("div",{className:"row gap wrap",children:DM.map(d=>{var f,u;return n.jsxs("span",{className:"type-filter",children:[n.jsx("button",{className:`chip-btn ${(f=e.types)!=null&&f.includes(d)?"on":""} ${(u=e.hideTypes)!=null&&u.includes(d)?"off":""}`,onClick:()=>{var p;return o({types:l(e.types,d),hideTypes:(p=e.hideTypes)==null?void 0:p.filter(m=>m!==d)})},children:d}),n.jsx("button",{className:"chip-x",title:`Hide ${d}`,onClick:()=>{var p;return o({hideTypes:l(e.hideTypes,d),types:(p=e.types)==null?void 0:p.filter(m=>m!==d)})},children:"⌫"})]},d)})})]}),n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Genes"}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:`chip-btn ${e.genes==="with"?"on":""}`,onClick:()=>o({genes:e.genes==="with"?void 0:"with"}),children:"gene-associated"}),n.jsx("button",{className:`chip-btn ${e.genes==="without"?"on":""}`,onClick:()=>o({genes:e.genes==="without"?void 0:"without"}),children:"no gene association"}),n.jsx("button",{className:`chip-btn ${e.favoritesOnly?"on":""}`,onClick:()=>o({favoritesOnly:!e.favoritesOnly}),children:"★ favorites"})]})]}),n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Compartment"}),n.jsx("div",{className:"row gap wrap",children:Object.entries(t.compartments).map(([d,f])=>{var u;return n.jsx("button",{className:`chip-btn ${(u=e.compartments)!=null&&u.includes(d)?"on":""}`,onClick:()=>o({compartments:l(e.compartments,d)}),children:f},d)})})]}),i.subsystems.size>0&&n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Subsystem"}),n.jsx("input",{className:"input tiny",placeholder:"Filter subsystems…",value:a,onChange:d=>s(d.target.value)}),n.jsx("div",{className:"f-scroll",children:c.map(d=>{var f;return n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:!!((f=e.subsystems)!=null&&f.includes(d)),onChange:()=>o({subsystems:l(e.subsystems,d)})})," ",n.jsx("span",{className:"ellipsis",children:d})," ",n.jsx("span",{className:"muted",children:i.subsystems.get(d).length})]},d)})})]}),n.jsx("div",{className:"row end",children:n.jsx("button",{className:"btn small",onClick:()=>S.setState({rxnFilters:{}}),children:"Clear all"})})]})})}function OM(){var s;const e=S(o=>o.metFilters),t=S(o=>o.model),i=o=>S.setState(l=>{const r=l.metFilters.compartments??[],c=r.includes(o)?r.filter(d=>d!==o):[...r,o];return{metFilters:{...l.metFilters,compartments:c.length?c:void 0}}}),a=((s=e.compartments)!=null&&s.length?1:0)+(e.favoritesOnly?1:0);return n.jsx(Kt,{className:"filter-pop",trigger:(o,l)=>n.jsxs("button",{className:`btn small ${o||a?"on":""}`,onClick:l,children:["Filters",a?` · ${a}`:""," ▾"]}),children:()=>n.jsxs("div",{className:"filters",children:[n.jsxs("div",{className:"f-group",children:[n.jsx("div",{className:"f-title",children:"Compartment"}),n.jsx("div",{className:"row gap wrap",children:Object.entries(t.compartments).map(([o,l])=>{var r;return n.jsx("button",{className:`chip-btn ${(r=e.compartments)!=null&&r.includes(o)?"on":""}`,onClick:()=>i(o),children:l},o)})})]}),n.jsx("div",{className:"f-group",children:n.jsx("button",{className:`chip-btn ${e.favoritesOnly?"on":""}`,onClick:()=>S.setState(o=>({metFilters:{...o.metFilters,favoritesOnly:!o.metFilters.favoritesOnly||void 0}})),children:"★ favorites only"})})]})})}function $M(){const e=S(a=>a.savedViews),[t,i]=E.useState(!1);return n.jsx(Kt,{trigger:(a,s)=>n.jsx("button",{className:`btn small ${a?"on":""}`,onClick:s,children:"Views ▾"}),children:a=>n.jsxs("div",{className:"menu-list",children:[n.jsx("div",{className:"menu-label",children:"Built-in"}),_x.map(s=>n.jsx("button",{onClick:()=>{B.applyView(s),a()},children:s.name},s.id)),e.length>0&&n.jsx("div",{className:"menu-label",children:"Saved"}),e.map(s=>n.jsxs("div",{className:"menu-row",children:[n.jsx("button",{onClick:()=>{B.applyView(s),a()},children:s.name}),n.jsx("button",{className:"icon-btn tiny",onClick:()=>B.deleteView(s.id),children:n.jsx(q,{name:"x",size:10})})]},s.id)),n.jsx("div",{className:"dd-sep"}),t?n.jsx("input",{className:"input tiny",autoFocus:!0,placeholder:"View name, then Enter",onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.value.trim()&&(B.saveView(s.currentTarget.value.trim()),i(!1),a()),s.key==="Escape"&&i(!1)}}):n.jsx("button",{onClick:()=>i(!0),children:"+ Save current search & filters…"})]})})}function LM(){var r,c,d,f,u;const e=S(p=>p.rxnFilters),t=S(p=>p.metFilters),i=S(p=>p.explorerTab),a=S(p=>{var m;return((m=p.model)==null?void 0:m.compartments)??{}}),s=S(p=>p.hideZero),o=[],l=p=>()=>S.setState(m=>{const h={...m.rxnFilters};return delete h[p],{rxnFilters:h}});return i==="reactions"?(s&&o.push({label:"Hide zero flux",clear:()=>S.setState({hideZero:!1})}),e.ids&&o.push({label:e.ids.label,clear:l("ids")}),e.absFluxGt!=null&&o.push({label:`|flux| > ${e.absFluxGt}`,clear:l("absFluxGt")}),e.absFluxLt!=null&&o.push({label:`|flux| < ${e.absFluxLt}`,clear:l("absFluxLt")}),e.reversibility&&o.push({label:e.reversibility,clear:l("reversibility")}),e.modifiedOnly&&o.push({label:"Modified bounds",clear:l("modifiedOnly")}),(r=e.types)!=null&&r.length&&o.push({label:`Only ${e.types.join(", ")}`,clear:l("types")}),(c=e.hideTypes)!=null&&c.length&&o.push({label:`Hide ${e.hideTypes.join(", ")}`,clear:l("hideTypes")}),e.genes&&o.push({label:e.genes==="with"?"Gene-associated":"No gene association",clear:l("genes")}),(d=e.subsystems)!=null&&d.length&&o.push({label:e.subsystems.length===1?e.subsystems[0]:`${e.subsystems.length} subsystems`,clear:l("subsystems")}),(f=e.compartments)!=null&&f.length&&o.push({label:e.compartments.map(p=>a[p]??p).join(", "),clear:l("compartments")}),e.favoritesOnly&&o.push({label:"★ Favorites",clear:l("favoritesOnly")})):i==="metabolites"&&(s&&o.push({label:"Hide zero turnover",clear:()=>S.setState({hideZero:!1})}),t.ids&&o.push({label:t.ids.label,clear:()=>S.setState(p=>({metFilters:{...p.metFilters,ids:void 0}}))}),(u=t.compartments)!=null&&u.length&&o.push({label:t.compartments.map(p=>a[p]??p).join(", "),clear:()=>S.setState(p=>({metFilters:{...p.metFilters,compartments:void 0}}))}),t.favoritesOnly&&o.push({label:"★ Favorites",clear:()=>S.setState(p=>({metFilters:{...p.metFilters,favoritesOnly:void 0}}))})),o.length?n.jsxs("div",{className:"filter-chips",children:[o.map(p=>n.jsxs("span",{className:"fchip",children:[p.label,n.jsx("button",{onClick:p.clear,title:"Remove filter",children:"×"})]},p.label)),o.length>1&&n.jsx("button",{className:"link small",onClick:()=>S.setState({rxnFilters:{},metFilters:{},hideZero:!1}),children:"Clear all"})]}):null}function TM(){const e=Kn("lab-subsystems",230,150,520),t=S(m=>m.index),i=S(m=>m.rxnFilters.subsystems),a=S(m=>ee.fluxResult(m)),s=S(m=>m.settings.zeroTolerance),o=S(m=>m.selection.reactions),[l,r]=E.useState(""),c=E.useMemo(()=>[...t.subsystems.entries()].sort((m,h)=>m[0].localeCompare(h[0])),[t]),d=E.useMemo(()=>new Set(o),[o]),f=c.filter(([m])=>`${m} ${ct(m)}`.toLowerCase().includes(l.toLowerCase())),u=c.filter(([,m])=>m.every(h=>d.has(h))).length,p=(m,h)=>{const g=new Set(m);B.setSelection("reactions",h?o.filter(y=>!g.has(y)):[...o,...m.filter(y=>!d.has(y))])};return n.jsxs("div",{className:"subsys",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"right"}),n.jsx("input",{className:"input tiny",placeholder:"Subsystems…",value:l,onChange:m=>r(m.target.value)}),u>0&&n.jsxs("div",{className:"subsys-selnote small muted",children:[u," subsystem",u>1?"s":""," selected · ",o.length," reactions"]}),n.jsx("div",{className:"subsys-list",children:f.map(([m,h])=>{const g=a!=null&&a.reactionFluxes?h.filter(x=>Math.abs(a.reactionFluxes[x]??0)>=s).length:null,y=(i==null?void 0:i.length)===1&&i[0]===m,b=h.reduce((x,v)=>x+(d.has(v)?1:0),0),_=b===h.length;return n.jsxs("div",{className:`subsys-item ${y?"on":""} ${_?"picked":""}`,title:m,children:[n.jsx("input",{type:"checkbox",checked:_,ref:x=>{x&&(x.indeterminate=b>0&&!_)},title:_?`Deselect the ${h.length} reactions`:`Select all ${h.length} reactions (e.g. for FVA on selection)`,onChange:()=>p(h,_)}),n.jsxs("button",{className:"subsys-name",onClick:()=>{S.setState(x=>({rxnFilters:{...x.rxnFilters,subsystems:y?void 0:[m]}})),y||B.navigate({kind:"subsystem",id:m})},children:[n.jsx("span",{className:"ellipsis",children:ct(m)}),n.jsxs("span",{className:"muted mono",children:[g!=null?`${g}/`:"",h.length]})]})]},m)})})]})}function n_(e,t){const i=document.createElement("a");i.href=URL.createObjectURL(new Blob([t],{type:"text/csv"})),i.download=e,i.click()}function FM({rows:e}){const t=S(l=>l.selection.reactions),i=S(l=>l.index),a=S(l=>ee.fluxResult(l)),s=S(l=>ee.activeState(l)),o=()=>n_("reactions_selection.csv",cx([["reaction","name","equation","lower_bound","upper_bound","flux"],...t.map(l=>{var d;const r=i.rxn.get(l),c=ee.bounds(s,r);return[l,r.name,r.equation,c[0],c[1],((d=a==null?void 0:a.reactionFluxes)==null?void 0:d[l])??""]})]));return n.jsxs("div",{className:"action-bar",children:[n.jsxs("b",{children:[t.length," reaction",t.length>1?"s":""," selected"]}),n.jsxs("button",{className:"btn small primary",onClick:()=>vn(t),children:[n.jsx(q,{name:"plus",size:12})," Add to Map"]}),n.jsx("button",{className:"btn small",onClick:()=>S.setState({dialog:{kind:"confirm-block",rids:t}}),children:"Block…"}),n.jsx("button",{className:"btn small",onClick:()=>B.resetBounds(t),disabled:!t.some(l=>s.bounds[l]),children:"Reset bounds"}),n.jsx("button",{className:"btn small",onClick:()=>{B.simulate("fva",{reactions:t}),B.setSection("simulate")},title:"Flux variability of just these reactions (fast on large models)",children:"FVA on selection"}),n.jsx("button",{className:"btn small",onClick:()=>B.showInExplorer("reactions",t,`Selection (${t.length})`),children:"Filter to selection"}),n.jsx("button",{className:"btn small",onClick:o,children:"Export CSV"}),n.jsxs("button",{className:"btn small",onClick:()=>B.setSelection("reactions",e),disabled:t.length===e.length,children:["Select all ",e.length]}),n.jsx("button",{className:"btn small",onClick:()=>B.clearSelection(),children:"Clear"}),a&&n.jsxs("span",{className:"muted small",children:["Σ|flux| ",W(t.reduce((l,r)=>{var c;return l+Math.abs(((c=a.reactionFluxes)==null?void 0:c[r])??0)},0))]})]})}function XM(){const e=S(s=>s.selection.metabolites),t=S(s=>s.index),i=S(s=>{var o;return(o=ee.fluxResult(s))==null?void 0:o.metaboliteTurnover}),a=()=>{const s=Array.from(new Set(e.flatMap(o=>t.metRxns.get(o)??[])));B.showInExplorer("reactions",s,`Connected to ${e.length} metabolite${e.length>1?"s":""}`)};return n.jsxs("div",{className:"action-bar",children:[n.jsxs("b",{children:[e.length," metabolite",e.length>1?"s":""," selected"]}),n.jsxs("button",{className:"btn small primary",onClick:()=>Fs(e),children:[n.jsx(q,{name:"plus",size:12})," Add to Map"]}),n.jsx("button",{className:"btn small",onClick:a,children:"Connected reactions"}),n.jsx("button",{className:"btn small",onClick:()=>n_("metabolites_selection.csv",cx([["metabolite","name","formula","compartment","turnover"],...e.map(s=>{const o=t.met.get(s);return[s,o.name,o.formula,o.compartment,(i==null?void 0:i[s])??""]})])),children:"Export CSV"}),n.jsx("button",{className:"btn small",onClick:()=>B.clearSelection(),children:"Clear"})]})}const KM=".section, .li-sec",zM=".section-title, .insp-sub",i_=e=>`gemsmap.collapsed.${e}`,UM=e=>{try{return new Set(JSON.parse(localStorage.getItem(i_(e))||"[]"))}catch{return new Set}},Td=(e,t)=>{try{localStorage.setItem(i_(e),JSON.stringify([...t]))}catch{}},qM=e=>e.split(/[(·:]/)[0].replace(/\d+/g,"").replace(/\s+/g," ").trim().toLowerCase();function VM(e,t){let i=t;for(;i&&i.parentElement!==e;)i=i.parentElement;return i}function pl(e){const[t,i]=E.useState(null),[a,s]=E.useState(()=>UM(e)),o=E.useRef(a);o.current=a;const l=E.useCallback(()=>{t&&t.querySelectorAll(KM).forEach(d=>{const f=d.querySelector(zM),u=f&&VM(d,f);if(!f||!u||u!==d.firstElementChild||d.children.length<2){d.removeAttribute("data-foldable"),d.removeAttribute("data-collapsed");return}const p=qM(f.textContent??"");p&&(d.setAttribute("data-foldable",p),u.setAttribute("data-sec-head",""),f.setAttribute("data-sec-title",""),o.current.has(p)?d.setAttribute("data-collapsed",""):d.removeAttribute("data-collapsed"))})},[t]);return E.useEffect(()=>{if(!t)return;l();let d;const f=new MutationObserver(()=>{clearTimeout(d),d=window.setTimeout(l,0)});f.observe(t,{childList:!0,subtree:!0});const u=p=>{const m=p.target;if(m.closest("button, a, input, select, label, textarea"))return;const h=m.closest("[data-sec-title]"),g=h==null?void 0:h.closest("[data-foldable]");if(!h||!g)return;const y=g.getAttribute("data-foldable");s(b=>{const _=new Set(b);return _.has(y)?_.delete(y):_.add(y),Td(e,_),_})};return t.addEventListener("click",u),()=>{f.disconnect(),clearTimeout(d),t.removeEventListener("click",u)}},[t,l,e]),E.useEffect(l,[a,l]),{ref:i,collapseAll:()=>{const d=Array.from((t==null?void 0:t.querySelectorAll("[data-foldable]"))??[]).map(u=>u.getAttribute("data-foldable")),f=new Set([...a,...d]);Td(e,f),s(f)},expandAll:()=>{const d=new Set;Td(e,d),s(d)}}}function Fc({api:e}){return n.jsxs("div",{className:"sections-bar",children:[n.jsx("span",{className:"muted small",children:"Sections"}),n.jsxs("button",{className:"link small",onClick:e.expandAll,title:"Show every section",children:[n.jsx(q,{name:"expandDown",size:11})," Expand all"]}),n.jsxs("button",{className:"link small",onClick:e.collapseAll,title:"Fold every section to its title (click a title to open it)",children:[n.jsx(q,{name:"expandUp",size:11})," Collapse all"]})]})}const Fd=112,gg=30,WM=9;function a_({center:e}){const t=S(u=>u.index),i=S(u=>ee.fluxResult(u)),a=S(u=>u.settings.zeroTolerance),s=S(u=>u.settings.showCofactorsInNetwork),[o,l]=E.useState("1"),r=E.useMemo(()=>{const u=(i==null?void 0:i.reactionFluxes)??null,p=G=>{if(s)return!1;const M=t.met.get(G);return Fa(M?{id:M.id,name:M.name,compartment:M.compartment}:void 0)},m=new Map,h=[],g=new Map,y=(G,M,A,X)=>{if(m.has(G))return G;const I=g.get(X)??[];return I.length>=WM?null:(I.push(G),g.set(X,I),m.set(G,{key:G,ref:M,label:A,x:X*Fd,y:0}),G)},b=G=>(u==null?void 0:u[G])??null,_=G=>{const M=b(G);return M==null?1:Math.abs(M)<a?.6:1+Math.min(4,Math.log10(1+Math.abs(M))*2)},x=G=>u!=null&&Math.abs(b(G)??0)<a,v=G=>G,j=G=>{var M;return((M=t.met.get(G))==null?void 0:M.name)||G},N=(G,M)=>{var I;const A=((I=t.rxn.get(G))==null?void 0:I.stoichiometry[M])??0,X=b(G);return Math.sign(A*(X!=null&&Math.abs(X)>=a?Math.sign(X):1))},C=(G,M)=>{var A;return Object.keys(((A=t.rxn.get(G))==null?void 0:A.stoichiometry)??{}).filter(X=>X!==M&&!p(X))},w=G=>[...G].sort((M,A)=>Math.abs(b(A)??0)-Math.abs(b(M)??0));if(e.kind==="metabolite"){const G=y(`m:${e.id}`,e,j(e.id),0);m.get(G).center=!0;const M=w(t.metRxns.get(e.id)??[]);for(const A of M){const X=N(A,e.id)>0?-1:1,I=y(`r:${A}`,{kind:"reaction",id:A},v(A),X);if(I){h.push(X<0?{a:I,b:G,w:_(A),dim:x(A)}:{a:G,b:I,w:_(A),dim:x(A)});for(const K of C(A,e.id).slice(0,2)){const L=y(`m:${K}`,{kind:"metabolite",id:K},j(K),X*2);if(L&&h.push(X<0?{a:L,b:I,w:_(A),dim:x(A)}:{a:I,b:L,w:_(A),dim:x(A)}),L&&o==="2")for(const D of w(t.metRxns.get(K)??[]).filter(F=>F!==A).slice(0,2)){const F=y(`r:${D}`,{kind:"reaction",id:D},v(D),X*3);F&&h.push({a:X<0?F:L,b:X<0?L:F,w:_(D),dim:x(D)})}}}}}else if(e.kind==="reaction"){const G=t.rxn.get(e.id),M=y(`r:${e.id}`,e,e.id,0);if(m.get(M).center=!0,G){const A=b(G.id),X=A!=null&&A<-a;for(const[I,K]of Object.entries(G.stoichiometry)){if(p(I))continue;const L=K<0!==X?-1:1,D=y(`m:${I}`,{kind:"metabolite",id:I},j(I),L);if(!D)continue;h.push(L<0?{a:D,b:M,w:_(G.id),dim:x(G.id)}:{a:M,b:D,w:_(G.id),dim:x(G.id)});const F=w((t.metRxns.get(I)??[]).filter(U=>U!==G.id)).slice(0,o==="2"?3:0);for(const U of F){const z=y(`r:${U}`,{kind:"reaction",id:U},U,L*2);if(!z)continue;const O=N(U,I)>0;h.push(O?{a:z,b:D,w:_(U),dim:x(U)}:{a:D,b:z,w:_(U),dim:x(U)})}}}}let k=0,P=0,H=1;for(const[G,M]of g)M.forEach((A,X)=>{const I=m.get(A);I.y=(X-(M.length-1)/2)*gg}),k=Math.min(k,G*Fd),P=Math.max(P,G*Fd),H=Math.max(H,M.length);return{nodes:[...m.values()],edges:h,minX:k,maxX:P,h:H*gg}},[e,t,i,a,s,o]);if(e.kind!=="metabolite"&&e.kind!=="reaction")return null;const c=60,d=`${r.minX-c} ${-r.h/2-16} ${r.maxX-r.minX+c*2} ${r.h+32}`,f=new Map(r.nodes.map(u=>[u.key,u]));return n.jsxs("div",{className:"localnet",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:"insp-sub",children:"Local network"}),n.jsxs("div",{className:"row gap",children:[n.jsxs("label",{className:"check small",title:"Show ATP, NAD(P)H, H₂O, H⁺, CO₂…",children:[n.jsx("input",{type:"checkbox",checked:s,onChange:u=>B.setSettings({showCofactorsInNetwork:u.target.checked})})," cofactors"]}),n.jsx(jn,{value:o,options:["1","2"],onChange:l,labels:{1:"1 hop",2:"2 hops"}})]})]}),r.nodes.length<=1?n.jsx("div",{className:"muted small",children:"No non-cofactor neighbours."}):n.jsxs("svg",{className:"localnet-svg",viewBox:d,style:{height:qe(Math.min(340,r.h+40))},children:[n.jsx("defs",{children:n.jsx("marker",{id:"ln-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto-start-reverse",children:n.jsx("path",{d:"M0 0L10 5L0 10z",fill:"currentColor"})})}),r.edges.map((u,p)=>{const m=f.get(u.a),h=f.get(u.b),g=h.x-m.x,y=m.x+Math.sign(g)*26,b=h.x-Math.sign(g)*30;return n.jsx("path",{className:`ln-edge ${u.dim?"dim":""}`,d:`M${y},${m.y} C${(y+b)/2},${m.y} ${(y+b)/2},${h.y} ${b},${h.y}`,strokeWidth:u.w,markerEnd:"url(#ln-arrow)"},p)}),r.nodes.map(u=>{var p;return n.jsxs("g",{className:`ln-node k-${u.ref.kind} ${u.center?"center":""}`,transform:`translate(${u.x},${u.y})`,onClick:()=>!u.center&&B.navigate(u.ref),children:[n.jsxs("title",{children:[u.ref.id,u.ref.kind==="metabolite"?` — ${u.label}`:` — ${((p=t.rxn.get(u.ref.id))==null?void 0:p.name)??""}`]}),u.ref.kind==="reaction"?n.jsx("rect",{x:-27,y:-9,width:54,height:18,rx:4}):n.jsx("rect",{x:-27,y:-9,width:54,height:18,rx:9}),n.jsx("text",{y:3.5,textAnchor:"middle",children:u.label.length>11?u.label.slice(0,10)+"…":u.label})]},u.key)})]})]})}const YM=e=>new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function ZM(){const e=S(a=>a.model),t=fi(e),i=(t==null?void 0:t.count)??0;return n.jsx(Kt,{align:"right",className:"changes-pop edits-pop",trigger:(a,s)=>n.jsx("button",{className:`mod-btn ${i?"mod edited":""} ${a?"on":""}`,onClick:s,title:i?"The working model differs from the imported file":"Structure: reactions, metabolites, boundary reactions",children:i?n.jsxs(n.Fragment,{children:[n.jsx(q,{name:"tidy",size:11})," Edited · ",i,(t==null?void 0:t.dirty)&&n.jsx("span",{className:"dirty-dot",title:"Not exported to a file yet",children:"●"})]}):n.jsxs("span",{className:"muted",children:[n.jsx(q,{name:"tidy",size:11})," Structure"]})}),children:a=>{var s;return n.jsxs("div",{className:"changes",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("b",{children:["Model changes · ",e.filename]}),n.jsxs("span",{className:"muted small",children:[i," edit",i===1?"":"s"]})]}),n.jsx("div",{className:"muted small",children:i?n.jsxs(n.Fragment,{children:["Simulations, the medium and exports use the edited model. Edits are kept in COBRAGUI and re-applied when this model is opened again",t!=null&&t.dirty?"; they are not in any file yet.":"; the last export includes them."]}):"The model is the imported file. Add or edit reactions and metabolites from the explorer, the inspector or the right-click menu."}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("button",{className:"btn small",onClick:()=>{a(),Ya()},children:[n.jsx(q,{name:"plus",size:11})," Reaction"]}),n.jsxs("button",{className:"btn small",onClick:()=>{a(),Ks()},children:[n.jsx(q,{name:"plus",size:11})," Metabolite"]}),n.jsx("button",{className:"btn small",onClick:()=>{a(),S.setState({dialog:{kind:"validate-model"}})},children:"Validate model"})]}),t!=null&&t.loadErrors.length?n.jsxs("div",{className:"ed-msg warn",children:[n.jsx("span",{children:"⚠"}),t.loadErrors.join(" ")]}):null,i>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"row gap",children:[n.jsxs("button",{className:"btn small",onClick:()=>{Xd("undo"),Xe.undo()},title:"Ctrl+Z walks back model edits and state changes in the order they were made",children:["Undo: ",(s=t.items[i-1])==null?void 0:s.label.slice(0,40)]}),t.redo.length>0&&n.jsx("button",{className:"btn small",onClick:()=>{Xd("redo"),Xe.redo()},children:"Redo"})]}),n.jsx("div",{className:"change-list",children:[...t.items].reverse().map(o=>n.jsxs("details",{className:"change",children:[n.jsxs("summary",{className:"row between",children:[n.jsx("span",{className:"small",children:o.label}),n.jsx("span",{className:"muted small",children:YM(o.time)})]}),(o.details??[]).map((l,r)=>n.jsx("div",{className:"mono small",children:l},r))]},o.id))}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small primary",onClick:()=>{a(),S.setState({dialog:{kind:"export-model"}})},children:"Export model…"}),n.jsx("button",{className:"btn small",onClick:()=>Xe.exportPatch(),title:"model_patch.json: the edits and their net effect (added / removed / changed), to document or reproduce them",children:"Export patch"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn small danger",onClick:()=>{window.confirm(`Revert all ${i} structural edits? The model becomes the imported file again.`)&&(a(),Xe.discard())},children:"Discard all"})]})]}),!i&&(t!=null&&t.redo.length)?n.jsxs("button",{className:"btn small",onClick:()=>{Xd("redo"),Xe.redo()},children:["Redo: ",t.redo[0].label]}):null]})}})}function s_(e){var s;const t=S.getState(),i=(s=t.index)==null?void 0:s.rxn.get(e);if(!i||!t.model)return;const a=t_(i,t.model,t.index);Ya(void 0,{...a,id:h0(`${e}_copy`,o=>t.index.rxn.has(o)),name:a.name?`${a.name} (copy)`:""})}function o_(e){var i;const t=(i=S.getState().index)==null?void 0:i.met.get(e);t&&Ks(void 0,{name:t.name,compartment:t.compartment,formula:t.formula??"",charge:t.charge,annotation:t.annotation})}function l_(e,t="reactant"){var a;const i=(a=S.getState().index)==null?void 0:a.met.get(e);Ya(void 0,{rows:[{key:ti("row"),met:e,amount:1,side:t}],...i?{compartment:i.compartment}:{}})}function Xd(e){S.setState(t=>{const i=e==="undo"?t.undoOrder:t.redoOrder,a=i.lastIndexOf("model"),s=a<0?i:[...i.slice(0,a),...i.slice(a+1)];return e==="undo"?{undoOrder:s,redoOrder:[...t.redoOrder,"model"]}:{redoOrder:s,undoOrder:[...t.undoOrder,"model"]}})}const QM=(e,t)=>{var i;(i=navigator.clipboard)==null||i.writeText(e).then(()=>V().toast(`Copied ${t}`),()=>V().toast("Clipboard unavailable"))};function JM(){const e=Kn("lab-inspector",344,260,760),t=pl("lab-inspector"),i=S(l=>l.inspectorOpen),a=S(l=>l.nav),s=S(l=>l.index);if(!i||!s)return null;const o=a.stack[a.index];return n.jsxs("aside",{className:"lab-inspector",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"left"}),n.jsxs("div",{className:"li-nav",children:[n.jsx("button",{className:"icon-btn",title:"Back (Alt ←)",disabled:a.index<=0,onClick:B.back,children:n.jsx(q,{name:"chevL",size:15})}),n.jsx("button",{className:"icon-btn",title:"Forward (Alt →)",disabled:a.index>=a.stack.length-1,onClick:B.forward,children:n.jsx(q,{name:"chevR",size:15})}),n.jsx(e4,{}),n.jsx("button",{className:"icon-btn",title:"Close inspector",onClick:()=>S.setState({inspectorOpen:!1}),children:n.jsx(q,{name:"x",size:13})})]}),n.jsx(Fc,{api:t}),n.jsx("div",{className:"li-body",ref:t.ref,children:n.jsxs("div",{children:[!o&&n.jsx(t4,{}),(o==null?void 0:o.kind)==="metabolite"&&n.jsx(n4,{id:o.id}),(o==null?void 0:o.kind)==="reaction"&&n.jsx(i4,{id:o.id}),(o==null?void 0:o.kind)==="gene"&&n.jsx(s4,{id:o.id}),(o==null?void 0:o.kind)==="subsystem"&&n.jsx(o4,{id:o.id})]},o?`${o.kind}:${o.id}:${a.index}`:"empty")})]})}function e4(){const e=S(s=>s.nav),t=S(s=>s.index),i=Math.max(0,e.stack.length-7),a=s=>{var o;return s.kind==="metabolite"&&((o=t.met.get(s.id))==null?void 0:o.name)||s.id};return n.jsxs("div",{className:"crumbs",children:[i>0&&n.jsx("span",{className:"muted",children:"…"}),e.stack.slice(i).map((s,o)=>{const l=i+o;return n.jsxs("span",{className:"crumb-wrap",children:[o>0||i>0?n.jsx("span",{className:"crumb-sep",children:"›"}):null,n.jsx("button",{className:`crumb k-${s.kind} ${l===e.index?"on":""}`,title:`${s.kind}: ${s.id}`,onClick:()=>B.goTo(l),children:a(s)})]},l)})]})}function t4(){return n.jsxs("div",{className:"li-empty",children:[n.jsx("div",{className:"insp-title",children:"Inspector"}),n.jsx("p",{className:"muted small",children:"Click any metabolite, reaction or gene — in a table, an equation, a search result or the local network — to inspect it here. Keep clicking to walk through the network; use ← → (Alt ←/→) to go back."}),n.jsxs("p",{className:"muted small",children:["Press ",n.jsx("kbd",{children:"Ctrl K"})," to search the whole model."]})]})}function Xc({kind:e,title:t,sub:i,r:a,children:s}){return n.jsxs("div",{className:"li-head",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:"insp-kind",children:e}),n.jsx(rk,{r:a})]}),n.jsx("div",{className:"insp-title",children:t}),i&&n.jsx("div",{className:"mono small muted",children:i}),s&&n.jsx("div",{className:"li-actions",children:s})]})}function In({k:e,children:t,mono:i}){return n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:e}),n.jsx("span",{className:i?"mono":"",children:t})]})}function g0({a:e}){const t=Object.entries(e??{});return t.length?n.jsxs("details",{className:"li-sec",children:[n.jsxs("summary",{className:"insp-sub",children:["Annotations · ",t.length]}),n.jsx("div",{className:"ann",children:t.map(([i,a])=>n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:i}),n.jsx("span",{className:"mono small",children:Array.isArray(a)?a.join(", "):a})]},i))})]}):null}function r_(){const e=S(i=>ee.fluxResult(i)),t=S(i=>i.activeStateId);return!e||e.modelStateId===t?null:n.jsxs("div",{className:"note small",children:["Values from “",e.name,"” (state ",n.jsx("b",{children:e.metadata.state.name}),"), not from the active state."]})}function n4({id:e}){var y,b;const t=S(_=>_.index),i=S(_=>_.model),a=S(_=>ee.fluxResult(_)),s=S(_=>_.settings.zeroTolerance),o=S(_=>_.compare.result),l=t.met.get(e);if(!l)return n.jsxs("div",{className:"li-sec muted",children:["Unknown metabolite ",e]});const r=t.metRxns.get(e)??[],c=a==null?void 0:a.reactionFluxes,d=(y=a==null?void 0:a.metaboliteTurnover)==null?void 0:y[e],f=[],u=[],p=[];for(const _ of r){const x=t.rxn.get(_).stoichiometry[e];if(c){const v=x*(c[_]??0);(v>s?f:v<-s?u:p).push(_)}else(x>0?f:u).push(_)}const m=(_,x)=>Math.abs(((c==null?void 0:c[x])??0)*t.rxn.get(x).stoichiometry[e])-Math.abs(((c==null?void 0:c[_])??0)*t.rxn.get(_).stoichiometry[e]);f.sort(m),u.sort(m);const h=Tc({kind:"metabolite",id:e}),g=(b=o==null?void 0:o.metabolites)==null?void 0:b.find(_=>_.id===e);return n.jsxs(n.Fragment,{children:[n.jsxs(Xc,{kind:"Metabolite",title:l.name||l.id,sub:l.id,r:{kind:"metabolite",id:e},children:[n.jsxs("button",{className:"btn small",onClick:()=>Fs([e],!1),children:[n.jsx(q,{name:"plus",size:12})," Add to map"]}),h&&n.jsxs("button",{className:"btn small",onClick:()=>ec({kind:"metabolite",id:e}),children:[n.jsx(q,{name:"fit",size:12})," Focus in map"]}),n.jsx("button",{className:"btn small",onClick:()=>B.showInExplorer("reactions",r,`Connected to ${e}`),children:"Connected reactions"}),n.jsx(b0,{items:[["ID",l.id],["name",l.name],["formula",l.formula??""]]}),n.jsxs("div",{className:"li-edit",children:[n.jsxs("button",{className:"btn small",onClick:()=>Ks(e),children:[n.jsx(q,{name:"tidy",size:11})," Edit"]}),n.jsx(Kt,{trigger:(_,x)=>n.jsx("button",{className:`btn small ${_?"on":""}`,onClick:x,title:"Exchange, sink or demand reaction for this metabolite",children:"Boundary ▾"}),children:_=>n.jsxs("div",{className:"menu-list",children:[n.jsxs("button",{onClick:()=>{_(),ks(e,"exchange")},children:[n.jsx("span",{children:"Create Exchange"}),n.jsx("span",{className:"muted small",children:"exchange with the environment"})]}),n.jsxs("button",{onClick:()=>{_(),ks(e,"sink")},children:[n.jsx("span",{children:"Create Sink"}),n.jsx("span",{className:"muted small",children:"artificial supply / removal"})]}),n.jsxs("button",{onClick:()=>{_(),ks(e,"demand")},children:[n.jsx("span",{children:"Create Demand"}),n.jsx("span",{className:"muted small",children:"irreversible removal"})]})]})}),n.jsx("button",{className:"btn small",onClick:()=>l_(e),title:"Open the reaction builder with this metabolite",children:"New reaction with it"}),n.jsx(Kt,{align:"right",trigger:(_,x)=>n.jsx("button",{className:`btn small ${_?"on":""}`,onClick:x,children:"⋯"}),children:_=>n.jsxs("div",{className:"menu-list",children:[n.jsx("button",{onClick:()=>{_(),o_(e)},children:"Duplicate…"}),n.jsx("button",{onClick:()=>{_(),S.setState({dialog:{kind:"delete-metabolite",id:e}})},children:"Delete metabolite…"})]})})]})]}),n.jsxs("div",{className:"li-sec",children:[n.jsx(In,{k:"Formula",mono:!0,children:l.formula??"—"}),n.jsx(In,{k:"Charge",mono:!0,children:l.charge??"—"}),n.jsx(In,{k:"Compartment",children:i.compartments[l.compartment]??l.compartment}),n.jsx(In,{k:n.jsxs("span",{children:["Turnover ",n.jsx(Qn,{text:"Derived proxy: 0.5 × Σ |coefficient × flux| over the reactions of this metabolite, from the active flux result. Not a flux of the metabolite itself."})]}),mono:!0,children:a?n.jsxs(n.Fragment,{children:[W(d)," ",n.jsx("span",{className:"muted small",children:yt})]}):n.jsx("span",{className:"muted",children:"— (no simulation)"})}),n.jsx(r_,{}),g&&n.jsxs("button",{className:"btn small block",onClick:()=>{B.setSection("compare"),B.explainTurnover(e)},children:["Why did turnover ",g.delta!=null&&g.delta>=0?"increase":"decrease","? (",W(g.a)," → ",W(g.b),")"]})]}),n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"insp-sub",children:[c?"Producing":"Produced by (as written)"," · ",f.length]}),n.jsx(hr,{rids:f,metId:e}),n.jsxs("div",{className:"insp-sub",children:[c?"Consuming":"Consumed by (as written)"," · ",u.length]}),n.jsx(hr,{rids:u,metId:e}),c&&p.length>0&&n.jsxs("details",{children:[n.jsxs("summary",{className:"insp-sub",children:["No flux · ",p.length]}),n.jsx(hr,{rids:p,metId:e})]}),!c&&n.jsx("div",{className:"muted small",children:"⇌ marks reversible reactions — they may run either way. Run a simulation to split by actual flux."})]}),n.jsx("div",{className:"li-sec",children:n.jsx(a_,{center:{kind:"metabolite",id:e}})}),n.jsx(g0,{a:l.annotation})]})}function hr({rids:e,metId:t}){const i=S(c=>c.index),a=S(c=>ee.fluxResult(c)),s=S(c=>c.settings.zeroTolerance),[o,l]=E.useState(!1),r=o?e:e.slice(0,12);return e.length?n.jsxs("div",{className:"rxn-list",children:[r.map(c=>{var p;const d=i.rxn.get(c),f=(p=a==null?void 0:a.reactionFluxes)==null?void 0:p[c],u=t?d.stoichiometry[t]:void 0;return n.jsxs("div",{className:"rxn-row",onClick:()=>B.navigate({kind:"reaction",id:c}),onContextMenu:m=>{m.preventDefault(),S.setState({contextMenu:{x:m.clientX,y:m.clientY,refs:[{kind:"reaction",id:c}]}})},children:[n.jsxs("div",{className:"row between",children:[n.jsxs(Xt,{r:{kind:"reaction",id:c},children:[c,d.reversible&&n.jsx("span",{className:"muted",children:" ⇌"})]}),a&&n.jsx("span",{className:`mono small ${f!=null&&Math.abs(f)<s?"zero":""}`,title:u!=null&&f!=null?`contribution to this metabolite: ${W(u*f)}`:void 0,children:W(f)})]}),n.jsxs("div",{className:"muted small ellipsis",title:d.equationNames,children:[d.name?`${d.name} · `:"",d.equationNames]})]},c)}),e.length>12&&n.jsx("button",{className:"link small",onClick:()=>l(!o),children:o?"Show fewer":`Show all ${e.length}`})]}):n.jsx("div",{className:"muted small li-none",children:"none"})}function b0({items:e}){const[t,i]=E.useState(!1);return n.jsxs("span",{className:"pop-wrap",children:[n.jsx("button",{className:"btn small",onClick:()=>i(!t),onBlur:()=>setTimeout(()=>i(!1),150),children:"Copy ▾"}),t&&n.jsx("div",{className:"popover left menu-list",children:e.filter(([,a])=>a).map(([a,s])=>n.jsxs("button",{onMouseDown:()=>QM(s,a),children:["Copy ",a]},a))})]})}function i4({id:e}){var y,b;const t=S(_=>_.index),i=S(_=>_.model),a=S(_=>ee.activeState(_)),s=S(_=>ee.fluxResult(_)),o=S(_=>ee.fvaResult(_)),l=S(_=>_.settings.zeroTolerance),[r,c]=E.useState(!0),d=t.rxn.get(e);if(!d)return n.jsxs("div",{className:"li-sec muted",children:["Unknown reaction ",e]});const f=(y=s==null?void 0:s.reactionFluxes)==null?void 0:y[e],u=(b=o==null?void 0:o.fva)==null?void 0:b[e],p=ee.objective(a).coefficients[e],m=Tc({kind:"reaction",id:e}),h=Object.entries(d.stoichiometry).filter(([,_])=>_<0),g=Object.entries(d.stoichiometry).filter(([,_])=>_>0);return n.jsxs(n.Fragment,{children:[n.jsxs(Xc,{kind:`${lx(d.type)} reaction`,title:d.id,sub:d.name!==d.id?d.name:void 0,r:{kind:"reaction",id:e},children:[n.jsxs("button",{className:"btn small",onClick:()=>vn([e],"vertical"),children:[n.jsx(q,{name:"plus",size:12})," Add to map"]}),m&&n.jsxs("button",{className:"btn small",onClick:()=>ec({kind:"reaction",id:e}),children:[n.jsx(q,{name:"fit",size:12})," Focus in map"]}),n.jsx("button",{className:"btn small",onClick:()=>B.setObjectiveReaction(e),disabled:p===1&&Object.keys(ee.objective(a).coefficients).length===1,children:"Set as objective"}),n.jsx(b0,{items:[["ID",d.id],["name",d.name],["equation",d.equation]]}),n.jsxs("div",{className:"li-edit",children:[n.jsxs("button",{className:"btn small",onClick:()=>Ya(e),title:"Equation, bounds, ID, name, GPR, annotations",children:[n.jsx(q,{name:"tidy",size:11})," Edit reaction"]}),n.jsx(Kt,{align:"right",trigger:(_,x)=>n.jsx("button",{className:`btn small ${_?"on":""}`,onClick:x,children:"⋯"}),children:_=>n.jsxs("div",{className:"menu-list",children:[n.jsx("button",{onClick:()=>{_(),s_(e)},children:"Duplicate…"}),n.jsx("button",{onClick:()=>{_(),S.setState({dialog:{kind:"delete-reaction",id:e}})},children:"Delete reaction…"})]})})]})]}),n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:"insp-sub",children:"Equation"}),n.jsx("button",{className:"link small",onClick:()=>c(!r),children:r?"show IDs":"show names"})]}),n.jsx(ck,{r:d,names:r})]}),n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:"insp-sub",children:"Flux"}),s&&n.jsx("span",{className:"muted small ellipsis",title:s.name,children:s.name})]}),s?n.jsxs("div",{className:"bignum mono",children:[W(f)," ",n.jsx("span",{className:"unit",children:yt})]}):n.jsx("div",{className:"muted small",children:"— No simulation yet."}),o&&u&&n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"FVA interval"}),n.jsxs("span",{className:"mono",children:["[",W(u.minimum),", ",W(u.maximum),"] · width ",W(sx(u.minimum,u.maximum,l))]})]}),n.jsx(r_,{})]}),n.jsx(a4,{r:d}),n.jsxs("div",{className:"li-sec",children:[n.jsx(In,{k:"Objective coefficient",mono:!0,children:p?W(p,3):"0"}),n.jsx(In,{k:"Subsystem",children:d.subsystem?n.jsx(Xt,{r:{kind:"subsystem",id:d.subsystem},children:d.subsystem}):"—"}),n.jsx(In,{k:"Compartments",children:d.compartments.map(_=>i.compartments[_]??_).join(", ")||"—"}),n.jsx(In,{k:"EC",mono:!0,children:d.ec.join(", ")||"—"})]}),n.jsx("div",{className:"li-sec",children:n.jsxs("div",{className:"part-cols",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"insp-sub",children:["Reactants · ",h.length]}),h.map(([_,x])=>n.jsx(bg,{id:_,c:x},_))]}),n.jsxs("div",{children:[n.jsxs("div",{className:"insp-sub",children:["Products · ",g.length]}),g.map(([_,x])=>n.jsx(bg,{id:_,c:x},_))]})]})}),n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"insp-sub",children:["Genes · ",d.genes.length]}),d.gpr?n.jsx(c_,{rule:d.gpr}):n.jsx("div",{className:"muted small",children:"No gene association."})]}),n.jsx("div",{className:"li-sec",children:n.jsx(a_,{center:{kind:"reaction",id:e}})}),n.jsx(g0,{a:d.annotation})]})}function bg({id:e,c:t}){const i=S(a=>{var s;return(s=a.index)==null?void 0:s.met.get(e)});return n.jsxs("div",{className:"met-chip",children:[Math.abs(t)!==1&&n.jsx("span",{className:"mono small muted",children:W(Math.abs(t),3)}),n.jsx(Xt,{r:{kind:"metabolite",id:e},title:e,children:(i==null?void 0:i.name)||e}),n.jsx("span",{className:"mono small muted ellipsis",children:e})]})}function c_({rule:e}){const t=e.split(/(\(|\)|\s+)/).filter(i=>i&&!/^\s+$/.test(i));return n.jsx("div",{className:"gpr",children:t.map((i,a)=>i==="("||i===")"?n.jsx("span",{className:"muted",children:i},a):/^(and|or)$/i.test(i)?n.jsxs("span",{className:"gpr-op",children:[" ",i.toUpperCase()," "]},a):n.jsx(Xt,{r:{kind:"gene",id:i},children:i},a))})}function a4({r:e}){const t=S(u=>ee.activeState(u)),i=ee.bounds(t,e),[a,s]=E.useState(i[0]),[o,l]=E.useState(i[1]);E.useEffect(()=>{s(i[0]),l(i[1])},[i[0],i[1],e.id]);const r=a!==i[0]||o!==i[1],c=i[0]!==e.lb||i[1]!==e.ub,d=a!=null&&o!=null&&a>o,f=()=>{d||B.setBounds(e.id,[a,o])};return n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("span",{className:"insp-sub",children:["Bounds ",n.jsxs("span",{className:"muted",children:["· state “",t.name,"”"]})]}),c&&n.jsx("span",{className:"tag warn",children:"modified"})]}),n.jsxs("div",{className:"bounds-grid",children:[n.jsxs("label",{children:[n.jsx("span",{children:"Lower"}),n.jsx(wn,{allowEmpty:!0,value:a,onCommit:s,placeholder:"−∞"})]}),n.jsxs("label",{children:[n.jsx("span",{children:"Upper"}),n.jsx(wn,{allowEmpty:!0,value:o,onCommit:l,placeholder:"∞"})]}),n.jsx("button",{className:"btn small primary",disabled:!r||d,onClick:f,children:"Apply"})]}),d&&n.jsx("div",{className:"small warn-text",children:"Lower bound must not exceed the upper bound."}),c&&n.jsxs("div",{className:"orig small",children:[i[0]!==e.lb&&n.jsxs("div",{children:["LB: ",n.jsxs("span",{className:"mono",children:[rt(e.lb,"lower")," → ",rt(i[0],"lower")]})]}),i[1]!==e.ub&&n.jsxs("div",{children:["UB: ",n.jsxs("span",{className:"mono",children:[rt(e.ub,"upper")," → ",rt(i[1],"upper")]})]})]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small",onClick:()=>B.blockReactions([e.id]),disabled:i[0]===0&&i[1]===0,children:"Block"}),n.jsx("button",{className:"btn small",onClick:()=>B.allowReversible(e.id),children:"Allow reversible"}),n.jsx("button",{className:"btn small",onClick:()=>B.resetBounds([e.id]),disabled:!c,children:"Reset original"})]})]})}function s4({id:e}){const t=S(l=>l.index),i=S(l=>ee.fluxResult(l)),a=S(l=>l.settings.zeroTolerance),s=t.gene.get(e);if(!s)return n.jsxs("div",{className:"li-sec muted",children:["Unknown gene ",e]});const o=i!=null&&i.reactionFluxes?s.reactions.filter(l=>Math.abs(i.reactionFluxes[l]??0)>=a).length:null;return n.jsxs(n.Fragment,{children:[n.jsxs(Xc,{kind:"Gene",title:s.id,sub:s.name&&s.name!==s.id?s.name:void 0,r:{kind:"gene",id:e},children:[n.jsxs("button",{className:"btn small",onClick:()=>vn(s.reactions,"vertical"),children:[n.jsx(q,{name:"plus",size:12})," Add reactions to map"]}),n.jsx("button",{className:"btn small",onClick:()=>B.showInExplorer("reactions",s.reactions,`Gene ${e}`),children:"Show in table"}),n.jsx(b0,{items:[["ID",s.id],["name",s.name]]})]}),n.jsxs("div",{className:"li-sec",children:[n.jsx(In,{k:"Associated reactions",mono:!0,children:s.reactions.length}),n.jsx(In,{k:"Active (non-zero flux)",mono:!0,children:o??"—"}),n.jsx("div",{className:"muted small",children:"Gene knockout simulation is planned; for now, block the associated reactions to explore an essential-gene hypothesis."})]}),n.jsxs("div",{className:"li-sec",children:[n.jsx("div",{className:"insp-sub",children:"Reactions · GPR"}),s.reactions.map(l=>{var c;const r=t.rxn.get(l);return n.jsxs("div",{className:"rxn-row",onClick:()=>B.navigate({kind:"reaction",id:l}),children:[n.jsxs("div",{className:"row between",children:[n.jsx(Xt,{r:{kind:"reaction",id:l},children:l}),i&&n.jsx("span",{className:"mono small",children:W((c=i.reactionFluxes)==null?void 0:c[l])})]}),n.jsx("div",{className:"muted small ellipsis",children:r.name}),r.gpr&&n.jsx("div",{className:"small gpr-line",children:n.jsx(c_,{rule:r.gpr})})]},l)})]}),n.jsx(g0,{a:s.annotation})]})}function o4({id:e}){const t=S(c=>c.index),i=S(c=>ee.fluxResult(c)),a=S(c=>c.settings.zeroTolerance),s=E.useMemo(()=>t.subsystems.get(e)??[],[t,e]),o=E.useMemo(()=>new Set(s.flatMap(c=>Object.keys(t.rxn.get(c).stoichiometry))),[s,t]),l=E.useMemo(()=>new Set(s.flatMap(c=>t.rxn.get(c).genes)),[s,t]),r=i!=null&&i.reactionFluxes?s.filter(c=>Math.abs(i.reactionFluxes[c]??0)>=a).length:null;return n.jsxs(n.Fragment,{children:[n.jsxs(Xc,{kind:"Subsystem",title:e,r:{kind:"subsystem",id:e},children:[n.jsxs("button",{className:"btn small primary",onClick:()=>vn(s,"hierarchical"),children:[n.jsx(q,{name:"plus",size:12})," Add subsystem to map"]}),n.jsx("button",{className:"btn small",onClick:()=>S.setState(c=>({rxnFilters:{...c.rxnFilters,subsystems:[e]},explorerTab:"reactions",section:"explore"})),children:"Filter table"}),n.jsx("button",{className:"btn small",title:"Select all reactions of the subsystem (adds to the current selection)",onClick:()=>{const c=S.getState().selection.reactions;B.setSelection("reactions",[...new Set([...c,...s])]),B.setTab("reactions")},children:"Select reactions"}),n.jsx("button",{className:"btn small",title:"Flux variability of just this subsystem's reactions",onClick:()=>{B.simulate("fva",{reactions:s}),B.setSection("simulate")},children:"FVA on subsystem"})]}),n.jsxs("div",{className:"li-sec",children:[n.jsxs("div",{className:"stats",children:[n.jsxs("div",{children:[n.jsx("b",{children:s.length}),n.jsx("span",{children:"reactions"})]}),n.jsxs("div",{children:[n.jsx("b",{children:o.size}),n.jsx("span",{children:"metabolites"})]}),n.jsxs("div",{children:[n.jsx("b",{children:l.size}),n.jsx("span",{children:"genes"})]})]}),r!=null&&n.jsxs(In,{k:"Active reactions",mono:!0,children:[r," / ",s.length]})]}),n.jsxs("div",{className:"li-sec",children:[n.jsx("div",{className:"insp-sub",children:"Reactions"}),n.jsx(hr,{rids:s})]})]})}const is=(e,t)=>{var i;return(i=navigator.clipboard)==null?void 0:i.writeText(e).then(()=>V().toast(`Copied ${t}`),()=>V().toast("Clipboard unavailable"))};function l4(){const e=S(l=>l.contextMenu),t=E.useRef(null),[i,a]=E.useState({x:0,y:0});if(E.useEffect(()=>{if(!e)return;const l=c=>{var d;c.target instanceof Node&&((d=t.current)!=null&&d.contains(c.target))||S.setState({contextMenu:null})},r=c=>{c.key==="Escape"&&S.setState({contextMenu:null})};return window.addEventListener("pointerdown",l,!0),window.addEventListener("wheel",l,!0),window.addEventListener("keydown",r),()=>{window.removeEventListener("pointerdown",l,!0),window.removeEventListener("wheel",l,!0),window.removeEventListener("keydown",r)}},[e]),E.useLayoutEffect(()=>{if(!e||!t.current)return;const l=t.current.getBoundingClientRect();a({x:Math.min(e.x,window.innerWidth-l.width-8),y:Math.min(e.y,window.innerHeight-l.height-8)})},[e]),!e||!e.refs.length)return null;const s=()=>S.setState({contextMenu:null}),o=(l,r,c={})=>n.jsxs("button",{className:"cm-item",disabled:c.disabled,onClick:()=>{s(),r()},children:[n.jsx("span",{children:l}),c.hint&&n.jsx("kbd",{children:c.hint})]});return n.jsx("div",{className:"context-menu lab-cm",ref:t,style:{left:i.x||e.x,top:i.y||e.y,position:"fixed"},onContextMenu:l=>l.preventDefault(),children:e.refs.length>1?n.jsx(c4,{refs:e.refs,item:o}):n.jsx(r4,{r:e.refs[0],item:o})})}function r4({r:e,item:t}){const i=S.getState(),a=i.index,s=i.favorites.includes(Oc(e)),o=Tc(e),l=ee.fluxResult(i);if(e.kind==="metabolite"){const c=a.met.get(e.id);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:e.id}),t("View details",()=>B.navigate(e)),t("View reactions",()=>B.showInExplorer("reactions",a.metRxns.get(e.id)??[],`Connected to ${e.id}`)),t("Add to a new reaction",()=>l_(e.id)),n.jsx("div",{className:"cm-label",children:"Create boundary reaction"}),t("Create Exchange",()=>ks(e.id,"exchange")),t("Create Sink",()=>ks(e.id,"sink")),t("Create Demand",()=>ks(e.id,"demand")),n.jsx("div",{className:"cm-sep"}),t("Edit metabolite",()=>Ks(e.id)),t("Duplicate…",()=>o_(e.id)),t("Delete…",()=>S.setState({dialog:{kind:"delete-metabolite",id:e.id}})),n.jsx("div",{className:"cm-sep"}),t("Add to map",()=>Fs([e.id],!1)),o&&t("Focus in map",()=>ec(e)),t(s?"Remove from favorites":"Add to favorites",()=>B.toggleFavorite(e)),n.jsx("div",{className:"cm-sep"}),t("Copy ID",()=>is(e.id,"ID")),t("Copy name",()=>is((c==null?void 0:c.name)??e.id,"name"),{disabled:!(c!=null&&c.name)}),t("Copy formula",()=>is((c==null?void 0:c.formula)??"","formula"),{disabled:!(c!=null&&c.formula)})]})}if(e.kind==="reaction"){const c=a.rxn.get(e.id),d=ee.activeState(i);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:e.id}),t("Inspect",()=>B.navigate(e)),t("Edit reaction",()=>Ya(e.id)),t("Set as objective",()=>B.setObjectiveReaction(e.id)),t("Edit bounds",()=>B.navigate(e)),t("Block reaction",()=>B.blockReactions([e.id])),d.bounds[e.id]&&t("Reset bounds to model file",()=>B.resetBounds([e.id])),n.jsx("div",{className:"cm-sep"}),t("Add to map",()=>vn([e.id],"vertical")),o&&t("Focus in map",()=>ec(e)),t(s?"Remove from favorites":"Add to favorites",()=>B.toggleFavorite(e)),l&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-label",children:"Simulation"}),t("Show flux",()=>B.navigate(e)),t("Show FVA (this reaction)",()=>B.simulate("fva",{reactions:[e.id]})),t("Compare with…",()=>B.setSection("compare")),t("Visualize on map",()=>{vn([e.id],"vertical",!1),S.setState({dialog:{kind:"visualize-result",resultId:l.id}})})]}),n.jsx("div",{className:"cm-sep"}),t("Duplicate…",()=>s_(e.id)),t("Delete reaction…",()=>S.setState({dialog:{kind:"delete-reaction",id:e.id}})),n.jsx("div",{className:"cm-sep"}),t("Copy ID",()=>is(e.id,"ID")),t("Copy equation",()=>is((c==null?void 0:c.equation)??"","equation"))]})}if(e.kind==="gene"){const c=a.gene.get(e.id);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:e.id}),t("Inspect",()=>B.navigate(e)),t("Associated reactions",()=>B.showInExplorer("reactions",(c==null?void 0:c.reactions)??[],`Gene ${e.id}`)),t("Add reactions to map",()=>vn((c==null?void 0:c.reactions)??[],"vertical")),t("Copy ID",()=>is(e.id,"ID"))]})}const r=a.subsystems.get(e.id)??[];return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:e.id}),t("Inspect",()=>B.navigate(e)),t(`Add subsystem to map (${r.length})`,()=>vn(r,"hierarchical")),t("Filter table",()=>S.setState(c=>({rxnFilters:{...c.rxnFilters,subsystems:[e.id]},explorerTab:"reactions",section:"explore"})))]})}function c4({refs:e,item:t}){const i=e.map(o=>o.id),a=e[0].kind,s=S.getState().index;return a==="metabolite"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"cm-title",children:[e.length," metabolites"]}),t(`Add ${e.length} to map`,()=>Fs(i)),t("Connected reactions",()=>B.showInExplorer("reactions",Array.from(new Set(i.flatMap(o=>s.metRxns.get(o)??[]))),`Connected to ${i.length} metabolites`)),t("Filter to selection",()=>B.showInExplorer("metabolites",i,`Selection (${i.length})`)),t("Clear selection",()=>B.clearSelection())]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"cm-title",children:[e.length," reactions"]}),t(`Add ${e.length} to map`,()=>vn(i)),t(`Block ${e.length}…`,()=>S.setState({dialog:{kind:"confirm-block",rids:i}})),t("Reset bounds",()=>B.resetBounds(i)),t("FVA on these",()=>B.simulate("fva",{reactions:i})),t("Create filter from selection",()=>B.showInExplorer("reactions",i,`Selection (${i.length})`)),t("Clear selection",()=>B.clearSelection())]})}function d4(){const e=S(i=>i.dialog);if(!e)return null;if(wM.includes(e.kind))return n.jsx(CM,{d:e});const t=()=>S.setState({dialog:null});return n.jsx("div",{className:"modal-backdrop",onPointerDown:t,children:n.jsxs("div",{className:"modal lab-modal",onPointerDown:i=>i.stopPropagation(),children:[e.kind==="visualize-result"&&n.jsx(u4,{id:e.resultId,close:t}),e.kind==="visualize-comparison"&&n.jsx(p4,{close:t}),e.kind==="confirm-block"&&n.jsx(h4,{rids:e.rids,close:t}),e.kind==="export-model"&&n.jsx(f4,{close:t})]})})}function Kc({title:e,close:t}){return n.jsxs("div",{className:"modal-head",children:[n.jsx("span",{children:e}),n.jsx("button",{className:"icon-btn",onClick:t,children:n.jsx(q,{name:"x",size:14})})]})}function m4(e){const t=R.getState().doc,i=new Set(e);return Object.values(t.reactions).filter(a=>a.reactionId&&i.has(a.reactionId)).length}function u4({id:e,close:t}){var r;const i=ee.result(e),a=i?m4(Object.keys(i.reactionFluxes??i.fva??((r=i.samples)==null?void 0:r.summary)??{})):0,[s,o]=E.useState({width:!0,color:"magnitude",turnoverRadius:!1,fvaRange:!0});if(!i)return null;const l=()=>{ak(i,s),t()};return n.jsxs(n.Fragment,{children:[n.jsx(Kc,{title:"Visualize result in the Map Builder",close:t}),n.jsxs("div",{className:"modal-body",style:{width:qe(520)},children:[n.jsxs("div",{children:[n.jsx("b",{children:"Dataset:"})," ",i.name," ",n.jsxs("span",{className:"muted small",children:["· ",i.metadata.methodLabel," · state ",i.metadata.state.name]})]}),n.jsxs("div",{className:"muted small",children:[a?`${a} reactions of this result are already drawn on the map.`:"No reaction of this result is on the map yet."," Only the data are sent — no reaction is drawn. Model ids are preserved, so the arrows already on the map bind by themselves; to draw a specific reaction use ",n.jsx("b",{children:"Add to map"})," (Explorer, Inspector or right-click)."]}),n.jsx("div",{className:"insp-sub",children:"Suggested mappings"}),i.samples?n.jsxs("div",{className:"map-sugg",children:[n.jsxs("div",{className:"small",children:["The samples become a ",n.jsx("b",{children:"samples"})," dataset: density and box plots show each reaction's distribution (right-click a reaction on the map → ",n.jsx("b",{children:"Add linked plot"}),")."]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:s.width,onChange:c=>o({...s,width:c.target.checked})})," |mean flux| of the samples ",n.jsx("span",{className:"arrow",children:"→"})," edge thickness"]}),n.jsxs("label",{className:"check",children:[n.jsxs("span",{className:"grow",children:["Mean flux of the samples ",n.jsx("span",{className:"arrow",children:"→"})," edge colour"]}),n.jsxs("select",{className:"input tiny",value:s.color,onChange:c=>o({...s,color:c.target.value}),children:[n.jsx("option",{value:"magnitude",children:"|mean| (sequential)"}),n.jsx("option",{value:"signed",children:"signed mean (diverging)"}),n.jsx("option",{value:"none",children:"none"})]})]})]}):i.reactionFluxes?n.jsxs("div",{className:"map-sugg",children:[n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:s.width,onChange:c=>o({...s,width:c.target.checked})})," Reaction |flux| ",n.jsx("span",{className:"arrow",children:"→"})," edge thickness"]}),n.jsxs("label",{className:"check",children:[n.jsxs("span",{className:"grow",children:["Reaction flux ",n.jsx("span",{className:"arrow",children:"→"})," edge colour"]}),n.jsxs("select",{className:"input tiny",value:s.color,onChange:c=>o({...s,color:c.target.value}),children:[n.jsx("option",{value:"magnitude",children:"|flux| (sequential)"}),n.jsx("option",{value:"signed",children:"signed flux (diverging)"}),n.jsx("option",{value:"none",children:"none"})]})]}),n.jsxs("label",{className:"check muted",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:!0})," Flux direction ",n.jsx("span",{className:"arrow",children:"→"})," arrow direction (always: arrows follow the sign of the flux)"]}),i.metaboliteTurnover&&n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:s.turnoverRadius,onChange:c=>o({...s,turnoverRadius:c.target.checked})})," Metabolite turnover ",n.jsx("span",{className:"arrow",children:"→"})," node size"]})]}):n.jsx("div",{className:"note small",children:"FVA intervals are sent as ranges (not as fluxes). On the map, select reactions and add an “FVA / range” plot (right-click → Add linked plot) to show them."}),n.jsxs("div",{className:"row end gap",children:[n.jsx("button",{className:"btn",onClick:t,children:"Cancel"}),n.jsx("button",{className:"btn primary",onClick:l,children:"Send to Map Builder"})]})]})]})}function p4({close:e}){const t=S(u=>u.compare.result),i=ee.result(t==null?void 0:t.a.id),a=ee.result(t==null?void 0:t.b.id),[s,o]=E.useState("log2fc"),[l,r]=E.useState(!0);if(!t||!i||!a)return null;const d=t.reactions.filter(u=>u.category==="reversal").length,f=()=>{sk(t,i,a,s,l),e()};return n.jsxs(n.Fragment,{children:[n.jsx(Kc,{title:"Visualize comparison",close:e}),n.jsxs("div",{className:"modal-body",style:{width:qe(520)},children:[n.jsxs("div",{children:[n.jsx("b",{children:a.name})," ",n.jsx("span",{className:"muted",children:"vs reference"})," ",n.jsx("b",{children:i.name})]}),n.jsx("div",{className:"insp-sub",children:"Suggested mappings"}),n.jsxs("div",{className:"map-sugg",children:[n.jsxs("label",{className:"check",children:[n.jsxs("span",{className:"grow",children:["Comparison ",n.jsx("span",{className:"arrow",children:"→"})," diverging reaction colour"]}),n.jsxs("select",{className:"input tiny",value:s,onChange:u=>o(u.target.value),children:[n.jsx("option",{value:"log2fc",children:"log₂FC |v|"}),n.jsx("option",{value:"delta",children:"Δ flux (B − A)"})]})]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:l,onChange:u=>r(u.target.checked)})," |flux| in B ",n.jsx("span",{className:"arrow",children:"→"})," edge thickness"]})]}),n.jsxs("div",{className:"muted small",children:["Only the data are sent — no reaction is drawn. To draw specific reactions use ",n.jsx("b",{children:"Add to map"}),"."]}),s==="log2fc"&&d>0&&n.jsxs("div",{className:"note small",children:[d," direction reversals have no log₂FC and will be drawn neutral. Δ flux shows them (sign change) — or inspect them in the comparison table."]}),n.jsxs("div",{className:"row end gap",children:[n.jsx("button",{className:"btn",onClick:e,children:"Cancel"}),n.jsx("button",{className:"btn primary",onClick:f,children:"Send to Map Builder"})]})]})]})}function h4({rids:e,close:t}){const i=S(s=>s.index),a=S(s=>ee.activeState(s));return n.jsxs(n.Fragment,{children:[n.jsx(Kc,{title:`Block ${e.length} reaction${e.length>1?"s":""}?`,close:t}),n.jsxs("div",{className:"modal-body",style:{width:qe(480)},children:[n.jsxs("div",{children:["Bounds will be set to ",n.jsx("span",{className:"mono",children:"[0, 0]"})," in state ",n.jsx("b",{children:a.name}),". This is recorded as one modification and can be undone."]}),n.jsxs("div",{className:"block-list",children:[e.slice(0,14).map(s=>{const o=i.rxn.get(s);return n.jsxs("div",{className:"kv small",children:[n.jsx("span",{className:"mono",children:s}),n.jsxs("span",{className:"mono",children:[Ua(ee.bounds(a,o))," → [0, 0]"]})]},s)}),e.length>14&&n.jsxs("div",{className:"muted small",children:["…and ",e.length-14," more"]})]}),n.jsxs("div",{className:"row end gap",children:[n.jsx("button",{className:"btn",onClick:t,children:"Cancel"}),n.jsxs("button",{className:"btn primary",onClick:()=>{B.blockReactions(e),t()},children:["Block ",e.length]})]})]})]})}function f4({close:e}){const t=S(d=>ee.activeState(d)),i=S(d=>d.model),a=S(d=>{var f;return((f=d.annotation)==null?void 0:f.curation.accepted)??0}),s=S(d=>{var f;return((f=d.annotation)==null?void 0:f.curation.formulas)??0}),o=S(d=>{var f,u;return((u=(f=d.model)==null?void 0:f.edits)==null?void 0:u.count)??0}),[l,r]=E.useState(!1),c=async d=>{r(!0),await Z4(d),r(!1),e()};return n.jsxs(n.Fragment,{children:[n.jsx(Kc,{title:"Save as model",close:e}),n.jsxs("div",{className:"modal-body",style:{width:qe(460)},children:[n.jsxs("div",{children:["Writes a ",n.jsx("b",{children:"new"})," model file from ",n.jsx("span",{className:"mono",children:i.filename})," with state ",n.jsx("b",{children:t.name})," applied (",Object.keys(t.bounds).length," bound changes",t.objective?", objective changed":"","). The imported file is never modified."]}),o>0&&n.jsxs("div",{className:"note small",children:["Includes the ",n.jsx("b",{children:o})," structural edit",o>1?"s":""," (reactions / metabolites added, changed or removed), listed in the model notes."]}),a>0&&n.jsxs("div",{className:"note small",children:["Includes the metabolite curation: ",n.jsx("b",{children:a})," metabolites with MetaNetX cross-references added",s?n.jsxs(n.Fragment,{children:[", ",n.jsx("b",{children:s})," formulas filled"]}):null,". SBML writes them as MIRIAM annotations."]}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn",disabled:l,onClick:()=>c("sbml"),children:"SBML (.xml)"}),n.jsx("button",{className:"btn",disabled:l,onClick:()=>c("json"),children:"COBRA JSON"}),n.jsx("button",{className:"btn",disabled:l,onClick:()=>c("mat"),children:"MATLAB (.mat)"})]}),l&&n.jsxs("div",{className:"muted small",children:[n.jsx("span",{className:"spinner sm"})," COBRApy is writing the file…"]})]})]})}function g4(){const e=S(M=>M.model),t=S(M=>ee.activeState(M)),i=S(M=>M.mediumPresets),[a,s]=E.useState(null),[o,l]=E.useState(null),[r,c]=E.useState(null),[d,f]=E.useState("active"),[u,p]=E.useState(""),[m,h]=E.useState([]),[g,y]=E.useState(!1),b=Xn(u,100),_=JSON.stringify(t.bounds),x=E.useMemo(()=>ee.stateSpec(t),[t]);E.useEffect(()=>{let M=!0;return Se.medium(e.id,x).then(A=>{M&&(s(A),l(null))},A=>M&&l(A instanceof On?A.info:{title:"Error",message:String(A),hints:[]})),()=>{M=!1}},[e.id,_]);const v=()=>{const M={};for(const[A,X]of Object.entries((a==null?void 0:a.medium)??{}))X!=null&&(M[A]=X);return M},j=async(M,A,X)=>{c(A);try{const I=await X();Object.keys(I.bounds).length&&B.applyMediumBounds(I.bounds,M,A),h(I.notes??[])}catch(I){l(I instanceof On?I.info:{title:"Error",message:String(I),hints:[]})}finally{c(null)}},N=(M,A)=>{const X=A==null?1e3:Math.max(0,A);if(X===(M.uptakeMax??1/0))return;const I=v();X>0?I[M.reaction]=X:delete I[M.reaction];const K=M.metaboliteName||M.metabolite||M.reaction;j(t.mediumLabel?`${t.mediumLabel.replace(/ \(edited\)$/,"")} (edited)`:"Custom",`${K} (${M.reaction}) uptake ${M.uptakeUnbounded?"∞":W(M.uptakeMax)} → ${W(X)}`,()=>Se.setMedium(e.id,x,I))},C=M=>N(M,M.inMedium?0:M.originalUptakeMax&&M.originalUptakeMax>0?M.originalUptakeMax:10),w=(M,A)=>j(A,`Preset: ${A}`,()=>Se.mediumPreset(e.id,x,M)),k=(M,A)=>j(M,`Preset: ${M}`,()=>Se.setMedium(e.id,x,A)),P=E.useMemo(()=>{const M=(a==null?void 0:a.rows)??[],A=d==="active"?M.filter(I=>I.inMedium):d==="exchanges"?M.filter(I=>I.kind==="exchange"):M;if(!b.trim())return A;const X=mn(b);return A.filter(I=>mn(`${I.reaction} ${I.metabolite??""} ${I.metaboliteName} ${I.formula??""} ${I.reactionName}`).includes(X))},[a,d,b]),H=[{key:"in",label:"In",width:34,align:"center",title:"In the medium (uptake allowed)",sortValue:M=>M.inMedium?1:0,render:M=>n.jsx("input",{type:"checkbox",checked:M.inMedium,disabled:!!r||M.kind!=="exchange",title:M.kind!=="exchange"?`${M.kind} reactions are not part of COBRApy's medium — edit their bounds in the inspector`:M.inMedium?"Remove from medium (uptake 0)":"Allow uptake",onClick:A=>A.stopPropagation(),onChange:()=>C(M)})},{key:"name",label:"Compound",width:"minmax(150px, 2fr)",sortValue:M=>M.metaboliteName||M.metabolite,render:M=>n.jsx("span",{className:"ellipsis strong",title:M.metaboliteName,children:M.metaboliteName||M.metabolite||"—"})},{key:"formula",label:"Formula",width:90,sortValue:M=>M.formula,render:M=>n.jsx("span",{className:"mono ellipsis",children:M.formula??""})},{key:"exchange",label:"Exchange",width:"minmax(120px, 1.2fr)",sortValue:M=>M.reaction,render:M=>n.jsxs("span",{className:"mono ellipsis",children:[M.reaction,M.kind!=="exchange"&&n.jsx("span",{className:"tag",children:M.kind})]})},{key:"uptake",label:n.jsxs("span",{children:["Max uptake ",n.jsxs("span",{className:"muted",children:["(",yt,")"]})]}),width:190,align:"right",sortValue:M=>M.uptakeUnbounded?1/0:M.uptakeMax,render:M=>M.kind==="exchange"?n.jsx(wn,{className:"cell-edit med-in",allowEmpty:!0,value:M.uptakeUnbounded?null:M.uptakeMax,placeholder:"∞",onCommit:A=>N(M,A),title:"Maximum uptake rate; Enter to apply"}):n.jsx("span",{className:"mono",children:M.uptakeUnbounded?"∞":W(M.uptakeMax)})},{key:"secretion",label:"Max secretion",width:100,align:"right",sortValue:M=>M.secretionMax??1/0,render:M=>n.jsx("span",{className:"mono muted",children:M.secretionMax==null?"∞":W(M.secretionMax)})},{key:"orig",label:"Model file",width:110,align:"right",title:"Uptake limit in the imported model",sortValue:M=>M.originalUptakeMax,render:M=>{const A=(M.originalUptakeMax??-1)!==(M.uptakeMax??-1)&&!(M.uptakeUnbounded&&M.originalUptakeMax==null);return n.jsx("span",{className:`mono small ${A?"modified":"muted"}`,children:A?`${W(M.originalUptakeMax)} → ${M.uptakeUnbounded?"∞":W(M.uptakeMax)}`:W(M.originalUptakeMax)})}}],G=(a==null?void 0:a.rows.filter(M=>M.inMedium).length)??0;return n.jsxs("div",{className:"lab-page",children:[n.jsx(ul,{title:"Medium",sub:n.jsxs(n.Fragment,{children:["Uptake limits of exchange reactions, read and written through COBRApy's ",n.jsx("span",{className:"mono",children:"model.medium"}),". Applies to state ",n.jsx("b",{children:t.name}),t.mediumLabel?n.jsxs(n.Fragment,{children:[" · ",t.mediumLabel]}):null,"."]}),children:n.jsxs("span",{className:"muted small",children:[G," compounds available"]})}),n.jsxs("div",{className:"medium-presets",children:[n.jsx("span",{className:"muted small",children:"Presets"}),n.jsx("button",{className:"btn small",disabled:!!r,onClick:()=>w("original","Model file medium"),title:"Restore the uptake limits from the imported file",children:"Model file"}),n.jsx("button",{className:"btn small",disabled:!!r,onClick:()=>w("minimal","Minimal medium"),title:"COBRApy minimal_medium: smallest total uptake that still reaches the current optimum",children:"Minimal"}),n.jsx("button",{className:"btn small",disabled:!!r,onClick:()=>w("rich","Rich medium"),title:"Every exchange allows uptake of at least 10 mmol gDW⁻¹ h⁻¹",children:"Rich"}),n.jsx("button",{className:"btn small",disabled:!!r,onClick:()=>w("anaerobic","Anaerobic"),title:"Current medium with oxygen uptake closed",children:"Anaerobic"}),i.map(M=>n.jsxs("span",{className:"preset-chip",children:[n.jsx("button",{className:"btn small",disabled:!!r,onClick:()=>k(M.name,M.medium),children:M.name}),n.jsx("button",{className:"icon-btn tiny",title:"Delete preset",onClick:()=>B.deleteMediumPreset(M.id),children:n.jsx(q,{name:"x",size:10})})]},M.id)),g?n.jsx("input",{className:"input tiny",autoFocus:!0,placeholder:"Preset name, Enter to save",onKeyDown:M=>{M.key==="Enter"&&M.currentTarget.value.trim()&&(B.saveMediumPreset(M.currentTarget.value.trim(),v()),y(!1)),M.key==="Escape"&&y(!1)},onBlur:()=>y(!1)}):n.jsx("button",{className:"link small",onClick:()=>y(!0),children:"+ Save current as preset"})]}),m.length>0&&n.jsx("div",{className:"note small",children:m.join(" ")}),r&&n.jsxs("div",{className:"note small",children:["Applying: ",r,"…"]}),o&&n.jsx(ml,{info:o,onRetry:()=>l(null)}),n.jsxs("div",{className:"ex-toolbar",children:[n.jsxs("div",{className:"search-box ex-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:"Search compound name, metabolite id, exchange id, formula…",value:u,onChange:M=>p(M.target.value)})]}),n.jsx(jn,{value:d,options:["active","exchanges","boundary"],onChange:f,labels:{active:"Available only",exchanges:"All exchanges",boundary:"All boundary"}})]}),n.jsx("div",{className:"ex-table medium-table",children:a?n.jsx(ci,{rows:P,cols:H,rowKey:M=>M.reaction,rowHeight:28,onRowClick:M=>B.navigate({kind:"reaction",id:M.reaction}),onContextMenu:(M,A)=>S.setState({contextMenu:{x:A.clientX,y:A.clientY,refs:[{kind:"reaction",id:M.reaction}]}}),empty:d==="active"?"No uptake allowed — the model has no available substrates. Use a preset or switch to “All exchanges”.":"No match"}):!o&&n.jsx("div",{className:"muted pad",children:"Reading the medium from COBRApy…"})})]})}function y0(){const e=document.createElement("input");e.type="file",e.accept=".xml,.sbml,.json,.mat",e.onchange=()=>{var i;const t=(i=e.files)==null?void 0:i[0];t&&B.importFile(t)},e.click()}function yg(){return S(t=>t.model)?n.jsx(x4,{}):n.jsx(b4,{})}function b4(){const e=S(r=>r.backend),t=S(r=>r.busy),i=S(r=>r.importError),[a,s]=E.useState([]),[o,l]=E.useState(!1);return E.useEffect(()=>{e.status==="online"&&Se.examples().then(s,()=>s([]))},[e.status]),n.jsxs("div",{className:"lab-page center-page",children:[n.jsxs("div",{className:`dropzone ${o?"over":""}`,onDragOver:r=>{r.preventDefault(),r.stopPropagation(),l(!0)},onDragLeave:()=>l(!1),onDrop:r=>{r.preventDefault(),r.stopPropagation(),l(!1);const c=r.dataTransfer.files[0];c&&B.importFile(c)},children:[n.jsxs("svg",{width:"2.75rem",height:"2.75rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[n.jsx("circle",{cx:"6",cy:"6",r:"2.5"}),n.jsx("circle",{cx:"18",cy:"8",r:"2.5"}),n.jsx("circle",{cx:"9",cy:"18",r:"2.5"}),n.jsx("path",{d:"M8.3 7l7.3 1M16.8 10.3l-6.4 5.6"})]}),n.jsx("div",{className:"empty-title",children:"Drop a metabolic model here"}),n.jsx("div",{className:"muted",children:"SBML · COBRA JSON · MATLAB .mat"}),n.jsxs("button",{className:"btn primary",disabled:e.status!=="online"||!!t,onClick:y0,children:[n.jsx(q,{name:"import",size:14})," Import model"]}),a.length>0&&n.jsxs("div",{className:"examples",children:[n.jsx("span",{className:"muted small",children:"or try an example bundled with COBRApy:"}),a.map(r=>n.jsx("button",{className:"link",disabled:!!t,onClick:()=>B.importExample(r.name),children:r.label},r.name))]}),t&&n.jsxs("div",{className:"busy",children:[n.jsx("span",{className:"spinner"})," ",t]})]}),i&&n.jsx(ml,{info:i}),n.jsx(y4,{})]})}function y4(){var t,i,a;const e=S(s=>s.backend);return e.status==="online"?n.jsxs("div",{className:"muted small center",children:["GEMsMAP ",(t=e.health)==null?void 0:t.version," · COBRApy ",(i=e.health)==null?void 0:i.cobraVersion," · solver ",(a=e.health)==null?void 0:a.defaultSolver," · backend ready"]}):e.status==="checking"?n.jsxs("div",{className:"muted small center",children:[n.jsx("span",{className:"spinner"})," Connecting to the COBRApy backend…"]}):n.jsxs("div",{className:"error-card",children:[n.jsx("div",{className:"ec-title",children:"COBRApy backend is not running"}),n.jsx("div",{className:"ec-msg",children:"COBRAGUI runs all science in Python (COBRApy). Start GEMsMAP in a terminal, keep that window open, then retry:"}),n.jsx("pre",{className:"cmd",children:"gemsmap"}),n.jsxs("div",{className:"muted small",children:["Development checkout: ",n.jsx("span",{className:"mono",children:"npm run backend"})," (the first time, ",n.jsx("span",{className:"mono",children:"npm run backend:setup"})," creates ",n.jsx("span",{className:"mono",children:"backend/.venv"})," and installs COBRApy, FastAPI and uvicorn)."]}),n.jsx("div",{children:n.jsx("button",{className:"btn small",onClick:()=>B.checkBackend(),children:"Retry connection"})})]})}function x4(){var c;const e=S(d=>d.model),t=S(d=>ee.activeState(d)),i=S(d=>ee.fluxResult(d)),a=S(d=>d.results.length),s=e.summary,o=Object.keys(t.bounds).length>0||!!t.objective,l=i!=null&&i.reactionFluxes?Object.values(i.reactionFluxes).filter(d=>!ee.isZero(d)).length:null,r=e.warnings.filter(d=>d.level==="error").length;return n.jsxs("div",{className:"lab-page overview",children:[n.jsxs("div",{className:"ov-card",children:[n.jsxs("div",{className:"ov-main",children:[n.jsx("div",{className:"insp-kind",children:"Model"}),n.jsx("div",{className:"ov-title",children:e.name}),n.jsxs("div",{className:"mono small muted",children:[e.filename," · ",e.format.toUpperCase()," · sha256 ",e.checksum.slice(0,12)]}),n.jsxs("div",{className:"ov-stats",children:[n.jsxs("div",{children:[n.jsx("b",{children:s.reactions.toLocaleString()}),n.jsx("span",{children:"reactions"})]}),n.jsxs("div",{children:[n.jsx("b",{children:s.metabolites.toLocaleString()}),n.jsx("span",{children:"metabolites"})]}),n.jsxs("div",{children:[n.jsx("b",{children:s.genes.toLocaleString()}),n.jsx("span",{children:"genes"})]}),n.jsxs("div",{children:[n.jsx("b",{children:s.compartments}),n.jsx("span",{children:"compartments"})]})]})]}),n.jsxs("div",{className:"ov-side",children:[n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Objective"}),n.jsx("span",{className:"mono",children:Pi(ee.objective(t))})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Solver"}),n.jsx("span",{children:s.solver})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"State"}),n.jsx("span",{children:t.name})]}),n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:"Status"}),n.jsx("span",{children:o?n.jsx("span",{className:"modified-dot",children:"● Modified"}):n.jsx("span",{className:"ok",children:"Ready"})})]})]})]}),n.jsxs("div",{className:"quick-actions",children:[n.jsxs("button",{className:"qa",onClick:()=>B.setSection("explore"),children:[n.jsx(q,{name:"search",size:16}),n.jsx("b",{children:"Explore model"}),n.jsx("span",{children:"Search and browse metabolites, reactions, genes"})]}),n.jsxs("button",{className:"qa",onClick:()=>B.setSection("medium"),children:[n.jsx(q,{name:"particles",size:16}),n.jsx("b",{children:"Configure medium"}),n.jsxs("span",{children:[s.mediumSize," compounds available in the file"]})]}),n.jsxs("button",{className:"qa",onClick:()=>{B.setSection("simulate"),S.setState({objectiveEditorOpen:!0})},children:[n.jsx(q,{name:"sparkle",size:16}),n.jsx("b",{children:"Change objective"}),n.jsx("span",{className:"mono",children:Object.keys(ee.objective(t).coefficients).join(", ")||"none"})]}),n.jsxs("button",{className:"qa primary",onClick:()=>B.setSection("simulate"),children:[n.jsx(q,{name:"play",size:16}),n.jsx("b",{children:"Run simulation"}),n.jsx("span",{children:"FBA · pFBA · loopless · FVA"})]})]}),n.jsxs("div",{className:"ov-grid",children:[n.jsxs("div",{className:"ov-panel",children:[n.jsx("div",{className:"insp-sub",children:"Import & validation"}),n.jsxs("div",{className:"ok small",children:["Model imported successfully ",r?n.jsxs("span",{className:"warn-text",children:["· ",r," issue",r>1?"s":""," to review"]}):""]}),e.warnings.length===0&&n.jsx("div",{className:"muted small",children:"No validation notes."}),e.warnings.map(d=>n.jsx(_4,{w:d},d.code)),((c=e.validation.loader)==null?void 0:c.length)>0&&n.jsxs("details",{className:"small",children:[n.jsxs("summary",{className:"muted",children:["COBRApy reader messages · ",e.validation.loader.length]}),n.jsx("pre",{className:"log-pre",children:e.validation.loader.join(`
|
|
71
|
+
`)})]})]}),n.jsxs("div",{className:"ov-panel",children:[n.jsx("div",{className:"insp-sub",children:"Model statistics"}),n.jsxs("div",{className:"stat-table",children:[n.jsx(Sn,{k:"Exchange reactions",v:s.exchange,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["exchange"]},metFilters:{},sort:null})}),s.demand>0&&n.jsx(Sn,{k:"Demand reactions",v:s.demand,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["demand"]},metFilters:{},sort:null})}),s.sink>0&&n.jsx(Sn,{k:"Sink reactions",v:s.sink,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["sink"]},metFilters:{},sort:null})}),n.jsx(Sn,{k:"Transport reactions",v:s.transport,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["transport"]},metFilters:{},sort:null})}),n.jsx(Sn,{k:"Internal reactions",v:s.internal,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{types:["internal"]},metFilters:{},sort:null})}),n.jsx(Sn,{k:"Reversible",v:s.reversible,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{reversibility:"reversible"},metFilters:{},sort:null})}),n.jsx(Sn,{k:"Irreversible",v:s.irreversible,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!1,rxnFilters:{reversibility:"irreversible"},metFilters:{},sort:null})}),s.blockedByBounds>0&&n.jsx(Sn,{k:"Blocked by bounds",v:s.blockedByBounds}),s.subsystems>0&&n.jsx(Sn,{k:"Subsystems",v:s.subsystems}),l!=null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"stat-sep",children:["Active result · ",i.name]}),n.jsx(Sn,{k:"Active reactions",v:l,onClick:()=>B.applyView({id:"",name:"",tab:"reactions",query:"",hideZero:!0,rxnFilters:{},metFilters:{},sort:{key:"absFlux",dir:"desc"}})}),n.jsx(Sn,{k:"Zero-flux reactions",v:Object.keys(i.reactionFluxes).length-l})]})]}),a===0&&n.jsx("div",{className:"note small",children:"No simulation yet. Configure a medium and objective, then run FBA or pFBA."})]}),n.jsx(fk,{})]})]})}function Sn({k:e,v:t,onClick:i}){return i?n.jsxs("button",{className:"stat-row",onClick:i,children:[n.jsx("span",{children:e}),n.jsx("b",{className:"mono",children:t.toLocaleString()})]}):n.jsxs("div",{className:"stat-row",children:[n.jsx("span",{children:e}),n.jsx("b",{className:"mono",children:t.toLocaleString()})]})}function _4({w:e}){const[t,i]=E.useState(!1),a=E.useRef(null),s=["disconnected-metabolite","dead-end","no-formula"].includes(e.code);return n.jsxs("div",{className:`warn-row l-${e.level}`,ref:a,children:[n.jsxs("button",{className:"warn-head",onClick:()=>i(!t),children:[n.jsx("i",{className:`lvl l-${e.level}`}),n.jsx("b",{className:"mono",children:e.count.toLocaleString()}),n.jsx("span",{className:"grow",children:e.title}),n.jsx("span",{className:"muted",children:t?"▾":"▸"})]}),t&&n.jsxs("div",{className:"warn-body",children:[e.detail&&n.jsx("pre",{className:"log-pre",children:e.detail}),e.ids.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"warn-ids",children:[e.ids.slice(0,40).map(o=>n.jsx("button",{className:"chip",onClick:()=>B.navigate({kind:s?"metabolite":"reaction",id:o}),children:o},o)),e.ids.length>40&&n.jsxs("span",{className:"muted small",children:["+",e.ids.length-40," more"]})]}),n.jsx("button",{className:"btn small",onClick:()=>B.showInExplorer(s?"metabolites":"reactions",e.ids,`${e.title.split(" ").slice(0,3).join(" ")} (${e.count})`),children:"Show all in explorer"})]})]})]})}function Ru(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept=".json,.csv,.tsv,.txt",e.onchange=()=>{const t=Array.from(e.files??[]);t.length&&B.importResults(t)},e.click()}function v4({onDone:e}){const t=S(j=>ee.activeState(j)),i=S(j=>j.index),a=S(j=>j.searchIndex),s=S(j=>j.model.summary.objective),o=ee.objective(t),[l,r]=E.useState(Object.entries(o.coefficients)),[c,d]=E.useState(o.direction),[f,u]=E.useState(""),[p,m]=E.useState(null),[h,g]=E.useState(null);E.useEffect(()=>{r(Object.entries(o.coefficients)),d(o.direction)},[t.id,JSON.stringify(o)]);const y=E.useMemo(()=>f.trim()?a.search(f,["reaction"],8):[],[f,a]),b={coefficients:Object.fromEntries(l.filter(([,j])=>j!==0)),direction:c},_=JSON.stringify(b)!==JSON.stringify(o),x=l.length?l.map(([j,N],C)=>`${C&&N>=0?"+ ":N<0?"− ":""}${W(Math.abs(N),3)} × ${j}`).join(" "):"—",v=j=>{const N=[];for(const C of j.split(/[,;\n]+/).map(w=>w.trim()).filter(Boolean)){const[w,k="1"]=C.split(":").map(H=>H.trim());if(!i.rxn.has(w))return g(`Unknown reaction “${w}”`);const P=Number(k);if(!Number.isFinite(P))return g(`Invalid coefficient for ${w}: “${k}”`);N.push([w,P])}g(null),r(N)};return n.jsxs("div",{className:"objective-editor",children:[n.jsxs("div",{className:"row between",children:[n.jsx("span",{className:"insp-sub",children:"Objective"}),n.jsx(jn,{value:c,options:["max","min"],onChange:d,labels:{max:"Maximize",min:"Minimize"}})]}),n.jsxs("div",{className:"obj-terms",children:[l.map(([j,N],C)=>{var w;return n.jsxs("div",{className:"obj-term",children:[n.jsx(wn,{value:N,onCommit:k=>r(l.map((P,H)=>H===C?[P[0],k??0]:P)),className:"obj-w",title:"Weight"}),n.jsx("span",{className:"muted",children:"×"}),n.jsxs("div",{className:"grow",children:[n.jsx(Xt,{r:{kind:"reaction",id:j},children:j}),n.jsx("div",{className:"muted small ellipsis",children:(w=i.rxn.get(j))==null?void 0:w.name})]}),n.jsx("button",{className:"icon-btn tiny",title:"Remove",onClick:()=>r(l.filter((k,P)=>P!==C)),children:n.jsx(q,{name:"x",size:11})})]},j)}),!l.length&&n.jsx("div",{className:"muted small",children:"No objective — add a reaction below."})]}),n.jsxs("div",{className:"obj-add",children:[n.jsxs("div",{className:"search-box",children:[n.jsx(q,{name:"plus",size:13}),n.jsx("input",{placeholder:"Add reaction: search id, name, e.g. biomass…",value:f,onChange:j=>u(j.target.value)})]}),y.length>0&&n.jsx("div",{className:"obj-hits",children:y.map(j=>n.jsxs("button",{disabled:l.some(([N])=>N===j.id),onClick:()=>{r([...l,[j.id,1]]),u("")},children:[n.jsx("span",{className:"mono strong",children:j.id}),n.jsx("span",{className:"muted small ellipsis",children:j.name})]},j.id))})]}),n.jsxs("div",{className:"obj-preview",children:[n.jsx("span",{className:"muted small",children:"Objective:"})," ",n.jsxs("span",{className:"mono",children:[c==="max"?"maximize":"minimize"," ",x]})]}),n.jsxs("details",{className:"adv",open:p!=null,onToggle:j=>m(j.target.open?l.map(([N,C])=>`${N}:${C}`).join(", "):null),children:[n.jsx("summary",{children:"Advanced: edit as text"}),n.jsx("textarea",{className:"input mono",value:p??"",onChange:j=>m(j.target.value),placeholder:"BIOMASS:1, EX_product_e:0.2"}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:()=>p!=null&&v(p),children:"Parse"}),h&&n.jsx("span",{className:"small warn-text",children:h})]})]}),n.jsxs("div",{className:"row gap end",children:[t.objective&&n.jsx("button",{className:"btn small",onClick:()=>{B.setObjective(null),e==null||e()},title:`Model file objective: ${Object.keys(s.coefficients).join(", ")}`,children:"Reset to model objective"}),n.jsx("button",{className:"btn small primary",disabled:!_||!l.length,onClick:()=>{B.setObjective(b),e==null||e()},children:"Apply objective"})]})]})}const j4=["fba","pfba","loopless","fva","sampling"];function N4(e,t){const i=Object.keys((e==null?void 0:e.metadata.objective.coefficients)??{});return i.length===1&&/biomass|growth/i.test(`${i[0]} ${t(i[0])}`)?"h⁻¹":""}function w4(){const e=S(b=>b.model),t=S(b=>b.states),i=S(b=>ee.activeState(b)),a=S(b=>b.method),s=S(b=>b.simParams),o=S(b=>b.running),l=S(b=>b.objectiveEditorOpen),r=S(b=>b.selection.reactions),c=S(b=>b.rxnFilters),d=ee.objective(i),f=Object.keys(d.coefficients).length,[u,p]=E.useState("all"),m=E.useMemo(()=>{let b=0;for(const _ of e.reactions)_.type==="exchange"&&ee.uptakeOf(_,ee.bounds(i,_))>0&&b++;return b},[e,i]),h=a==="fva"&&u==="all"&&e.summary.reactions>1200,g=b=>S.setState(_=>({simParams:{..._.simParams,...b}})),y=()=>B.simulate(a,{reactions:a==="fva"&&u==="selection"&&r.length?r:null});return n.jsxs("div",{className:"lab-page sim",children:[n.jsx(ul,{title:"Simulation",sub:"COBRApy solves every method; the result keeps the exact state, medium and parameters used."}),n.jsx("div",{className:"method-cards",children:j4.map(b=>n.jsxs("button",{className:`method-card ${a===b?"on":""}`,onClick:()=>S.setState({method:b}),children:[n.jsxs("div",{className:"mc-title",children:[n.jsx("i",{className:`m-dot m-${b}`}),Qt[b].label,n.jsx(Qn,{text:Qt[b].more,children:"Learn more"})]}),n.jsx("div",{className:"mc-blurb",children:Qt[b].blurb})]},b))}),n.jsxs("div",{className:"sim-config",children:[n.jsxs("div",{className:"sim-row",children:[n.jsx("span",{className:"sim-k",children:"Objective"}),n.jsx("span",{className:"mono grow",children:Pi(d)}),i.objective&&n.jsx("span",{className:"tag warn",children:"changed"}),n.jsx("button",{className:"btn small",onClick:()=>S.setState({objectiveEditorOpen:!l}),children:l?"Close":"Change objective"})]}),l&&n.jsx("div",{className:"sim-editor",children:n.jsx(v4,{onDone:()=>S.setState({objectiveEditorOpen:!1})})}),n.jsxs("div",{className:"sim-row",children:[n.jsx("span",{className:"sim-k",children:"Model state"}),n.jsx("select",{className:"input",value:i.id,onChange:b=>B.setActiveState(b.target.value),children:t.map(b=>n.jsxs("option",{value:b.id,children:[b.name,b.changes.length?` · ${Object.keys(b.bounds).length} bound changes`:""]},b.id))}),n.jsx("span",{className:"muted small grow",children:Object.keys(i.bounds).length?`${Object.keys(i.bounds).length} reactions with modified bounds`:"Unmodified model file"}),n.jsx("button",{className:"btn small",onClick:()=>B.duplicateState(),children:"Duplicate state"})]}),n.jsxs("div",{className:"sim-row",children:[n.jsx("span",{className:"sim-k",children:"Medium"}),n.jsxs("span",{className:"grow",children:[m," compounds available",i.mediumLabel?` · ${i.mediumLabel}`:""]}),n.jsx("button",{className:"btn small",onClick:()=>B.setSection("medium"),children:"Configure medium"})]}),n.jsxs("details",{className:"adv sim-adv",open:a==="sampling"||void 0,children:[n.jsx("summary",{children:a==="sampling"?"Sampling options":"Advanced options"}),n.jsxs("div",{className:"sim-adv-grid",children:[(a==="pfba"||a==="fva")&&n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["Fraction of optimum ",n.jsx(Qn,{text:a==="pfba"?"pFBA keeps the objective ≥ this fraction of the optimum while minimizing total flux.":"FVA ranges are computed with the objective ≥ this fraction of the optimum."})]}),n.jsx("input",{className:"input tiny num",type:"number",min:0,max:1,step:.01,value:s.fractionOfOptimum,onChange:b=>g({fractionOfOptimum:Math.min(1,Math.max(0,+b.target.value))})})]}),a==="fva"&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:s.loopless,onChange:b=>g({loopless:b.target.checked})})," Loopless FVA (slower)"]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Reactions"}),n.jsxs("select",{className:"input tiny",value:u,onChange:b=>p(b.target.value),children:[n.jsxs("option",{value:"all",children:["All ",e.summary.reactions," reactions"]}),n.jsxs("option",{value:"selection",disabled:!r.length,children:["Selected in explorer (",r.length,")"]})]})]}),n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["pFBA factor ",n.jsx(Qn,{text:"Optional: also bound the total flux to ≤ factor × the pFBA minimum (≥ 1). Leave empty for standard FVA."})]}),n.jsx("input",{className:"input tiny num",type:"number",min:1,step:.05,value:s.pfbaFactor??"",placeholder:"off",onChange:b=>g({pfbaFactor:b.target.value===""?null:Math.max(1,+b.target.value)})})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Processes"}),n.jsx("input",{className:"input tiny num",type:"number",min:1,max:16,value:s.processes,onChange:b=>g({processes:Math.max(1,+b.target.value|0)})})]})]}),a==="sampling"&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["Samples ",n.jsx(Qn,{text:"Number of flux vectors kept. Each sample costs `thinning` hit-and-run steps; a few hundred are enough for a first look."})]}),n.jsx("input",{className:"input tiny num",type:"number",min:1,max:2e4,step:50,value:s.samples,onChange:b=>g({samples:Math.max(1,Math.min(2e4,+b.target.value|0))})})]}),n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["Sampler ",n.jsx(Qn,{text:"OptGP (default) can use several processes. ACHR is single-process; both are COBRApy hit-and-run samplers."})]}),n.jsxs("select",{className:"input tiny",value:s.sampler,onChange:b=>g({sampler:b.target.value}),children:[n.jsx("option",{value:"optgp",children:"OptGP"}),n.jsx("option",{value:"achr",children:"ACHR"})]})]}),n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["Thinning ",n.jsx(Qn,{text:"Steps between two kept samples (COBRApy default 100). Larger values give less correlated samples and take longer."})]}),n.jsx("input",{className:"input tiny num",type:"number",min:1,max:1e4,value:s.thinning,onChange:b=>g({thinning:Math.max(1,Math.min(1e4,+b.target.value|0))})})]}),s.sampler==="optgp"&&n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Processes"}),n.jsx("input",{className:"input tiny num",type:"number",min:1,max:16,value:s.processes,onChange:b=>g({processes:Math.max(1,+b.target.value|0)})})]}),n.jsxs("label",{className:"field",children:[n.jsxs("span",{children:["Seed ",n.jsx(Qn,{text:"Fix it to get the same samples again (reproducible). Empty: random."})]}),n.jsx("input",{className:"input tiny num",type:"number",min:0,placeholder:"any",title:"Empty: a random seed",value:s.seed??"",onChange:b=>g({seed:b.target.value===""?null:Math.max(0,+b.target.value|0)})})]}),n.jsxs("label",{className:"check",title:"Sample only flux states that keep the objective above a fraction of its optimum (COBRApy fix_objective_as_constraint)",children:[n.jsx("input",{type:"checkbox",checked:s.objectiveFraction!=null,onChange:b=>g({objectiveFraction:b.target.checked?.9:null})})," Keep objective ≥"]}),s.objectiveFraction!=null&&n.jsx("input",{className:"input tiny num",type:"number",min:0,max:1,step:.05,value:s.objectiveFraction,onChange:b=>g({objectiveFraction:Math.min(1,Math.max(0,+b.target.value))}),title:"Fraction of the optimal objective"}),s.objectiveFraction!=null&&n.jsx("span",{className:"muted small",children:"× optimum"})]}),(a==="fba"||a==="loopless")&&n.jsx("span",{className:"muted small",children:"No extra parameters. The solver and tolerances come from COBRApy's configuration."})]}),Object.keys(c).length>0&&a==="fva"&&n.jsx("div",{className:"muted small",children:"Tip: select the filtered rows in the explorer (header checkbox) to run FVA on just those."})]},a==="sampling"?"samp":"other")]}),a==="sampling"&&n.jsxs("div",{className:"note small",children:["Sampling explores the whole space allowed by the constraints",s.objectiveFraction!=null?n.jsxs(n.Fragment,{children:[" with the objective kept ≥ ",s.objectiveFraction," × optimum"]}):n.jsx(n.Fragment,{children:" (the objective is not optimized unless you constrain it)"}),". Cost ≈ warmup (",e.summary.reactions*2," LPs) + ",s.samples.toLocaleString()," × ",s.thinning," steps",e.summary.reactions>1500?" — on a model this size expect minutes; you can stop and keep the samples drawn so far":"","."]}),h&&n.jsxs("div",{className:"note small",children:["FVA on ",e.summary.reactions," reactions solves ",e.summary.reactions*2," LPs and can take a minute or more. For a quick look, select the reactions of interest in the explorer and run FVA on the selection."]}),n.jsxs("div",{className:"run-wrap",children:[n.jsx("button",{className:"btn primary run-btn",disabled:!!o||!f,onClick:y,children:o?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner"})," Running ",Qt[o.method].label,"…"]}):n.jsxs(n.Fragment,{children:[n.jsx(q,{name:"play",size:13})," Run ",Qt[a].label]})}),!f&&n.jsx("span",{className:"warn-text small",children:"Set an objective first."})]}),n.jsx(k4,{})]})}function C4({since:e}){const[,t]=E.useState(0);return E.useEffect(()=>{const i=setInterval(()=>t(a=>a+1),100);return()=>clearInterval(i)},[]),n.jsxs("span",{className:"mono",children:[((Date.now()-e)/1e3).toFixed(1)," s"]})}function k4(){const e=S(a=>a.running),t=S(a=>a.lastRun),i=S(a=>{var s;return ee.result((s=a.lastRun)==null?void 0:s.resultId,a)});return e?n.jsx(M4,{}):t!=null&&t.cancelled?n.jsxs("div",{className:"run-status cancelled",children:[n.jsxs("span",{children:[n.jsx(q,{name:"stop",size:10})," ",Qt[t.method??"fba"].label," cancelled — nothing was saved."]}),t.method!=="fva"&&n.jsx("span",{className:"muted small",children:"A single solve cannot be interrupted inside the solver: it finishes in the background (a new run waits for it) and its answer is discarded."})]}):t!=null&&t.error?n.jsx(ml,{info:t.error,title:"Simulation could not be completed"}):i?n.jsx(d_,{r:i}):null}function M4(){const e=S(l=>l.running),t=e.progress,i=e.method==="fva",a=e.method==="sampling",s=t&&t.total?t.done/t.total*100:null,o=Qt[e.method].label;return n.jsxs("div",{className:"run-status running col",children:[n.jsxs("div",{className:"row gap",children:[n.jsx("span",{className:"spinner"}),n.jsxs("span",{className:"grow",children:[e.stopping?`Stopping ${o}…`:`Running ${o} on “${e.stateName}”…`," ",n.jsx(C4,{since:e.startedAt})]}),!e.stopping&&n.jsxs(n.Fragment,{children:[(i||a)&&t&&t.done>0&&n.jsxs("button",{className:"btn small",onClick:()=>B.cancelRun(!0),title:a?"Stop after the current batch and keep the samples drawn so far, as a result marked “stopped at”":"Stop after the current chunk and save the intervals already computed, as a result marked “stopped at”",children:["Stop & keep ",t.done]}),n.jsxs("button",{className:"btn small danger",onClick:()=>B.cancelRun(),title:"Stop and discard",children:[n.jsx(q,{name:"stop",size:10})," Stop"]})]})]}),i&&n.jsxs("div",{className:"run-progress",children:[n.jsx("div",{className:"rp-track",children:n.jsx("span",{style:{width:`${s??0}%`}})}),n.jsx("span",{className:"mono small muted",children:t?`${t.done.toLocaleString()} / ${t.total.toLocaleString()} reactions`:"computing the optimum…"})]}),a&&n.jsxs("div",{className:"run-progress",children:[n.jsx("div",{className:"rp-track",children:n.jsx("span",{style:{width:`${(t==null?void 0:t.phase)==="sampling"?s??0:0}%`}})}),n.jsx("span",{className:"mono small muted",children:!t||t.phase==="warmup"||t.phase==="solving"||t.phase==="queued"?"warmup: extreme points of the flux space (one LP pair per reaction)…":`${t.done.toLocaleString()} / ${t.total.toLocaleString()} samples`})]})]})}function d_({r:e}){const t=S(o=>o.index),i=e.solverStatus==="optimal",a=N4(e,o=>{var l;return((l=t.rxn.get(o))==null?void 0:l.name)??""});if(!i)return n.jsxs("div",{className:"error-card",children:[n.jsxs("div",{className:"row gap",children:[n.jsx(tc,{status:e.solverStatus}),n.jsxs("span",{className:"ec-title",children:["Model ",ox[e.solverStatus].toLowerCase()," — no flux distribution"]})]}),n.jsxs("div",{className:"ec-msg",children:["“",e.name,"”: the solver returned ",n.jsx("b",{children:e.metadata.solverStatusRaw}),". No fluxes are shown — they are not zero, they do not exist for this problem."]}),e.diagnostics.length>0&&n.jsxs("div",{className:"ec-hints",children:[n.jsx("div",{className:"muted small",children:"Possible areas to inspect:"}),n.jsx("ul",{children:e.diagnostics.map((o,l)=>n.jsx("li",{children:o},l))})]}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:()=>B.setSection("medium"),children:"Medium"}),n.jsx("button",{className:"btn small",onClick:()=>{B.setSection("simulate"),S.setState({objectiveEditorOpen:!0})},children:"Objective"}),n.jsx("button",{className:"btn small",onClick:()=>S.setState({rxnFilters:{modifiedOnly:!0},explorerTab:"reactions",section:"explore"}),children:"Modified bounds"}),e.metadata.message&&n.jsxs("details",{className:"ec-details",children:[n.jsx("summary",{children:"Show details"}),n.jsx("pre",{children:e.metadata.message})]})]})]});const s=e.reactionFluxes?Object.values(e.reactionFluxes).filter(o=>!ee.isZero(o)).length:null;return n.jsxs("div",{className:"run-status ok",children:[n.jsxs("div",{className:"rs-grid",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Status"}),n.jsx(tc,{status:e.solverStatus})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Objective"}),n.jsxs("b",{className:"mono",children:[W(e.objectiveValue)," ",a]})]}),e.metadata.totalFlux!=null&&n.jsxs("div",{children:[n.jsx("span",{children:"Total flux (pFBA)"}),n.jsx("b",{className:"mono",children:W(e.metadata.totalFlux)})]}),s!=null&&n.jsxs("div",{children:[n.jsx("span",{children:"Active reactions"}),n.jsxs("b",{className:"mono",children:[s," / ",Object.keys(e.reactionFluxes).length]})]}),e.samples&&e.metadata.sampling&&n.jsxs("div",{children:[n.jsx("span",{children:"Samples"}),n.jsxs("b",{className:"mono",children:[e.metadata.sampling.n,e.metadata.partial?` of ${e.metadata.partial.total}`:""]}),e.metadata.sampling.invalid>0&&n.jsxs("span",{className:"tag warn",title:"Failed COBRApy's validation (bounds or mass balance) and were dropped",children:[e.metadata.sampling.invalid," invalid"]}),e.metadata.partial&&n.jsx("span",{className:"tag warn",children:"stopped early"})]}),e.fva&&n.jsxs("div",{children:[n.jsx("span",{children:"FVA reactions"}),n.jsxs("b",{className:"mono",children:[Object.keys(e.fva).length,e.metadata.partial?` of ${e.metadata.partial.total}`:""]}),e.metadata.partial&&n.jsx("span",{className:"tag warn",children:"stopped early"})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Solver"}),n.jsx("b",{children:e.metadata.solver})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Time"}),n.jsxs("b",{className:"mono",children:[e.metadata.elapsedSeconds.toFixed(2)," s"]})]})]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("b",{className:"grow ellipsis",children:e.name}),n.jsx("button",{className:"btn small",onClick:()=>B.setSection("results"),children:"Open result"}),e.reactionFluxes&&n.jsx("button",{className:"btn small",onClick:()=>{S.setState(o=>({sort:{...o.sort,reactions:{key:"absFlux",dir:"desc"}},hideZero:!0,explorerTab:"reactions",section:"explore",rxnFilters:{}}))},children:"Sort reactions by |flux|"}),n.jsx("button",{className:"btn small primary",onClick:()=>S.setState({dialog:{kind:"visualize-result",resultId:e.id}}),children:"Visualize result"})]})]})}function E4(e,t){var s;const i=e.samples;if(!i)return[];if(i.reactions[t])return i.reactions[t];const a=i.constant[t];return a==null?[]:Array(((s=e.metadata.sampling)==null?void 0:s.n)??1).fill(a)}function G4({s:e}){const t=Math.min(0,e.min??0),a=Math.max(0,e.max??0)-t||1,s=o=>`${((o??0)-t)/a*100}%`;return n.jsxs("span",{className:"smp-box",title:`2.5 %: ${W(e.q025)} · 25 %: ${W(e.q25)} · median: ${W(e.median)} · 75 %: ${W(e.q75)} · 97.5 %: ${W(e.q975)}`,children:[n.jsx("i",{className:"smp-zero",style:{left:s(0)}}),n.jsx("i",{className:"smp-whisk",style:{left:s(e.q025),width:`calc(${s(e.q975)} - ${s(e.q025)})`}}),n.jsx("i",{className:"smp-iqr",style:{left:s(e.q25),width:`max(2px, calc(${s(e.q75)} - ${s(e.q25)}))`}}),n.jsx("i",{className:"smp-med",style:{left:s(e.median)}})]})}function S4({r:e}){var y;const t=S(b=>b.index),i=S(b=>b.searchIndex),[a,s]=E.useState(""),o=Xn(a,110),[l,r]=E.useState(!0),[c,d]=E.useState(null),f=e.samples,u=E.useMemo(()=>Object.entries(f.summary).map(([b,_])=>{var x;return{id:b,name:((x=t.rxn.get(b))==null?void 0:x.name)??"",s:_,constant:!(b in f.reactions)}}),[f,t]),p=E.useMemo(()=>{const b=i.matchIds(o,"reaction");return u.filter(_=>(!l||!_.constant)&&(!b||b.has(_.id)))},[u,l,o,i]),m=u.filter(b=>b.constant).length,h=[{key:"id",label:"Reaction",width:"minmax(110px, 1fr)",sortValue:b=>b.id,render:b=>n.jsx("span",{className:"mono ellipsis",title:b.id,children:b.id})},{key:"name",label:"Name",width:"minmax(140px, 2fr)",sortValue:b=>b.name,render:b=>n.jsx("span",{className:"ellipsis",title:b.name,children:b.name})},{key:"mean",label:"Mean",width:84,align:"right",sortValue:b=>b.s.mean,render:b=>n.jsx("span",{className:"mono",children:W(b.s.mean)})},{key:"median",label:"Median",width:84,align:"right",sortValue:b=>b.s.median,render:b=>n.jsx("span",{className:"mono",children:W(b.s.median)})},{key:"sd",label:"SD",width:76,align:"right",title:"Standard deviation of the samples",sortValue:b=>b.s.sd,render:b=>n.jsx("span",{className:"mono muted",children:W(b.s.sd)})},{key:"ci",label:"95 % interval",width:170,align:"right",title:"2.5th – 97.5th percentile of the samples",sortValue:b=>(b.s.q975??0)-(b.s.q025??0),render:b=>n.jsxs("span",{className:"mono small",children:["[",W(b.s.q025),", ",W(b.s.q975),"]"]})},{key:"box",label:"Distribution",width:"minmax(120px, 1.4fr)",sortValue:b=>Math.abs(b.s.median??0),title:"Box plot on each row’s own scale (the line marks zero)",render:b=>n.jsx(G4,{s:b.s})}],g=c?u.find(b=>b.id===c):null;return n.jsxs("div",{className:"smp-layout",children:[n.jsxs("div",{className:"rw-table",children:[n.jsxs("div",{className:"ex-toolbar",children:[n.jsxs("div",{className:"search-box ex-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:"Search reactions…",value:a,onChange:b=>s(b.target.value)})]}),n.jsxs(pn,{checked:l,onChange:r,title:"Reactions with the same flux in every sample (often blocked, 0)",children:["Hide constant (",m,")"]}),n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",children:[p.length," of ",u.length]})]}),n.jsx("div",{className:"ex-table",children:n.jsx(ci,{rows:p,cols:h,rowKey:b=>b.id,active:c,onRowClick:b=>d(b.id),onKeyNav:b=>d(b.id),empty:n.jsx("div",{className:"muted small pad",children:"No reaction matches."})})}),n.jsxs("div",{className:"muted small pad-x",children:["Click a reaction for the histogram of its samples. Statistics over ",((y=e.metadata.sampling)==null?void 0:y.n)??"?"," samples, in ",yt,". The mean flux vector is feasible but is not an optimal (FBA) solution."]})]}),g&&n.jsx("div",{className:"smp-detail",children:n.jsx(A4,{r:e,row:g,onClose:()=>d(null)})})]})}function A4({r:e,row:t,onClose:i}){const a=E4(e,t.id),s=t.s,o=300,l=150,r=6,c=Math.min(s.min??0,0),d=Math.max(s.max??0,0),f=d-c||1,u=Math.max(8,Math.min(40,Math.round(Math.sqrt(a.length)*1.5))),p=new Array(u).fill(0);for(const y of a)p[Math.min(u-1,Math.max(0,Math.floor((y-c)/f*u)))]++;const m=Math.max(1,...p),h=y=>r+((y??0)-c)/f*(o-2*r),g=(o-2*r)/u;return n.jsxs("div",{className:"smp-hist",children:[n.jsxs("div",{className:"row gap",children:[n.jsx("b",{className:"mono grow",children:t.id}),n.jsx("button",{className:"link small",onClick:()=>B.navigate({kind:"reaction",id:t.id}),children:"Inspect"}),n.jsx("button",{className:"icon-btn tiny",title:"Close",onClick:i,children:n.jsx(q,{name:"x",size:11})})]}),n.jsx("div",{className:"muted small ellipsis",children:t.name}),t.constant?n.jsxs("div",{className:"note small",children:["Same flux in every sample: ",n.jsx("span",{className:"mono",children:W(s.mean)}),"."]}):n.jsxs("svg",{viewBox:`0 0 ${o} ${l+18}`,className:"smp-svg",role:"img","aria-label":`Histogram of ${t.id}`,children:[n.jsx("rect",{x:h(s.q025),y:0,width:Math.max(1,h(s.q975)-h(s.q025)),height:l,className:"smp-band"}),p.map((y,b)=>n.jsx("rect",{x:r+b*g+.5,y:l-y/m*l,width:Math.max(.5,g-1),height:y/m*l,className:"smp-bar",children:n.jsx("title",{children:`${W(c+b*f/u)} – ${W(c+(b+1)*f/u)}: ${y} samples`})},b)),n.jsx("line",{x1:h(0),x2:h(0),y1:0,y2:l,className:"smp-zero-line"}),n.jsx("line",{x1:h(s.median),x2:h(s.median),y1:0,y2:l,className:"smp-med-line"}),n.jsx("line",{x1:h(s.mean),x2:h(s.mean),y1:0,y2:l,className:"smp-mean-line"}),n.jsx("text",{x:r,y:l+14,className:"smp-axis",children:W(c)}),n.jsx("text",{x:o-r,y:l+14,className:"smp-axis",textAnchor:"end",children:W(d)})]}),n.jsxs("div",{className:"smp-stats",children:[n.jsx("span",{children:"Mean"}),n.jsx("b",{className:"mono",children:W(s.mean)}),n.jsx("span",{children:"Median"}),n.jsx("b",{className:"mono",children:W(s.median)}),n.jsx("span",{children:"SD"}),n.jsx("b",{className:"mono",children:W(s.sd)}),n.jsx("span",{children:"95 % interval"}),n.jsxs("b",{className:"mono",children:["[",W(s.q025),", ",W(s.q975),"]"]}),n.jsx("span",{children:"Quartiles"}),n.jsxs("b",{className:"mono",children:["[",W(s.q25),", ",W(s.q75),"]"]}),n.jsx("span",{children:"Range"}),n.jsxs("b",{className:"mono",children:["[",W(s.min),", ",W(s.max),"]"]})]}),n.jsxs("div",{className:"muted small",children:[n.jsx("i",{className:"smp-key med"})," median · ",n.jsx("i",{className:"smp-key mean"})," mean · shaded: 95 % interval · grey line: 0"]})]})}function D4(){const e=Kn("lab-results-list",250,160,560),t=S(c=>c.results),i=S(c=>c.activeResultId),a=S(c=>c.activeFvaId),s=S(c=>{var d;return(d=c.lastRun)==null?void 0:d.resultId}),[o,l]=E.useState(null),r=t.find(c=>c.id===o)??t.find(c=>c.id===s)??t.find(c=>c.id===i)??t[t.length-1];return t.length?n.jsxs("div",{className:"results-layout",children:[n.jsxs("div",{className:"result-list",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"right"}),n.jsxs("div",{className:"pane-scroll",children:[n.jsxs("div",{className:"rl-head row between",children:[n.jsxs("span",{children:["Results · ",t.length]}),n.jsxs("button",{className:"btn small",title:"Import results (JSON, CSV, TSV) — e.g. from another model",onClick:Ru,children:[n.jsx(q,{name:"import",size:11})," Import"]})]}),[...t].reverse().map(c=>n.jsxs("button",{className:`rl-item ${(r==null?void 0:r.id)===c.id?"on":""}`,onClick:()=>{l(c.id),B.selectResult(c.id)},children:[n.jsxs("div",{className:"row gap",children:[n.jsx("i",{className:`status-dot s-${c.solverStatus}`}),n.jsx("span",{className:"ellipsis strong grow",children:c.name})]}),n.jsxs("div",{className:"muted small row gap",children:[n.jsxs("span",{children:[c.metadata.methodLabel," · ",c.metadata.state.name]}),n.jsx("span",{className:"grow"}),n.jsx("span",{children:rx(c.createdAt??Date.parse(c.metadata.timestamp))})]}),n.jsxs("span",{className:"row gap",children:[(c.id===i||c.id===a)&&n.jsx("span",{className:"tag on",children:c.id===a?"active FVA":"active"}),n.jsx($4,{r:c})]})]},c.id))]})]}),r&&n.jsx(P4,{r},r.id)]}):n.jsxs("div",{className:"lab-page",children:[n.jsx(ul,{title:"Results"}),n.jsxs("div",{className:"empty-state",children:[n.jsx("div",{className:"empty-title",children:"No simulation yet."}),n.jsx("p",{className:"muted",children:"Configure a medium and objective, then run FBA or pFBA. Every run is kept here with its exact configuration."}),n.jsxs("div",{className:"row gap",children:[n.jsxs("button",{className:"btn primary",onClick:()=>B.setSection("simulate"),children:[n.jsx(q,{name:"play",size:12})," Run simulation"]}),n.jsxs("button",{className:"btn",onClick:Ru,children:[n.jsx(q,{name:"import",size:12})," Import results…"]})]}),n.jsx("p",{className:"muted small",children:"JSON exported by GEMsMAP (FBA, FVA or flux sampling) or the legacy GEM Explorer, or CSV/TSV flux and FVA tables."})]})]})}function P4({r:e}){var m;const[t,i]=E.useState(e.solverStatus==="optimal"?"reactions":"provenance"),[a,s]=E.useState(!1),o=S(h=>{var g;return(((g=h.index)==null?void 0:g.subsystems.size)??0)>0}),l=S(h=>{var g;return((g=h.model)==null?void 0:g.checksum)??""}),r=e.solverStatus==="optimal",c=!!e.samples,d=Object.values(e.exchanges??{}),f=e.fva?null:d.filter(h=>!ee.isZero(h.uptake)).length,u=e.fva?null:d.filter(h=>!ee.isZero(h.secretion)).length,p=async(h,g)=>{try{const{blob:y,filename:b}=await Se.exportResult(e,h,g);i0(y,b)}catch(y){B.log("error",y instanceof On?y.info.title:String(y))}};return n.jsxs("div",{className:"result-ws",children:[n.jsxs("div",{className:"rw-head",children:[n.jsxs("div",{className:"grow",children:[a?n.jsx("input",{className:"input title-input",autoFocus:!0,defaultValue:e.name,onBlur:h=>{B.renameResult(e.id,h.target.value),s(!1)},onKeyDown:h=>{h.key==="Enter"&&h.target.blur()}}):n.jsx("div",{className:"rw-title",onDoubleClick:()=>s(!0),title:"Double-click to rename",children:e.name}),n.jsxs("div",{className:"muted small",children:[e.metadata.methodLabel," — state ",n.jsx("b",{children:e.metadata.state.name})," · ",new Date(e.metadata.timestamp).toLocaleString()]})]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small",onClick:()=>s(!0),children:"Rename"}),r&&n.jsx("button",{className:"btn small primary",onClick:()=>S.setState({dialog:{kind:"visualize-result",resultId:e.id}}),children:"Visualize result"}),r&&!c&&n.jsx("button",{className:"btn small",onClick:()=>{S.setState(h=>({compare:{...h.compare,aId:e.id,result:null}})),B.setSection("compare")},children:"Compare with…"}),n.jsx(Kt,{align:"right",trigger:(h,g)=>n.jsx("button",{className:`btn small ${h?"on":""}`,onClick:g,children:"Export ▾"}),children:h=>n.jsxs("div",{className:"menu-list",children:[n.jsx("button",{onClick:()=>{p("json","fluxes"),h()},children:"JSON (with full metadata)"}),e.reactionFluxes&&n.jsx("button",{onClick:()=>{p("csv","fluxes"),h()},children:"CSV · reaction fluxes"}),e.fva&&n.jsx("button",{onClick:()=>{p("csv","fva"),h()},children:"CSV · FVA intervals"}),e.metaboliteTurnover&&n.jsx("button",{onClick:()=>{p("csv","turnover"),h()},children:"CSV · metabolite turnover"}),e.exchanges&&n.jsxs("button",{onClick:()=>{p("csv","exchanges"),h()},children:["CSV · exchanges",c?" (mean of the samples)":""]}),c&&n.jsx("button",{onClick:()=>{p("csv","samples"),h()},title:"Long format reaction,condition,flux — opens in the Map Builder as a samples dataset",children:"CSV · all samples"}),c&&n.jsx("button",{onClick:()=>{p("csv","summary"),h()},children:"CSV · per-reaction statistics"})]})}),e.stateSnapshot&&(!e.metadata.model.checksum||l.startsWith(e.metadata.model.checksum))&&n.jsx("button",{className:"btn small",title:"Create a model state with exactly the configuration used for this result",onClick:()=>B.stateFromResult(e.id),children:"Restore configuration"}),n.jsx("button",{className:"icon-btn",title:"Delete result",onClick:()=>B.deleteResult(e.id),children:n.jsx(q,{name:"trash",size:14})})]})]}),r?n.jsxs("div",{className:"rw-summary",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Status"}),n.jsx(tc,{status:e.solverStatus})]}),n.jsxs("div",{children:[n.jsx("span",{children:c?"Objective (mean of samples)":"Objective"}),n.jsx("b",{className:"mono",children:W(e.objectiveValue)})]}),c&&e.metadata.sampling&&n.jsxs("div",{children:[n.jsx("span",{children:"Samples"}),n.jsxs("b",{className:"mono",children:[e.metadata.sampling.n,e.metadata.partial?` of ${e.metadata.partial.total}`:""]})]}),c&&e.metadata.sampling&&n.jsxs("div",{children:[n.jsx("span",{children:"Variable reactions"}),n.jsxs("b",{className:"mono",children:[e.metadata.sampling.variable," / ",e.metadata.sampling.variable+e.metadata.sampling.constant]})]}),c&&(((m=e.metadata.sampling)==null?void 0:m.invalid)??0)>0&&n.jsxs("div",{children:[n.jsx("span",{children:"Dropped (invalid)"}),n.jsx("b",{className:"mono",children:e.metadata.sampling.invalid})]}),e.reactionFluxes&&n.jsxs("div",{children:[n.jsx("span",{children:"Active reactions"}),n.jsxs("b",{className:"mono",children:[Object.values(e.reactionFluxes).filter(h=>!ee.isZero(h)).length," / ",Object.keys(e.reactionFluxes).length]})]}),e.fva&&n.jsxs("div",{children:[n.jsx("span",{children:"Reactions analysed"}),n.jsx("b",{className:"mono",children:Object.keys(e.fva).length})]}),f!=null&&n.jsxs("div",{children:[n.jsx("span",{children:"Uptakes"}),n.jsx("b",{className:"mono",children:f})]}),u!=null&&n.jsxs("div",{children:[n.jsx("span",{children:"Secretions"}),n.jsx("b",{className:"mono",children:u})]}),e.metadata.totalFlux!=null&&n.jsxs("div",{children:[n.jsx("span",{children:"Σ|flux| (pFBA)"}),n.jsx("b",{className:"mono",children:W(e.metadata.totalFlux)})]})]}):n.jsx("div",{className:"pad",children:n.jsx(d_,{r:e})}),n.jsx("div",{className:"ex-tabs rw-tabs",children:["reactions","metabolites","exchanges","subsystems","genes","provenance"].map(h=>n.jsx("button",{className:t===h?"on":"",disabled:!r&&h!=="provenance"||h==="subsystems"&&!o||c&&(h==="subsystems"||h==="genes"),title:c&&(h==="subsystems"||h==="genes")?"Needs one flux vector; a sampling result is a distribution per reaction":h==="subsystems"&&!o?"This model has no subsystem annotations":void 0,onClick:()=>i(h),children:h==="provenance"?"How was this generated?":h[0].toUpperCase()+h.slice(1)},h))}),n.jsxs("div",{className:"rw-body",children:[r&&t==="reactions"&&(c?n.jsx(S4,{r:e}):e.fva?n.jsx(I4,{r:e}):n.jsx(R4,{r:e})),r&&t==="metabolites"&&(e.metaboliteTurnover?n.jsx(B4,{r:e}):n.jsx("div",{className:"note",children:c?"Metabolite turnover (0.5 × Σ|S·v|) is not linear in the fluxes, so the turnover of the mean is not the mean turnover; it is not computed for flux samples.":"Metabolite turnover is derived from one flux distribution. FVA defines independent intervals per reaction, so no turnover is computed."})),r&&t==="exchanges"&&n.jsx(O4,{r:e}),r&&t==="subsystems"&&n.jsx(Dk,{r:e}),r&&t==="genes"&&n.jsx(H4,{r:e}),t==="provenance"&&n.jsx(L4,{r:e})]})]})}function zc(e){const[t,i]=E.useState(""),[a,s]=E.useState(!0),[o,l]=E.useState(e);return{q:t,setQ:i,hideZero:a,setHideZero:s,sort:o,setSort:l,onSort:c=>l(d=>(d==null?void 0:d.key)===c?d.dir==="desc"?{key:c,dir:"asc"}:null:{key:c,dir:"desc"}),dq:Xn(t,110)}}function Uc({t:e,placeholder:t,zeroLabel:i,count:a,total:s,children:o}){return n.jsxs("div",{className:"ex-toolbar",children:[n.jsxs("div",{className:"search-box ex-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:t,value:e.q,onChange:l=>e.setQ(l.target.value)})]}),n.jsx(pn,{checked:e.hideZero,onChange:e.setHideZero,children:i}),o,n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",children:[a.toLocaleString()," of ",s.toLocaleString()]})]})}function R4({r:e}){var l;const t=S(r=>r.model),i=S(r=>r.searchIndex),a=zc({key:"absFlux",dir:"desc"}),s=zx(e,null,e),o=E.useMemo(()=>{const r=i.matchIds(a.dq,"reaction"),c=t.reactions.filter(d=>{var f;return(!r||r.has(d.id))&&(!a.hideZero||!ee.isZero((f=e.reactionFluxes)==null?void 0:f[d.id]))});return oi(c,a.sort,(d,f)=>Kx(d,f,s))},[t,i,a.dq,a.hideZero,a.sort,s,e]);return n.jsxs("div",{className:"rw-table",children:[n.jsx(Uc,{t:a,placeholder:"Search reactions…",zeroLabel:"Hide zero flux",count:o.length,total:t.reactions.length,children:n.jsx("button",{className:`btn small ${((l=a.sort)==null?void 0:l.key)==="absFlux"?"on":""}`,onClick:()=>a.setSort({key:"absFlux",dir:"desc"}),children:"Sort by |flux|"})}),n.jsx("div",{className:"ex-table",children:n.jsx(Ux,{rows:o,ctx:s,columns:["id","name","flux","lb","ub","equation","subsystem"],sort:a.sort,onSort:a.onSort,editable:!1})}),n.jsxs("div",{className:"muted small pad-x",children:["Bounds shown are those of the state used for this result. Fluxes in ",yt,"."]})]})}function I4({r:e}){const t=S(d=>d.index),i=zc({key:"width",dir:"desc"}),a=S(d=>d.searchIndex),s=S(d=>d.settings.zeroTolerance),o=E.useMemo(()=>Object.entries(e.fva??{}).map(([d,f])=>({id:d,min:f.minimum,max:f.maximum,width:sx(f.minimum,f.maximum,s)})),[e,s]),l=E.useMemo(()=>[Math.min(0,...o.map(d=>d.min??0)),Math.max(0,...o.map(d=>d.max??0))],[o]),r=E.useMemo(()=>{const d=a.matchIds(i.dq,"reaction"),f=o.filter(u=>(!d||d.has(u.id))&&(!i.hideZero||!(ee.isZero(u.min)&&ee.isZero(u.max))));return oi(f,i.sort,(u,p)=>{var m;return u==="id"?p.id.toLowerCase():u==="min"?p.min:u==="max"?p.max:u==="width"?p.width:u==="name"?(((m=t.rxn.get(p.id))==null?void 0:m.name)??"").toLowerCase():null})},[o,a,i.dq,i.hideZero,i.sort,t]),c=[{key:"id",label:"Reaction",width:"minmax(110px, 1fr)",render:d=>n.jsx("span",{className:"mono strong",children:d.id})},{key:"name",label:"Name",width:"minmax(140px, 1.6fr)",render:d=>{var f;return n.jsx("span",{className:"ellipsis",children:(f=t.rxn.get(d.id))==null?void 0:f.name})}},{key:"min",label:"Minimum",width:90,align:"right",render:d=>n.jsx("span",{className:"mono",children:W(d.min)})},{key:"max",label:"Maximum",width:90,align:"right",render:d=>n.jsx("span",{className:"mono",children:W(d.max)})},{key:"width",label:"Range",width:90,align:"right",title:"Width of the feasible interval (max − min)",render:d=>n.jsx("span",{className:"mono",children:W(d.width)})},{key:"bar",label:"Feasible interval",width:"minmax(160px, 2fr)",sortable:!1,render:d=>n.jsx(nl,{min:d.min,max:d.max,lo:l[0],hi:l[1]})}];return n.jsxs("div",{className:"rw-table",children:[n.jsx(Uc,{t:i,placeholder:"Search reactions…",zeroLabel:"Hide blocked (min = max = 0)",count:r.length,total:o.length}),n.jsx("div",{className:"note small",children:"FVA gives an independent feasible interval for each reaction. The intervals are not a joint flux distribution, and no midpoint is used as a flux. For one representative distribution, run FBA or pFBA."}),n.jsx("div",{className:"ex-table",children:n.jsx(ci,{rows:r,cols:c,rowKey:d=>d.id,sort:i.sort,onSort:i.onSort,onRowClick:d=>B.navigate({kind:"reaction",id:d.id}),onContextMenu:(d,f)=>S.setState({contextMenu:{x:f.clientX,y:f.clientY,refs:[{kind:"reaction",id:d.id}]}})})})]})}function B4({r:e}){const t=S(o=>o.model),i=S(o=>o.searchIndex),a=zc({key:"turnover",dir:"desc"}),s=E.useMemo(()=>{const o=i.matchIds(a.dq,"metabolite"),l=t.metabolites.filter(r=>{var c;return(!o||o.has(r.id))&&(!a.hideZero||!ee.isZero((c=e.metaboliteTurnover)==null?void 0:c[r.id]))});return oi(l,a.sort,(r,c)=>qx(r,c,e.metaboliteTurnover))},[t,i,a.dq,a.hideZero,a.sort,e]);return n.jsxs("div",{className:"rw-table",children:[n.jsx(Uc,{t:a,placeholder:"Search metabolites…",zeroLabel:"Hide zero turnover",count:s.length,total:t.metabolites.length}),n.jsx("div",{className:"ex-table",children:n.jsx(Vx,{rows:s,turnover:e.metaboliteTurnover,sort:a.sort,onSort:a.onSort})})]})}function H4({r:e}){const t=S(r=>r.model),i=S(r=>r.settings.zeroTolerance),a=zc({key:"active",dir:"desc"}),s=S(r=>r.searchIndex),o=E.useMemo(()=>r=>e.reactionFluxes?r.reactions.filter(c=>Math.abs(e.reactionFluxes[c]??0)>=i).length:null,[e,i]),l=E.useMemo(()=>{const r=s.matchIds(a.dq,"gene"),c=t.genes.filter(d=>(!r||r.has(d.id))&&(!a.hideZero||!e.reactionFluxes||(o(d)??0)>0));return oi(c,a.sort,(d,f)=>Wx(d,f,o))},[t,s,a.dq,a.hideZero,a.sort,o,e]);return n.jsxs("div",{className:"rw-table",children:[n.jsx(Uc,{t:a,placeholder:"Search genes…",zeroLabel:"Only genes with active reactions",count:l.length,total:t.genes.length}),n.jsx("div",{className:"ex-table",children:n.jsx(Yx,{rows:l,active:o,sort:a.sort,onSort:a.onSort})})]})}function O4({r:e}){const t=S(p=>p.index),[i,a]=E.useState(!0),[s,o]=E.useState({key:e.fva?"uptakeMax":"uptake",dir:"desc"}),l=!!e.fva,r=E.useMemo(()=>Object.entries(e.exchanges??{}).map(([p,m])=>{var h;return{id:p,met:m.metabolite,name:m.metabolite&&((h=t.met.get(m.metabolite))==null?void 0:h.name)||m.metabolite||p,...m}}),[e,t]),c=E.useMemo(()=>{const p=i?r.filter(m=>l?!(ee.isZero(m.uptakeMax)&&ee.isZero(m.secretionMax)):!ee.isZero(m.flux)):r;return oi(p,s,(m,h)=>m==="name"?h.name.toLowerCase():m==="id"?h.id.toLowerCase():h[m]??null)},[r,i,s,l]),d=p=>o(m=>(m==null?void 0:m.key)===p?m.dir==="desc"?{key:p,dir:"asc"}:null:{key:p,dir:"desc"}),f=p=>p==null||ee.isZero(p)?n.jsx("span",{className:"muted",children:"—"}):n.jsx("span",{className:"mono",children:W(p)}),u=[{key:"name",label:"Compound",width:"minmax(150px, 2fr)",render:p=>p.met?n.jsx(Xt,{r:{kind:"metabolite",id:p.met},children:p.name}):p.name},{key:"id",label:"Exchange",width:"minmax(120px, 1.3fr)",render:p=>n.jsxs("span",{className:"mono",children:[p.id,p.kind!=="exchange"&&n.jsx("span",{className:"tag",children:p.kind})]})},...l?[{key:"fluxMin",label:"Flux min",width:90,align:"right",render:p=>n.jsx("span",{className:"mono",children:W(p.fluxMin)})},{key:"fluxMax",label:"Flux max",width:90,align:"right",render:p=>n.jsx("span",{className:"mono",children:W(p.fluxMax)})},{key:"uptakeMax",label:"Max uptake",width:100,align:"right",render:p=>f(p.uptakeMax)},{key:"secretionMax",label:"Max secretion",width:110,align:"right",render:p=>f(p.secretionMax)}]:[{key:"uptake",label:"Uptake",width:100,align:"right",render:p=>f(p.uptake)},{key:"secretion",label:"Secretion",width:100,align:"right",render:p=>f(p.secretion)},{key:"flux",label:"Flux",width:90,align:"right",render:p=>n.jsx("span",{className:"mono muted",children:W(p.flux)})}]];return n.jsxs("div",{className:"rw-table",children:[n.jsxs("div",{className:"ex-toolbar",children:[n.jsx(pn,{checked:i,onChange:a,children:"Hide inactive exchanges"}),!l&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:`btn small ${(s==null?void 0:s.key)==="uptake"?"on":""}`,onClick:()=>o({key:"uptake",dir:"desc"}),children:"Sort by uptake"}),n.jsx("button",{className:`btn small ${(s==null?void 0:s.key)==="secretion"?"on":""}`,onClick:()=>o({key:"secretion",dir:"desc"}),children:"Sort by secretion"})]}),n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",children:[c.length," of ",r.length," · ",yt]})]}),n.jsx("div",{className:"ex-table",children:n.jsx(ci,{rows:c,cols:u,rowKey:p=>p.id,sort:s,onSort:d,onRowClick:p=>B.navigate({kind:"reaction",id:p.id})})})]})}function $4({r:e}){const t=S(l=>{var r;return((r=l.model)==null?void 0:r.checksum)??""}),i=e.metadata.partial;if(i)return n.jsxs("span",{className:"tag warn",title:"FVA stopped early: intervals exist only for these reactions",children:[i.done,"/",i.total]});if(!e.origin)return null;const a=e.metadata.model.checksum,s=!!a&&!t.startsWith(a),o=e.origin.total?Math.round((e.origin.matched??0)/e.origin.total*100):null;return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"tag",title:`Imported from ${e.origin.file}`,children:"imported"}),s&&n.jsx("span",{className:"tag warn",title:`Computed with ${e.metadata.model.filename||"another model"} — compared by reaction id`,children:"other model"}),o!=null&&o<100&&n.jsxs("span",{className:"tag warn",title:"Reaction ids of the result found in the loaded model",children:[o,"% ids"]})]})}function L4({r:e}){const t=e.metadata,i=S(o=>o.index),a=Object.entries(t.medium).filter(([,o])=>o!=null&&o>0),s=(o,l)=>n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:o}),n.jsx("span",{children:l})]});return n.jsxs("div",{className:"provenance",children:[n.jsx("div",{className:"prov-title",children:"How was this generated?"}),e.origin&&n.jsx(T4,{r:e}),s("Model",n.jsxs("span",{children:[n.jsx("b",{children:t.model.name||t.model.modelId})," ",n.jsx("span",{className:"mono small muted",children:t.model.filename})]})),s("Model checksum",n.jsxs("span",{className:"mono small",children:["sha256 ",t.model.checksum.slice(0,16),"…"]})),s("State",t.state.name),s("Method",`${t.methodLabel}${Object.keys(t.parameters).length?" · "+Object.entries(t.parameters).filter(([,o])=>o!=null).map(([o,l])=>`${o} ${l}`).join(", "):""}`),s("Objective",n.jsxs("span",{className:"mono",children:[Pi(t.objective),t.objectiveIsModelDefault?n.jsx("span",{className:"muted",children:" (model file)"}):null]})),s("Medium",`${a.length} exchange reactions allow uptake`),n.jsxs("details",{className:"prov-list",children:[n.jsx("summary",{className:"muted small",children:"Show medium"}),a.map(([o,l])=>{var r,c;return n.jsxs("div",{className:"kv small",children:[n.jsx(Xt,{r:{kind:"reaction",id:o},children:o}),n.jsxs("span",{className:"mono",children:[W(l)," · ",((c=i.met.get(((r=i.rxn.get(o))==null?void 0:r.boundaryMetabolite)??""))==null?void 0:c.name)??""]})]},o)})]}),s("Modified bounds",t.boundChanges.length?`${t.boundChanges.length} reaction${t.boundChanges.length>1?"s":""}`:"none (model file bounds)"),t.boundChanges.length>0&&n.jsx("div",{className:"prov-list",children:t.boundChanges.map(o=>n.jsxs("div",{className:"kv small",children:[n.jsx(Xt,{r:{kind:"reaction",id:o.reaction},children:o.reaction}),n.jsxs("span",{className:"mono",children:[Ua(o.original)," → ",Ua(o.current)]})]},o.reaction))}),s("Solver",`${t.solver} · status ${t.solverStatusRaw}`),s("Status",n.jsx(tc,{status:e.solverStatus})),s("Objective value",n.jsx("span",{className:"mono",children:W(e.objectiveValue)})),t.totalFlux!=null&&s("pFBA total flux (minimized)",n.jsx("span",{className:"mono",children:W(t.totalFlux)})),s("Timestamp",new Date(t.timestamp).toLocaleString()),s("Computation time",`${t.elapsedSeconds.toFixed(3)} s`),s("Software",`COBRApy ${t.cobraVersion}`),t.message&&s("Solver message",n.jsx("span",{className:"mono small",children:t.message}))]})}function T4({r:e}){var o;const t=S(l=>l.model),i=e.origin,a=e.metadata.model.checksum,s=!!a&&t.checksum.startsWith(a);return n.jsxs("div",{className:"note small",children:[n.jsxs("div",{children:[n.jsx("b",{children:"Imported"})," from ",n.jsx("span",{className:"mono",children:i.file})," (",i.format,") on ",new Date(i.importedAt).toLocaleString(),". Values are as stored in the file."]}),n.jsx("div",{children:s?"Computed with the loaded model (same file checksum).":a?n.jsxs(n.Fragment,{children:["Computed with ",n.jsx("b",{children:e.metadata.model.filename||"another model"}),", not the loaded model — comparisons match reactions by id."]}):"The source model is not recorded in the file."}),i.total!=null&&n.jsxs("div",{children:[i.matched," of ",i.total," reaction ids exist in the loaded model (",t.filename,")",i.matched!==i.total?"; the others are kept for comparison but cannot be shown in model tables.":"."]}),i.derivedWith&&n.jsxs("div",{children:["Metabolite turnover and exchanges were not in the file; COBRApy derived them from these fluxes with ",i.derivedWith,"."]}),(o=i.notes)==null?void 0:o.map((l,r)=>n.jsx("div",{children:l},r))]})}const F4=[{id:"overview",label:"Overview",icon:"file"},{id:"explore",label:"Explore",icon:"search"},{id:"medium",label:"Medium",icon:"particles"},{id:"simulate",label:"Simulation",icon:"play"},{id:"results",label:"Results",icon:"plot"},{id:"compare",label:"Compare",icon:"swap"},{id:"annotation",label:"Metabolite analysis",icon:"sparkle"}];function X4(){const e=S(a=>a.model),t=S(a=>a.section),i=S(a=>a.busy);return e?n.jsxs("div",{className:"lab",children:[n.jsx(K4,{}),n.jsxs("main",{className:"lab-main",children:[t==="overview"&&n.jsx(yg,{}),t==="explore"&&n.jsx(PM,{}),t==="medium"&&n.jsx(g4,{}),t==="simulate"&&n.jsx(w4,{}),t==="results"&&n.jsx(D4,{}),t==="compare"&&n.jsx(Fk,{}),t==="annotation"&&n.jsx(gk,{})]}),n.jsx(JM,{}),n.jsx(l4,{}),n.jsx(d4,{})]}):n.jsxs("div",{className:"lab",children:[n.jsx("div",{className:"lab-main",children:n.jsx(yg,{})}),i&&e===null&&null]})}function K4(){const e=Kn("lab-side",188,52,420,{narrow:[1100,52]}),t=S(r=>r.section),i=S(r=>r.results),a=S(r=>r.favorites),s=S(r=>r.savedViews),o=S(r=>r.index),l=S(r=>r.running);return n.jsxs("nav",{className:`lab-side ${e.width<110?"compact":""}`,style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"right"}),n.jsxs("div",{className:"pane-scroll ls-scroll",children:[n.jsx("div",{className:"ls-group",children:F4.map(r=>n.jsxs("button",{className:`ls-item ${t===r.id?"on":""}`,onClick:()=>B.setSection(r.id),children:[n.jsx(q,{name:r.icon,size:15}),n.jsx("span",{children:r.label}),r.id==="results"&&i.length>0&&n.jsx("span",{className:"ls-count",children:i.length}),r.id==="simulate"&&l&&n.jsx("span",{className:"spinner sm"})]},r.id))}),n.jsxs("div",{className:"ls-group",children:[n.jsx("div",{className:"ls-title",children:"Favorites"}),!a.length&&n.jsx("div",{className:"ls-hint",children:"Star entities (☆ in the inspector) to pin them here."}),a.map(r=>{var u,p;const c=r.indexOf(":"),d=r.slice(0,c),f=r.slice(c+1);return n.jsxs("button",{className:"ls-fav",title:d==="metabolite"?(u=o.met.get(f))==null?void 0:u.name:(p=o.rxn.get(f))==null?void 0:p.name,onClick:()=>B.navigate({kind:d,id:f}),children:[n.jsx("span",{className:`kind k-${d}`,children:d[0].toUpperCase()}),n.jsx("span",{className:"ellipsis mono",children:f})]},r)})]}),n.jsxs("div",{className:"ls-group",children:[n.jsx("div",{className:"ls-title",children:"Views"}),[..._x.slice(0,3),...s].map(r=>n.jsx("button",{className:"ls-view",onClick:()=>B.applyView(r),children:n.jsx("span",{className:"ellipsis",children:r.name})},r.id))]})]})]})}function z4(){const e=S(a=>a.model),t=S(a=>a.running),i=S(a=>a.method);return e?n.jsxs(n.Fragment,{children:[n.jsx(Qr,{workspace:"lab"}),n.jsxs("div",{className:"lab-header",children:[n.jsxs("span",{className:"lh-model",title:`${e.filename} · sha256 ${e.checksum.slice(0,12)}`,children:[n.jsx("span",{className:"muted",children:"Model"})," ",n.jsx("b",{children:e.name})]}),n.jsx(U4,{}),n.jsx(q4,{}),n.jsx(ZM,{}),n.jsxs("div",{className:"run-split",children:[n.jsx("button",{className:"btn primary small",disabled:!!t,onClick:()=>B.simulate(i),title:"Run with the active state",children:t?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner sm light"})," ",Qt[t.method].short,"…"]}):n.jsxs(n.Fragment,{children:["Run ",Qt[i].short," ",n.jsx(q,{name:"play",size:11})]})}),t?n.jsx("button",{className:"btn small split stop-btn",onClick:()=>B.cancelRun(),disabled:!!t.stopping,title:`Stop ${Qt[t.method].label} (nothing is saved)`,children:n.jsx(q,{name:"stop",size:10})}):n.jsx(Kt,{align:"right",trigger:(a,s)=>n.jsx("button",{className:`btn primary small split ${a?"on":""}`,onClick:s,children:"▾"}),children:a=>n.jsxs("div",{className:"menu-list",children:[["fba","pfba","loopless","fva","sampling"].map(s=>n.jsxs("button",{className:s===i?"on":"",onClick:()=>{S.setState({method:s}),B.simulate(s),a()},children:[n.jsxs("span",{children:["Run ",Qt[s].label]}),n.jsx("span",{className:"muted small",children:Qt[s].blurb})]},s)),n.jsx("div",{className:"dd-sep"}),n.jsx("button",{onClick:()=>{B.setSection("simulate"),a()},children:"Simulation options…"})]})})]})]})]}):n.jsx(Qr,{workspace:"lab"})}function U4(){const e=S(s=>s.states),t=S(s=>ee.activeState(s)),[i,a]=E.useState(null);return n.jsx(Kt,{trigger:(s,o)=>n.jsxs("button",{className:`state-btn ${s?"on":""}`,onClick:o,title:"Model state (scenario)",children:[n.jsx("span",{className:"muted",children:"State"})," ",n.jsx("b",{children:t.name})," ▾"]}),children:s=>n.jsxs("div",{className:"menu-list state-menu",children:[n.jsx("div",{className:"menu-label",children:"Model states"}),e.map(o=>n.jsxs("div",{className:`menu-row ${o.id===t.id?"on":""}`,children:[i===o.id?n.jsx("input",{className:"input tiny",autoFocus:!0,defaultValue:o.name,onBlur:l=>{B.renameState(o.id,l.target.value),a(null)},onKeyDown:l=>{l.key==="Enter"&&l.target.blur(),l.key==="Escape"&&a(null)}}):n.jsxs("button",{onClick:()=>{B.setActiveState(o.id),s()},children:[n.jsxs("span",{children:[o.id===t.id?"● ":"",o.name]}),n.jsxs("span",{className:"muted small",children:[Object.keys(o.bounds).length," bounds",o.objective?" · objective":""]})]}),n.jsx("button",{className:"icon-btn tiny",title:"Rename",onClick:()=>a(o.id),children:n.jsx(q,{name:"text",size:11})}),n.jsx("button",{className:"icon-btn tiny",title:"Duplicate",onClick:()=>B.duplicateState(o.id),children:n.jsx(q,{name:"plus",size:11})}),e.length>1&&n.jsx("button",{className:"icon-btn tiny",title:"Delete state",onClick:()=>B.deleteState(o.id),children:n.jsx(q,{name:"trash",size:11})})]},o.id)),n.jsx("div",{className:"dd-sep"}),n.jsxs("button",{onClick:()=>{const o=B.duplicateState();o&&a(o)},children:["Duplicate “",t.name,"”…"]}),n.jsx("button",{onClick:()=>{B.newState(),s()},children:"New state from the model file"}),n.jsx("button",{onClick:()=>{B.setSection("compare"),s()},children:"Compare states…"})]})})}function q4(){const e=S(s=>ee.activeState(s)),t=S(s=>s.model),i=Object.keys(e.bounds).length+(e.objective?1:0),a=()=>{const s=new Blob([JSON.stringify({format:"cobragui-modifications",version:1,model:{filename:t.filename,checksum:t.checksum},state:e.name,bounds:e.bounds,objective:e.objective,changes:e.changes},null,1)],{type:"application/json"});i0(s,`${e.name.replace(/\W+/g,"_")}_modifications.json`)};return n.jsx(Kt,{align:"right",className:"changes-pop",trigger:(s,o)=>n.jsx("button",{className:`mod-btn ${i?"mod":""} ${s?"on":""}`,onClick:o,title:"Model modifications in this state",children:i?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"modified-dot",children:"●"})," Modified · ",i]}):n.jsx("span",{className:"muted",children:"Unmodified"})}),children:()=>n.jsxs("div",{className:"changes",children:[n.jsxs("div",{className:"row between",children:[n.jsxs("b",{children:["Model modifications · ",e.name]}),n.jsxs("span",{className:"muted small",children:[e.changes.length," recorded"]})]}),n.jsxs("div",{className:"muted small",children:[Object.keys(e.bounds).length," reactions with modified bounds",e.objective?" · objective changed":"",". The imported file is never modified."]}),n.jsxs("div",{className:"change-list",children:[!e.changes.length&&n.jsx("div",{className:"muted small",children:"No changes yet."}),[...e.changes].reverse().slice(0,80).map(s=>n.jsxs("div",{className:"change",children:[n.jsxs("div",{className:"row between",children:[n.jsx("button",{className:"link mono",onClick:()=>s.target!=="Objective"&&s.target!=="Model"&&B.navigate({kind:"reaction",id:s.target}),children:s.target}),n.jsx("span",{className:"muted small",children:rx(s.time)})]}),n.jsxs("div",{className:"mono small",children:[s.before," → ",s.after]}),s.note&&n.jsx("div",{className:"muted small",children:s.note})]},s.id))]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("button",{className:"btn small",disabled:!e.undo.length,onClick:B.undo,children:[n.jsx(q,{name:"undo",size:12})," Undo"]}),n.jsxs("button",{className:"btn small",disabled:!e.redo.length,onClick:B.redo,children:[n.jsx(q,{name:"redo",size:12})," Redo"]}),n.jsx("button",{className:"btn small warn",disabled:!i,onClick:()=>{window.confirm(`Revert all ${i} modifications of “${e.name}” to the model file?`)&&B.resetState()},children:"Revert"}),n.jsx("button",{className:"btn small",disabled:!e.changes.length,onClick:a,children:"Export modifications"}),n.jsx("button",{className:"btn small",onClick:()=>S.setState({dialog:{kind:"export-model"}}),children:"Save as model…"})]})]})})}function V4(){var c,d,f,u;const e=S(p=>p.backend),t=S(p=>p.model),i=S(p=>ee.fluxResult(p)),a=S(p=>ee.fvaResult(p)),s=S(p=>p.running),o=S(p=>p.logOpen),l=S(p=>p.settings),r=S(p=>p.busy);return n.jsxs("footer",{className:"bottombar lab-status",children:[n.jsx("span",{className:`be-dot ${e.status}`,title:e.status==="online"?`COBRApy ${(c=e.health)==null?void 0:c.cobraVersion} · solvers ${(d=e.health)==null?void 0:d.solvers.join(", ")}`:"Backend offline — start GEMsMAP with the gemsmap command"}),n.jsx("span",{className:"small",children:e.status==="online"?`COBRApy ${(f=e.health)==null?void 0:f.cobraVersion} · ${(u=e.health)==null?void 0:u.defaultSolver}`:e.status==="checking"?"Connecting…":n.jsx("button",{className:"link",onClick:()=>B.checkBackend(),children:"Backend offline — retry"})}),r&&n.jsxs("span",{className:"small",children:[n.jsx("span",{className:"spinner sm"})," ",r]}),s&&n.jsxs("span",{className:"small",children:[n.jsx("span",{className:"spinner sm"})," ",s.stopping?"Stopping":"Running"," ",Qt[s.method].label,"…",s.progress?` ${s.progress.done}/${s.progress.total}`:"",!s.stopping&&n.jsx("button",{className:"link small",onClick:()=>B.cancelRun(),children:"Stop"})]}),t&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sb-sep"}),n.jsx("span",{className:"small muted",children:"Flux:"}),i?n.jsxs("button",{className:"link small",onClick:()=>B.setSection("results"),children:[i.name," · obj ",W(i.objectiveValue)]}):n.jsx("span",{className:"small muted",children:"—"}),a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"small muted",children:"FVA:"}),n.jsx("button",{className:"link small",onClick:()=>B.setSection("results"),children:a.name})]})]}),n.jsx("span",{className:"grow"}),n.jsx(Kt,{align:"right",trigger:(p,m)=>n.jsxs("button",{className:`link small ${p?"on":""}`,onClick:m,children:["Zero threshold |v| < ",l.zeroTolerance]}),children:()=>n.jsxs("div",{className:"filters settings-pop",children:[n.jsx("div",{className:"f-title",children:"Numerical zero"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"|flux| <"}),n.jsx("input",{className:"input tiny",type:"number",step:"any",min:0,value:l.zeroTolerance,onChange:p=>B.setSettings({zeroTolerance:Math.max(0,+p.target.value||0)})})]}),n.jsx("div",{className:"muted small",children:"Values below the threshold count as zero for “hide zero”, active-reaction counts and comparison categories. The solver's own tolerance is reported in each result."}),n.jsx("div",{className:"row gap",children:[1e-12,1e-9,1e-6].map(p=>n.jsx("button",{className:"btn small",onClick:()=>B.setSettings({zeroTolerance:p}),children:p},p))})]})}),n.jsx("button",{className:`link small ${o?"on":""}`,onClick:()=>S.setState({logOpen:!o}),children:"Activity log"}),e.health&&n.jsx(W4,{}),o&&n.jsx(Y4,{})]})}function xg(){const e=S.getState().backend.health;return[`GEMsMAP ${(e==null?void 0:e.version)??"unknown"}`,`Python ${(e==null?void 0:e.python)??"?"} on ${(e==null?void 0:e.platform)??"?"}`,`COBRApy ${(e==null?void 0:e.cobraVersion)??"?"}, solvers: ${(e==null?void 0:e.solvers.join(", "))??"?"} (default ${(e==null?void 0:e.defaultSolver)??"?"})`,`Browser: ${navigator.userAgent}`,`Address: ${location.origin}`].join(`
|
|
72
|
+
`)}function W4(){const e=S(s=>{var o;return(o=s.backend.health)==null?void 0:o.version}),[t,i]=E.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(xg()),i(!0),setTimeout(()=>i(!1),2e3)}catch{i(!1)}};return n.jsx(Kt,{align:"right",trigger:(s,o)=>n.jsxs("button",{className:`link small ${s?"on":""}`,onClick:o,title:"Version and diagnostics",children:["GEMsMAP ",e]}),children:()=>n.jsxs("div",{className:"filters settings-pop",children:[n.jsxs("div",{className:"f-title",children:["GEMsMAP ",e]}),n.jsx("div",{className:"muted small",children:"To report a problem, paste this block into your report. It lists versions only, no model or file names."}),n.jsx("textarea",{className:"input mono small",readOnly:!0,rows:5,value:xg(),onFocus:s=>s.currentTarget.select()}),n.jsx("div",{className:"row gap",children:n.jsx("button",{className:"btn small",onClick:a,children:t?"Copied":"Copy diagnostics"})})]})})}function Y4(){const e=S(i=>i.log),t=i=>i==="error"?"✕":i==="warn"?"!":"·";return n.jsxs("div",{className:"log-panel",children:[n.jsxs("div",{className:"row between",children:[n.jsx("b",{children:"Activity log"}),n.jsx("button",{className:"icon-btn tiny",onClick:()=>S.setState({logOpen:!1}),children:n.jsx(q,{name:"x",size:11})})]}),n.jsxs("div",{className:"log-list",children:[!e.length&&n.jsx("div",{className:"muted small",children:"Nothing yet."}),[...e].reverse().map((i,a)=>n.jsxs("div",{className:`log-line l-${i.level}`,children:[n.jsx("span",{className:"mono muted",children:new Date(i.time).toLocaleTimeString()}),n.jsx("span",{className:"log-ico",children:t(i.level)}),n.jsx("span",{children:i.text})]},a))]})]})}async function Z4(e){const t=S.getState();if(!t.model)return;const i=ee.activeState(t);try{const{blob:a,filename:s}=await Se.exportModel(t.model.id,ee.stateSpec(i),e);i0(a,s),B.log("info",`Model exported with state “${i.name}”: ${s}`)}catch(a){B.log("error",`Model export failed: ${a instanceof On?a.info.message:String(a)}`)}}function m_({r:e}){return S(i=>{var a,s;return e.kind==="reaction"?(a=i.index)==null?void 0:a.rxn.has(e.id):(s=i.index)==null?void 0:s.met.has(e.id)})?n.jsx("button",{className:"btn small insp-action",onClick:()=>ek(e),title:"Open in the COBRAGUI inspector (bounds, flux, connected reactions)",children:"Inspect in COBRAGUI →"}):null}function Q4(){const e=S(i=>i.workspace),t=S(i=>i.running);return n.jsxs("div",{className:"ws-switch",role:"tablist","aria-label":"Workspace",children:[n.jsxs("button",{role:"tab","aria-selected":e==="lab",className:e==="lab"?"on":"",onClick:()=>B.setWorkspace("lab"),title:"COBRAGUI — explore, edit and simulate the GEM with COBRApy",children:["COBRAGUI",t&&n.jsx("span",{className:"spinner sm"})]}),n.jsx("button",{role:"tab","aria-selected":e==="map",className:e==="map"?"on":"",onClick:()=>B.setWorkspace("map"),title:"Map Builder — pathway figures, flux mapping, export",children:"Map Builder"}),n.jsx("button",{role:"tab","aria-selected":e==="templates",className:e==="templates"?"on":"",onClick:()=>B.setWorkspace("templates"),title:"Template Builder — model-independent pathway templates (biological identity + layout), reusable with any GEM",children:"Templates"})]})}const J4=e=>!!e&&Object.values(e.identifiers).some(t=>t==null?void 0:t.length)&&(e.identity.status==="confirmed"||e.identity.status==="suggested"),e5=e=>{var t;return(e.ec.length>0||Object.values(e.identifiers).some(i=>i==null?void 0:i.length)||!!e.summary&&!!((t=e.provenance)!=null&&t.length))&&(e.identity.status==="confirmed"||e.identity.status==="suggested")};function hl(e){const t=new Map(e.biology.entities.map(c=>[c.id,c])),i=e.biology.metabolites,a=i.filter(c=>J4(t.get(c.entity))).length,s=e.biology.reactions.filter(e5).length,o=i.filter(c=>!!c.compartment).length,l=(c,d)=>d?c/d:1,r=[l(a,i.length),l(s,e.biology.reactions.length)];return{metabolitesIdentified:a,metabolites:i.length,reactionsIdentified:s,reactions:e.biology.reactions.length,compartmentsDefined:o,overall:i.length||e.biology.reactions.length?r.reduce((c,d)=>c+d,0)/r.length:0}}const t5=/(_[cemprxngvlh]\d?|\[[a-z0-9]+\])$/;function qc(e){var y,b,_,x,v,j,N,C;const t=[],i=(w,k,P,H,G)=>t.push({severity:w,code:k,message:P,...H&&G?{element:{kind:H,id:G}}:{}}),a=e.metadata;a.id||i("error","metadata","The template has no id"),(y=a.name)!=null&&y.trim()||i("error","metadata","The template has no name","template",a.id),/^\d+\.\d+(\.\d+)?$/.test(a.template_version??"")||i("warning","metadata",`Template version "${a.template_version}" is not of the form 1.0.0`,"template",a.id),(b=a.authors)!=null&&b.length||i("info","metadata","No author given","template",a.id);const s=new Map(e.biology.entities.map(w=>[w.id,w])),o=new Map(e.biology.metabolites.map(w=>[w.id,w])),l=w=>{const k=o.get(w),P=k&&s.get(k.entity);return`${(P==null?void 0:P.name)??w}${k!=null&&k.compartment?` [${wi(k.compartment).toLowerCase()}]`:""}`},r=new Map;for(const w of e.biology.entities){const k=Object.entries(w.identifiers).flatMap(([P,H])=>(H??[]).map(G=>[P,G]));w.generic&&i("info","generic-entity",`${w.name}: generic entity (a class of compounds) — kept generic, review how GEMs represent it`,"entity",w.id),(w.identity.status==="unresolved"||!k.length)&&!w.generic?i("warning","missing-identity",`${w.name}: identity not defined (no database identifier)`,"entity",w.id):w.identity.status==="ambiguous"?i("warning","ambiguous-identity",`${w.name}: ambiguous identity — ${((_=w.identity.candidates)==null?void 0:_.length)??"several"} candidates, choose one`,"entity",w.id):w.identity.status==="suggested"&&i("info","suggested-identity",`${w.name}: identity suggested${w.identity.source==="ai"?" by AI":w.identity.source==="auto"?" by Auto Identify":""}, not reviewed yet`,"entity",w.id),w.identity.conflict&&i("warning","identity-conflict",`${w.name}: potential identity conflict — a ${w.identity.conflict.source} suggestion says "${w.identity.conflict.name}"`,"entity",w.id);for(const[P,H]of k){const G=ri(P,H);if(!G){i("error","invalid-identifier",`${w.name}: "${H}" is not a valid ${sa[P]??P} identifier`,"entity",w.id);continue}if((P==="bigg.metabolite"?t5.test(H)&&!/_[A-Z]$/.test(H):/\[[a-z0-9]+\]$/i.test(H))&&i("warning","model-id",`${w.name}: "${H}" looks like a model ID (compartment suffix) — templates store database identities only`,"entity",w.id),P==="bigg.metabolite")continue;const M=r.get(G);M&&M!==w.id?i("warning","shared-identifier",`${w.name} and ${(x=s.get(M))==null?void 0:x.name} share ${sa[P]??P} ${H} — the same compound twice?`,"entity",w.id):r.set(G,w.id)}(((v=w.identifiers["kegg.compound"])==null?void 0:v.length)??0)>1&&i("info","several-kegg",`${w.name}: several KEGG compounds (${w.identifiers["kegg.compound"].join(", ")}) — keep exact identities here and put anomers under related forms`,"entity",w.id)}const c=new Map,d=new Set(e.layout.nodes.filter(w=>!w.attach).map(w=>w.metabolite)),f=new Set(e.biology.reactions.flatMap(w=>w.participants.map(k=>k.metabolite))),u=new Set(e.biology.connectors.map(w=>w.metabolite));for(const w of e.biology.metabolites){s.has(w.entity)||i("error","unknown-entity",`Metabolite ${w.id} points at a missing entity ${w.entity}`,"metabolite",w.id),w.compartment&&!e.biology.compartments.some(P=>P.id===w.compartment)&&i("info","undeclared-compartment",`${l(w.id)}: compartment ${w.compartment} has no fallback policy (models without it will search the cytosol)`,"metabolite",w.id);const k=`${w.entity}@${w.compartment}`;c.has(k)?i("warning","duplicate-metabolite",`${l(w.id)} is defined twice (${c.get(k)}, ${w.id}) — draw several instances of one metabolite instead`,"metabolite",w.id):c.set(k,w.id),d.has(w.id)&&!f.has(w.id)&&!u.has(w.id)&&e.biology.metabolites.length>1&&i("warning","unconnected",`${l(w.id)} is not connected to any reaction`,"metabolite",w.id),!d.has(w.id)&&!f.has(w.id)&&!u.has(w.id)&&i("info","orphan",`${l(w.id)} is neither drawn nor used`,"metabolite",w.id);for(const P of w.alternatives??[])s.has(P)||i("error","unknown-entity",`${l(w.id)}: unknown alternative entity ${P}`,"metabolite",w.id)}const p=new Map;for(const w of e.biology.reactions){const k=w.name||w.id,P=w.participants.filter(D=>D.coefficient<0),H=w.participants.filter(D=>D.coefficient>0);w.participants.length?(P.length||i("error","no-substrates",`Reaction ${k} has no substrate`,"reaction",w.id),H.length||i("error","no-products",`Reaction ${k} has no product`,"reaction",w.id)):i("error","no-participants",`Reaction ${k} has no participants`,"reaction",w.id);for(const D of w.participants)o.has(D.metabolite)||i("error","broken-edge",`Reaction ${k} references a missing metabolite ${D.metabolite}`,"reaction",w.id),(!D.coefficient||!Number.isFinite(D.coefficient))&&i("error","coefficient",`Reaction ${k}: coefficient of ${l(D.metabolite)} must be a non-zero number`,"reaction",w.id);const G=P.filter(D=>H.some(F=>F.metabolite===D.metabolite));G.length&&i("warning","both-sides",`Reaction ${k}: ${G.map(D=>l(D.metabolite)).join(", ")} on both sides`,"reaction",w.id),w.summary?i("info","summary-reaction",`${k}: pathway summary${(j=w.provenance)!=null&&j.length?` (${w.provenance.map(D=>`${D.source} ${D.id}`).join(", ")})`:""} — not atom-balanced; linked to a GEM only when the model makes it in one or two reactions`,"reaction",w.id):!w.ec.length&&!Object.values(w.identifiers).some(D=>D==null?void 0:D.length)?i("warning","missing-reaction-identity",`Reaction ${k}: no EC number or database identifier — matching will rely on its participants only`,"reaction",w.id):w.identity.status==="suggested"?i("info","suggested-identity",`Reaction ${k}: identity suggested, not reviewed yet`,"reaction",w.id):w.identity.status==="ambiguous"&&i("warning","ambiguous-identity",`Reaction ${k}: ambiguous identity`,"reaction",w.id);for(const D of w.ec)/^\d+\.\d+\.\d+\.(\d+|n\d+|-)$/.test(D)||i("error","invalid-identifier",`Reaction ${k}: malformed EC number ${D}`,"reaction",w.id);for(const[D,F]of Object.entries(w.identifiers))for(const U of F??[])ri(D,U)||i("error","invalid-identifier",`Reaction ${k}: "${U}" is not a valid ${sa[D]??D} identifier`,"reaction",w.id);w.reversible===null&&i("info","direction",`Reaction ${k}: reversibility not stated`,"reaction",w.id);const M=w.participants.map(D=>{var F,U;return`${(F=o.get(D.metabolite))==null?void 0:F.entity}@${(U=o.get(D.metabolite))==null?void 0:U.compartment}:${Math.sign(D.coefficient)}`}).sort().join("|"),A=w.participants.map(D=>{var F,U;return`${(F=o.get(D.metabolite))==null?void 0:F.entity}@${(U=o.get(D.metabolite))==null?void 0:U.compartment}:${-Math.sign(D.coefficient)}`}).sort().join("|"),X=p.get(M)??p.get(A);if(X&&w.participants.length){const D=e.biology.reactions.find(U=>U.id===X);p.get(M)===void 0&&w.reversible===!1&&D.reversible===!1?i("warning","direction",`Reactions ${D.name} and ${k} are irreversible in opposite directions — a futile pair or a direction error?`,"reaction",w.id):i("warning","duplicate-reaction",`Reaction ${k} has the same equation as ${D.name}`,"reaction",w.id)}else p.set(M,w.id);const I=[],K={};for(const D of w.participants){const F=s.get(((N=o.get(D.metabolite))==null?void 0:N.entity)??""),U=iu(F==null?void 0:F.formula);if(!U){I.push((F==null?void 0:F.name)??D.metabolite);continue}for(const[z,O]of Object.entries(U))K[z]=(K[z]??0)+O*D.coefficient}const L=Object.entries(K).filter(([,D])=>Math.abs(D)>1e-9);w.summary||(!I.length&&L.length&&P.length&&H.length?i("warning","unbalanced",`Reaction ${k} is not balanced (heavy atoms, products − substrates: ${L.map(([D,F])=>`${D} ${F>0?"+":""}${F}`).join(", ")}) — missing cofactor or wrong stoichiometry?`,"reaction",w.id):I.length&&w.participants.length&&i("info","balance-unchecked",`Reaction ${k}: balance not checked (no formula for ${I.slice(0,3).join(", ")}${I.length>3?"…":""})`,"reaction",w.id))}for(const w of e.biology.connectors)o.has(w.metabolite)||i("error","broken-edge",`Pathway link ${w.id} starts at a missing metabolite`,"connector",w.id),(C=w.target.pathway)!=null&&C.trim()||i("warning","connector-target",`Pathway link from ${l(w.metabolite)} has no target pathway name`,"connector",w.id);const m=new Set(e.layout.nodes.map(w=>w.id));for(const w of e.layout.nodes)o.has(w.metabolite)||i("error","broken-node",`Drawn node ${w.id} points at a missing metabolite`,"node",w.id);const h=new Set(e.biology.reactions.map(w=>w.id));for(const w of e.layout.reactions)h.has(w.reaction)||i("error","broken-edge",`A drawn arrow points at a missing reaction ${w.reaction}`,"reaction",w.reaction),[...w.sources,...w.targets].some(k=>!m.has(k))&&i("error","broken-edge",`The arrow of ${w.reaction} ends at a missing node`,"reaction",w.reaction);for(const w of e.layout.ports)e.biology.connectors.some(k=>k.id===w.connector)||i("error","broken-node",`Port ${w.id} points at a missing pathway link`,"node",w.id);const g=new Map(e.biology.reactions.map(w=>[w.id,w]));for(const w of e.layout.nodes){if(!w.attach)continue;const k=g.get(w.attach.reaction);if(!k){i("error","broken-node",`Cofactor drawing ${w.id} is attached to a missing reaction`,"node",w.id);continue}const P=w.attach.side==="in"?-1:1;k.participants.some(H=>H.metabolite===w.metabolite&&Math.sign(H.coefficient)===P)||i("warning","cofactor-drawing",`Reaction ${k.name}: drawn cofactor ${l(w.metabolite)} is not a ${w.attach.side==="in"?"substrate":"product"} of the reaction`,"reaction",k.id)}return e.biology.metabolites.some(w=>w.compartment)||i("info","no-compartments","No preferred compartments: the matcher proposes them in each GEM and you choose when mapping","template",a.id),a.review_status==="ai-generated"&&i("info","review-status","AI-generated — needs review: identities are suggestions until a person confirms them","template",a.id),e.biology.metabolites.length||i("info","empty","The template is empty","template",a.id),t}const Vc=e=>({errors:e.filter(t=>t.severity==="error").length,warnings:e.filter(t=>t.severity==="warning").length,infos:e.filter(t=>t.severity==="info").length}),$e=Ts(()=>({view:"library",openId:null,kind:"new",savedJson:null,suspended:null,recovered:null,panel:"none",importing:null}));let wo=null;const fl="templates.draft";function n5(e){const t=(a,s)=>a.reduce((o,l)=>{const r=l.match(new RegExp(`^${s}_(\\d+)$`));return r?Math.max(o,+r[1]):o},0),i={n:{prefix:Zt.node,n:t([...e.layout.nodes.map(a=>a.id),...e.layout.ports.map(a=>a.id)],Zt.node)},g:{prefix:Zt.group,n:t(e.layout.groups.map(a=>a.id),Zt.group)},t:{prefix:Zt.label,n:t(e.layout.labels.map(a=>a.id),Zt.label)}};m1(a=>{const s=i[a];if(!s)return null;const o=R.getState().doc;let l;do l=`${s.prefix}_${String(++s.n).padStart(3,"0")}`;while(o.nodes[l]||o.groups[l]||o.texts[l]);return l})}function Ln(){const e=R.getState();return e.design?Jp(e.design,e.doc):null}function fr(){const e=Ln(),{savedJson:t}=$e.getState();return!!e&&JSON.stringify(x0(e))!==t}const x0=e=>({...e,metadata:{...e.metadata,modified:""},validation:void 0});function Ri(e,t,i={}){S.getState().workspace!=="templates"&&($e.setState({suspended:null}),S.setState({workspace:"templates"}));const a=R.getState();!wo&&!a.design&&(wo={doc:a.doc,model:a.model,datasets:a.datasets,conditions:a.conditions,mappings:a.mappings,view:a.view,style:a.style,past:a.past,future:a.future,selection:a.selection,camera:a.camera,name:a.name,validation:a.validation,tool:a.tool}),n5(e),R.setState({design:e,doc:MC(e),model:null,datasets:[],conditions:[],mappings:[],validation:[],view:{activeCondition:"",compare:"absolute",reference:""},style:{...u1(),metaboliteLabel:"name"},past:[],future:[],selection:[],dialog:null,contextMenu:null,tool:"select",name:e.metadata.name}),R.getState().actions.commit(()=>({design:R.getState().design})),R.setState({past:[]}),$e.setState({view:"designer",openId:t==="new"||t==="imported"?null:e.metadata.id,kind:t,savedJson:i.savedJson!==void 0?i.savedJson:JSON.stringify(x0(Ln())),suspended:null,panel:"none"}),setTimeout(()=>R.getState().actions.fitAll(),0)}function u_(){if(m1(null),!wo){R.setState({design:null});return}R.setState({...wo,design:null,dialog:null,contextMenu:null}),wo=null}function Kd(){u_(),$e.setState({view:"library",openId:null,savedJson:null,suspended:null,panel:"none"}),Bp(fl)}function i5(){const e=Ln();if(!e)return null;if(Up(e.metadata.id))throw new Error("Built-in templates are read-only — use “Duplicate” to make your own version");const t=dl(e);return R.setState({design:{...R.getState().design,metadata:t.metadata},name:t.metadata.name}),$e.setState({openId:t.metadata.id,kind:"user",savedJson:JSON.stringify(x0(Ln()))}),Bp(fl),t}function a5(e){const t=Vc(qc(e));return{...e,validation:{checked:new Date().toISOString(),errors:t.errors,warnings:t.warnings,completeness:hl(e)}}}let _g;R.subscribe((e,t)=>{!e.design||e.design===t.design&&e.doc===t.doc||(clearTimeout(_g),_g=window.setTimeout(()=>{const i=Ln(),a=$e.getState();i&&fr()&&Xr(fl,{file:i,openId:a.openId,kind:a.kind})},800))});S.subscribe((e,t)=>{if(e.workspace===t.workspace)return;const i=$e.getState();if(t.workspace==="templates"&&i.view==="designer"){const a=Ln(),s=i.savedJson;u_(),$e.setState({suspended:a?{file:a}:null,savedJson:s})}else if(e.workspace==="templates"&&i.view==="designer"&&i.suspended){const{file:a}=i.suspended;Ri(a,i.kind,{savedJson:i.savedJson}),$e.setState({openId:i.openId})}});async function s5(){var t;const e=await Cc(fl);e&&w1((t=e.file)==null?void 0:t.format)&&$e.setState({recovered:{...e,file:{...e.file,format:Ka}}})}function o5(){$e.setState({recovered:null}),Bp(fl)}const vg=["confirmed","suggested","ambiguous","unresolved"],Wn=e=>!!e&&typeof e=="object"&&!Array.isArray(e),on=e=>typeof e=="string"?e:void 0,at=e=>Array.isArray(e)?e:[];function l5(e){let t;try{t=JSON.parse(e)}catch(i){return{errors:[`Not valid JSON: ${i.message}`],warnings:[]}}return r5(t)}function r5(e){const t=[],i=[];if(!Wn(e))return{errors:["The file does not contain a JSON object"],warnings:i};if(Op(e.format))return{errors:["This is a GEMsMAP project (.gemsmap), not a template — open it with File → Open project"],warnings:i};if(!w1(e.format))return{errors:[`Unknown format "${String(e.format)}" — expected "${Ka}"`],warnings:i};const a=on(e.schema_version)??"",[s,o]=a.split(".").map(Number),[l,r]=Fp.split(".").map(Number);if(Number.isFinite(s)?s!==l?t.push(`Schema ${a} is not supported by this GEMsMAP (reads ${l}.x)`):o>r&&i.push(`Written by a newer GEMsMAP (schema ${a}); unknown fields are kept but ignored`):t.push("Missing schema_version"),Wn(e.metadata)||t.push("Missing metadata"),Wn(e.biology)||t.push("Missing biology section"),Wn(e.layout)||t.push("Missing layout section"),t.length)return{errors:t,warnings:i};const c=structuredClone(e);c.format=Ka;const d=c.metadata;on(d.id)||t.push("metadata.id is required"),on(d.name)||t.push("metadata.name is required"),c.metadata={...c.metadata,description:on(d.description)??"",pathway:on(d.pathway)??on(d.name)??"",template_version:on(d.template_version)??"1.0.0",scope:Wn(d.scope)?{level:on(d.scope.level)??"universal",taxa:at(d.scope.taxa),...on(d.scope.note)?{note:on(d.scope.note)}:{}}:{level:"universal",taxa:[]},authors:at(d.authors).filter(h=>typeof h=="string"),created:on(d.created)??new Date().toISOString(),modified:on(d.modified)??new Date().toISOString(),license:on(d.license)??"",tags:at(d.tags),citations:at(d.citations)};const f=c.biology;c.biology={compartments:at(f.compartments),entities:at(f.entities),metabolites:at(f.metabolites),reactions:at(f.reactions),connectors:at(f.connectors)};const u=c.layout;c.layout={nodes:at(u.nodes),ports:at(u.ports),reactions:at(u.reactions),groups:at(u.groups),labels:at(u.labels)};const p=new Map,m=(h,g)=>{if(typeof h!="string"||!h){t.push(`A ${g} has no id`);return}const y=p.get(g)??new Set;y.has(h)&&t.push(`Duplicate ${g} id ${h}`),y.add(h),p.set(g,y)};c.biology.compartments=c.biology.compartments.filter(h=>Md(h==null?void 0:h.id)?(h.fallback=at(h.fallback).filter(g=>g==="intracellular"||Md(g)),!0):(i.push(`Unknown compartment "${String(h==null?void 0:h.id)}" ignored`),!1));for(const h of c.biology.entities)m(h.id,"entity"),(typeof h.name!="string"||!h.name)&&(i.push(`Entity ${h.id} has no name`),h.name=h.id),h.synonyms=at(h.synonyms),h.identifiers=Wn(h.identifiers)?Object.fromEntries(Object.entries(h.identifiers).map(([g,y])=>[g,at(y).map(String)])):{},(!Wn(h.identity)||!vg.includes(h.identity.status))&&(i.push(`Entity ${h.name}: no valid identity status — set to unresolved`),h.identity={status:"unresolved"});for(const h of c.biology.metabolites)m(h.id,"metabolite"),h.compartment!=null&&!Md(h.compartment)&&(i.push(`Metabolite ${h.id}: unknown compartment "${String(h.compartment)}" — set to none`),h.compartment=null),h.compartment??(h.compartment=null),["required","recommended","optional"].includes(h.level)||(h.level="required");for(const h of c.biology.reactions)m(h.id,"reaction"),h.participants=at(h.participants),h.ec=at(h.ec),h.identifiers=Wn(h.identifiers)?Object.fromEntries(Object.entries(h.identifiers).map(([g,y])=>[g,at(y).map(String)])):{},typeof h.reversible!="boolean"&&(h.reversible=null),["required","recommended","optional"].includes(h.level)||(h.level="required"),(!Wn(h.identity)||!vg.includes(h.identity.status))&&(h.identity={status:"unresolved"}),typeof h.name!="string"&&(h.name=h.id);for(const h of c.biology.connectors)m(h.id,"pathway link"),Wn(h.target)||(h.target={pathway:""});for(const h of c.layout.nodes)m(h.id,"node"),(!Number.isFinite(h.x)||!Number.isFinite(h.y))&&t.push(`Node ${h.id} has no valid position`);for(const h of c.layout.ports)m(h.id,"port");for(const h of c.layout.reactions)h.sources=at(h.sources),h.targets=at(h.targets),h.routing??(h.routing="straight");return t.length?{errors:t,warnings:i}:{file:c,errors:t,warnings:i}}const c5=e=>e.toLowerCase().normalize("NFKD").replace(/[^\w]+/g,"_").replace(/^_+|_+$/g,"").slice(0,60)||"template";function _0(e){Di(`${c5(e.metadata.name)}${Gw}`,JSON.stringify(a5(e),null,1)+`
|
|
73
|
+
`,"application/json")}function v0(){const e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=async()=>{var i;const t=(i=e.files)==null?void 0:i[0];t&&p_(t.name,await t.text())},e.click()}function p_(e,t){const i=l5(t);if(!i.file){V().toast(`Could not import ${e}: ${i.errors.slice(0,3).join(" · ")}`);return}const a=[...i.warnings];let s=i.file;Up(s.metadata.id)&&(s={...s,metadata:{...s.metadata,id:qp(),derived_from:s.metadata.derived_from??{id:i.file.metadata.id,name:i.file.metadata.name,template_version:i.file.metadata.template_version}}},a.push(`Same id as the built-in “${i.file.metadata.name}” — imported as a separate template`)),$e.setState({importing:{file:s,warnings:a,fileName:e}})}const jg=e=>({...e,metadata:{...e.metadata,id:qp()}});function Ng(e){const t=dl(e);return V().toast(`Saved “${t.metadata.name}” to your templates`),t}function d5(e,t){const i=dl(Vp(e,t));Ri(i,"user"),V().toast(`Created “${i.metadata.name}” — the original is unchanged`)}function h_(e){const t=D1(e);if(!t)return V().toast("Save the template first");B.setWorkspace("map"),setTimeout(()=>{const i=R.getState();V().openTemplate(Kp(Sc(t))),i.model||V().toast(`Inserted “${t.metadata.name}” unmapped — load a GEM (Model tab, or send one from COBRAGUI) and click Auto-bind`)},0)}function Co(){const e=$e.getState();try{if(e.kind==="builtin"){const i=dl(Vp(Ln(),`${R.getState().design.metadata.name} — my version`));return Ri(i,"user"),V().toast(`Built-in templates are read-only — saved your changes as “${i.metadata.name}”`),!0}const t=i5();return t&&V().toast(`Saved “${t.metadata.name}”`),!!t}catch(t){return V().toast(t.message),!1}}function f_(){const e=Ln();e&&_0(e)}function wg(){const e=Fn(t=>t.scale);return n.jsxs("div",{className:"dd-row",title:"Size of panels, menus and text (Ctrl Alt + / Ctrl Alt − / Ctrl Alt 0). The map and its exports do not change.",children:[n.jsx("span",{children:"Interface size"}),n.jsxs("span",{className:"dd-steps",children:[n.jsx("button",{"aria-label":"Smaller interface",onClick:()=>tl(-1),disabled:e<=vi[0],children:"−"}),n.jsx("button",{className:"dd-val",title:"Back to 100 %",onClick:()=>$c(1),children:z3(e)}),n.jsx("button",{"aria-label":"Larger interface",onClick:()=>tl(1),disabled:e>=vi[vi.length-1],children:"+"})]})]})}function Zn({icon:e,title:t,onClick:i,on:a,disabled:s}){return n.jsx("button",{className:`icon-btn ${a?"on":""}`,title:t,onClick:i,disabled:s,children:n.jsx(q,{name:e,size:16})})}function m5(){const e=R(b=>b.name),t=R(b=>b.tool),i=R(b=>b.canvas),a=R(b=>b.camera.k),s=R(b=>b.past.length>0),o=R(b=>b.future.length>0),l=R(b=>b.leftOpen),r=R(b=>b.rightOpen),[c,d]=E.useState(!1),f=E.useRef(null),u=S(b=>b.workspace==="lab"),p=S(b=>b.workspace==="templates"),m=R(b=>!!b.design),h=V();E.useEffect(()=>{if(!c)return;const b=_=>{var x;(x=f.current)!=null&&x.contains(_.target)||d(!1)};return window.addEventListener("pointerdown",b),()=>window.removeEventListener("pointerdown",b)},[c]);const g=[["select","select","Select (V)"],["pan","pan","Pan (C) — or hold Space and drag, or drag with the right mouse button"],["metabolite","metabolite","Metabolite (M)"],["slot","slot","Empty slot (S)"],["reaction","reaction","Reaction (R)"],["text","text","Text (T)"]].filter(([b])=>!m||b!=="slot"),y=(b,_,x)=>n.jsxs("button",{onClick:()=>{d(!1),_()},children:[n.jsx("span",{children:b}),x&&n.jsx("kbd",{children:x})]});return n.jsxs("header",{className:"topbar",children:[n.jsxs("div",{className:"tb-row",children:[n.jsxs("div",{className:"tb-left",children:[n.jsx("div",{className:"logo",role:"img","aria-label":"GEMsMAP",title:"GEMsMAP — visualization and constraint-based analysis of genome-scale metabolic models",children:n.jsx(Z3,{width:30})}),n.jsx(Q4,{}),n.jsxs("div",{className:"menu-wrap",ref:f,children:[n.jsx("button",{className:"menu-btn",onClick:()=>d(!c),children:"File"}),c&&p&&n.jsxs("div",{className:"dropdown",children:[y("New template",()=>Ri(k1("New template"),"new")),y("Import template (.gemsmap-template.json)…",v0,"Ctrl O"),m&&y("Save template",()=>{Co()},"Ctrl S"),m&&y("Export template…",f_,"Ctrl E"),m&&y("Export figure of the template…",()=>R.setState({dialog:{kind:"export"}})),n.jsx("div",{className:"dd-sep"}),y("Go to the Map Builder",()=>S.setState({workspace:"map"})),n.jsx(wg,{}),y("Keyboard shortcuts",()=>R.setState({dialog:{kind:"help"}}),"?")]}),c&&!p&&n.jsxs("div",{className:"dropdown",children:[y("New project",()=>h.newProject()),y("Open example (central carbon metabolism)",()=>ra(()=>Promise.resolve().then(()=>I0),void 0).then(b=>h.loadProject(b.demoProject()))),y("Open project…",()=>$n("project"),"Ctrl O"),y("Save project (.gemsmap)",()=>Bc(),"Ctrl S"),n.jsx("div",{className:"dd-sep"}),y("Import GEM into COBRAGUI (COBRApy: SBML / JSON / MAT)…",()=>{S.setState({workspace:"lab"}),y0()}),y("Import GEM into the map only (JSON / SBML)…",()=>$n("model")),y("Import fluxes / data…",()=>$n("data")),n.jsx("div",{className:"dd-sep"}),y("Export figure…",()=>R.setState({dialog:{kind:"export"}}),"Ctrl E"),y("Download model as COBRA JSON",()=>ra(()=>Promise.resolve().then(()=>kN),void 0).then(async b=>{const _=R.getState();if(!_.model)return h.toast("No model loaded");(await ra(async()=>{const{download:x}=await Promise.resolve().then(()=>OC);return{download:x}},void 0)).download(`${_.model.id}.json`,b.toCobraJson(_.model),"application/json")})),n.jsx("div",{className:"dd-sep"}),n.jsx(wg,{}),y("Keyboard shortcuts",()=>R.setState({dialog:{kind:"help"}}),"?")]})]}),!u&&!p&&n.jsx("input",{className:"doc-name",value:e,onChange:b=>R.setState({name:b.target.value}),spellCheck:!1})]}),n.jsxs("div",{className:"tb-right",children:[!p&&n.jsxs("button",{className:"search-btn",onClick:()=>R.setState({paletteOpen:!0}),children:[n.jsx(q,{name:"search",size:14}),n.jsx("span",{children:u?"Search model or run a command":"Search or run a command"}),n.jsx("kbd",{children:"Ctrl K"})]}),!u&&!p&&n.jsxs("button",{className:"btn primary",onClick:()=>R.setState({dialog:{kind:"export"}}),children:[n.jsx(q,{name:"export",size:14})," Export"]})]})]}),u?n.jsx("div",{className:"tb-center lab",children:n.jsx(z4,{})}):p&&!m?n.jsx("div",{className:"tb-center tb-brand",children:n.jsx(Qr,{workspace:"templates"})}):n.jsxs("div",{className:"tb-center tb-tools",children:[n.jsx(Qr,{workspace:p?"templates":"map"}),n.jsxs("div",{className:"tb-tools-group",children:[n.jsx(Zn,{icon:"panelL",title:"Toggle left panel",on:l,onClick:()=>R.setState({leftOpen:!l})}),n.jsx("span",{className:"tb-sep"}),g.map(([b,_,x])=>n.jsx(Zn,{icon:_,title:x,on:t===b,onClick:()=>R.setState({tool:b})},b)),n.jsx("span",{className:"tb-sep"}),n.jsx(Zn,{icon:"undo",title:"Undo (Ctrl Z)",onClick:h.undo,disabled:!s}),n.jsx(Zn,{icon:"redo",title:"Redo (Ctrl Shift Z)",onClick:h.redo,disabled:!o}),n.jsx("span",{className:"tb-sep"}),n.jsx(Zn,{icon:"grid",title:"Show grid",on:i.showGrid,onClick:()=>h.setCanvas({showGrid:!i.showGrid})}),n.jsx(Zn,{icon:"magnet",title:"Snap to grid",on:i.snap,onClick:()=>h.setCanvas({snap:!i.snap})}),n.jsx("span",{className:"tb-sep"}),n.jsxs("button",{className:"zoom",title:"Zoom (wheel) — click to reset",onClick:()=>h.setCamera({k:1}),children:[Math.round(a*100),"%"]}),n.jsx(Zn,{icon:"fit",title:"Fit all (F)",onClick:h.fitAll}),n.jsx("span",{className:"tb-sep"}),n.jsx(Zn,{icon:"panelR",title:"Toggle inspector",on:r,onClick:()=>R.setState({rightOpen:!r})})]})]})]})}function u5(){var r;const e=R(c=>c.conditions),t=R(c=>c.view),i=R(c=>c.animation),a=V(),s=E.useRef(1);if(E.useEffect(()=>{if(!i.playing||e.length<2)return;const c=setInterval(()=>{const d=R.getState(),f=d.conditions.findIndex(m=>m.id===d.view.activeCondition),u=d.conditions.length;let p=f+s.current;if(p>=u||p<0){if(d.animation.loop==="once"){a.setAnimation({playing:!1});return}d.animation.loop==="pingpong"?(s.current*=-1,p=f+s.current):p=(p+u)%u}a.setView({activeCondition:d.conditions[p].id})},i.stepSeconds*1e3);return()=>clearInterval(c)},[i.playing,i.stepSeconds,i.loop,e.length,a]),!e.length)return n.jsx("footer",{className:"bottombar",children:n.jsx("span",{className:"muted small",children:"No conditions yet — import a flux table (Data tab) or open the demo."})});const o=e.findIndex(c=>c.id===t.activeCondition),l=e.every(c=>typeof c.time=="number")&&e.length>2;return n.jsxs("footer",{className:"bottombar",children:[n.jsxs("div",{className:"bb-group",children:[n.jsx("span",{className:"bb-label",children:"Condition"}),n.jsx("div",{className:"cond-chips",children:e.map(c=>n.jsxs("button",{className:`cond-chip ${c.id===t.activeCondition?"on":""}`,onClick:()=>a.setView({activeCondition:c.id}),style:{"--c":c.color},children:[n.jsx("i",{}),c.name]},c.id))})]}),l&&n.jsxs("div",{className:"bb-group timeline",children:[n.jsx("input",{type:"range",min:0,max:e.length-1,value:Math.max(0,o),onChange:c=>a.setView({activeCondition:e[+c.target.value].id})}),n.jsx("span",{className:"mono small",children:(r=e[o])==null?void 0:r.time})]}),n.jsxs("div",{className:"bb-group",children:[n.jsx(Zn,{icon:i.playing?"pause":"play",title:"Play through conditions",on:i.playing,onClick:()=>a.setAnimation({playing:!i.playing})}),n.jsxs("select",{className:"input tiny",value:i.loop,onChange:c=>a.setAnimation({loop:c.target.value}),title:"Loop mode",children:[n.jsx("option",{value:"loop",children:"↻ loop"}),n.jsx("option",{value:"pingpong",children:"⇄ ping-pong"}),n.jsx("option",{value:"once",children:"→ once"})]}),n.jsx("select",{className:"input tiny",value:i.stepSeconds,onChange:c=>a.setAnimation({stepSeconds:+c.target.value}),title:"Speed",children:[.5,.8,1.2,2,3].map(c=>n.jsxs("option",{value:c,children:[c,"s / step"]},c))}),n.jsx(Zn,{icon:"particles",title:"Animated flux particles (presentation mode, not exported)",on:i.particles,onClick:()=>a.setAnimation({particles:!i.particles})})]}),n.jsxs("div",{className:"bb-group",children:[n.jsx("span",{className:"bb-label",children:"Compare"}),n.jsxs("select",{className:"input tiny",value:t.compare,onChange:c=>a.setView({compare:c.target.value}),children:[n.jsx("option",{value:"absolute",children:"absolute"}),n.jsx("option",{value:"difference",children:"difference (Δ)"}),n.jsx("option",{value:"foldchange",children:"fold change"}),n.jsx("option",{value:"log2fc",children:"log₂ fold change"})]}),t.compare!=="absolute"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small",children:"vs"}),n.jsx("select",{className:"input tiny",value:t.reference,onChange:c=>a.setView({reference:c.target.value}),children:e.map(c=>n.jsx("option",{value:c.id,children:c.name},c.id))})]})]})]})}const Ul={absolute:"",difference:"Δ",foldchange:"fold change",log2fc:"log₂ FC"};function Hs(e,t,i){if(!t)return null;const a=e.columns.indexOf(i);return a<0?null:Ec(e,t,a)}function g_(e,t,i){switch(t){case"entry":{const a=e.filter((s,o)=>i==null?void 0:i[o]);return(a.length?a:e).reduce((s,o)=>s+o,0)}case"sum":return e.reduce((a,s)=>a+s,0);case"mean":return e.reduce((a,s)=>a+s,0)/e.length;case"min":return e.reduce((a,s)=>Math.abs(s)<Math.abs(a)?s:a);case"max":return e.reduce((a,s)=>Math.abs(s)>Math.abs(a)?s:a)}}function ca(e,t,i){if(t.collapsed){const s=[],o=[];for(const l of t.collapsed.members){const r=Hs(e,l.reactionId,i);r!=null&&(s.push(r*l.sign),o.push(l.entry))}return s.length?g_(s,t.collapsed.aggregate,o):null}const a=Hs(e,t.reactionId,i);return a==null?null:t.reversedToModel?-a:a}function p5(e,t,i){if(!e.samples)return[];if(t.collapsed){const s=[],o=[];for(const r of t.collapsed.members){const c=Vm(e,r.reactionId,i);c!=null&&c.length&&(s.push(c.map(d=>d*r.sign)),o.push(r.entry))}if(!s.length)return[];const l=Math.min(...s.map(r=>r.length));return Array.from({length:l},(r,c)=>g_(s.map(d=>d[c]),t.collapsed.aggregate,o))}const a=t.reactionId?Vm(e,t.reactionId,i):[];return t.reversedToModel?a.map(s=>-s):a}function Cg(e,t,i){if(e==="absolute")return t;if(t==null||i==null)return null;const a=1e-9;switch(e){case"difference":return t-i;case"foldchange":return Math.abs(i)<a?null:t/i;case"log2fc":return Math.abs(i)<a||Math.abs(t)<a?null:Math.log2(Math.abs(t)/Math.abs(i))}}const h5=e=>e==="sqrt"?t=>Math.sign(t)*Math.sqrt(Math.abs(t)):e==="log"?t=>Math.sign(t)*Math.log10(1+Math.abs(t)):t=>t;function ql(e,t,i,a){const s=e.filter(Number.isFinite);if(t==="percentile"){const f=(i?s.map(Math.abs):s).slice().sort((m,h)=>m-h),u=m=>{if(f.length<2)return .5;let h=0,g=f.length-1;for(;h<g;){const y=h+g>>1;f[y]<m?h=y+1:g=y}return h/(f.length-1)},p=[f[0]??0,f[f.length-1]??1];return{t:i?m=>.5+Math.sign(m)*u(Math.abs(m))/2:u,domain:p}}const o=h5(t);if(i){const f=a?Math.max(Math.abs(a[0]),Math.abs(a[1])):Math.max(1e-9,...s.map(Math.abs)),u=o(f)||1;return{t:p=>.5+Math.max(-1,Math.min(1,o(p)/u))/2,domain:[-f,f]}}const l=a?a[0]:Math.min(0,...s),r=a?a[1]:Math.max(1e-9,...s),c=o(l),d=o(r);return{t:f=>d===c?.5:Math.max(0,Math.min(1,(o(f)-c)/(d-c))),domain:[l,r]}}function j0(e,t,i,a,s,o,l){const r={reactions:{},nodes:{},legend:[]},c=o.baseEdgeWidth,d=Object.values(e.reactions),f=Object.values(e.nodes);for(const y of d)r.reactions[y.id]={value:null,width:c,color:l.edge,opacity:1,dir:1,dashed:y.role==="exchange"};for(const y of f)r.nodes[y.id]={r:y.r??o.nodeRadius,fill:y.fill??l.nodeFill,opacity:1,value:null};const u=i.filter(y=>y.enabled),p=new Map(t.map(y=>[y.id,y])),m=a.compare,h=m==="absolute"?s.map(y=>y.id):s.map(y=>y.id).filter(y=>y!==a.reference);let g=!1;for(const y of u){const b=p.get(y.datasetId);if(!(!b||!b.visible))if(y.target==="reaction"){const _=(C,w)=>Cg(m,ca(b,C,w),ca(b,C,a.reference)),x=[];for(const C of d)for(const w of h){const k=_(C,w);k!=null&&x.push(k)}if(!x.length)continue;g=!0;const v=x.some(C=>C<0),j=m==="foldchange"?1:0,N=`${Ul[m]?Ul[m]+" ":""}${b.kind==="flux"?"Flux":b.name}`;if(y.property==="width"||y.property==="opacity"){const C=x.map(P=>Math.abs(P-j)),w=ql(C,y.scale,!1,y.domain??[0,Math.max(...C)]),k=y.range??(y.property==="width"?[c*.5,c*7]:[.15,1]);for(const P of d){const H=_(P,a.activeCondition),G=r.reactions[P.id];if(H==null)continue;const M=w.t(Math.abs(H-j));y.property==="width"?G.width=k[0]+M*(k[1]-k[0]):G.opacity=k[0]+M*(k[1]-k[0])}y.property==="width"&&r.legend.push({kind:"width",title:N,domain:w.domain,range:k,unit:m==="absolute"?b.unit:void 0})}else if(y.property==="color"){const C=m==="absolute"&&y.magnitude,w=!C&&(m!=="absolute"||v),k=G=>C?Math.abs(G):G-j,P=ql(x.map(k),y.scale,w,y.domain??(C?[0,Math.max(...x.map(Math.abs))]:void 0)),H=za(y.palette??(w?"blue-red":"viridis"));for(const G of d){const M=_(G,a.activeCondition);M!=null&&(r.reactions[G.id].color=Bs(H,P.t(k(M))))}C?r.legend.push({kind:"color",title:`|${N}|`,domain:P.domain,palette:H.id,diverging:!1,unit:b.unit}):r.legend.push({kind:"color",title:N,domain:[P.domain[0]+j,P.domain[1]+j],palette:H.id,diverging:w,unit:m==="absolute"?b.unit:void 0})}else if(y.property==="label")for(const C of d){const w=_(C,a.activeCondition);w!=null&&(r.reactions[C.id].valueLabel=String(+w.toPrecision(3)))}for(const C of d){const w=ca(b,C,a.activeCondition),k=r.reactions[C.id];k.value=w,w!=null&&(Math.abs(w)<1e-9?(k.dir=0,k.color=l.edgeMuted,k.width=Math.min(k.width,c*.6)):k.dir=w>0?1:-1)}}else{const _=(N,C)=>Cg(m,Hs(b,N,C),Hs(b,N,a.reference)),x=[];for(const N of f)for(const C of h){const w=_(N.metaboliteId,C);w!=null&&x.push(w)}if(!x.length)continue;const v=`${Ul[m]?Ul[m]+" ":""}${b.kind==="turnover"?"Turnover":b.kind==="metabolite"?"Concentration":b.name}`,j=m==="foldchange"?1:0;if(y.property==="radius"||y.property==="opacity"){const N=x.map(k=>Math.abs(k-j)),C=ql(N,y.scale,!1,y.domain??[0,Math.max(...N)]),w=y.range??(y.property==="radius"?[o.nodeRadius*.6,o.nodeRadius*2.4]:[.2,1]);for(const k of f){const P=_(k.metaboliteId,a.activeCondition);if(P==null)continue;const H=C.t(Math.abs(P-j));y.property==="radius"?r.nodes[k.id].r=w[0]+H*(w[1]-w[0]):r.nodes[k.id].opacity=w[0]+H*(w[1]-w[0]),r.nodes[k.id].value=P}y.property==="radius"&&r.legend.push({kind:"radius",title:v,domain:C.domain,range:w,unit:b.unit})}else if(y.property==="fill"){const N=m!=="absolute"||x.some(k=>k<0),C=ql(x.map(k=>k-j),y.scale,N,y.domain),w=za(y.palette??(N?"purple-orange":"plasma"));for(const k of f){const P=_(k.metaboliteId,a.activeCondition);P!=null&&(r.nodes[k.id].fill=Bs(w,C.t(P-j)),r.nodes[k.id].value=P)}r.legend.push({kind:"color",title:v,domain:[C.domain[0]+j,C.domain[1]+j],palette:w.id,diverging:N,unit:b.unit})}}}if(o.showFluxValues)for(const y of d){const b=r.reactions[y.id];b.valueLabel==null&&b.value!=null&&(b.valueLabel=String(+b.value.toPrecision(3)))}return g&&s.length>1&&r.legend.unshift({kind:"conditions",title:"Conditions",items:s.map(y=>({name:y.name,color:y.color}))}),r}function Ve({icon:e,title:t,onClick:i,label:a}){return n.jsxs("button",{className:"ctx-btn",title:t,onClick:i,children:[n.jsx(q,{name:e,size:15}),a&&n.jsx("span",{children:a})]})}const zd=()=>n.jsx("span",{className:"ctx-sep"});function f5(){const e=R(j=>j.selection),t=R(j=>j.doc),i=R(j=>j.camera),a=R(j=>j.model),[s,o]=E.useState(null);if(!e.length)return null;const l=V(),r=e.map(j=>Oe(j)[0]),d=l.selectedNodeIds().map(j=>t.nodes[j]).filter(Boolean),f=e.filter(j=>j.startsWith("reaction:")).map(j=>t.reactions[Oe(j)[1]]).filter(Boolean),u=r.every(j=>j==="node");let p=d.map(j=>({x:j.x,y:j.y}));if(!p.length)for(const j of e){const[N,C]=Oe(j);if(N==="text"&&t.texts[C]&&p.push({x:t.texts[C].x,y:t.texts[C].y-14}),N==="legend"&&p.push(Kr(t)),N==="plot"&&t.plots[C]){const w=Ta(t,t.plots[C].anchor);w&&p.push({x:w.x+t.plots[C].dx+t.plots[C].w/2,y:w.y+t.plots[C].dy})}}if(!p.length)return null;const m=(Math.min(...p.map(j=>j.x))+Math.max(...p.map(j=>j.x)))/2*i.k+i.x,h=Math.min(...p.map(j=>j.y))*i.k+i.y-46,g=e.length===1,y=g&&r[0]==="node"?t.nodes[Oe(e[0])[1]]:null,b=g&&r[0]==="reaction"?f[0]:null,_=j=>{var w,k;const N=(w=t.nodes[j.sources[0]])==null?void 0:w.metaboliteId,C=(k=t.nodes[j.targets[0]])==null?void 0:k.metaboliteId;return!!a&&!!N&&!!C&&!!a.metabolites[N]&&!!a.metabolites[C]},x=u&&d.length===2&&d.every(j=>j.metaboliteId)&&!!a,v=()=>n.jsx("div",{className:"ctx-menu",children:["density","bar","line","heatmap","box","range"].map(j=>n.jsx("button",{onClick:()=>{l.addPlotsForSelection(j),o(null)},children:j==="range"?"FVA / range":j[0].toUpperCase()+j.slice(1)},j))});return n.jsxs("div",{className:"ctx-toolbar",style:{left:Math.max(8,m),top:Math.max(8,h)},onPointerDown:j=>j.stopPropagation(),children:[y&&n.jsxs(n.Fragment,{children:[a&&n.jsx(Ve,{icon:"link",title:"Bind to model metabolite (double-click)",label:y.metaboliteId?"Rebind":"Bind",onClick:()=>R.setState({dialog:{kind:"metabolite",at:y,bindNodeId:y.id}})}),a&&y.metaboliteId&&n.jsxs(n.Fragment,{children:[n.jsx(Ve,{icon:"expandUp",title:"Expand 1 reaction upstream",onClick:()=>l.expandNode(y.id,"up",1)}),n.jsx(Ve,{icon:"expandDown",title:"Expand 1 reaction downstream",onClick:()=>l.expandNode(y.id,"down",1)})]}),n.jsx(Ve,{icon:"plot",title:"Add plot for this metabolite",onClick:()=>l.addPlot({kind:"node",id:y.id},"bar")})]}),b&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"ctx-wrap",children:[n.jsx(Ve,{icon:"plot",title:"Add linked mini-plot (P)",label:"Plot",onClick:()=>o(s==="plot"?null:"plot")}),s==="plot"&&v()]}),n.jsx(Ve,{icon:"swap",title:"Reverse drawn direction",onClick:()=>l.reverseReaction(b.id)}),n.jsx(Ve,{icon:"curve",title:"Straight / curved / orthogonal",onClick:()=>l.updateReaction(b.id,{routing:b.routing==="straight"?"curved":b.routing==="curved"?"orthogonal":"straight",bend:void 0})}),b.collapsed&&n.jsx(Ve,{icon:"expandDown",title:"Expand the hidden reactions",label:"Expand",onClick:()=>l.expandGlyph(b.id)}),!b.collapsed&&_(b)&&n.jsx(Ve,{icon:"path",title:"Find routes between these two metabolites in the model",label:b.reactionId?"Routes":"Find routes",onClick:()=>R.setState({dialog:{kind:"routes",from:b.sources[0],to:b.targets[0],replaceGlyph:b.id}})})]}),!g&&f.length>1&&!u&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"ctx-wrap",children:[n.jsx(Ve,{icon:"plot",title:"Add a plot to every selected reaction",label:"Plots",onClick:()=>o(s==="plot"?null:"plot")}),s==="plot"&&v()]}),n.jsx(Ve,{icon:"group",title:"Collapse the selected arrows into one summary arrow (expandable)",label:"Collapse",onClick:()=>l.collapseSelection()})]}),u&&d.length===2&&n.jsx(Ve,{icon:"group",title:"Collapse everything drawn between these two metabolites into one arrow",label:"Collapse between",onClick:()=>l.collapseSelection()}),d.length>=2&&!b&&n.jsxs(n.Fragment,{children:[!g&&n.jsx(zd,{}),n.jsx(Ve,{icon:"vertical",title:"Vertical pathway",onClick:()=>l.layoutSelection("vertical")}),n.jsx(Ve,{icon:"horizontal",title:"Horizontal pathway",onClick:()=>l.layoutSelection("horizontal")}),n.jsx(Ve,{icon:"circle",title:"Circular (cycles: TCA, urea…)",onClick:()=>l.layoutSelection("circle")}),n.jsx(Ve,{icon:"hier",title:"Hierarchical",onClick:()=>l.layoutSelection("hierarchical")}),n.jsx(Ve,{icon:"gridLayout",title:"Grid",onClick:()=>l.layoutSelection("grid")}),n.jsx(Ve,{icon:"organic",title:"Organic (force-directed)",onClick:()=>l.layoutSelection("organic")}),n.jsx(zd,{}),n.jsxs("div",{className:"ctx-wrap",children:[n.jsx(Ve,{icon:"alignLeft",title:"Align & distribute",onClick:()=>o(s==="align"?null:"align")}),s==="align"&&n.jsxs("div",{className:"ctx-menu grid3",children:[n.jsx("button",{title:"Align left",onClick:()=>l.alignSelection("left"),children:n.jsx(q,{name:"alignLeft"})}),n.jsx("button",{title:"Align centre (vertical axis)",onClick:()=>l.alignSelection("centerX"),children:n.jsx(q,{name:"alignCX"})}),n.jsx("button",{title:"Align right",onClick:()=>l.alignSelection("right"),children:n.jsx(q,{name:"alignRight"})}),n.jsx("button",{title:"Align top",onClick:()=>l.alignSelection("top"),children:n.jsx(q,{name:"alignTop"})}),n.jsx("button",{title:"Align middle (horizontal axis)",onClick:()=>l.alignSelection("centerY"),children:n.jsx(q,{name:"alignCY"})}),n.jsx("button",{title:"Align bottom",onClick:()=>l.alignSelection("bottom"),children:n.jsx(q,{name:"alignBottom"})}),n.jsx("button",{title:"Distribute horizontally",onClick:()=>l.distributeSelection("x"),children:n.jsx(q,{name:"distH"})}),n.jsx("button",{title:"Distribute vertically",onClick:()=>l.distributeSelection("y"),children:n.jsx(q,{name:"distV"})}),n.jsx("button",{title:"Equal spacing (layout spacing)",onClick:()=>{const j=d,N=Math.max(...j.map(w=>w.x))-Math.min(...j.map(w=>w.x)),C=Math.max(...j.map(w=>w.y))-Math.min(...j.map(w=>w.y));l.distributeSelection(N>C?"x":"y",!0)},children:n.jsx(q,{name:"tidy"})})]})]}),n.jsx(Ve,{icon:"tidy",title:"Tidy selection (auto-detect row / column / ring)",label:"Tidy",onClick:()=>l.tidySelection()}),n.jsx(Ve,{icon:"group",title:"Group as pathway (Ctrl+G)",onClick:()=>l.groupSelection("pathway")}),n.jsx(Ve,{icon:"template",title:"Save selection as reusable template",onClick:()=>R.setState({dialog:{kind:"saveTemplate"}})}),x&&n.jsx(Ve,{icon:"path",title:"Find shortest metabolic path between these two",label:"Path",onClick:()=>l.findPath(d[0].metaboliteId,d[1].metaboliteId)})]}),n.jsx(zd,{}),n.jsx(Ve,{icon:"lock",title:"Lock: skip in clicks and box selection (L). Hold 3 s to unlock.",onClick:()=>l.toggleLock()}),n.jsx(Ve,{icon:"trash",title:"Delete (Del)",onClick:()=>l.deleteSelection()})]})}function N0(e){return e.length?e.reduce((t,i)=>t+i,0)/e.length:NaN}function g5(e){if(e.length<2)return 0;const t=N0(e);return Math.sqrt(e.reduce((i,a)=>i+(a-t)**2,0)/(e.length-1))}function va(e,t){if(!e.length)return NaN;const i=(e.length-1)*t,a=Math.floor(i),s=Math.ceil(i);return e[a]+(e[s]-e[a])*(i-a)}function b5(e,t,i,a=64){if(!e.length)return[];const o=1.06*(g5(e)||Math.abs(N0(e))*.02||.001)*Math.pow(e.length,-.2),l=[],r=1/(e.length*o*Math.sqrt(2*Math.PI));for(let c=0;c<a;c++){const d=t+(i-t)*c/(a-1);let f=0;for(const u of e){const p=(d-u)/o;f+=Math.exp(-.5*p*p)}l.push([d,f*r])}return l}function y5(e){let t=e>>>0;const i=()=>{t=t+1831565813>>>0;let s=t;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296};return{next:i,normal:()=>{const s=Math.max(i(),1e-12);return Math.sqrt(-2*Math.log(s))*Math.cos(2*Math.PI*i())}}}function x5(e,t,i=3){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return[e];const s=(t-e)/i,o=Math.pow(10,Math.floor(Math.log10(s))),l=s/o,r=(l>=5?10:l>=2?5:l>=1?2:1)*o,c=[];for(let d=Math.ceil(e/r)*r;d<=t+r*1e-9;d+=r)c.push(+d.toPrecision(12));return c}function jt(e,t=3){if(e==null||!Number.isFinite(e))return"—";if(e===0)return"0";const i=Math.abs(e);return i>=1e3||i<.001?e.toExponential(1):String(+e.toPrecision(t))}const _5=166;function v5({legend:e,pos:t,items:i,theme:a,selected:s}){if(!e.visible||!i.length)return null;let o=0;const l=150,r=[];i.forEach((f,u)=>{const p=o,m=n.jsxs("text",{x:0,y:p+9,fontSize:9,fontWeight:600,fill:a.text,children:[f.title,"unit"in f&&f.unit?n.jsxs("tspan",{fontWeight:400,fill:a.plotAxis,children:[" (",f.unit,")"]}):null]});if(f.kind==="conditions")r.push(n.jsxs("g",{children:[m,f.items.map((h,g)=>n.jsxs("g",{transform:`translate(${g%2*70},${p+16+Math.floor(g/2)*13})`,children:[n.jsx("rect",{x:0,y:0,width:14,height:8,fill:h.color,opacity:.85}),n.jsx("text",{x:19,y:7.5,fontSize:8.5,fill:a.text,children:h.name})]},g))]},u)),o+=20+Math.ceil(f.items.length/2)*13+8;else if(f.kind==="width"){const h=[f.domain[0],(f.domain[0]+f.domain[1])/2,f.domain[1]];r.push(n.jsxs("g",{children:[m,h.map((g,y)=>{const b=(g-f.domain[0])/(f.domain[1]-f.domain[0]||1),_=f.range[0]+b*(f.range[1]-f.range[0]);return n.jsxs("g",{transform:`translate(0,${p+20+y*13})`,children:[n.jsx("line",{x1:0,x2:46,y1:0,y2:0,stroke:a.edge,strokeWidth:_}),n.jsx("text",{x:54,y:3,fontSize:8.5,fill:a.text,children:jt(g,2)})]},y)})]},u)),o+=20+3*13+6}else if(f.kind==="radius"){const h=[f.domain[1]*.1,f.domain[1]*.5,f.domain[1]];r.push(n.jsxs("g",{children:[m,h.map((g,y)=>{const b=Math.sqrt(g/(f.domain[1]||1)),_=f.range[0]+b*(f.range[1]-f.range[0]);return n.jsxs("g",{transform:`translate(${12+y*42},${p+36})`,children:[n.jsx("circle",{r:_,fill:a.nodeFill,opacity:.85}),n.jsx("text",{y:22,fontSize:8,textAnchor:"middle",fill:a.text,children:jt(g,2)})]},y)})]},u)),o+=66}else{const h=za(f.palette),g=24,y=120/g;r.push(n.jsxs("g",{children:[m,Array.from({length:g},(b,_)=>n.jsx("rect",{x:_*y,y:p+15,width:y+.3,height:9,fill:Bs(h,(_+.5)/g)},_)),n.jsx("text",{x:0,y:p+34,fontSize:8,fill:a.text,children:jt(f.domain[0],2)}),f.diverging&&n.jsx("text",{x:60,y:p+34,fontSize:8,textAnchor:"middle",fill:a.text,children:jt((f.domain[0]+f.domain[1])/2,2)}),n.jsx("text",{x:120,y:p+34,fontSize:8,textAnchor:"end",fill:a.text,children:jt(f.domain[1],2)})]},u)),o+=44}});const c=e.scale??1,d=8/c;return n.jsxs("g",{transform:`translate(${t.x},${t.y}) scale(${c})`,"data-sel":"legend:legend","data-legend-h":o,fontFamily:a.font,children:[n.jsx("rect",{x:-8,y:-8,width:l+16,height:o+8,fill:a.background,opacity:.001}),r,s&&n.jsx("rect",{className:"ui-only",x:-8,y:-8,width:l+16,height:o+8,fill:"none",stroke:"#4f5bd5",strokeWidth:1.2/c,strokeDasharray:`${4/c} ${3/c}`}),s&&[["nw",-8,-8,"nwse-resize"],["ne",l+8,-8,"nesw-resize"],["se",l+8,o,"nwse-resize"],["sw",-8,o,"nesw-resize"]].map(([f,u,p,m])=>n.jsx("rect",{className:"ui-only","data-resize":`legend:${f}`,x:u-d/2,y:p-d/2,width:d,height:d,rx:1.5/c,fill:"#fff",stroke:"#4f5bd5",strokeWidth:1.2/c,style:{cursor:m}},f))]})}function j5(){const e=E.useDeferredValue(R(y=>y.doc)),t=R(y=>y.camera),i=R(y=>y.viewport);Fn(y=>y.factor);const a=E.useMemo(()=>wa(e),[e]),s=Math.min(1,i.w*.2/Zr(168),i.h*.25/Zr(110)),o=Math.round(168*s),l=Math.round(110*s),r={x:-t.x/t.k,y:-t.y/t.k,w:i.w/t.k,h:i.h/t.k},c=Math.min((a==null?void 0:a.x)??0,r.x),d=Math.min((a==null?void 0:a.y)??0,r.y),f=Math.max(((a==null?void 0:a.x)??0)+((a==null?void 0:a.w)??0),r.x+r.w),u=Math.max(((a==null?void 0:a.y)??0)+((a==null?void 0:a.h)??0),r.y+r.h),p=Math.min(o/(f-c||1),l/(u-d||1)),{edges:m,dots:h}=E.useMemo(()=>{let y="",b="";for(const _ of Object.values(e.reactions)){const x=e.nodes[_.sources[0]],v=e.nodes[_.targets[0]];x&&v&&(y+=`M${((x.x-c)*p).toFixed(1)} ${((x.y-d)*p).toFixed(1)}L${((v.x-c)*p).toFixed(1)} ${((v.y-d)*p).toFixed(1)}`)}for(const _ of Object.values(e.nodes))b+=`M${((_.x-c)*p).toFixed(1)} ${((_.y-d)*p).toFixed(1)}h0`;return{edges:y,dots:b}},[e,c,d,p]);if(!a||Object.keys(e.nodes).length<3)return null;const g=y=>{const b=y.currentTarget.getBoundingClientRect(),_=o/b.width,x=(y.clientX-b.left)*_/p+c,v=(y.clientY-b.top)*_/p+d;V().setCamera({x:i.w/2-x*t.k,y:i.h/2-v*t.k})};return n.jsx("div",{className:"minimap",onPointerDown:y=>y.stopPropagation(),children:n.jsxs("svg",{width:qe(o),height:qe(l),viewBox:`0 0 ${o} ${l}`,onClick:g,children:[n.jsx("path",{d:m,stroke:"#b8bcc6",strokeWidth:.8,fill:"none"}),n.jsx("path",{d:h,stroke:"#6b7080",strokeWidth:2.6,strokeLinecap:"round",fill:"none"}),n.jsx("rect",{x:(r.x-c)*p,y:(r.y-d)*p,width:r.w*p,height:r.h*p,fill:"rgba(79,91,213,0.08)",stroke:"#4f5bd5",strokeWidth:1})]})})}function w0(e,t){const i=new Map(t.map((a,s)=>[a.id,s]));return e.columns.map((a,s)=>s).sort((a,s)=>(i.get(e.columns[a])??1e9+a)-(i.get(e.columns[s])??1e9+s))}const Wc=(e,t)=>w0(e,t).map(i=>e.columns[i]);function N5(e,t,i){if(e.datasetId){const o=t.find(l=>l.id===e.datasetId);if(o)return o}const a=t.filter(o=>o.target===i&&o.visible),s=e.type==="density"||e.type==="box"?["samples","fva","flux"]:e.type==="range"?["fva","samples","flux"]:["flux","metabolite","turnover","samples","fva"];for(const o of s){const l=a.find(r=>r.kind===o);if(l)return l}return a[0]}const w5=7,C5=[["nw",0,0,"nwse-resize"],["n",.5,0,"ns-resize"],["ne",1,0,"nesw-resize"],["e",1,.5,"ew-resize"],["se",1,1,"nwse-resize"],["s",.5,1,"ns-resize"],["sw",0,1,"nesw-resize"],["w",0,.5,"ew-resize"]];function k5({plot:e,x:t,y:i,title:a,glyph:s,metaboliteId:o,datasets:l,conditions:r,view:c,theme:d,selected:f}){const u=N5(e,l,s?"reaction":"metabolite"),{w:p,h:m}=e,h=e.fontSize??w5,g=6,y=6,b=Math.round(h*2),_=e.showAxis?Math.round(h*2.3):6,x=p-g-y,v=m-b-_,j=s!=null&&s.reversedToModel?-1:1,N=s?s.reactionId??(s.collapsed?"__collapsed__":void 0):o,C=u?w0(u,r):[],w=u?C.map(L=>r.find(D=>D.id===u.columns[L])??{id:u.columns[L],name:u.columns[L],color:"#888"}):[],k=L=>!u||!N?null:s?ca(u,s,u.columns[C[L]]):Ec(u,N,C[L]),P=L=>!(u!=null&&u.samples)||!N?[]:s?p5(u,s,C[L]):Vm(u,N,C[L]),H=L=>{const D=u!=null&&u.ranges&&N?Wm(u,N,C[L]):null;if(D)return j>0?D:[-D[1],-D[0]];const F=P(L).slice().sort((U,z)=>U-z);return F.length?[va(F,.025),va(F,.975)]:null};let G=null,M=null;const A=n.jsx("text",{x:p/2,y:b+v/2+3,fontSize:h,textAnchor:"middle",fill:d.plotAxis,fontStyle:"italic",children:"no data"}),X=e.type==="density"&&!(u!=null&&u.samples)?"bar":e.type;if(!u||!N)G=A;else if(X==="density"||X==="box"){const L=w.flatMap((D,F)=>P(F)).sort((D,F)=>D-F);if(!L.length)G=A;else{let D=va(L,.005),F=va(L,.995);const U=(F-D)*.08||Math.abs(D)*.1||.1;D-=U,F+=U,M={lo:D,hi:F};const z=O=>g+(O-D)/(F-D)*x;if(X==="density"){const O=w.map((he,J)=>b5(P(J),D,F,60)),Z=Math.max(1e-9,...O.flat().map(he=>he[1])),oe=he=>b+v-he/Z*v;G=n.jsxs("g",{children:[O.map((he,J)=>{if(!he.length)return null;const Pe=he.map(([Ke,Mn])=>`${z(Ke).toFixed(1)},${oe(Mn).toFixed(1)}`).join(" L"),ye=w[J].color,_e=w[J].id===c.activeCondition;return n.jsx("g",{opacity:_e?1:.85,children:n.jsx("path",{d:`M${z(D).toFixed(1)},${(b+v).toFixed(1)} L${Pe} L${z(F).toFixed(1)},${(b+v).toFixed(1)} Z`,fill:Ef(ye,.28),stroke:ye,strokeWidth:_e?1.1:.7})},J)}),w.map((he,J)=>{const Pe=N0(P(J));return Number.isFinite(Pe)?n.jsx("line",{x1:z(Pe),x2:z(Pe),y1:b,y2:b+v,stroke:he.color,strokeWidth:.8,strokeDasharray:"2.5 1.5"},"m"+J):null})]})}else{const O=Math.min(10,v/w.length-2);G=n.jsx("g",{children:w.map((Z,oe)=>{const he=P(oe).slice().sort((Un,sn)=>Un-sn);if(!he.length)return null;const J=va(he,.25),Pe=va(he,.5),ye=va(he,.75),_e=ye-J,Ke=Math.max(he[0],J-1.5*_e),Mn=Math.min(he[he.length-1],ye+1.5*_e),Ct=b+v/w.length*(oe+.5);return n.jsxs("g",{children:[n.jsx("line",{x1:z(Ke),x2:z(Mn),y1:Ct,y2:Ct,stroke:Z.color,strokeWidth:.8}),n.jsx("rect",{x:z(J),y:Ct-O/2,width:Math.max(.5,z(ye)-z(J)),height:O,fill:Ef(Z.color,.3),stroke:Z.color,strokeWidth:.8}),n.jsx("line",{x1:z(Pe),x2:z(Pe),y1:Ct-O/2,y2:Ct+O/2,stroke:Z.color,strokeWidth:1.2})]},oe)})})}}}else if(X==="range"){const L=w.map((F,U)=>H(U)),D=L.flatMap(F=>F||[]);if(!D.length)G=A;else{let F=Math.min(...D),U=Math.max(...D);const z=(U-F)*.1||.1;F-=z,U+=z,M={lo:F,hi:U};const O=Z=>g+(Z-F)/(U-F)*x;G=n.jsx("g",{children:L.map((Z,oe)=>{if(!Z)return null;const he=b+v/w.length*(oe+.5),J=k(oe);return n.jsxs("g",{stroke:w[oe].color,children:[n.jsx("line",{x1:O(Z[0]),x2:O(Z[1]),y1:he,y2:he,strokeWidth:1.4}),n.jsx("line",{x1:O(Z[0]),x2:O(Z[0]),y1:he-3,y2:he+3,strokeWidth:1}),n.jsx("line",{x1:O(Z[1]),x2:O(Z[1]),y1:he-3,y2:he+3,strokeWidth:1}),J!=null&&n.jsx("circle",{cx:O(J),cy:he,r:1.8,fill:w[oe].color,stroke:"none"})]},oe)})})}}else if(X==="heatmap"){const L=w.map((F,U)=>k(U)),D=L.filter(F=>F!=null);if(!D.length)G=A;else{const F=Math.max(1e-9,...D.map(Math.abs)),U=za(D.some(Z=>Z<0)?"blue-red":"viridis"),z=D.some(Z=>Z<0),O=x/w.length;G=n.jsx("g",{children:L.map((Z,oe)=>n.jsxs("g",{children:[n.jsx("rect",{x:g+oe*O,y:b,width:O-1,height:v,fill:Z==null?"#eee":Bs(U,z?.5+Z/(2*F):Z/F),stroke:w[oe].id===c.activeCondition?d.text:"none",strokeWidth:.8}),n.jsx("text",{x:g+oe*O+O/2,y:b+v/2+2.5,fontSize:h,textAnchor:"middle",fill:Z!=null&&(z?Math.abs(Z)/F>.6:Z/F<.55)?"#fff":"#111",children:jt(Z,2)}),e.showAxis&&n.jsx("text",{x:g+oe*O+O/2,y:m-5,fontSize:h,textAnchor:"middle",fill:d.plotAxis,children:w[oe].name})]},oe))})}}else{const L=w.map((F,U)=>k(U)),D=L.filter(F=>F!=null);if(!D.length)G=A;else{const F=Math.min(0,...D),U=Math.max(0,...D),z=U-F||1,O=ye=>b+v-(ye-F)/z*v,Z=x/w.length,oe=X==="line"&&w.every(ye=>typeof ye.time=="number"),he=oe?Math.min(...w.map(ye=>ye.time)):0,J=oe?Math.max(...w.map(ye=>ye.time)):1,Pe=ye=>oe?g+4+(w[ye].time-he)/(J-he||1)*(x-8):g+Z*(ye+.5);G=n.jsxs("g",{children:[n.jsx("line",{x1:g,x2:g+x,y1:O(0),y2:O(0),stroke:d.plotAxis,strokeWidth:.5}),X==="bar"?L.map((ye,_e)=>ye==null?null:n.jsx("rect",{x:g+_e*Z+Z*.15,y:Math.min(O(ye),O(0)),width:Z*.7,height:Math.max(.5,Math.abs(O(ye)-O(0))),fill:w[_e].color,opacity:w[_e].id===c.activeCondition?1:.55},_e)):n.jsxs("g",{children:[n.jsx("path",{d:L.map((ye,_e)=>ye==null?"":`${_e===0?"M":"L"}${Pe(_e).toFixed(1)},${O(ye).toFixed(1)}`).join(" "),fill:"none",stroke:d.edge,strokeWidth:.9}),L.map((ye,_e)=>ye==null?null:n.jsx("circle",{cx:Pe(_e),cy:O(ye),r:w[_e].id===c.activeCondition?2.8:2,fill:w[_e].color},_e))]}),e.showAxis&&w.map((ye,_e)=>n.jsx("text",{x:X==="line"?Pe(_e):g+Z*(_e+.5),y:m-5,fontSize:h,textAnchor:"middle",fill:d.plotAxis,children:ye.name},_e)),n.jsx("text",{x:g,y:b-1,fontSize:h-1,fill:d.plotAxis,children:jt(U,2)})]})}}const I=M?x5(M.lo,M.hi,3):[],K=M?L=>g+(L-M.lo)/(M.hi-M.lo)*x:()=>0;return n.jsxs("g",{transform:`translate(${t.toFixed(1)},${i.toFixed(1)})`,"data-sel":`plot:${e.id}`,children:[n.jsx("rect",{x:0,y:0,width:p,height:m,fill:d.background,stroke:d.plotAxis,strokeWidth:.6}),n.jsx("text",{x:p/2,y:h+3,fontSize:h+1,textAnchor:"middle",fill:d.text,fontFamily:d.font,children:e.title??a}),G,e.showAxis&&M&&n.jsxs("g",{children:[n.jsx("line",{x1:g,x2:g+x,y1:b+v,y2:b+v,stroke:d.plotAxis,strokeWidth:.6}),I.map(L=>n.jsxs("g",{children:[n.jsx("line",{x1:K(L),x2:K(L),y1:b+v,y2:b+v+2,stroke:d.plotAxis,strokeWidth:.6}),n.jsx("text",{x:K(L),y:b+v+9,fontSize:h-.5,textAnchor:"middle",fill:d.plotAxis,children:jt(L,2)})]},L))]}),f&&n.jsx("rect",{className:"ui-only",x:-3,y:-3,width:p+6,height:m+6,fill:"none",stroke:"#4f5bd5",strokeWidth:1.5}),f&&C5.map(([L,D,F,U])=>n.jsx("rect",{className:"ui-only","data-resize":`${e.id}:${L}`,x:D*p-4,y:F*m-4,width:8,height:8,rx:1.5,fill:"#fff",stroke:"#4f5bd5",strokeWidth:1.2,style:{cursor:U}},L))]})}const M5=E.memo(k5),E5=[["nw",0,0,"nwse-resize"],["n",.5,0,"ns-resize"],["ne",1,0,"nesw-resize"],["e",1,.5,"ew-resize"],["se",1,1,"nwse-resize"],["s",.5,1,"ns-resize"],["sw",0,1,"nesw-resize"],["w",0,.5,"ew-resize"]],da="#4f5bd5";function ko(e,t){let i=0;for(const a of e)i+=/[A-Z0-9]/.test(a)?.64:/[il.,:;'|!]/.test(a)?.28:.52;return{hw:i*t/2+2,hh:t*.62}}function Mo(e,t,i){const a=e.metaboliteId?t==null?void 0:t.metabolites[e.metaboliteId]:void 0;return e.labelMode==="custom"?e.label??"":e.labelMode==="name"?(a==null?void 0:a.name)??e.label??"?":e.labelMode==="id"?e.metaboliteId??e.label??"?":i.metaboliteLabel==="none"?"":i.metaboliteLabel==="name"&&a?a.name:e.label??(e.metaboliteId?bt(e.metaboliteId):"?")}function G5(e,t,i){const a=e.reactionId?t==null?void 0:t.reactions[e.reactionId]:void 0,s=e.collapsed?e.collapsed.members.map(l=>l.reactionId):e.lumped??(e.reactionId?[e.reactionId]:[]),o=s.length<=2?s.join(" + "):`${s[0]} … ${s[s.length-1]}`;if(e.labelMode==="custom")return e.label??"";if(e.labelMode==="name")return(a==null?void 0:a.name)??e.label??o;if(e.labelMode==="id")return o||(e.label??"");if(i.reactionLabel==="none")return"";if(i.reactionLabel==="name"&&a)return a.name;if(e.collapsed&&!e.label){const l=e.collapsed.members.map(r=>r.reactionId);return l.length<=2?l.join(" + "):`${l[0]} … ${l[l.length-1]}`}return e.label??e.reactionId??""}const b_=e=>e?{transition:"stroke-width .45s ease, stroke .45s ease, fill .45s ease, r .45s ease"}:void 0,y_=e=>Math.max(6,e-2);function S5(e,t,i,a,s){const o=e.attach.side==="out",l={x:t.x+i.x*(o?5:-5),y:t.y+i.y*(o?5:-5)},r={x:l.x+i.x*(o?9:-9),y:l.y+i.y*(o?9:-9)},{hw:c,hh:d}=ko(e.label??"",y_(a)),f=r.x-e.x,u=r.y-e.y,p=Math.hypot(f,u)||1,m=Math.min(Math.abs(f)>1e-6?c/Math.abs(f/p):1/0,Math.abs(u)>1e-6?d/Math.abs(u/p):1/0)+2,h={x:e.x+f/p*m,y:e.y+u/p*m};if(!o)return{d:`M${h.x.toFixed(1)},${h.y.toFixed(1)} Q${r.x.toFixed(1)},${r.y.toFixed(1)} ${l.x.toFixed(1)},${l.y.toFixed(1)}`};const g=Math.atan2(h.y-r.y,h.x-r.x),y=V1(s)*.7,b={x:h.x-Math.cos(g)*y,y:h.y-Math.sin(g)*y};return{d:`M${l.x.toFixed(1)},${l.y.toFixed(1)} Q${r.x.toFixed(1)},${r.y.toFixed(1)} ${b.x.toFixed(1)},${b.y.toFixed(1)}`,tip:{x:h.x,y:h.y,angle:g}}}const A5=E.memo(function({g:t,parts:i,radii:a,rv:s,isSel:o,ctx:l,cofs:r}){var D,F,U;const{model:c,style:d,theme:f,interactive:u,particles:p}=l,m=d.fontSize,h=b_(u),g={},y={};i.forEach((z,O)=>{z&&(g[z.id]=z,y[z.id]=a[O])});const b=(z,O)=>{const Z=g[z];if((Z==null?void 0:Z.shape)==="label"&&O){const{hw:oe,hh:he}=ko(Mo(Z,c,d),m);return Math.min(Math.abs(O.x)>1e-6?oe/Math.abs(O.x):1/0,Math.abs(O.y)>1e-6?he/Math.abs(O.y):1/0)-3}return y[z]??d.nodeRadius},_=(s==null?void 0:s.width)??d.baseEdgeWidth,x=V1(_)*.8,v=(s==null?void 0:s.dir)??1,j=(s==null?void 0:s.value)==null&&!t.collapsed&&(t.reactionId?!!((D=c==null?void 0:c.reactions[t.reactionId])!=null&&D.reversible):((F=t.design)==null?void 0:F.reversible)===!0),N=q1(t,g,b,v<0||j?x:0,v>=0||j?x:0);if(!N)return null;const C=(s==null?void 0:s.color)??f.edge,w=!t.reactionId,k=G5(t,c,d),P=d.reactionLabelSize??m-1,H=t.labelOffset?{x:N.mid.x+t.labelOffset.x,y:N.mid.y+t.labelOffset.y}:{x:N.mid.x+N.normal.x*(9+_/2),y:N.mid.y+N.normal.y*(9+_/2)},G=t.labelOffset||Math.abs(N.normal.x)<.3?"middle":N.normal.x<0?"end":"start",M=t.labelAngle?`rotate(${t.labelAngle} ${H.x.toFixed(1)} ${H.y.toFixed(1)})`:void 0,A=t.reactionId?c==null?void 0:c.reactions[t.reactionId]:void 0;let X="";if(d.currency==="inline"&&A&&c){const z=ws(A,c.metabolites),O=z.cofactorsIn.map(bt).join("+"),Z=z.cofactorsOut.map(bt).join("+");(O||Z)&&(X=`${O||"∅"} → ${Z||"∅"}`)}let I=0;if(u&&o&&A&&c&&!t.lumped){const z=ws(A,c.metabolites),O=new Set([...t.sources,...t.targets].map(Z=>{var oe;return(oe=g[Z])==null?void 0:oe.metaboliteId}));I=[...z.substrates,...z.products].filter(Z=>!O.has(Z)).length}const K=(U=t.collapsed)!=null&&U.showBadge?String(t.collapsed.members.length):"",L=s!=null&&s.dashed?`${Math.max(2,_*1.5)} ${Math.max(2.5,_*1.8)}`:void 0;return n.jsxs("g",{"data-sel":`reaction:${t.id}`,opacity:(s==null?void 0:s.opacity)??1,children:[u&&N.segments.map((z,O)=>n.jsx("path",{className:"ui-only",d:z.d,stroke:"transparent",strokeWidth:Math.max(12,_+8),fill:"none"},"h"+O)),o&&N.segments.map((z,O)=>n.jsx("path",{className:"ui-only",d:z.d,stroke:da,strokeOpacity:.35,strokeWidth:_+6,fill:"none",strokeLinecap:"round"},"s"+O)),N.segments.map((z,O)=>n.jsx("path",{d:z.d,fill:"none",stroke:C,strokeWidth:_,strokeDasharray:L,strokeLinecap:"butt",style:h},O)),N.segments.map((z,O)=>{const Z=[];return(v>=0||j)&&z.side!=="source"&&Z.push(z.endTip),(v<0||j)&&z.side!=="target"&&Z.push(z.startTip),Z.map((oe,he)=>n.jsx("path",{d:kf(oe,_),fill:C,stroke:"none",style:h},`a${O}${he}`))}),p&&(s!=null&&s.dir)?N.segments.map((z,O)=>n.jsx("path",{className:"ui-only flow",d:z.d,fill:"none",stroke:"#ffffff",strokeOpacity:.85,strokeWidth:Math.max(1,_*.45),strokeLinecap:"round",strokeDasharray:"0.1 9",style:{animationDuration:`${Math.max(.25,2.2/Math.sqrt(Math.abs(s.value??1)+.2))}s`,animationDirection:s.dir<0?"reverse":"normal"}},"p"+O)):null,k&&n.jsxs("text",{x:H.x,y:H.y+P*.33,fontSize:P,fontStyle:"italic",textAnchor:G,transform:M,fill:w&&u?f.slotStroke:f.rxnLabel,children:[k,(s==null?void 0:s.valueLabel)!=null&&n.jsx("tspan",{x:H.x,dy:P+1,fontStyle:"normal",fill:f.text,fontSize:Math.max(6,P-1),children:s.valueLabel})]}),!k&&(s==null?void 0:s.valueLabel)!=null&&n.jsx("text",{x:H.x,y:H.y+m*.33,fontSize:m-2,textAnchor:G,fill:f.text,children:s.valueLabel}),K&&n.jsxs("g",{children:[n.jsx("rect",{x:N.mid.x-(6+K.length*2.6),y:N.mid.y-6,width:12+K.length*5.2,height:12,rx:6,fill:f.background,stroke:C,strokeWidth:Math.min(2,Math.max(1,_*.5))}),n.jsx("text",{x:N.mid.x,y:N.mid.y+2.9,fontSize:8,fontWeight:700,textAnchor:"middle",fill:f.text,children:K})]}),I>0&&n.jsxs("text",{className:"ui-only",x:N.mid.x-N.normal.x*(10+_/2),y:N.mid.y-N.normal.y*(10+_/2)+3,fontSize:m-2,fontWeight:600,textAnchor:"middle",fill:"#e0a100",children:[n.jsxs("title",{children:[I," participant(s) hidden — choose them in the Inspector"]}),"+",I]}),X&&n.jsx("text",{x:N.mid.x-N.normal.x*(8+_/2),y:N.mid.y-N.normal.y*(8+_/2)+3,fontSize:m-3,textAnchor:G==="end"?"start":G==="start"?"end":"middle",fill:f.plotAxis,children:X}),r==null?void 0:r.map(z=>{const O=S5(z,N.mid,N.dir,m,Math.max(.8,_*.6));return n.jsxs("g",{children:[n.jsx("path",{d:O.d,fill:"none",stroke:C,strokeOpacity:.75,strokeWidth:Math.max(.7,_*.6)}),O.tip&&n.jsx("path",{d:kf(O.tip,Math.max(.7,_*.6)),fill:C,fillOpacity:.75,stroke:"none"})]},z.id)})]})},(e,t)=>{var i,a;return e.g===t.g&&e.isSel===t.isSel&&e.ctx===t.ctx&&e.parts.length===t.parts.length&&e.parts.every((s,o)=>s===t.parts[o])&&e.radii.every((s,o)=>s===t.radii[o])&&D5(e.rv,t.rv)&&(((i=e.cofs)==null?void 0:i.length)??0)===(((a=t.cofs)==null?void 0:a.length)??0)&&(e.cofs??[]).every((s,o)=>s===t.cofs[o])});function D5(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.color===t.color&&e.opacity===t.opacity&&e.dir===t.dir&&e.dashed===t.dashed&&e.valueLabel===t.valueLabel&&e.value===t.value}const Ud={provisional:{fill:"#d97706",text:"?"},ambiguous:{fill:"#d97706",text:"?"},unresolved:{fill:"#9ca3af",text:"?"}},kg={confirmed:{fill:"#15803d",text:"✓"},suggested:{fill:"#d97706",text:"?"},ambiguous:{fill:"#ea580c",text:"!"},unresolved:{fill:"#9ca3af",text:"○"}},P5=E.memo(function({n:t,r:i,fill:a,opacity:s,isSel:o,ctx:l}){var x,v;const{model:r,style:c,theme:d,interactive:f}=l;if(t.attach){const j=y_(c.fontSize),{hw:N,hh:C}=ko(t.label??"",j);return n.jsxs("g",{"data-sel":`node:${t.id}`,opacity:s,children:[f&&n.jsx("rect",{className:"ui-only",x:t.x-N-2,y:t.y-C-1,width:N*2+4,height:C*2+2,fill:"transparent"}),o&&n.jsx("rect",{className:"ui-only",x:t.x-N-2,y:t.y-C-1,width:N*2+4,height:C*2+2,rx:3,fill:"none",stroke:da,strokeWidth:1.2}),n.jsx("text",{x:t.x,y:t.y+j*.35,fontSize:j,textAnchor:"middle",fill:d.plotAxis,children:t.label})]})}const u=c.fontSize,p=b_(f),m=!t.design&&(!t.metaboliteId||!(r!=null&&r.metabolites[t.metaboliteId])),h=((x=t.design)==null?void 0:x.kind)==="port",g=t.metaboliteId&&r&&!r.metabolites[t.metaboliteId],y=Mo(t,r,c),b=SC(t,t.labelPos,i,u),_=t.role==="exchange";return n.jsxs("g",{"data-sel":`node:${t.id}`,opacity:s,children:[f&&t.shape!=="label"&&n.jsx("circle",{className:"ui-only handle","data-handle":t.id,cx:t.x,cy:t.y,r:i+7,fill:"transparent"}),f&&t.shape==="label"&&(()=>{const{hw:j,hh:N}=ko(y||"?",u);return n.jsx("rect",{className:"ui-only handle","data-handle":t.id,x:t.x-j-6,y:t.y-N-6,width:j*2+12,height:N*2+12,rx:6,fill:"transparent"})})(),o&&n.jsx("circle",{className:"ui-only",cx:t.x,cy:t.y,r:i+4,fill:"none",stroke:da,strokeWidth:1.6}),t.shape==="label"?(()=>{const{hw:j,hh:N}=ko(y||"?",u),C=!!a&&a!==d.nodeFill;return n.jsxs(n.Fragment,{children:[f&&n.jsx("rect",{className:"ui-only",x:t.x-j,y:t.y-N,width:j*2,height:N*2,fill:"transparent"}),o&&n.jsx("rect",{className:"ui-only",x:t.x-j-2,y:t.y-N-1,width:j*2+4,height:N*2+2,rx:3,fill:"none",stroke:da,strokeWidth:1.4}),C&&n.jsx("rect",{x:t.x-j,y:t.y-N+1,width:j*2,height:N*2-2,rx:N*.6,fill:a,opacity:.35,style:p}),h&&n.jsx("rect",{x:t.x-j-5,y:t.y-N-2,width:j*2+10,height:N*2+4,rx:N+2,fill:d.background,stroke:d.plotAxis,strokeWidth:1,strokeDasharray:"3 2"}),n.jsx("text",{x:t.x,y:t.y+u*.35,fontSize:u,textAnchor:"middle",fill:m&&f?d.slotStroke:h?d.plotAxis:d.metLabel,fontStyle:m&&f||h?"italic":void 0,children:y||"?"})]})})():_?n.jsx("circle",{cx:t.x,cy:t.y,r:i,fill:d.background,stroke:d.nodeFill,strokeWidth:1.4,strokeDasharray:"2.2 1.8",style:p}):m&&f?n.jsx("circle",{cx:t.x,cy:t.y,r:i,fill:d.background,stroke:g?"#e0a100":d.slotStroke,strokeWidth:1.3,strokeDasharray:"3 2"}):n.jsx("circle",{cx:t.x,cy:t.y,r:i,fill:a??d.nodeFill,stroke:d.nodeStrokeWidth?d.nodeStroke:"none",strokeWidth:d.nodeStrokeWidth||void 0,style:p}),t.locked&&f&&n.jsx("circle",{className:"ui-only",cx:t.x+i*.8,cy:t.y-i*.8,r:2,fill:"#e0a100"}),f&&((v=t.design)==null?void 0:v.kind)==="metabolite"&&t.design.status&&n.jsxs("g",{className:"ui-only",pointerEvents:"none",children:[n.jsx("circle",{cx:t.x-i*.9,cy:t.y-i*.9,r:4.2,fill:t.design.conflict?"#dc2626":kg[t.design.status].fill,stroke:"#fff",strokeWidth:.8}),n.jsx("text",{x:t.x-i*.9,y:t.y-i*.9+2.3,fontSize:6.5,fontWeight:700,textAnchor:"middle",fill:"#fff",children:t.design.conflict?"!":kg[t.design.status].text})]}),f&&t.template&&Ud[t.template.status]&&n.jsxs("g",{className:"ui-only",pointerEvents:"none",children:[n.jsx("circle",{cx:t.x-i*.9,cy:t.y-i*.9,r:4.2,fill:Ud[t.template.status].fill,stroke:"#fff",strokeWidth:.8}),n.jsx("text",{x:t.x-i*.9,y:t.y-i*.9+2.3,fontSize:6.5,fontWeight:700,textAnchor:"middle",fill:"#fff",children:Ud[t.template.status].text})]}),t.shape!=="label"&&y&&t.labelPos!=="none"&&n.jsx("text",{x:b.x,y:b.y,fontSize:u,textAnchor:b.anchor,fill:m&&f?d.slotStroke:d.metLabel,fontStyle:m&&f?"italic":void 0,children:y})]})});function Mg({t:e,theme:t,selected:i}){return n.jsxs("g",{"data-sel":`text:${e.id}`,transform:e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0,children:[n.jsx("text",{x:e.x,y:e.y,fontSize:e.size,fontWeight:e.weight,fontStyle:e.italic?"italic":void 0,fill:e.color??t.text,children:e.text}),i&&n.jsx("rect",{className:"ui-only",x:e.x-3,y:e.y-e.size,width:e.text.length*e.size*.56+6,height:e.size*1.3,fill:"none",stroke:da,strokeWidth:1,strokeDasharray:"3 2"})]})}function R5({doc:e,model:t,datasets:i,conditions:a,view:s,style:o,theme:l,ev:r,selected:c,particles:d,interactive:f}){const u=o.fontSize,p=E.useMemo(()=>({model:t,style:o,theme:l,interactive:f,particles:d}),[t,o,l,f,d]),m=E.useMemo(()=>{const h=new Map;for(const g of Object.values(e.nodes))g.attach&&e.reactions[g.attach.glyph]&&h.set(g.attach.glyph,[...h.get(g.attach.glyph)??[],g]);return h},[e.nodes,e.reactions]);return n.jsxs("g",{fontFamily:l.font,children:[n.jsx("g",{id:"background-texts",children:Object.values(e.texts).filter(h=>h.background).map(h=>n.jsx(Mg,{t:h,theme:l,selected:c.has(`text:${h.id}`)},h.id))}),n.jsx("g",{id:"groups",children:Object.values(e.groups).map(h=>{if(h.hidden)return null;const g=W1(h,e.nodes);if(!g)return null;const y=c.has(`group:${h.id}`),b=h.kind==="compartment";return n.jsxs("g",{"data-sel":`group:${h.id}`,children:[n.jsx("rect",{x:g.x,y:g.y,width:g.w,height:g.h,rx:b?14:6,fill:h.fill,pointerEvents:h.fill==="none"?"stroke":void 0,stroke:h.stroke==="none"?y?da:"none":y?da:h.stroke,strokeWidth:b?1.2:1,strokeDasharray:h.dashed?"5 4":void 0}),n.jsx("text",{x:g.x+8,y:g.y+13,fontSize:u+1,fontWeight:600,fontStyle:b?"normal":"italic",fill:l.text,children:h.title}),h.locked&&f&&n.jsx("text",{className:"ui-only",x:g.x+g.w-8,y:g.y+14,fontSize:u,textAnchor:"end",fill:"#a07800",children:"🔒 locked"}),h.subtitle&&n.jsx("text",{x:g.x+8,y:g.y+25,fontSize:u-1,fill:l.plotAxis,children:h.subtitle}),y&&f&&!h.locked&&E5.map(([_,x,v,j])=>n.jsx("rect",{className:"ui-only","data-resize":`group/${h.id}:${_}`,x:g.x+x*g.w-4,y:g.y+v*g.h-4,width:8,height:8,rx:1.5,fill:"#fff",stroke:da,strokeWidth:1.2,style:{cursor:j}},_))]},h.id)})}),n.jsx("g",{id:"reactions",children:Object.values(e.reactions).map(h=>{const g=[...h.sources,...h.targets].map(y=>e.nodes[y]);return n.jsx(A5,{g:h,parts:g,radii:g.map(y=>{var b;return y?((b=r.nodes[y.id])==null?void 0:b.r)??o.nodeRadius:0}),rv:r.reactions[h.id],isSel:c.has(`reaction:${h.id}`),ctx:p,cofs:m.get(h.id)},h.id)})}),n.jsx("g",{id:"plot-connectors",children:Object.values(e.plots).map(h=>{if(!h.showConnector)return null;const g=Ta(e,h.anchor);if(!g)return null;const y=g.x+h.dx,b=g.y+h.dy,_=Math.max(y,Math.min(g.x,y+h.w)),x=Math.max(b,Math.min(g.y,b+h.h));return _===g.x&&x===g.y?null:n.jsx("line",{x1:g.x,y1:g.y,x2:_,y2:x,stroke:l.plotAxis,strokeWidth:.6,strokeDasharray:"2 2"},h.id)})}),n.jsx("g",{id:"metabolites",children:Object.values(e.nodes).map(h=>{const g=r.nodes[h.id];return n.jsx(P5,{n:h,r:(g==null?void 0:g.r)??o.nodeRadius,fill:g==null?void 0:g.fill,opacity:(g==null?void 0:g.opacity)??1,isSel:c.has(`node:${h.id}`),ctx:p},h.id)})}),n.jsx("g",{id:"plots",children:Object.values(e.plots).map(h=>{const g=Ta(e,h.anchor);if(!g)return null;const y=h.anchor.kind==="reaction"?e.reactions[h.anchor.id]:void 0,b=h.anchor.kind==="node"?e.nodes[h.anchor.id]:void 0;let _="";if(y){const x=y.sources.map(j=>e.nodes[j]).filter(Boolean).map(j=>Mo(j,t,{...o,metaboliteLabel:o.metaboliteLabel==="none"?"id":o.metaboliteLabel})),v=y.targets.map(j=>e.nodes[j]).filter(Boolean).map(j=>Mo(j,t,{...o,metaboliteLabel:o.metaboliteLabel==="none"?"id":o.metaboliteLabel}));_=`${x.join(" + ")} → ${v.join(" + ")}`}else b&&(_=Mo(b,t,o));return n.jsx(M5,{plot:h,x:g.x+h.dx,y:g.y+h.dy,title:_,glyph:y,metaboliteId:b==null?void 0:b.metaboliteId,datasets:i,conditions:a,view:s,theme:l,selected:c.has(`plot:${h.id}`)},h.id)})}),n.jsx("g",{id:"annotations",children:Object.values(e.texts).filter(h=>!h.background).map(h=>n.jsx(Mg,{t:h,theme:l,selected:c.has(`text:${h.id}`)},h.id))}),n.jsx(v5,{legend:e.legend,pos:Kr(e),items:r.legend,theme:l,selected:c.has("legend:legend")})]})}const Iu=E.memo(R5);function Eg(e,t=!1){const i=new Set;for(const[a,s]of Object.entries(e))if(!(a==="bigg.metabolite"&&!t))for(const o of s??[]){const l=ri(a,o);l&&i.add(l)}return i}function gl(e,t){const i=Eg(e.identifiers),a=Eg(t.identifiers);return i.size&&a.size?[...i].some(s=>a.has(s)):$t(e.name)===$t(t.name)}function eo(e,t,i){var a;return{name:e.name,short:e.short,formula:e.formula,synonyms:e.synonyms,identifiers:e.xrefs,library:e.id,sources:["GEMsMAP library"],score:t,match:i,related:(a=e.related)==null?void 0:a.map(s=>({note:s.note,names:s.names,identifiers:s.xrefs}))}}function x_(e,t=12){const i=e.trim();if(!i)return[];const a=$t(i),s=[];for(const o of N1){const l=Object.entries(o.xrefs).flatMap(([f,u])=>(u??[]).map(p=>[f,p])),r=i.toLowerCase();if($t(o.name)===a||o.id.toLowerCase()===r){s.push(eo(o,1,"exact name"));continue}const c=l.find(([f,u])=>u.toLowerCase()===r||`${f}:${u}`.toLowerCase()===r||f==="chebi"&&/^chebi:\s*\d+$/i.test(i)&&ri("chebi",i)===ri("chebi",u));if(c){s.push(eo(o,1,`${c[0]} ${c[1]}`));continue}const d=o.synonyms.find(f=>$t(f)===a);if(d){s.push(eo(o,.9,`synonym “${d}”`));continue}if(a.length>=2&&[o.name,...o.synonyms].some(f=>$t(f).startsWith(a))){s.push(eo(o,.7,"name starts with the query"));continue}a.length>=3&&[o.name,...o.synonyms].some(f=>$t(f).includes(a))&&s.push(eo(o,.5,"name contains the query"))}return s.sort((o,l)=>l.score-o.score||o.name.length-l.name.length).slice(0,t)}function C0(e){const t=[];for(const i of e.flat()){const a=t.find(s=>gl(s,i));if(!a){t.push({...i,identifiers:{...i.identifiers},synonyms:[...i.synonyms],sources:[...i.sources]});continue}a.score=Math.max(a.score,i.score),a.sources=[...new Set([...a.sources,...i.sources])],a.library??(a.library=i.library),a.formula??(a.formula=i.formula),a.charge??(a.charge=i.charge);for(const[s,o]of Object.entries(i.identifiers)){const l=a.identifiers[s]??[],r=new Set(l.map(c=>ri(s,c)));a.identifiers[s]=[...l,...(o??[]).filter(c=>!r.has(ri(s,c)))]}a.synonyms=[...new Set([...a.synonyms,...i.synonyms])].slice(0,24)}return t.sort((i,a)=>a.score-i.score||(i.library?-1:0)-(a.library?-1:0))}const k0=()=>new Date().toISOString();function Eo(e,t){return{...e,name:t.name,short:e.short&&e.identity.status==="confirmed"?e.short:t.short??e.short,formula:t.formula??e.formula,charge:t.charge??e.charge,synonyms:[...new Set([...t.synonyms])].slice(0,24),identifiers:t.identifiers,related:t.related??e.related,library:t.library,identity:{status:"confirmed",source:"user",note:`Chosen from ${t.sources.join(" + ")} (${t.match})`,reviewed:k0()}}}const I5=e=>({...e,identity:{status:"confirmed",source:e.identity.source==="builtin"?"builtin":"user",note:e.identity.note,reviewed:k0()}});function B5(e,t,i){if(!t.length)return e;const a=t[0],s=t.filter(o=>o.score>=a.score-.15&&o.score>=.85);if(e.identity.status==="confirmed")return!s.length||s.some(o=>gl(e,o))?e:{...e,identity:{...e.identity,conflict:{name:a.name,identifiers:a.identifiers,source:i,note:a.match}}};if(s.length>1){const o={status:"ambiguous",source:i,note:`${s.length} plausible candidates for “${e.name}”`,candidates:s.slice(0,6).map(l=>({name:l.name,identifiers:l.identifiers,...l.formula?{formula:l.formula}:{},note:`${l.sources.join(" + ")} · ${l.match}`}))};return{...e,identity:o}}return a.score<.85?e:{...e,name:a.name,short:e.short??a.short,formula:a.formula??e.formula,charge:a.charge??e.charge,synonyms:[...new Set([e.name,...a.synonyms])].filter(o=>$t(o)!==$t(a.name)||o===a.name).slice(0,24),identifiers:a.identifiers,related:a.related??e.related,library:a.library,identity:{status:"suggested",source:i,note:`${a.sources.join(" + ")} · ${a.match}`}}}async function H5(e,t,i="auto"){const a={resolved:0,review:0,unresolved:0,conflicts:0,keptConfirmed:0,reviewIds:[]},s=[];for(const o of e.biology.entities){const l=[...new Set([o.name,...o.synonyms.slice(0,2)].filter(Boolean))],r=await Promise.all(l.map(f=>t(f).catch(()=>[]))),c=C0(r),d=B5(o,c,i);o.identity.status==="confirmed"?(a.keptConfirmed++,d.identity.conflict&&!o.identity.conflict&&(a.conflicts++,a.reviewIds.push(o.id))):d.identity.status==="suggested"?a.resolved++:d.identity.status==="ambiguous"?(a.review++,a.reviewIds.push(o.id)):(a.unresolved++,a.reviewIds.push(o.id)),s.push(d)}return{file:{...e,biology:{...e.biology,entities:s}},summary:a}}function O5(e,t){const i={...e.identifiers};for(const[a,s]of Object.entries(t.identifiers))i[a]=[...new Set([...i[a]??[],...s])];return{...e,canonicalName:t.canonicalName??e.canonicalName,ec:[...new Set([...e.ec,...t.ec])],identifiers:i,reversible:e.reversible??t.reversible??null,identity:{status:"confirmed",source:"user",note:`Chosen from ${t.sources.join(" + ")}${t.equation?`: ${t.equation}`:""}`,reviewed:k0()}}}const Gg=(e,t={})=>{const i={...e};for(const[a,s]of Object.entries(t))i[a]=[...new Set([...i[a]??[],...s??[]])];return i},gr=()=>R.getState().design,mt=e=>{gr()&&R.getState().actions.commit(t=>({design:e(t.design)}))},Je=(e,t)=>({...e,biology:{...e.biology,...t}}),St=(e,t,i)=>e.map(a=>a.id===t?i(a):a),$5=e=>{var a,s;const t=R.getState(),i=t.doc.nodes[e];return((a=i==null?void 0:i.design)==null?void 0:a.kind)==="metabolite"?(s=t.design)==null?void 0:s.biology.metabolites.find(o=>o.id===i.design.id):void 0};function __(e,t){if(t.compartment)return t.compartment;const i=new Set(t.participants.filter(a=>a.main).map(a=>{var s;return((s=e.biology.metabolites.find(o=>o.id===a.metabolite))==null?void 0:s.compartment)??null}));return i.size>1?"transport":[...i][0]??null}function Sg(e,t){const i=e.biology.entities.find(o=>gl(o,t));if(i)return{f:i.identity.status==="confirmed"?e:Je(e,{entities:St(e.biology.entities,i.id,o=>Eo(o,t))}),id:i.id};const a=qi(e.biology.entities.map(o=>o.id),Zt.entity),s=Eo({id:a,name:t.name,synonyms:[],identifiers:{},identity:{status:"unresolved"}},t);return{f:Je(e,{entities:[...e.biology.entities,s]}),id:a}}const fe={updateMetadata(e){mt(t=>({...t,metadata:{...t.metadata,...e}})),e.name&&R.setState({name:e.name})},setCompartments(e){mt(t=>Je(t,{compartments:e}))},updateEntity(e,t){mt(i=>Je(i,{entities:St(i.biology.entities,e,a=>({...a,...t}))}))},updateMetabolite(e,t){mt(i=>Je(i,{metabolites:St(i.biology.metabolites,e,a=>({...a,...t}))}))},updateReaction(e,t){mt(i=>Je(i,{reactions:St(i.biology.reactions,e,a=>({...a,...t}))}))},updateConnector(e,t){mt(i=>Je(i,{connectors:St(i.biology.connectors,e,a=>({...a,...t}))}))},assignIdentity(e,t,i){mt(a=>{const s=a.biology.metabolites.find(u=>u.id===e);if(!s)return a;let o=a,l=s.entity;const r=o.biology.entities.find(u=>u.id===s.entity),c=o.biology.entities.find(u=>u.id!==s.entity&&gl(u,t)),d=o.biology.metabolites.some(u=>u.id!==e&&u.entity===s.entity);c||d?{f:o,id:l}=Sg(o,t):o=Je(o,{entities:St(o.biology.entities,r.id,u=>Eo(u,t))});const f=i!=null&&i.trim()&&i.trim()!==t.short&&i.trim()!==t.name?i.trim():ou(s.label)?void 0:s.label;return Je(o,{metabolites:St(o.biology.metabolites,e,u=>{const{label:p,...m}=u;return{...m,entity:l,...f?{label:f}:{}}})})})},confirmEntity(e){mt(t=>Je(t,{entities:St(t.biology.entities,e,I5)}))},chooseCandidate(e,t){mt(i=>Je(i,{entities:St(i.biology.entities,e,a=>{var o;const s=(o=a.identity.candidates)==null?void 0:o[t];return s?Eo(a,{name:s.name,formula:s.formula,synonyms:a.synonyms,identifiers:s.identifiers,sources:["review"],match:s.note??"stored candidate"}):a})}))},resolveConflict(e,t){mt(i=>Je(i,{entities:St(i.biology.entities,e,a=>{const s=a.identity.conflict;if(!s)return a;if(!t){const{conflict:o,...l}=a.identity;return{...a,identity:l}}return Eo(a,{name:s.name,synonyms:[],identifiers:s.identifiers,sources:[s.source],match:"accepted suggestion"})})}))},clearIdentity(e){mt(t=>Je(t,{entities:St(t.biology.entities,e,i=>({...i,identifiers:{},related:void 0,library:void 0,identity:{status:"unresolved",source:"user"}}))}))},setReactionIdentity(e,t){mt(i=>Je(i,{reactions:St(i.biology.reactions,e,a=>O5(a,t))}))},confirmReaction(e){mt(t=>Je(t,{reactions:St(t.biology.reactions,e,i=>({...i,identity:{...i.identity,status:"confirmed",source:i.identity.source==="builtin"?"builtin":"user",reviewed:new Date().toISOString()}}))}))},addSideParticipant(e,t,i,a=1){mt(s=>{const o=s.biology.reactions.find(p=>p.id===e);if(!o)return s;const{f:l,id:r}=Sg(s,t),c=__(l,o),d=c==="transport"?null:c;let f=l.biology.metabolites.find(p=>p.entity===r&&p.compartment===d),u=l.biology.metabolites;return f||(f={id:qi(u.map(p=>p.id),Zt.metabolite),entity:r,compartment:d,level:"optional"},u=[...u,f]),o.participants.some(p=>p.metabolite===f.id&&Math.sign(p.coefficient)===i)?s:Je(l,{metabolites:u,reactions:St(l.biology.reactions,e,p=>({...p,participants:[...p.participants,{metabolite:f.id,coefficient:i*Math.abs(a),main:!1}]}))})})},removeParticipant(e,t,i){mt(a=>Je(a,{reactions:St(a.biology.reactions,e,s=>({...s,participants:s.participants.filter(o=>o.main||!(o.metabolite===t&&Math.sign(o.coefficient)===Math.sign(i)))}))}))},setCoefficient(e,t,i,a){a>0&&mt(s=>Je(s,{reactions:St(s.biology.reactions,e,o=>({...o,participants:o.participants.map(l=>l.metabolite===t&&Math.sign(l.coefficient)===Math.sign(i)?{...l,coefficient:Math.sign(i)*a}:l)}))}))},addPort(e,t,i="out",a){var f;const s=R.getState(),o=s.doc.nodes[e];if(!s.design||((f=o==null?void 0:o.design)==null?void 0:f.kind)!=="metabolite")return;const l=qi(s.design.biology.connectors.map(u=>u.id),Zt.connector),r=ke("n"),c=ke("r"),d=i==="out";R.getState().actions.commit(u=>({design:Je(u.design,{connectors:[...u.design.biology.connectors,{id:l,metabolite:o.design.id,direction:i,target:{pathway:t,...a?{template:a}:{}}}]}),doc:{...u.doc,nodes:{...u.doc.nodes,[r]:{id:r,x:o.x+110,y:o.y,shape:"label",label:t,design:{kind:"port",id:l}}},reactions:{...u.doc.reactions,[c]:{id:c,sources:[d?e:r],targets:[d?r:e],routing:"straight",role:"exchange",design:{kind:"link",id:l}}}},selection:[Ne("node",r)]}))},addInstance(e){var a;const t=R.getState().doc.nodes[e];if(((a=t==null?void 0:t.design)==null?void 0:a.kind)!=="metabolite")return;const i=ke("n");R.getState().actions.commit(s=>({doc:{...s.doc,nodes:{...s.doc.nodes,[i]:{...t,id:i,x:t.x+60,y:t.y+40,locked:!1}}},selection:[Ne("node",i)]}))},makeIndependent(e){const t=R.getState(),i=t.doc.nodes[e],a=$5(e);if(!t.design||!a||!i)return;const s=qi(t.design.biology.metabolites.map(o=>o.id),Zt.metabolite);R.getState().actions.commit(o=>({design:Je(o.design,{metabolites:[...o.design.biology.metabolites,{...a,id:s,aliases:void 0}]}),doc:{...o.doc,nodes:{...o.doc.nodes,[e]:{...i,design:{kind:"metabolite",id:s}}}}}))},addMetaboliteAt(e,t){const i=R.getState().actions.addNode(e,{label:t??`M${Object.keys(R.getState().doc.nodes).length+1}`});return R.setState({dialog:{kind:"identity",nodeId:i}}),i},async autoIdentify(e,t="auto"){const i=gr();if(!i)return null;const{file:a,summary:s}=await H5(i,e,t);if(!gr())return null;const l=new Map(i.biology.entities.map(c=>[c.id,c])),r=new Map(a.biology.entities.map(c=>[c.id,c]));return mt(c=>Je(c,{entities:c.biology.entities.map(d=>l.get(d.id)===d&&r.has(d.id)?r.get(d.id):d)})),s},applyBiggIds(e){const t=()=>({added:0,known:0,several:0,none:0,review:[]}),i={entities:t(),reactions:t()},a=gr();if(!a)return i;for(const s of a.biology.entities){const o=e.entities[s.id];o&&(o.status==="one"?i.entities.added++:i.entities[o.status]++,o.status==="several"&&i.entities.review.push(`${s.name}: ${o.candidates.map(l=>l.bigg).join(" / ")}`))}for(const s of a.biology.reactions){const o=e.reactions[s.id];o&&(o.status==="one"?i.reactions.added++:i.reactions[o.status]++,o.status==="several"&&i.reactions.review.push(`${s.name}: ${o.candidates.map(l=>l.bigg).join(" / ")}`))}return!i.entities.added&&!i.reactions.added||mt(s=>Je(s,{entities:s.biology.entities.map(o=>{const l=e.entities[o.id];if((l==null?void 0:l.status)!=="one")return o;const r=[o.identity.note,`BiGG ${l.bigg} added from the BiGG tables (same identifiers)`].filter(Boolean).join(" · ");return{...o,identifiers:Gg(o.identifiers,{...l.identifiers,"bigg.metabolite":[l.bigg]}),identity:{...o.identity,note:r}}}),reactions:s.biology.reactions.map(o=>{const l=e.reactions[o.id];if((l==null?void 0:l.status)!=="one")return o;const r=[o.identity.note,`BiGG ${l.bigg} added from the BiGG tables (participants${o.ec.length?" + EC":""})`].filter(Boolean).join(" · ");return{...o,identifiers:Gg(o.identifiers,{...l.identifiers,"bigg.reaction":[l.bigg]}),ec:o.ec.length?o.ec:l.ec??[],identity:{...o.identity,note:r}}})})),i},demoteIdentities(){mt(e=>Je(e,{entities:e.biology.entities.map(t=>t.identity.status==="confirmed"?{...t,identity:{...t.identity,status:"suggested",source:"imported"}}:t),reactions:e.biology.reactions.map(t=>t.identity.status==="confirmed"?{...t,identity:{...t.identity,status:"suggested",source:"imported"}}:t)}))}},Vl=14;function v_(e){const t=R.getState().doc,i=new Set;for(const a of e){const[s,o]=Oe(a);if(s==="node")i.add(o);else if(s==="reaction"){const l=t.reactions[o];l==null||l.sources.concat(l.targets).forEach(r=>i.add(r))}}return[...i].filter(a=>t.nodes[a]&&!t.nodes[a].locked)}function Ag(e){const t=R.getState().doc,i=v_(e).map(r=>t.nodes[r]);for(const r of e){const[c,d]=Oe(r);c==="text"&&t.texts[d]&&!t.texts[d].locked&&i.push(t.texts[d])}if(i.length<2)return null;const a=Math.min(...i.map(r=>r.x))-Vl,s=Math.min(...i.map(r=>r.y))-Vl,o=Math.max(...i.map(r=>r.x))+Vl,l=Math.max(...i.map(r=>r.y))+Vl;return{x:a,y:s,w:o-a,h:l-s}}function L5(){const e=R(c=>c.doc),t=R(c=>c.datasets),i=R(c=>c.mappings),a=R(c=>c.view),s=R(c=>c.conditions),o=R(c=>c.style),l=Ot[o.preset];return{ev:E.useMemo(()=>j0(e,t,i,a,s,o,l),[e,t,i,a,s,o,l]),theme:l}}function j_(){const e=E.useRef(null),t=E.useRef(null),i=R(Y=>Y.doc),a=R(Y=>Y.model),s=R(Y=>Y.datasets),o=R(Y=>Y.conditions),l=R(Y=>Y.view),r=R(Y=>Y.style),c=R(Y=>Y.camera),d=R(Y=>Y.canvas),f=R(Y=>Y.tool),u=R(Y=>Y.selection),p=R(Y=>Y.animation.particles),m=R(Y=>Y.placing),{ev:h,theme:g}=L5(),[y,b]=E.useState(null);E.useEffect(()=>b(null),[m]);const _=E.useMemo(()=>m?j0(m.preview,[],[],l,[],r,g):null,[m,l,r,g]),x=E.useMemo(()=>m?wa(m.preview):null,[m]),v=E.useMemo(()=>new Set,[]),j=E.useMemo(()=>new Set(u),[u]),[N,C]=E.useState(null),w=E.useMemo(()=>f==="select"&&(!N||N.mode==="scale")?Ag(u):null,[u,i,f,N==null?void 0:N.mode]),[k,P]=E.useState({}),[H,G]=E.useState(null),M=E.useRef(null),[A,X]=E.useState(null),I=E.useRef(!1),[K,L]=E.useState(!1),[D,F]=E.useState(null),U=E.useRef(void 0),z=E.useRef(null),O=E.useRef(!1),Z=()=>{window.clearTimeout(U.current),U.current=void 0,z.current=null,F(null)},oe=E.useRef(null);oe.current=N,E.useEffect(()=>{const Y=e.current;let ae=!0;const $=new ResizeObserver(()=>{R.setState({viewport:{w:Y.clientWidth,h:Y.clientHeight}}),ae&&(ae=!1,V().fitAll())});return $.observe(Y),()=>$.disconnect()},[]),E.useEffect(()=>{const Y=t.current,ae=ne=>{ne.preventDefault();const Re=Y.getBoundingClientRect(),ue={x:ne.clientX-Re.left,y:ne.clientY-Re.top};if(!ne.ctrlKey&&(Math.abs(ne.deltaX)>.5||ne.deltaMode===0&&Math.abs(ne.deltaY)<50&&!Number.isInteger(ne.deltaY))||ne.shiftKey){const re=R.getState().camera;V().setCamera({x:re.x-(ne.shiftKey?ne.deltaY:ne.deltaX),y:re.y-(ne.shiftKey?0:ne.deltaY)})}else V().zoomBy(Math.exp(-ne.deltaY*(ne.ctrlKey?.01:.0015)),ue)};Y.addEventListener("wheel",ae,{passive:!1});const $=ne=>ne.target instanceof Element&&!!ne.target.closest("input,textarea,select,[contenteditable]"),T=ne=>{ne.code==="Space"&&!$(ne)&&(ne.preventDefault(),I.current||(I.current=!0,L(!0)))},Q=ne=>{ne.code==="Space"&&($(ne)||ne.preventDefault(),I.current=!1,L(!1))};return window.addEventListener("keydown",T),window.addEventListener("keyup",Q),()=>{Y.removeEventListener("wheel",ae),window.removeEventListener("keydown",T),window.removeEventListener("keyup",Q)}},[]);const he=(Y,ae)=>{const $=t.current.getBoundingClientRect(),T=R.getState().camera;return{x:(Y-$.left-T.x)/T.k,y:(ae-$.top-T.y)/T.k}},J=Y=>d.snap?Math.round(Y/d.gridSize)*d.gridSize:Y,Pe=Y=>{const $=R.getState().doc,T={},Q=new Set;for(const ne of Y){const[Re,ue]=Oe(ne);if(Re==="node")Q.add(ue);else if(Re==="group"&&$.groups[ue]){const le=$.groups[ue];ru(le,$.nodes).forEach(re=>Q.add(re)),le.box&&(T[ne]={x:le.box.x,y:le.box.y})}else if(Re==="reaction"){const le=$.reactions[ue];le==null||le.sources.concat(le.targets).forEach(re=>Q.add(re))}else Re==="text"&&$.texts[ue]?T[ne]={x:$.texts[ue].x,y:$.texts[ue].y}:Re==="legend"&&(T[ne]=Kr($))}for(const ne of Q)$.nodes[ne]&&!$.nodes[ne].locked&&(T[Ne("node",ne)]={x:$.nodes[ne].x,y:$.nodes[ne].y});for(const ne of Y){const[Re,ue]=Oe(ne);if(Re!=="plot"||!$.plots[ue])continue;const le=$.plots[ue];(le.anchor.kind==="node"?[le.anchor.id]:$.reactions[le.anchor.id]?[...$.reactions[le.anchor.id].sources,...$.reactions[le.anchor.id].targets]:[]).some(ie=>Q.has(ie))||(T[ne]={x:le.dx,y:le.dy})}return T},ye=Y=>{var ie,xe,we,ce;A&&X(null),R.setState({contextMenu:null});const ae=R.getState(),$=Y.target,T=he(Y.clientX,Y.clientY);if(ae.placing&&!I.current&&f!=="pan"&&Y.button!==1){Y.button===0?V().placeAt(T):Y.button===2&&(O.current=!0,V().cancelPlacing());return}if(Y.button===2){O.current=!1,C({mode:"pan",sx:Y.clientX,sy:Y.clientY,cx:ae.camera.x,cy:ae.camera.y,fromRight:!0,moved:!1});return}if(Y.button===1||I.current||f==="pan"){C({mode:"pan",sx:Y.clientX,sy:Y.clientY,cx:ae.camera.x,cy:ae.camera.y});return}const Q=(ie=$.closest("[data-resize]"))==null?void 0:ie.getAttribute("data-resize");if(Q){const[pe,ve]=Q.split(":");if(pe.startsWith("group/")){const ge=pe.slice(6),He=ae.doc.groups[ge],Ze=He&&W1(He,ae.doc.nodes);if(Ze){V().beginGesture(),He.box||V().live(ot=>({...ot,groups:{...ot.groups,[ge]:{...ot.groups[ge],box:Ze}}})),C({mode:"gresize",id:ge,dir:ve,start:Ze,startWorld:T});return}}if(pe==="sel"){const ge=Ag(ae.selection);if(ge){const He={x:ve.includes("e")?ge.x+ge.w:ge.x,y:ve.includes("s")?ge.y+ge.h:ge.y},Ze={x:ve.includes("e")?ge.x:ge.x+ge.w,y:ve.includes("s")?ge.y:ge.y+ge.h},ot={},Mt=new Set(v_(ae.selection));for(const Vt of Mt)ot[Ne("node",Vt)]={x:ae.doc.nodes[Vt].x,y:ae.doc.nodes[Vt].y};for(const Vt of ae.selection){const[Zc,xl]=Oe(Vt);Zc==="text"&&ae.doc.texts[xl]&&!ae.doc.texts[xl].locked&&(ot[Vt]={x:ae.doc.texts[xl].x,y:ae.doc.texts[xl].y})}const Rt={};for(const Vt of Object.values(ae.doc.reactions))[...Vt.sources,...Vt.targets].every(Zc=>Mt.has(Zc))&&(Vt.bend||Vt.labelOffset)&&(Rt[Vt.id]={bend:Vt.bend,off:Vt.labelOffset});V().beginGesture(),C({mode:"scale",anchor:Ze,corner:He,start:ot,bends:Rt});return}}if(pe==="legend"){const ge=Kr(ae.doc),He=Number(((xe=$.closest("[data-legend-h]"))==null?void 0:xe.getAttribute("data-legend-h"))??100);V().beginGesture(),C({mode:"resize",id:"legend",dir:ve,start:{dx:ge.x,dy:ge.y,w:ae.doc.legend.scale??1,h:He},startWorld:T});return}const Be=ae.doc.plots[pe];if(Be){V().beginGesture(),C({mode:"resize",id:pe,dir:ve,start:{dx:Be.dx,dy:Be.dy,w:Be.w,h:Be.h},startWorld:T});return}}let ne=(we=$.closest("[data-handle]"))==null?void 0:we.getAttribute("data-handle");const Re=$.closest("[data-sel]");let ue=(Re==null?void 0:Re.getAttribute("data-sel"))??null;const le=(ce=$.closest("[data-bend]"))==null?void 0:ce.getAttribute("data-bend"),re=ue&&V().isLocked(ue)?ue:ne&&V().isLocked(Ne("node",ne))?Ne("node",ne):null;if(re){ue=null,ne=null;const pe=e.current.getBoundingClientRect();z.current={x:Y.clientX,y:Y.clientY},F({x:Y.clientX-pe.left,y:Y.clientY-pe.top}),window.clearTimeout(U.current),window.addEventListener("pointerup",Z,{once:!0}),U.current=window.setTimeout(()=>{U.current=void 0,F(null),C(null),V().unlock(re)},3e3)}if(le){const pe=ae.doc.reactions[le];V().beginGesture(),C({mode:"bend",rid:le,startBend:pe.bend??0,startWorld:T});return}if(ne&&(f==="select"||f==="reaction")){C({mode:"connect",from:ne,cur:T});return}if(f==="reaction"&&(ue!=null&&ue.startsWith("node:"))){C({mode:"connect",from:Oe(ue)[1],cur:T});return}if(!ue&&(f==="metabolite"||f==="slot")){ae.design?fe.addMetaboliteAt({x:J(T.x),y:J(T.y)}):f==="metabolite"&&ae.model?R.setState({dialog:{kind:"metabolite",at:{x:J(T.x),y:J(T.y)}}}):V().addNode(T,{label:`M${Object.keys(ae.doc.nodes).length+1}`}),Y.shiftKey||R.setState({tool:"select"});return}if(!ue&&f==="text"){V().addText(T);return}if(ue){let pe=null,ve=ae.selection;if(Y.shiftKey||Y.metaKey||Y.ctrlKey){if(V().toggleSelect(ue),ve=R.getState().selection,!ve.includes(ue))return}else ve.includes(ue)?ve.length>1&&(pe=ue):(V().select([ue]),ve=[ue]);C({mode:"drag",startWorld:T,start:Pe(ve),primary:ue,moved:!1,deferSelect:pe});return}Y.shiftKey||V().clearSelection(),C({mode:"box",start:T,cur:T,additive:Y.shiftKey})};E.useEffect(()=>{if(!N)return;const Y=$=>{var ne,Re,ue;const T=oe.current;if(!T)return;const Q=he($.clientX,$.clientY);if(z.current&&Math.hypot($.clientX-z.current.x,$.clientY-z.current.y)>5&&Z(),T.mode==="pan"){if(T.fromRight&&!T.moved){if(Math.hypot($.clientX-T.sx,$.clientY-T.sy)<4)return;T.moved=!0}V().setCamera({x:T.cx+$.clientX-T.sx,y:T.cy+$.clientY-T.sy})}else if(T.mode==="gresize"){const le=Q.x-T.startWorld.x,re=Q.y-T.startWorld.y,ie=T.start;let{x:xe,y:we,w:ce,h:pe}=ie;const ve=60;if(T.dir.includes("e")&&(ce=Math.max(ve,ie.w+le)),T.dir.includes("w")&&(ce=Math.max(ve,ie.w-le),xe=ie.x+ie.w-ce),T.dir.includes("s")&&(pe=Math.max(ve,ie.h+re)),T.dir.includes("n")&&(pe=Math.max(ve,ie.h-re),we=ie.y+ie.h-pe),$.shiftKey&&T.dir.length===2){const ge=Math.max(ce/ie.w,pe/ie.h),He=ie.w*ge,Ze=ie.h*ge;T.dir.includes("w")&&(xe=ie.x+ie.w-He),T.dir.includes("n")&&(we=ie.y+ie.h-Ze),ce=He,pe=Ze}const Be=ge=>Math.round(ge);V().live(ge=>({...ge,groups:{...ge.groups,[T.id]:{...ge.groups[T.id],box:{x:Be(xe),y:Be(we),w:Be(ce),h:Be(pe)}}}}))}else if(T.mode==="scale"){const le=T.corner.x-T.anchor.x,re=T.corner.y-T.anchor.y,ie=Math.max(.05,((Q.x-T.anchor.x)*le+(Q.y-T.anchor.y)*re)/(le*le+re*re||1)),xe=T.anchor;V().live(we=>{const ce={...we.nodes},pe={...we.texts},ve={...we.reactions};for(const[Be,ge]of Object.entries(T.start)){const[He,Ze]=Oe(Be),ot={x:Math.round(xe.x+(ge.x-xe.x)*ie),y:Math.round(xe.y+(ge.y-xe.y)*ie)};He==="node"&&ce[Ze]?ce[Ze]={...ce[Ze],...ot}:He==="text"&&pe[Ze]&&(pe[Ze]={...pe[Ze],...ot})}for(const[Be,ge]of Object.entries(T.bends))ve[Be]&&(ve[Be]={...ve[Be],...ge.bend?{bend:Math.round(ge.bend*ie)}:{},...ge.off?{labelOffset:{x:ge.off.x*ie,y:ge.off.y*ie}}:{}});return{...we,nodes:ce,texts:pe,reactions:ve}})}else if(T.mode==="resize"&&T.id==="legend"){const le=Q.x-T.startWorld.x,re=Q.y-T.startWorld.y,{dx:ie,dy:xe,w:we,h:ce}=T.start,pe=_5,ve=ce+16,Be=(T.dir.includes("e")?le:-le)/(pe*we),ge=(T.dir.includes("s")?re:-re)/(ve*we),He=Math.min(4,Math.max(.4,we*(1+(Math.abs(Be)>Math.abs(ge)?Be:ge)))),Ze=T.dir.includes("w")?ie+(pe-8)*we-(pe-8)*He:ie,ot=T.dir.includes("n")?xe+ce*we-ce*He:xe;V().live(Mt=>({...Mt,legend:{...Mt.legend,x:Math.round(Ze),y:Math.round(ot),auto:!1,scale:Math.round(He*100)/100}}))}else if(T.mode==="resize"){const le=Q.x-T.startWorld.x,re=Q.y-T.startWorld.y,ie=T.start;let{dx:xe,dy:we,w:ce,h:pe}=ie;const ve=50,Be=36;if(T.dir.includes("e")&&(ce=Math.max(ve,ie.w+le)),T.dir.includes("w")&&(ce=Math.max(ve,ie.w-le),xe=ie.dx+ie.w-ce),T.dir.includes("s")&&(pe=Math.max(Be,ie.h+re)),T.dir.includes("n")&&(pe=Math.max(Be,ie.h-re),we=ie.dy+ie.h-pe),$.shiftKey&&T.dir.length===2){const He=Math.max(ce/ie.w,pe/ie.h),Ze=ie.w*He,ot=ie.h*He;T.dir.includes("w")&&(xe=ie.dx+ie.w-Ze),T.dir.includes("n")&&(we=ie.dy+ie.h-ot),ce=Ze,pe=ot}const ge=He=>Math.round(He);V().live(He=>({...He,plots:{...He.plots,[T.id]:{...He.plots[T.id],dx:ge(xe),dy:ge(we),w:ge(ce),h:ge(pe)}}}))}else if(T.mode==="box"||T.mode==="connect")C({...T,cur:Q});else if(T.mode==="bend"){const le=R.getState(),re=le.doc.reactions[T.rid],ie=le.doc.nodes[re.sources[0]],xe=le.doc.nodes[re.targets[0]];if(!ie||!xe)return;const we=Math.hypot(xe.x-ie.x,xe.y-ie.y)||1,ce={x:-(xe.y-ie.y)/we,y:(xe.x-ie.x)/we},pe={x:(ie.x+xe.x)/2,y:(ie.y+xe.y)/2},ve=Math.round(((Q.x-pe.x)*ce.x+(Q.y-pe.y)*ce.y)*(re.labelFlip?-1:1));V().live(Be=>({...Be,reactions:{...Be.reactions,[T.rid]:{...Be.reactions[T.rid],bend:ve,routing:Math.abs(ve)>2?"curved":"straight"}}}))}else if(T.mode==="drag"){let le=Q.x-T.startWorld.x,re=Q.y-T.startWorld.y;if(!T.moved){if(Math.hypot(le,re)*R.getState().camera.k<3)return;V().beginGesture(),T.moved=!0}if($.shiftKey){const pe=Math.round(Math.atan2(re,le)/(Math.PI/4))*(Math.PI/4),ve=le*Math.cos(pe)+re*Math.sin(pe);le=ve*Math.cos(pe),re=ve*Math.sin(pe)}const ie=T.primary&&T.start[T.primary]?T.start[T.primary]:Object.values(T.start)[0],xe={};if(ie){const pe=ie.x+le,ve=ie.y+re;let Be=J(pe),ge=J(ve);if(d.smartGuides&&!$.altKey&&((ne=T.primary)!=null&&ne.startsWith("node:"))){const Ze=6/R.getState().camera.k;let ot=Ze,Mt=Ze;for(const Rt of Object.values(R.getState().doc.nodes))T.start[Ne("node",Rt.id)]||(Math.abs(Rt.x-pe)<ot&&(ot=Math.abs(Rt.x-pe),Be=Rt.x,xe.x=Rt.x),Math.abs(Rt.y-ve)<Mt&&(Mt=Math.abs(Rt.y-ve),ge=Rt.y,xe.y=Rt.y))}$.shiftKey||(le=Be-ie.x,re=ge-ie.y)}P(xe),V().moveFrom(T.start,le,re);const we=Object.keys(T.start);let ce=null;if(we.length===1&&we[0].startsWith("node:")&&ie){const pe=R.getState(),ve=Oe(we[0])[1],Be=(Re=pe.doc.nodes[ve])==null?void 0:Re.metaboliteId;if(Be){const ge=ie.x+le,He=ie.y+re;let ot=Math.max(14,18/pe.camera.k);for(const Mt of Object.values(pe.doc.nodes)){if(Mt.id===ve||Mt.metaboliteId!==Be)continue;const Rt=Math.hypot(Mt.x-ge,Mt.y-He);Rt<ot&&(ot=Rt,ce={from:ve,into:Mt.id,x:Mt.x,y:Mt.y})}}}(ce==null?void 0:ce.into)!==((ue=M.current)==null?void 0:ue.into)&&(M.current=ce,G(ce))}},ae=$=>{var ne,Re;const T=oe.current;if(Z(),C(null),P({}),!T)return;T.mode==="pan"&&T.fromRight&&T.moved&&(O.current=!0);const Q=R.getState();if(T.mode==="box"){const ue=Math.min(T.start.x,T.cur.x),le=Math.max(T.start.x,T.cur.x),re=Math.min(T.start.y,T.cur.y),ie=Math.max(T.start.y,T.cur.y);if((le-ue)*Q.camera.k<3&&(ie-re)*Q.camera.k<3)return;const xe=ce=>ce.x>=ue&&ce.x<=le&&ce.y>=re&&ce.y<=ie,we=[];for(const ce of Object.values(Q.doc.nodes))!ce.locked&&xe(ce)&&we.push(Ne("node",ce.id));for(const ce of Object.values(Q.doc.reactions))!ce.locked&&[...ce.sources,...ce.targets].every(pe=>Q.doc.nodes[pe]&&xe(Q.doc.nodes[pe]))&&we.push(Ne("reaction",ce.id));for(const ce of Object.values(Q.doc.texts))!ce.locked&&xe(ce)&&we.push(Ne("text",ce.id));for(const ce of Object.values(Q.doc.plots)){const pe=Ta(Q.doc,ce.anchor);!ce.locked&&pe&&xe({x:pe.x+ce.dx+ce.w/2,y:pe.y+ce.dy+ce.h/2})&&we.push(Ne("plot",ce.id))}V().select(we,T.additive)}else if(T.mode==="gresize"||T.mode==="scale")V().syncGroupMembers();else if(T.mode==="drag"){T.moved&&V().syncGroupMembers(),!T.moved&&T.deferSelect&&V().select([T.deferSelect]);const ue=M.current;M.current=null,G(null),ue&&V().mergeNodes(ue.from,ue.into)}else if(T.mode==="connect"){const ue=document.elementFromPoint($.clientX,$.clientY),le=((ne=ue==null?void 0:ue.closest('[data-sel^="node:"]'))==null?void 0:ne.getAttribute("data-sel"))??((Re=ue==null?void 0:ue.closest("[data-handle]"))==null?void 0:Re.getAttribute("data-handle")),re=le?le.startsWith("node:")?Oe(le)[1]:le:null,ie=Q.doc.nodes[T.from];if(re&&re!==T.from){const xe=Q.doc.nodes[re];Q.model&&(ie!=null&&ie.metaboliteId)&&(xe!=null&&xe.metaboliteId)?V().requestConnection(T.from,re):V().addReaction([T.from],[re],{},!1)}else if(!re&&ie&&Math.hypot(T.cur.x-ie.x,T.cur.y-ie.y)>20){const xe={x:J(T.cur.x),y:J(T.cur.y)},we=V().addNode(xe,{label:`M${Object.keys(Q.doc.nodes).length+1}`});V().addReaction([T.from],[we],{},!1),R.setState({selection:[Ne("node",we)]})}}};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",ae),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",ae)}},[N==null?void 0:N.mode]);const _e=Y=>{var ue,le,re,ie,xe;const ae=(ue=Y.target.closest("[data-sel]"))==null?void 0:ue.getAttribute("data-sel"),$=ae&&!V().isLocked(ae)?ae:null,T=he(Y.clientX,Y.clientY),Q=R.getState();if(Q.design){const[we,ce]=$?Oe($):[null,""];if(!$){fe.addMetaboliteAt({x:J(T.x),y:J(T.y)});return}if(we==="node"&&((re=(le=Q.doc.nodes[ce])==null?void 0:le.design)==null?void 0:re.kind)==="metabolite"){R.setState({selection:[$],dialog:{kind:"identity",nodeId:ce}});return}if(we==="node"){R.setState({selection:[$]});return}if(we==="reaction"&&((xe=(ie=Q.doc.reactions[ce])==null?void 0:ie.design)==null?void 0:xe.kind)==="reaction"){R.setState({selection:[$],dialog:{kind:"identity",reactionId:Q.doc.reactions[ce].design.id}});return}}if(!$){Q.model?R.setState({dialog:{kind:"metabolite",at:{x:J(T.x),y:J(T.y)}}}):V().addNode(T,{label:`M${Object.keys(Q.doc.nodes).length+1}`});return}const[ne,Re]=Oe($);ne==="node"?Q.model?R.setState({dialog:{kind:"metabolite",at:T,bindNodeId:Re}}):X({id:$,value:Q.doc.nodes[Re].label??""}):ne==="text"?X({id:$,value:Q.doc.texts[Re].text}):ne==="reaction"?X({id:$,value:Q.doc.reactions[Re].label??Q.doc.reactions[Re].reactionId??""}):ne==="group"&&X({id:$,value:Q.doc.groups[Re].title})},Ke=()=>{if(!A)return;const[Y,ae]=Oe(A.id),$=A.value;Y==="node"?V().updateNode(ae,{label:$||void 0}):Y==="text"?V().updateText(ae,{text:$||"Text"}):Y==="reaction"?V().updateReaction(ae,{label:$||void 0}):Y==="group"&&V().updateGroup(ae,{title:$}),X(null)},Mn=Y=>{var Q;if(Y.preventDefault(),O.current){O.current=!1;return}const ae=((Q=Y.target.closest("[data-sel]"))==null?void 0:Q.getAttribute("data-sel"))??null,$=R.getState();ae&&!$.selection.includes(ae)&&!V().isLocked(ae)&&V().select([ae]);const T=e.current.getBoundingClientRect();R.setState({contextMenu:{x:Y.clientX-T.left,y:Y.clientY-T.top,target:ae,world:he(Y.clientX,Y.clientY)}})},Ct=d.gridSize*c.k,Un=d.showGrid&&Ct>=4,sn=(N==null?void 0:N.mode)==="connect"?N:null,di=sn?i.nodes[sn.from]:null,qt=(N==null?void 0:N.mode)==="box"?N:null,kt=u.length===1&&u[0].startsWith("reaction:")?i.reactions[Oe(u[0])[1]]:null;let En=null;if(kt&&kt.sources.length===1&&kt.targets.length===1&&kt.routing!=="orthogonal"){const Y=i.nodes[kt.sources[0]],ae=i.nodes[kt.targets[0]];if(Y&&ae){const $=Math.hypot(ae.x-Y.x,ae.y-Y.y)||1,T=kt.labelFlip?-1:1,Q={x:-(ae.y-Y.y)/$*T,y:(ae.x-Y.x)/$*T},ne=kt.routing==="curved"?kt.bend??$*.15:kt.bend??0;En={x:(Y.x+ae.x)/2+Q.x*ne,y:(Y.y+ae.y)/2+Q.y*ne}}}const mi=(()=>{if(!A)return null;const[Y,ae]=Oe(A.id);let $=null;if(Y==="node")$=i.nodes[ae];else if(Y==="text")$={x:i.texts[ae].x,y:i.texts[ae].y-i.texts[ae].size};else if(Y==="reaction")$=Ta(i,{kind:"reaction",id:ae});else if(Y==="group"){const T=i.groups[ae].nodeIds.map(Q=>i.nodes[Q]).filter(Boolean);$={x:Math.min(...T.map(Q=>Q.x))-20,y:Math.min(...T.map(Q=>Q.y))-40}}return $?{left:$.x*c.k+c.x,top:$.y*c.k+c.y}:null})(),ya=(N==null?void 0:N.mode)==="pan"&&(!N.fromRight||N.moved)?"grabbing":f==="pan"||K?"grab":m?"copy":f==="select"?"default":f==="text"?"text":"crosshair",me=m&&x?(()=>{var ae,$;const Y=y??{x:(((ae=t.current)==null?void 0:ae.clientWidth)??800)/2/c.k-c.x/c.k,y:((($=t.current)==null?void 0:$.clientHeight)??600)/2/c.k-c.y/c.k};return{x:Y.x-(x.x+x.w/2),y:Y.y-(x.y+x.h/2)}})():null;return n.jsxs("div",{className:"canvas",ref:e,style:{background:g.background==="#ffffff"?"#f7f7f8":"#0b0d10"},children:[n.jsxs("svg",{ref:t,className:`canvas-svg tool-${f}`,style:{cursor:ya},onPointerDown:ye,onDoubleClick:_e,onContextMenu:Mn,onPointerMove:m?Y=>b(he(Y.clientX,Y.clientY)):void 0,children:[n.jsxs("defs",{children:[n.jsx("pattern",{id:"gridDots",width:Ct,height:Ct,patternUnits:"userSpaceOnUse",patternTransform:`translate(${c.x},${c.y})`,children:n.jsx("circle",{cx:.75,cy:.75,r:.75,fill:g.background==="#ffffff"?"#c9ccd3":"#2b3038"})}),n.jsx("pattern",{id:"gridMajor",width:Ct*5,height:Ct*5,patternUnits:"userSpaceOnUse",patternTransform:`translate(${c.x},${c.y})`,children:n.jsx("circle",{cx:1,cy:1,r:1.1,fill:g.background==="#ffffff"?"#aeb2bb":"#3b414b"})})]}),Un&&n.jsx("rect",{className:"ui-only",width:"100%",height:"100%",fill:"url(#gridDots)"}),Un&&n.jsx("rect",{className:"ui-only",width:"100%",height:"100%",fill:"url(#gridMajor)"}),n.jsxs("g",{transform:`translate(${c.x},${c.y}) scale(${c.k})`,children:[n.jsx("g",{id:"scene-root",children:n.jsx(Iu,{doc:i,model:a,datasets:s,conditions:o,view:l,style:r,theme:g,ev:h,selected:j,particles:p,interactive:!0})}),w&&n.jsxs("g",{className:"ui-only",children:[n.jsx("rect",{x:w.x,y:w.y,width:w.w,height:w.h,fill:"none",stroke:"#4f5bd5",strokeWidth:1/c.k,strokeDasharray:`${4/c.k} ${3/c.k}`,pointerEvents:"none"}),[["nw",0,0,"nwse-resize"],["ne",1,0,"nesw-resize"],["se",1,1,"nwse-resize"],["sw",0,1,"nesw-resize"]].map(([Y,ae,$,T])=>n.jsx("rect",{"data-resize":`sel:${Y}`,x:w.x+ae*w.w-5/c.k,y:w.y+$*w.h-5/c.k,width:10/c.k,height:10/c.k,rx:2/c.k,fill:"#fff",stroke:"#4f5bd5",strokeWidth:1.4/c.k,style:{cursor:T},children:n.jsx("title",{children:"Drag to resize the selection (proportions kept)"})},Y))]}),k.x!=null&&n.jsx("line",{x1:k.x,x2:k.x,y1:-1e5,y2:1e5,stroke:"#e8505b",strokeWidth:.8/c.k,strokeDasharray:`${4/c.k} ${3/c.k}`}),k.y!=null&&n.jsx("line",{y1:k.y,y2:k.y,x1:-1e5,x2:1e5,stroke:"#e8505b",strokeWidth:.8/c.k,strokeDasharray:`${4/c.k} ${3/c.k}`}),H&&n.jsxs("g",{pointerEvents:"none",children:[n.jsx("circle",{cx:H.x,cy:H.y,r:22/Math.sqrt(c.k),fill:"rgba(46,160,90,0.12)",stroke:"#2ea05a",strokeWidth:2/c.k,strokeDasharray:`${4/c.k} ${2/c.k}`}),n.jsx("text",{x:H.x,y:H.y-26/Math.sqrt(c.k),textAnchor:"middle",fontSize:11/c.k,fontWeight:600,fill:"#2ea05a",children:"release to merge"})]}),di&&sn&&n.jsx("line",{x1:di.x,y1:di.y,x2:sn.cur.x,y2:sn.cur.y,stroke:"#4f5bd5",strokeWidth:1.5/c.k,strokeDasharray:`${5/c.k} ${3/c.k}`,pointerEvents:"none"}),qt&&n.jsx("rect",{x:Math.min(qt.start.x,qt.cur.x),y:Math.min(qt.start.y,qt.cur.y),width:Math.abs(qt.cur.x-qt.start.x),height:Math.abs(qt.cur.y-qt.start.y),fill:"rgba(79,91,213,0.08)",stroke:"#4f5bd5",strokeWidth:1/c.k,pointerEvents:"none"}),En&&n.jsx("circle",{"data-bend":kt.id,cx:En.x,cy:En.y,r:4.5/c.k,fill:"#fff",stroke:"#4f5bd5",strokeWidth:1.5/c.k,style:{cursor:"move"}}),m&&me&&_&&x&&n.jsxs("g",{className:"ui-only place-ghost",pointerEvents:"none",transform:`translate(${me.x},${me.y})`,children:[n.jsx("rect",{x:x.x-12,y:x.y-12,width:x.w+24,height:x.h+24,rx:10/c.k,fill:"rgba(79,91,213,0.04)",stroke:"#4f5bd5",strokeOpacity:.6,strokeWidth:1.2/c.k,strokeDasharray:`${6/c.k} ${4/c.k}`}),n.jsx("g",{opacity:.42,children:n.jsx(Iu,{doc:m.preview,model:a,datasets:[],conditions:[],view:l,style:r,theme:g,ev:_,selected:v,particles:!1,interactive:!1})})]})]})]}),m&&n.jsxs("div",{className:"place-hint",children:["Placing ",n.jsx("b",{children:m.name})," — click where it goes · ",n.jsx("kbd",{children:"Esc"})," or right-click to cancel · ",n.jsx("kbd",{children:"Space"}),"+drag to pan"]}),A&&mi&&n.jsx("input",{className:"inline-edit",autoFocus:!0,value:A.value,style:mi,onChange:Y=>X({...A,value:Y.target.value}),onKeyDown:Y=>{Y.key==="Enter"&&Ke(),Y.key==="Escape"&&X(null),Y.stopPropagation()},onBlur:Ke}),D&&n.jsxs("div",{className:"hold-ring",style:{left:D.x,top:D.y},title:"Keep holding to unlock",children:[n.jsxs("svg",{width:"2.125rem",height:"2.125rem",viewBox:"0 0 34 34",children:[n.jsx("circle",{cx:"17",cy:"17",r:"14",className:"hold-track"}),n.jsx("circle",{cx:"17",cy:"17",r:"14",className:"hold-progress"})]}),n.jsx("span",{children:"unlock"})]}),!N&&n.jsx(f5,{}),n.jsx(j5,{}),Object.keys(i.nodes).length===0&&n.jsx(T5,{})]})}function T5(){return n.jsxs("div",{className:"empty-hint",children:[n.jsx("div",{className:"empty-title",children:"Start a pathway figure"}),n.jsxs("div",{className:"empty-row",children:[n.jsx("kbd",{children:"double-click"})," add a metabolite · ",n.jsx("kbd",{children:"M"})," metabolite tool · ",n.jsx("kbd",{children:"S"})," empty slot"]}),n.jsx("div",{className:"empty-row",children:"drag from a node's outer ring to draw a reaction · drop on empty space to extend the chain"}),n.jsxs("div",{className:"empty-row",children:["or insert a ",n.jsx("b",{children:"template"})," from the left panel · ",n.jsx("kbd",{children:"Ctrl K"})," for everything"]}),n.jsx("button",{className:"btn primary",onClick:()=>ra(()=>Promise.resolve().then(()=>I0),void 0).then(e=>V().loadProject(e.demoProject())),children:"Open the central carbon demo"})]})}const Dg=new WeakMap;function F5(e){let t=Dg.get(e);if(t)return t;const i=[...Object.values(e.metabolites).map(a=>({kind:"metabolite",id:a.id,name:a.name,detail:`${a.formula??""} · ${e.compartments[a.compartment]??a.compartment}`})),...Object.values(e.reactions).map(a=>{var s;return{kind:"reaction",id:a.id,name:a.name,detail:[a.subsystem,(s=a.ec)==null?void 0:s.join(","),a.genes.slice(0,4).join(" ")].filter(Boolean).join(" · ")}}),...Object.values(e.genes).map(a=>({kind:"gene",id:a.id,name:a.name??a.id,detail:"gene"}))];return t=new Hc(i,{keys:[{name:"id",weight:3},{name:"name",weight:2},{name:"detail",weight:.6}],threshold:.34,ignoreLocation:!0,includeScore:!0}),Dg.set(e,t),t}function Yc(e,t,i,a=30){if(!e||!t.trim())return[];const s=[],o=t.trim().toLowerCase();for(const r of Object.values(e.metabolites))(!i||i.includes("metabolite"))&&(r.id.toLowerCase()===o||bt(r.id).toLowerCase()===o)&&s.push({kind:"metabolite",id:r.id,name:r.name,detail:e.compartments[r.compartment]??r.compartment});if(!i||i.includes("reaction")){const r=Object.values(e.reactions).find(c=>c.id.toLowerCase()===o);r&&s.push({kind:"reaction",id:r.id,name:r.name,detail:r.subsystem??""})}const l=F5(e).search(t,{limit:a*2}).map(r=>r.item).filter(r=>(!i||i.includes(r.kind))&&!s.some(c=>c.id===r.id&&c.kind===r.kind));return[...s,...l].slice(0,a)}function X5(){const e=S.getState(),t=!!e.model,i=s=>()=>B.setSection(s),a=[...["pfba","fba","loopless","fva"].map(s=>({id:"run-"+s,group:"Simulate",label:`Run ${Qt[s].label}`,hint:s===e.method?"header ▶":void 0,run:()=>{S.setState({method:s}),B.simulate(s)}})),{id:"objective",group:"Model",label:"Change objective",run:()=>{B.setSection("simulate"),S.setState({objectiveEditorOpen:!0})}},{id:"medium",group:"Model",label:"Configure medium",run:i("medium")},{id:"find-r",group:"Find",label:"Find reaction",hint:"R then F",run:()=>{B.setTab("reactions"),setTimeout(()=>{var s;return(s=document.getElementById("lab-explorer-search"))==null?void 0:s.focus()},30)}},{id:"find-m",group:"Find",label:"Find metabolite",hint:"M then F",run:()=>{B.setTab("metabolites"),setTimeout(()=>{var s;return(s=document.getElementById("lab-explorer-search"))==null?void 0:s.focus()},30)}},{id:"find-g",group:"Find",label:"Find gene",run:()=>{B.setTab("genes"),setTimeout(()=>{var s;return(s=document.getElementById("lab-explorer-search"))==null?void 0:s.focus()},30)}},{id:"hide-zero",group:"View",label:e.hideZero?"Show zero-flux rows":"Hide zero flux",run:()=>S.setState({hideZero:!e.hideZero,section:"explore"})},{id:"sort-flux",group:"View",label:"Sort reactions by |flux| ↓",run:()=>S.setState(s=>({sort:{...s.sort,reactions:{key:"absFlux",dir:"desc"}},explorerTab:"reactions",section:"explore"}))},{id:"add-sel",group:"Map",label:`Add selection to map (${e.selection.reactions.length||e.selection.metabolites.length})`,run:()=>e.selection.reactions.length?vn(e.selection.reactions):Fs(e.selection.metabolites)},{id:"vis-result",group:"Map",label:"Visualize active result on map",run:()=>{const s=ee.fluxResult();s&&S.setState({dialog:{kind:"visualize-result",resultId:s.id}})}},{id:"compare",group:"Compare",label:"Compare results",run:i("compare")},{id:"dup",group:"State",label:"Duplicate current state",run:()=>B.duplicateState()},{id:"new-state",group:"State",label:"New state from the model file",run:()=>B.newState()},{id:"undo",group:"State",label:"Undo (state change or model edit)",hint:"Ctrl Z",run:()=>B.undo()},{id:"redo",group:"State",label:"Redo (state change or model edit)",hint:"Ctrl Shift Z",run:()=>B.redo()},{id:"revert",group:"State",label:"Revert state to the model file",run:()=>B.resetState()},{id:"new-reaction",group:"Edit model",label:"New reaction…",run:()=>Ya()},{id:"new-metabolite",group:"Edit model",label:"New metabolite (search model and databases)…",run:()=>Ks()},{id:"validate-model",group:"Edit model",label:"Validate model",run:()=>S.setState({dialog:{kind:"validate-model"}})},{id:"export-patch",group:"Edit model",label:"Export model patch (model_patch.json)",run:()=>Xe.exportPatch()},{id:"save-model",group:"File",label:"Save modified model as SBML / JSON / MAT…",run:()=>S.setState({dialog:{kind:"export-model"}})},{id:"import",group:"File",label:"Import model (SBML / JSON / MAT)…",run:y0},{id:"import-results",group:"File",label:"Import results (JSON / CSV / TSV)…",run:Ru},...["overview","explore","medium","simulate","results","compare"].map(s=>({id:"go-"+s,group:"Go to",label:s[0].toUpperCase()+s.slice(1),run:i(s)})),{id:"to-map",group:"Go to",label:"Switch to Map Builder",run:()=>B.setWorkspace("map")},{id:"log",group:"View",label:"Show activity log",run:()=>S.setState({logOpen:!0})},{id:"inspector",group:"View",label:"Toggle inspector",run:()=>S.setState({inspectorOpen:!e.inspectorOpen})},...jx];return t?a:a.filter(s=>["import","to-map"].includes(s.id)||s.id.startsWith("ui-"))}function K5(){const[e,t]=E.useState(""),[i,a]=E.useState(0),s=S(p=>p.searchIndex),o=E.useMemo(X5,[]),l=E.useMemo(()=>new Hc(o,{keys:["label","group"],threshold:.38,ignoreLocation:!0}),[o]),r=()=>R.setState({paletteOpen:!1}),c=E.useMemo(()=>{const p=[],m=e.trim();if(m&&s){const g=s.search(m,void 0,60);for(const[y,b]of[["metabolite","Metabolites"],["reaction","Reactions"],["gene","Genes"]]){const _=g.filter(x=>x.kind===y).slice(0,6).map(x=>({type:"hit",hit:x}));_.length&&p.push({title:b,items:_})}}const h=m?l.search(m,{limit:8}).map(g=>g.item):o.slice(0,10);return h.length&&p.push({title:"Commands",items:h.map(g=>({type:"cmd",cmd:g}))}),p},[e,s,l,o]),d=c.flatMap(p=>p.items),f=(p,m=!1)=>{if(!p)return;if(r(),p.type==="cmd")return p.cmd.run();const{kind:h,id:g}=p.hit;if(m){h==="reaction"?vn([g],"vertical"):h==="metabolite"&&Fs([g],!1);return}S.getState().section==="overview"&&B.setSection("explore"),B.navigate({kind:h,id:g})};let u=-1;return n.jsx("div",{className:"modal-backdrop top",onPointerDown:r,children:n.jsxs("div",{className:"palette lab-palette",onPointerDown:p=>p.stopPropagation(),children:[n.jsx("input",{autoFocus:!0,className:"palette-input",placeholder:"Search metabolites, reactions, genes — or type a command (Run pFBA, medium…)",value:e,onChange:p=>{t(p.target.value),a(0)},onKeyDown:p=>{p.key==="Escape"&&r(),p.key==="ArrowDown"&&(a(m=>Math.min(d.length-1,m+1)),p.preventDefault()),p.key==="ArrowUp"&&(a(m=>Math.max(0,m-1)),p.preventDefault()),p.key==="Enter"&&f(d[i],p.shiftKey)}}),n.jsxs("div",{className:"palette-list",children:[c.map(p=>n.jsxs("div",{children:[n.jsx("div",{className:"pl-group",children:p.title}),p.items.map(m=>{u++;const h=u;if(m.type==="cmd")return n.jsxs("button",{className:`palette-item ${h===i?"active":""}`,onMouseEnter:()=>a(h),onClick:()=>f(m),children:[n.jsx("span",{className:"pi-group",children:m.cmd.group}),n.jsx("span",{className:"pi-label",children:m.cmd.label}),m.cmd.hint&&n.jsx("kbd",{children:m.cmd.hint})]},m.cmd.id);const g=m.hit;return n.jsxs("div",{className:`palette-item hit ${h===i?"active":""}`,onMouseEnter:()=>a(h),onClick:()=>f(m),children:[n.jsx("span",{className:`kind k-${g.kind}`,children:g.kind[0].toUpperCase()}),n.jsx("span",{className:"mono strong",children:g.id}),n.jsxs("span",{className:"pi-label ellipsis",children:[g.name,g.detail?n.jsxs("span",{className:"muted",children:[" · ",g.detail]}):null]}),n.jsxs("span",{className:"pi-actions",children:[g.kind!=="gene"&&n.jsx("button",{className:"btn small",title:"Shift+Enter",onClick:y=>{y.stopPropagation(),f(m,!0)},children:"Add to map"}),g.kind==="reaction"&&n.jsx("button",{className:"btn small",onClick:y=>{y.stopPropagation(),r(),B.setObjectiveReaction(g.id)},children:"Set objective"}),g.kind==="metabolite"&&n.jsx("button",{className:"btn small",onClick:y=>{var b;y.stopPropagation(),r(),B.showInExplorer("reactions",((b=S.getState().index)==null?void 0:b.metRxns.get(g.id))??[],`Connected to ${g.id}`)},children:"Connected reactions"})]})]},g.kind+g.id)})]},p.title)),!d.length&&n.jsx("div",{className:"muted small pad",children:"Nothing found"})]}),n.jsxs("div",{className:"palette-foot muted small",children:[n.jsx("kbd",{children:"↑↓"})," move · ",n.jsx("kbd",{children:"Enter"})," inspect / run · ",n.jsx("kbd",{children:"Shift Enter"})," add to map · ",n.jsx("kbd",{children:"Esc"})," close"]})]})})}function z5(){const e=V(),t=R.getState();return[{id:"add-met",group:"Create",label:"Add metabolite",hint:"M",run:()=>R.setState({tool:"metabolite"})},{id:"add-slot",group:"Create",label:"Add empty slot (template node)",hint:"S",run:()=>R.setState({tool:"slot"})},{id:"add-rxn",group:"Create",label:"Reaction tool",hint:"R",run:()=>R.setState({tool:"reaction"})},{id:"add-text",group:"Create",label:"Add text",hint:"T",run:()=>R.setState({tool:"text"})},{id:"add-plot",group:"Create",label:"Add density plot to selected reactions",hint:"P",run:()=>e.addPlotsForSelection("density")},{id:"add-heat",group:"Create",label:"Add heatmap to selected reactions",run:()=>e.addPlotsForSelection("heatmap")},{id:"add-bar",group:"Create",label:"Add bar chart to selected reactions",run:()=>e.addPlotsForSelection("bar")},{id:"layout-v",group:"Layout",label:"Vertical layout",run:()=>e.layoutSelection("vertical")},{id:"layout-h",group:"Layout",label:"Horizontal layout",run:()=>e.layoutSelection("horizontal")},{id:"layout-c",group:"Layout",label:"Circular layout",run:()=>e.layoutSelection("circle")},{id:"layout-g",group:"Layout",label:"Grid layout",run:()=>e.layoutSelection("grid")},{id:"layout-hi",group:"Layout",label:"Hierarchical layout",run:()=>e.layoutSelection("hierarchical")},{id:"layout-o",group:"Layout",label:"Organic layout",run:()=>e.layoutSelection("organic")},{id:"tidy",group:"Layout",label:"Tidy selection",run:()=>e.tidySelection()},{id:"group",group:"Layout",label:"Group as pathway",hint:"Ctrl G",run:()=>e.groupSelection("pathway")},{id:"compartment",group:"Layout",label:"Group as compartment",run:()=>e.groupSelection("compartment")},{id:"collapse",group:"Layout",label:"Collapse selection into one arrow (hide reactions)",run:()=>e.collapseSelection()},{id:"expand",group:"Layout",label:"Expand selected collapsed arrow",run:()=>e.selectedIds("reaction").forEach(a=>e.expandGlyph(a))},{id:"routes",group:"Model",label:"Find routes for the selected arrow…",run:()=>{const a=t.doc.reactions[e.selectedIds("reaction")[0]];a?R.setState({dialog:{kind:"routes",from:a.sources[0],to:a.targets[0],replaceGlyph:a.id}}):e.toast("Select an arrow first")}},{id:"autobind",group:"Model",label:"Auto-bind template slots to model",run:()=>e.autoBindAll()},{id:"path",group:"Model",label:"Find metabolic path…",run:()=>R.setState({dialog:{kind:"path"}})},{id:"validate",group:"Model",label:"Show model validation",run:()=>R.setState({dialog:{kind:"validation"}})},{id:"import-gem",group:"File",label:"Import GEM (JSON / SBML)…",run:()=>$n("model")},{id:"import-flux",group:"File",label:"Import fluxes / data (CSV, TSV)…",run:()=>$n("data")},{id:"open",group:"File",label:"Open project (.gemsmap)…",run:()=>$n("project")},{id:"save",group:"File",label:"Save project (.gemsmap)",hint:"Ctrl S",run:()=>Bc()},{id:"export",group:"File",label:"Export SVG / PDF / PNG…",hint:"Ctrl E",run:()=>R.setState({dialog:{kind:"export"}})},{id:"demo",group:"File",label:"Open central carbon demo",run:()=>ra(()=>Promise.resolve().then(()=>I0),void 0).then(a=>e.loadProject(a.demoProject()))},{id:"new",group:"File",label:"New empty project",run:()=>e.newProject()},{id:"save-tpl",group:"File",label:"Save selection as template…",run:()=>R.setState({dialog:{kind:"saveTemplate"}})},{id:"grid",group:"View",label:"Toggle grid",run:()=>e.setCanvas({showGrid:!t.canvas.showGrid})},{id:"snap",group:"View",label:"Toggle snap to grid",run:()=>e.setCanvas({snap:!t.canvas.snap})},{id:"fit",group:"View",label:"Fit all",hint:"F",run:()=>e.fitAll()},{id:"particles",group:"View",label:"Toggle flux particles",run:()=>e.setAnimation({particles:!t.animation.particles})},{id:"play",group:"View",label:"Play / pause condition animation",run:()=>e.setAnimation({playing:!t.animation.playing})},...jx,{id:"rxn-ids",group:"Labels",label:"Show reaction IDs",run:()=>e.setStyle({reactionLabel:"id"})},{id:"rxn-names",group:"Labels",label:"Show reaction names",run:()=>e.setStyle({reactionLabel:"name"})},{id:"met-ids",group:"Labels",label:"Show metabolite IDs",run:()=>e.setStyle({metaboliteLabel:"id"})},{id:"met-names",group:"Labels",label:"Show metabolite names",run:()=>e.setStyle({metaboliteLabel:"name"})},{id:"flux-vals",group:"Labels",label:"Toggle flux values",run:()=>e.setStyle({showFluxValues:!t.style.showFluxValues})},{id:"to-lab",group:"Workspace",label:"Switch to COBRAGUI (COBRApy)",run:()=>B.setWorkspace("lab")},{id:"help",group:"Help",label:"Keyboard shortcuts",hint:"?",run:()=>R.setState({dialog:{kind:"help"}})},...t.conditions.map(a=>({id:"cond-"+a.id,group:"Condition",label:`Change condition → ${a.name}`,run:()=>e.setView({activeCondition:a.id})})),...["absolute","difference","foldchange","log2fc"].map(a=>({id:"cmp-"+a,group:"Condition",label:`Compare mode: ${a}`,run:()=>e.setView({compare:a})})),...Object.keys(Ot).map(a=>({id:"style-"+a,group:"Style",label:`Style preset: ${Ot[a].name}`,run:()=>e.setStyle({preset:a})})),...zp.map(a=>({id:"tpl-"+a.id,group:"Template",label:`Insert template: ${a.name}`,run:()=>e.openTemplate(a)})),{id:"tpl-confirm",group:"Template",label:"Confirm all provisional template mappings",run:()=>e.confirmProvisional()},...t.userTemplates.map(a=>({id:"tpl-"+a.id,group:"Template",label:`Insert my template: ${a.name}`,run:()=>e.instantiateTemplate(a)}))]}function U5(){const e=R(i=>i.paletteOpen),t=S(i=>i.workspace);return!e||t==="templates"?null:t==="lab"?n.jsx(K5,{}):n.jsx(q5,{})}function q5(){const[e,t]=E.useState(""),[i,a]=E.useState(0),s=R(u=>u.model),o=R(u=>u.doc),l=E.useMemo(()=>z5(),[]),r=E.useMemo(()=>new Hc(l,{keys:["label","group"],threshold:.4,ignoreLocation:!0}),[l]),c=()=>R.setState({paletteOpen:!1}),d=E.useMemo(()=>{const u=[],p=e.trim()?r.search(e,{limit:12}).map(m=>m.item):l.slice(0,12);if(u.push(...p),e.trim().length>=2){const m=e.trim().toLowerCase().replace(/^find\s+/,"");for(const h of Object.values(o.nodes))if(((h.metaboliteId??"")+" "+(h.label??"")).toLowerCase().includes(m)&&u.push({id:"focus-"+h.id,group:"On canvas",label:`Focus ${h.metaboliteId??h.label}`,run:()=>V().focusNode(h.id)}),u.length>30)break;for(const h of Object.values(o.reactions))((h.reactionId??"")+" "+(h.label??"")).toLowerCase().includes(m)&&u.push({id:"focus-r-"+h.id,group:"On canvas",label:`Focus reaction ${h.reactionId??h.label}`,run:()=>{const g=h.sources[0];V().focusNode(g),R.setState({selection:[Ne("reaction",h.id)]})}});for(const h of Yc(s,m,["metabolite","reaction"],8))u.push(h.kind==="metabolite"?{id:"m-"+h.id,group:"Model · add",label:`Add ${h.id} — ${h.name}`,run:()=>V().addMetaboliteFromModel(h.id)}:{id:"r-"+h.id,group:"Model · add",label:`Add reaction ${h.id} — ${h.name}`,run:()=>V().addModelReaction(h.id)})}return u},[e,r,l,o,s]),f=u=>{u&&(c(),u.run())};return n.jsx("div",{className:"modal-backdrop top",onPointerDown:c,children:n.jsxs("div",{className:"palette",onPointerDown:u=>u.stopPropagation(),children:[n.jsx("input",{autoFocus:!0,className:"palette-input",placeholder:"Type a command, metabolite or reaction…",value:e,onChange:u=>{t(u.target.value),a(0)},onKeyDown:u=>{u.key==="Escape"&&c(),u.key==="ArrowDown"&&(a(p=>Math.min(d.length-1,p+1)),u.preventDefault()),u.key==="ArrowUp"&&(a(p=>Math.max(0,p-1)),u.preventDefault()),u.key==="Enter"&&f(d[i])}}),n.jsxs("div",{className:"palette-list",children:[d.map((u,p)=>n.jsxs("button",{className:`palette-item ${p===i?"active":""}`,onMouseEnter:()=>a(p),onClick:()=>f(u),children:[n.jsx("span",{className:"pi-group",children:u.group}),n.jsx("span",{className:"pi-label",children:u.label}),u.hint&&n.jsx("kbd",{children:u.hint})]},u.id+p)),!d.length&&n.jsx("div",{className:"muted small pad",children:"Nothing found"})]})]})})}function Ge({label:e,onClick:t,hint:i,disabled:a}){return n.jsxs("button",{className:"cm-item",disabled:a,onClick:()=>{R.setState({contextMenu:null}),t()},children:[n.jsx("span",{children:e}),i&&n.jsx("kbd",{children:i})]})}function N_(){var f,u;const e=R(p=>p.contextMenu),t=R(p=>p.doc),i=R(p=>p.model),a=R(p=>p.selection);if(!e)return null;const s=V(),[o,l]=e.target?Oe(e.target):[null,null],r=o==="node"&&l?t.nodes[l]:null,c=o==="reaction"&&l?t.reactions[l]:null,d=!!(r!=null&&r.metaboliteId&&(i!=null&&i.metabolites[r.metaboliteId]));return e.target&&s.isLocked(e.target)?n.jsxs("div",{className:"context-menu",style:{left:e.x,top:e.y},onPointerDown:p=>p.stopPropagation(),children:[n.jsxs("div",{className:"cm-title",children:["Locked ",o]}),n.jsx(Ge,{label:"Unlock",onClick:()=>s.unlock(e.target)}),n.jsx("div",{className:"cm-label",children:"Tip: hold the mouse 3 s on it to unlock"})]}):n.jsxs("div",{className:"context-menu",style:{left:e.x,top:e.y},onPointerDown:p=>p.stopPropagation(),children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:r.metaboliteId??r.label??"slot"}),r.template&&i&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-label",children:"Template mapping"}),n.jsx(Ge,{label:"Change mapping / view evidence",onClick:()=>R.setState({selection:[`node:${r.id}`],rightOpen:!0})}),r.metaboliteId&&n.jsx(Ge,{label:"Clear mapping",onClick:()=>s.setTemplateMapping(r.id,void 0)}),r.template.status==="provisional"&&r.metaboliteId&&n.jsx(Ge,{label:"Confirm mapping",onClick:()=>s.setTemplateMapping(r.id,r.metaboliteId)}),n.jsx("div",{className:"cm-sep"})]}),i&&n.jsx(Ge,{label:d?"Rebind metabolite…":"Bind to model metabolite…",onClick:()=>R.setState({dialog:{kind:"metabolite",at:r,bindNodeId:r.id}})}),d&&n.jsx("div",{className:"cm-sep"}),d&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-label",children:"Expand network"}),n.jsx(Ge,{label:"↑ 1 reaction upstream",onClick:()=>s.expandNode(r.id,"up",1)}),n.jsx(Ge,{label:"↑ 2 reactions upstream",onClick:()=>s.expandNode(r.id,"up",2)}),n.jsx(Ge,{label:"↓ 1 reaction downstream",onClick:()=>s.expandNode(r.id,"down",1)}),n.jsx(Ge,{label:"↓ 2 reactions downstream",onClick:()=>s.expandNode(r.id,"down",2)}),n.jsx(Ge,{label:"↓ 5 reactions downstream",onClick:()=>s.expandNode(r.id,"down",5)}),n.jsx(Ge,{label:"Find path to…",onClick:()=>R.setState({dialog:{kind:"path"}})})]}),n.jsx("div",{className:"cm-sep"}),n.jsx(Ge,{label:"Add bar plot",onClick:()=>s.addPlot({kind:"node",id:r.id},"bar")})]}),c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-title",children:c.reactionId??c.label??"reaction"}),n.jsx("div",{className:"cm-label",children:"Add linked plot"}),["density","bar","line","heatmap","box","range"].map(p=>n.jsx(Ge,{label:p==="range"?"FVA / range":p[0].toUpperCase()+p.slice(1),onClick:()=>s.addPlot({kind:"reaction",id:c.id},p)},p)),n.jsx("div",{className:"cm-sep"}),n.jsx(Ge,{label:"Reverse drawn direction",onClick:()=>s.reverseReaction(c.id)}),n.jsx(Ge,{label:"Straight",onClick:()=>s.updateReaction(c.id,{routing:"straight",bend:void 0})}),n.jsx(Ge,{label:"Curved",onClick:()=>s.updateReaction(c.id,{routing:"curved",bend:void 0})}),n.jsx(Ge,{label:"Orthogonal",onClick:()=>s.updateReaction(c.id,{routing:"orthogonal",bend:void 0})}),n.jsx(Ge,{label:"Flip label side",onClick:()=>s.updateReaction(c.id,{labelFlip:!c.labelFlip})}),n.jsx("div",{className:"cm-sep"}),c.collapsed?n.jsx(Ge,{label:`Expand ${c.collapsed.members.length} hidden reactions`,onClick:()=>s.expandGlyph(c.id)}):n.jsx(Ge,{label:a.length>1?"Collapse selection into one arrow":"Collapse into summary arrow",onClick:()=>s.collapseSelection()}),i&&!c.collapsed&&((f=t.nodes[c.sources[0]])==null?void 0:f.metaboliteId)&&((u=t.nodes[c.targets[0]])==null?void 0:u.metaboliteId)&&n.jsx(Ge,{label:"Find routes in the model…",onClick:()=>R.setState({dialog:{kind:"routes",from:c.sources[0],to:c.targets[0],replaceGlyph:c.id}})}),c.reactionId&&Object.values(t.reactions).filter(p=>p.reactionId===c.reactionId).length>1&&n.jsx(Ge,{label:`Merge duplicate ${c.reactionId} arrows`,onClick:()=>s.mergeDuplicates(c.reactionId)})]}),!e.target&&n.jsxs(n.Fragment,{children:[n.jsx(Ge,{label:"Add metabolite here",onClick:()=>i?R.setState({dialog:{kind:"metabolite",at:e.world}}):s.addNode(e.world,{label:"M"})}),n.jsx(Ge,{label:"Add empty slot here",hint:"S",onClick:()=>s.addNode(e.world,{label:`M${Object.keys(t.nodes).length+1}`})}),n.jsx(Ge,{label:"Add text here",hint:"T",onClick:()=>s.addText(e.world)}),n.jsx(Ge,{label:"Add panel label",onClick:()=>s.addText(e.world,{text:"b",size:22,weight:700,kind:"panel"})}),n.jsx(Ge,{label:"Paste",hint:"Ctrl V",onClick:()=>s.paste(0)}),n.jsx("div",{className:"cm-sep"}),n.jsx(Ge,{label:"Fit all",hint:"F",onClick:()=>s.fitAll()})]}),a.length>1&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-sep"}),n.jsx(Ge,{label:"Group as pathway",hint:"Ctrl G",onClick:()=>s.groupSelection("pathway")}),!c&&n.jsx(Ge,{label:a.length===2?"Collapse everything between these two":"Collapse arrows into one",onClick:()=>s.collapseSelection()}),n.jsx(Ge,{label:"Group as compartment",onClick:()=>s.groupSelection("compartment")}),n.jsx(Ge,{label:"Save as template…",onClick:()=>R.setState({dialog:{kind:"saveTemplate"}})})]}),e.target&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cm-sep"}),n.jsx(Ge,{label:"Lock (skip in selection)",hint:"L",onClick:()=>s.toggleLock()}),n.jsx(Ge,{label:"Duplicate",hint:"Ctrl D",onClick:()=>s.duplicate()}),n.jsx(Ge,{label:"Delete",hint:"Del",onClick:()=>s.deleteSelection()})]})]})}var V5={trailer:59};function w_(e=256){let t=0,i=new Uint8Array(e);return{get buffer(){return i.buffer},reset(){t=0},bytesView(){return i.subarray(0,t)},bytes(){return i.slice(0,t)},writeByte(s){a(t+1),i[t]=s,t++},writeBytes(s,o=0,l=s.length){a(t+l);for(let r=0;r<l;r++)i[t++]=s[r+o]},writeBytesView(s,o=0,l=s.byteLength){a(t+l),i.set(s.subarray(o,o+l),t),t+=l}};function a(s){var o=i.length;if(o>=s)return;var l=1024*1024;s=Math.max(s,o*(o<l?2:1.125)>>>0),o!=0&&(s=Math.max(s,256));let r=i;i=new Uint8Array(s),t>0&&i.set(r.subarray(0,t),0)}}var qd=12,Pg=5003,W5=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function Y5(e,t,i,a,s=w_(512),o=new Uint8Array(256),l=new Int32Array(Pg),r=new Int32Array(Pg)){let c=l.length,d=Math.max(2,a);o.fill(0),r.fill(0),l.fill(-1);let f=0,u=0,p=d+1,m=p,h=!1,g=m,y=(1<<g)-1,b=1<<p-1,_=b+1,x=b+2,v=0,j=i[0],N=0;for(let k=c;k<65536;k*=2)++N;N=8-N,s.writeByte(d),w(b);let C=i.length;for(let k=1;k<C;k++)e:{let P=i[k],H=(P<<qd)+j,G=P<<N^j;if(l[G]===H){j=r[G];break e}let M=G===0?1:c-G;for(;l[G]>=0;)if(G-=M,G<0&&(G+=c),l[G]===H){j=r[G];break e}w(j),j=P,x<1<<qd?(r[G]=x++,l[G]=H):(l.fill(-1),x=b+2,h=!0,w(b))}return w(j),w(_),s.writeByte(0),s.bytesView();function w(k){for(f&=W5[u],u>0?f|=k<<u:f=k,u+=g;u>=8;)o[v++]=f&255,v>=254&&(s.writeByte(v),s.writeBytesView(o,0,v),v=0),f>>=8,u-=8;if((x>y||h)&&(h?(g=m,y=(1<<g)-1,h=!1):(++g,y=g===qd?1<<g:(1<<g)-1)),k==_){for(;u>0;)o[v++]=f&255,v>=254&&(s.writeByte(v),s.writeBytesView(o,0,v),v=0),f>>=8,u-=8;v>0&&(s.writeByte(v),s.writeBytesView(o,0,v),v=0)}}}var Z5=Y5;function C_(e,t,i){return e<<8&63488|t<<2&992|i>>3}function k_(e,t,i,a){return e>>4|t&240|(i&240)<<4|(a&240)<<8}function M_(e,t,i){return e>>4<<8|t&240|i>>4}function Wl(e,t,i){return e<t?t:e>i?i:e}function br(e){return e*e}function Rg(e,t,i){var a=0,s=1e100;let o=e[t],l=o.cnt;o.ac;let r=o.rc,c=o.gc,d=o.bc;for(var f=o.fw;f!=0;f=e[f].fw){let p=e[f],m=p.cnt,h=l*m/(l+m);if(!(h>=s)){var u=0;u+=h*br(p.rc-r),!(u>=s)&&(u+=h*br(p.gc-c),!(u>=s)&&(u+=h*br(p.bc-d),!(u>=s)&&(s=u,a=f)))}}o.err=s,o.nn=a}function Vd(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function Q5(e,t){let i=t==="rgb444"?4096:65536,a=new Array(i),s=e.length;if(t==="rgba4444")for(let o=0;o<s;++o){let l=e[o],r=l>>24&255,c=l>>16&255,d=l>>8&255,f=l&255,u=k_(f,d,c,r),p=u in a?a[u]:a[u]=Vd();p.rc+=f,p.gc+=d,p.bc+=c,p.ac+=r,p.cnt++}else if(t==="rgb444")for(let o=0;o<s;++o){let l=e[o],r=l>>16&255,c=l>>8&255,d=l&255,f=M_(d,c,r),u=f in a?a[f]:a[f]=Vd();u.rc+=d,u.gc+=c,u.bc+=r,u.cnt++}else for(let o=0;o<s;++o){let l=e[o],r=l>>16&255,c=l>>8&255,d=l&255,f=C_(d,c,r),u=f in a?a[f]:a[f]=Vd();u.rc+=d,u.gc+=c,u.bc+=r,u.cnt++}return a}function J5(e,t,i={}){let{format:a="rgb565",clearAlpha:s=!0,clearAlphaColor:o=0,clearAlphaThreshold:l=0,oneBitAlpha:r=!1}=i;if(!e||!e.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let c=new Uint32Array(e.buffer),d=i.useSqrt!==!1,f=a==="rgba4444",u=Q5(c,a),p=u.length,m=p-1,h=new Uint32Array(p+1);for(var g=0,y=0;y<p;++y){let A=u[y];if(A!=null){var b=1/A.cnt;f&&(A.ac*=b),A.rc*=b,A.gc*=b,A.bc*=b,u[g++]=A}}br(t)/g<.022&&(d=!1);for(var y=0;y<g-1;++y)u[y].fw=y+1,u[y+1].bk=y,d&&(u[y].cnt=Math.sqrt(u[y].cnt));d&&(u[y].cnt=Math.sqrt(u[y].cnt));var _,x,v;for(y=0;y<g;++y){Rg(u,y);var j=u[y].err;for(x=++h[0];x>1&&(v=x>>1,!(u[_=h[v]].err<=j));x=v)h[x]=_;h[x]=y}var N=g-t;for(y=0;y<N;){for(var C;;){var w=h[1];if(C=u[w],C.tm>=C.mtm&&u[C.nn].mtm<=C.tm)break;C.mtm==m?w=h[1]=h[h[0]--]:(Rg(u,w),C.tm=y);var j=u[w].err;for(x=1;(v=x+x)<=h[0]&&(v<h[0]&&u[h[v]].err>u[h[v+1]].err&&v++,!(j<=u[_=h[v]].err));x=v)h[x]=_;h[x]=w}var k=u[C.nn],P=C.cnt,H=k.cnt,b=1/(P+H);f&&(C.ac=b*(P*C.ac+H*k.ac)),C.rc=b*(P*C.rc+H*k.rc),C.gc=b*(P*C.gc+H*k.gc),C.bc=b*(P*C.bc+H*k.bc),C.cnt+=k.cnt,C.mtm=++y,u[k.bk].fw=k.fw,u[k.fw].bk=k.bk,k.mtm=m}let G=[];var M=0;for(y=0;;++M){let A=Wl(Math.round(u[y].rc),0,255),X=Wl(Math.round(u[y].gc),0,255),I=Wl(Math.round(u[y].bc),0,255),K=255;f&&(K=Wl(Math.round(u[y].ac),0,255),r&&(K=K<=(typeof r=="number"?r:127)?0:255),s&&K<=l&&(A=X=I=o,K=0));let L=f?[A,X,I,K]:[A,X,I];if(e6(G,L)||G.push(L),(y=u[y].fw)==0)break}return G}function e6(e,t){for(let i=0;i<e.length;i++){let a=e[i],s=a[0]===t[0]&&a[1]===t[1]&&a[2]===t[2],o=a.length>=4&&t.length>=4?a[3]===t[3]:!0;if(s&&o)return!0}return!1}function t6(e,t,i="rgb565"){if(!e||!e.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");if(t.length>256)throw new Error("applyPalette() only works with 256 colors or less");let a=new Uint32Array(e.buffer),s=a.length,o=i==="rgb444"?4096:65536,l=new Uint8Array(s),r=new Array(o);if(i==="rgba4444")for(let c=0;c<s;c++){let d=a[c],f=d>>24&255,u=d>>16&255,p=d>>8&255,m=d&255,h=k_(m,p,u,f),g=h in r?r[h]:r[h]=n6(m,p,u,f,t);l[c]=g}else{let c=i==="rgb444"?M_:C_;for(let d=0;d<s;d++){let f=a[d],u=f>>16&255,p=f>>8&255,m=f&255,h=c(m,p,u),g=h in r?r[h]:r[h]=i6(m,p,u,t);l[d]=g}}return l}function n6(e,t,i,a,s){let o=0,l=1e100;for(let r=0;r<s.length;r++){let c=s[r],d=c[3],f=Aa(d-a);if(f>l)continue;let u=c[0];if(f+=Aa(u-e),f>l)continue;let p=c[1];if(f+=Aa(p-t),f>l)continue;let m=c[2];f+=Aa(m-i),!(f>l)&&(l=f,o=r)}return o}function i6(e,t,i,a){let s=0,o=1e100;for(let l=0;l<a.length;l++){let r=a[l],c=r[0],d=Aa(c-e);if(d>o)continue;let f=r[1];if(d+=Aa(f-t),d>o)continue;let u=r[2];d+=Aa(u-i),!(d>o)&&(o=d,s=l)}return s}function Aa(e){return e*e}function a6(e={}){let{initialCapacity:t=4096,auto:i=!0}=e,a=w_(t),s=5003,o=new Uint8Array(256),l=new Int32Array(s),r=new Int32Array(s),c=!1;return{reset(){a.reset(),c=!1},finish(){a.writeByte(V5.trailer)},bytes(){return a.bytes()},bytesView(){return a.bytesView()},get buffer(){return a.buffer},get stream(){return a},writeHeader:d,writeFrame(f,u,p,m={}){let{transparent:h=!1,transparentIndex:g=0,delay:y=0,palette:b=null,repeat:_=0,colorDepth:x=8,dispose:v=-1}=m,j=!1;if(i?c||(j=!0,d(),c=!0):j=!!m.first,u=Math.max(0,Math.floor(u)),p=Math.max(0,Math.floor(p)),j){if(!b)throw new Error("First frame must include a { palette } option");o6(a,u,p,b,x),Ig(a,b),_>=0&&l6(a,_)}let N=Math.round(y/10);s6(a,v,N,h,g);let C=!!b&&!j;r6(a,u,p,C?b:null),C&&Ig(a,b),c6(a,f,u,p,x,o,l,r)}};function d(){E_(a,"GIF89a")}}function s6(e,t,i,a,s){e.writeByte(33),e.writeByte(249),e.writeByte(4),s<0&&(s=0,a=!1);var o,l;a?(o=1,l=2):(o=0,l=0),t>=0&&(l=t&7),l<<=2,e.writeByte(0|l|0|o),Yi(e,i),e.writeByte(s||0),e.writeByte(0)}function o6(e,t,i,a,s=8){let o=1,l=0,r=M0(a.length)-1,c=o<<7|s-1<<4|l<<3|r;Yi(e,t),Yi(e,i),e.writeBytes([c,0,0])}function l6(e,t){e.writeByte(33),e.writeByte(255),e.writeByte(11),E_(e,"NETSCAPE2.0"),e.writeByte(3),e.writeByte(1),Yi(e,t),e.writeByte(0)}function Ig(e,t){let i=1<<M0(t.length);for(let a=0;a<i;a++){let s=[0,0,0];a<t.length&&(s=t[a]),e.writeByte(s[0]),e.writeByte(s[1]),e.writeByte(s[2])}}function r6(e,t,i,a){if(e.writeByte(44),Yi(e,0),Yi(e,0),Yi(e,t),Yi(e,i),a){let s=0,o=0,l=M0(a.length)-1;e.writeByte(128|s|o|0|l)}else e.writeByte(0)}function c6(e,t,i,a,s=8,o,l,r){Z5(i,a,t,s,e,o,l,r)}function Yi(e,t){e.writeByte(t&255),e.writeByte(t>>8&255)}function E_(e,t){for(var i=0;i<t.length;i++)e.writeByte(t.charCodeAt(i))}function M0(e){return Math.max(Math.ceil(Math.log2(e)),1)}const G_="http://www.w3.org/2000/svg";function Bg(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(t){const a=t[1].length===3?t[1].split("").map(s=>s+s).join(""):t[1];return[parseInt(a.slice(0,2),16),parseInt(a.slice(2,4),16),parseInt(a.slice(4,6),16)]}const i=/^rgba?\(([^)]+)\)/i.exec(e.trim());if(i){const a=i[1].split(",").map(s=>parseFloat(s));return[a[0],a[1],a[2]]}return null}const as=(e,t,i)=>e+(t-e)*i;function Hg(e,t,i){const a=Bg(e),s=Bg(t);return!a||!s?i<.5?e:t:`rgb(${a.map((o,l)=>Math.round(as(o,s[l],i))).join(",")})`}function d6(e,t,i){const a={};for(const o of new Set([...Object.keys(e.reactions),...Object.keys(t.reactions)])){const l=e.reactions[o],r=t.reactions[o];if(!l||!r){a[o]=(i<.5?l:r)??l??r;continue}const c=i<.5?l:r;a[o]={...c,value:l.value!=null&&r.value!=null?as(l.value,r.value,i):c.value,width:as(l.width,r.width,i),color:Hg(l.color,r.color,i),opacity:as(l.opacity,r.opacity,i)}}const s={};for(const o of new Set([...Object.keys(e.nodes),...Object.keys(t.nodes)])){const l=e.nodes[o],r=t.nodes[o];if(!l||!r){s[o]=(i<.5?l:r)??l??r;continue}s[o]={r:as(l.r,r.r,i),fill:Hg(l.fill,r.fill,i),opacity:as(l.opacity,r.opacity,i),value:i<.5?l.value:r.value}}return{reactions:a,nodes:s,legend:i<.5?e.legend:t.legend}}function m6(e,t,i,a){const s=R.getState(),o=Ot[s.style.preset];Pp.flushSync(()=>{t.render(n.jsx("svg",{xmlns:G_,children:n.jsx("g",{id:"gif-scene",children:n.jsx(Iu,{doc:s.doc,model:s.model,datasets:s.datasets,conditions:s.conditions,view:{...s.view,activeCondition:i},style:s.style,theme:o,ev:a,selected:new Set,particles:!1,interactive:!1})})}))});const l=e.querySelector("#gif-scene").cloneNode(!0);return l.querySelectorAll(".ui-only").forEach(r=>r.remove()),l.removeAttribute("id"),new XMLSerializer().serializeToString(l).replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"/g,"")}function Wd(e){return e.replace(/[<>&"]/g,t=>({"<":"<",">":">","&":"&",'"':"""})[t])}async function Og(e,t,i){const a=new Image,s=URL.createObjectURL(new Blob([e],{type:"image/svg+xml"}));try{await new Promise((r,c)=>{a.onload=()=>r(),a.onerror=()=>c(new Error("Rasterisation failed")),a.src=s})}finally{setTimeout(()=>URL.revokeObjectURL(s),0)}const o=document.createElement("canvas");o.width=t,o.height=i;const l=o.getContext("2d",{willReadFrequently:!0});return l.fillStyle="#ffffff",l.fillRect(0,0,t,i),l.drawImage(a,0,0,t,i),l.getImageData(0,0,t,i).data}const E0=8e3,G0=36e6;function S0(e,t,i){let a=Math.round(e/25.4*i),s=Math.round(t/25.4*i);const o=Math.min(1,E0/Math.max(a,s),Math.sqrt(G0/Math.max(1,a*s)));return o<1&&(a=Math.round(a*o),s=Math.round(s*o)),{w:Math.max(64,a),h:Math.max(32,s),capped:o<1}}async function u6(e,t,i){const a=R.getState(),s=t.conditions.filter(D=>a.conditions.some(F=>F.id===D));if(s.length<2)throw new Error("Choose at least two conditions");const{svg:o,wMm:l,hMm:r}=Ic({...e,background:"white"}),c=/viewBox="([-\d.]+) ([-\d.]+) ([-\d.]+) ([-\d.]+)"/.exec(o);if(!c)throw new Error("Could not size the frames");const[d,f,u,p]=c.slice(1).map(Number),{w:m,h,capped:g}=S0(l,r,t.dpi),y=Ot[a.style.preset],b=s.map(D=>j0(a.doc,a.datasets,a.mappings,{...a.view,activeCondition:D},a.conditions,a.style,y)),_=[],x=D=>{var F;return((F=a.conditions.find(U=>U.id===D))==null?void 0:F.name)??D},v=Math.max(100,t.hold*1e3),j=60,N=t.loopBack?[...s.keys(),0]:[...s.keys()];N.forEach((D,F)=>{const U=F===N.length-1;if(t.loopBack&&U||_.push({cond:s[D],ev:b[D],label:x(s[D]),delay:v,key:!0}),U)return;const z=N[F+1];for(let O=1;O<=t.tween;O++){const Z=O/(t.tween+1);_.push({cond:Z<.5?s[D]:s[z],ev:d6(b[D],b[z],Z),label:`${x(s[D])} → ${x(s[z])}`,delay:j,key:!1})}});const C=document.createElement("div");C.style.cssText="position:absolute;left:-99999px;top:0;width:10px;height:10px;overflow:hidden",document.body.appendChild(C);const w=Rp(C),k=Math.max(10,u/40),P=D=>{var F;return((F=a.conditions.find(U=>U.id===D))==null?void 0:F.color)??y.text},H=D=>{const F=m6(C,w,D.cond,D.ev),U=t.label?`<g font-family="${Wd(y.font)}" font-weight="700"><rect x="${d+k*.6}" y="${f+k*.5}" width="${k*.5}" height="${k*1.1}" rx="${k*.12}" fill="${P(D.cond)}"/><text x="${d+k*1.35}" y="${f+k*1.4}" font-size="${k}" fill="${y.text}">${Wd(D.label)}</text></g>`:"";return`<svg xmlns="${G_}" width="${m}" height="${h}" viewBox="${d} ${f} ${u} ${p}" font-family="${Wd(y.font)}" text-rendering="geometricPrecision" shape-rendering="geometricPrecision"><rect x="${d}" y="${f}" width="${u}" height="${p}" fill="${e.background==="white"?y.background:"#ffffff"}"/>${F}${U}</svg>`},G=_.filter(D=>D.key),M=G.length+_.length;let A=0;const X=async()=>{i==null||i(++A/(M+1)),await new Promise(D=>setTimeout(D,0))};let I;try{const D=Math.max(1,Math.floor(m*h*G.length/6e5)),F=[];for(const O of G){const Z=await Og(H(O),m,h);for(let oe=0;oe<Z.length;oe+=4*D)F.push(Z[oe],Z[oe+1],Z[oe+2],255);await X()}const U=J5(new Uint8Array(F),256),z=a6();for(let O=0;O<_.length;O++){const Z=t6(await Og(H(_[O]),m,h),U);z.writeFrame(Z,m,h,{palette:O===0?U:void 0,delay:_[O].delay,repeat:0}),await X()}z.finish(),I=z.bytes()}finally{w.unmount(),C.remove()}i==null||i(1);const L=`${a.name.replace(/[^\w.-]+/g,"_")||"figure"}_${s.map(x).join("-").replace(/[^\w.-]+/g,"_").slice(0,60)}.gif`;return Di(L,new Blob([I],{type:"image/gif"})),`${L} · ${m} × ${h} px${g?" (capped — choose a size in mm for the full dpi)":` · ${t.dpi} dpi`} · ${_.length} frames · ${(I.length/1024/1024).toFixed(1)} MB`}const p6=Object.freeze(Object.defineProperty({__proto__:null,GIF_MAX_PIXELS:G0,GIF_MAX_SIDE:E0,exportGif:u6,gifFrameSize:S0},Symbol.toStringTag,{value:"Module"})),$g=1e-9;function Bu({fromNode:e,toNode:t,replaceGlyph:i,onDone:a}){var P,H;const s=R(G=>G.model),o=R(G=>G.doc),[l,r]=E.useState(2),[c,d]=E.useState(!1),[f,u]=E.useState(null),p=R(G=>G.datasets),m=R(G=>G.conditions),h=R(G=>G.view.activeCondition),g=p.find(G=>G.visible&&G.target==="reaction"&&(G.kind==="flux"||G.kind==="samples")),[y,b]=E.useState(!0),[_,x]=E.useState(()=>g!=null&&g.columns.includes(h)?h:"*"),v=(P=o.nodes[e])==null?void 0:P.metaboliteId,j=(H=o.nodes[t])==null?void 0:H.metaboliteId,N=E.useMemo(()=>{if(!s||!v||!j)return null;const G=performance.now();let M;if(g&&y){const X=_==="*"?g.columns.map((K,L)=>L):[g.columns.indexOf(_)].filter(K=>K>=0),I=new Map;M=K=>{const L=`${K.reactionId}|${K.reversed}`;let D=I.get(L);return D===void 0&&(D=X.some(F=>{const U=Ec(g,K.reactionId,F)??0;return K.reversed?U<-$g:U>$g}),I.set(L,D)),D}}return{..._N(s,v,j,{maxExtra:l,allowCurrency:c,limit:30,allow:M}),ms:performance.now()-G,filtered:!!M}},[s,v,j,l,c,g,y,_]),C=G=>{var M;return((M=m.find(A=>A.id===G))==null?void 0:M.name)??G};if(!s||!v||!j)return n.jsx("div",{className:"notice",children:"Both ends must be bound to model metabolites."});const w=G=>bt(G),k=(G,M)=>{V().applyRoute(e,t,G.steps,{replaceGlyph:i,collapse:M}),a()};return n.jsxs("div",{className:"routes",children:[n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("span",{className:"small",children:[n.jsx("b",{className:"mono",children:v})," → ",n.jsx("b",{className:"mono",children:j})]}),n.jsx("span",{className:"grow"}),n.jsxs("label",{className:"small",children:["up to shortest +",n.jsx("select",{className:"input tiny",value:l,onChange:G=>r(+G.target.value),children:[0,1,2,3,4].map(G=>n.jsx("option",{value:G,children:G},G))})," steps"]}),n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:c,onChange:G=>d(G.target.checked)})," allow cofactors as links"]})]}),g?n.jsxs("div",{className:"row gap wrap route-flux",children:[n.jsxs("label",{className:"check small",title:"Every reaction of the route must carry flux in the direction the route uses it",children:[n.jsx("input",{type:"checkbox",checked:y,onChange:G=>b(G.target.checked)})," Only routes that carry flux"]}),y&&n.jsxs("label",{className:"small",children:["in",n.jsxs("select",{className:"input tiny",value:_,onChange:G=>x(G.target.value),children:[Wc(g,m).map(G=>n.jsx("option",{value:G,children:C(G)},G)),n.jsx("option",{value:"*",children:"any condition (per step)"})]})]}),n.jsxs("span",{className:"muted small",children:["· ",g.name]})]}):n.jsx("div",{className:"muted small",children:"Import flux data to keep only the routes that carry flux."}),N&&N.shortest==null&&n.jsx("div",{className:"notice",children:N.filtered?n.jsxs(n.Fragment,{children:["No route from ",v," to ",j," carries flux",_==="*"?"":n.jsxs(n.Fragment,{children:[" in ",n.jsx("b",{children:C(_)})]}),". Try another condition, more steps, cofactors as links — or untick “Only routes that carry flux”."]}):n.jsxs(n.Fragment,{children:["No directed route from ",v," to ",j," through non-currency metabolites (bounds respected). Try the opposite direction or allow cofactors."]})}),N&&N.shortest!=null&&n.jsxs("div",{className:"muted small",children:[N.filtered?"Carrying flux — shortest":"Shortest",": ",n.jsx("b",{children:N.shortest})," reaction",N.shortest>1?"s":""," · ",N.routes.length," route",N.routes.length!==1?"s":""," up to ",N.shortest+l," steps",N.truncated?" (list truncated: showing the shortest)":""," · ",N.ms.toFixed(0)," ms"]}),n.jsx("div",{className:"route-list",children:N==null?void 0:N.routes.map((G,M)=>n.jsxs("div",{className:`route ${f===M?"hl":""}`,onMouseEnter:()=>u(M),onMouseLeave:()=>u(null),children:[n.jsx("div",{className:"route-len",children:G.steps.length}),n.jsx("div",{className:"route-chain",children:G.mets.map((A,X)=>{var I,K;return n.jsxs("span",{className:"rc-seg",children:[n.jsx("span",{className:"rc-met",title:(I=s.metabolites[A])==null?void 0:I.name,children:w(A)}),X<G.steps.length&&n.jsxs("span",{className:"rc-rxn",title:`${((K=s.reactions[G.steps[X].reactionId])==null?void 0:K.name)??""}${G.steps[X].reversed?" (runs backwards)":""}`,children:[n.jsxs("span",{className:"mono",children:[G.steps[X].reactionId,G.steps[X].reversed?"⁻":""]}),"→"]})]},X)})}),n.jsxs("div",{className:"route-actions",children:[n.jsx("button",{className:"btn small primary",onClick:()=>k(G,!1),title:"Draw every reaction and intermediate metabolite",children:"Insert"}),G.steps.length>1&&n.jsxs("button",{className:"btn small",onClick:()=>k(G,!0),title:"Insert as one collapsed arrow (expand later)",children:[n.jsx(q,{name:"group",size:12})," Collapsed"]})]})]},M))}),n.jsx("div",{className:"muted small",children:"Currency metabolites (ATP, NAD(P)H, H₂O, H⁺, CO₂, CoA…) are not used as links unless allowed. ⁻ marks a reversible reaction used backwards."})]})}const S_={confirmed:{icon:"✓",label:"Confirmed",color:"#15803d"},auto_high:{icon:"✓",label:"Mapped automatically",color:"#15803d"},provisional:{icon:"?",label:"Provisional — review",color:"#b45309"},ambiguous:{icon:"?",label:"Needs your choice",color:"#b45309"},unresolved:{icon:"○",label:"Unresolved",color:"#8d90a0"},absent:{icon:"✕",label:"Absent from model",color:"#8d90a0"}},A0={high:"High",medium:"Medium",low:"Low"};function Hu(e,t,i,a=0){return E.useMemo(()=>{if(!e||!t)return null;const s=la(oa(t).fingerprint);return Zp(e,t,{profile:s,overrides:i})},[e,t,i,a])}const Lg=new WeakMap;function h6(e,t){let i=Lg.get(t);i||(i=new Map,Lg.set(t,i));const a=la(oa(t).fingerprint),s=(a==null?void 0:a.updated)??"";let o=i.get(e.id);return(!o||o.stamp!==s)&&(o={stamp:s,r:Zp(e,t,{profile:a})},i.set(e.id,o)),o.r}function f6({spec:e,model:t}){const i=h6(e,t),a=i.coverage,s=a.coreMapped===a.core,o=i.slots.filter(c=>c.status==="provisional"||c.status==="ambiguous").length,l=[...new Set(i.slots.map(c=>c.expected.expected).filter(Boolean))].map(c=>dn[c]).join(" + "),r=`Template match / model coverage (not pathway activity)
|
|
74
|
+
Core metabolites: ${a.coreMapped}/${a.core} · core reactions: ${a.coreReactionsMapped}/${a.coreReactions}
|
|
75
|
+
Expected: ${e.compartmentSummary}; in this model: ${l||"—"}
|
|
76
|
+
${o?`${o} slot(s) need review · `:""}mapping quality: ${A0[i.quality]}`;return n.jsxs("span",{className:`tag ${s?"on":a.coreMapped/Math.max(1,a.core)<.6?"warn":""}`,title:r,children:[a.coreMapped,"/",a.core,o?" ?":""]})}function g6({templateId:e,at:t,onClose:i}){const a=Rc(e),s=R(N=>N.model),[o,l]=E.useState({}),[r,c]=E.useState({}),[d,f]=E.useState(!1),[u,p]=E.useState(null),m=Hu(a,s,o),h=Hu(a,s);if(!a||!s||!m||!h)return null;const g=new Set(h.slots.filter(N=>N.status==="provisional"||N.status==="ambiguous"||N.status==="unresolved").map(N=>N.slot.slot)),y=m.slots.filter(N=>g.has(N.slot.slot)),b=m.slots.filter(N=>N.status==="auto_high"||N.status==="confirmed"),_=d?m.slots:y,x=(N,C)=>{const w=m.slots.find(H=>H.slot.slot===N),k=C&&w?Qp(s,C):new Map,P={};for(const H of m.slots){if(!w||H.slot.slot===N||H.entity.id!==w.entity.id||H.expected.expected===w.expected.expected||H.slot.slot in o&&r[H.slot.slot]!==N||H.status==="auto_high"||H.status==="confirmed"&&!(H.slot.slot in o))continue;const G=H.expected.expected?k.get(H.expected.expected):void 0;G&&(P[H.slot.slot]=G)}l(H=>{const G={...H};for(const[M,A]of Object.entries(r))A===N&&delete G[M];return C===void 0?delete G[N]:G[N]=C,{...G,...P}}),c(H=>{const G=Object.fromEntries(Object.entries(H).filter(([M,A])=>A!==N&&M!==N));for(const M of Object.keys(P))G[M]=N;return G})},v=()=>{const N=oa(s);let C=la(N.fingerprint);for(const w of m.slots){if(!(w.slot.slot in o))continue;const k={entity:w.entity.id,compartment:w.expected.expected,metaboliteId:o[w.slot.slot],templateId:a.id,templateVersion:a.version};C=au(C,{fingerprint:N.fingerprint,id:s.id,name:s.name},k),k.metaboliteId&&!r[w.slot.slot]&&(C=F1(C,s,{...k,metaboliteId:k.metaboliteId}).profile)}C&&bo(C),V().instantiatePathway(a,m,t),i()},j=m.coverage;return n.jsxs(an,{title:`${a.name} → ${s.name}`,onClose:i,width:720,children:[n.jsxs("div",{className:"tm-summary",children:[n.jsxs("span",{className:"tm-pill ok",children:["✓ ",b.length," mapped"]}),n.jsxs("span",{className:"tm-pill warn",children:["? ",m.slots.filter(N=>N.status==="provisional"||N.status==="ambiguous").length," to review"]}),n.jsxs("span",{className:"tm-pill",children:["○ ",m.slots.filter(N=>N.status==="unresolved"||N.status==="absent").length," open"]}),n.jsx("span",{className:"grow"}),n.jsxs("span",{className:"muted small",title:"Pathway coverage (how much of the template exists in the model) is reported separately from mapping confidence.",children:["Coverage ",n.jsxs("b",{children:[j.coreMapped,"/",j.core]})," core metabolites · ",n.jsxs("b",{children:[j.coreReactionsMapped,"/",j.coreReactions]})," core reactions · quality ",n.jsx("b",{children:A0[m.quality]})]})]}),n.jsxs("div",{className:"muted small",children:[m.context.summary,". Expected compartment: ",n.jsx("b",{children:a.compartmentSummary}),". Structure in the model only — not evidence of flux."]}),m.notes.map(N=>n.jsx("div",{className:"tm-note",children:N},N)),Object.keys(r).length>0&&n.jsxs("div",{className:"tm-note",children:["Same compound, other compartment: ",Object.entries(r).map(([N,C])=>{const w=m.slots.find(P=>P.slot.slot===N),k=m.slots.find(P=>P.slot.slot===C);return n.jsxs("span",{children:[n.jsx("b",{children:w==null?void 0:w.entity.name})," ",w!=null&&w.expected.expected?dn[w.expected.expected]:""," → ",n.jsx("span",{className:"mono",children:o[N]})," (follows ",n.jsx("span",{className:"mono",children:k&&o[C]}),") "]},N)})]}),n.jsx("div",{className:"row between",children:n.jsxs("div",{className:"seg",children:[n.jsxs("button",{className:d?"":"on",onClick:()=>f(!1),children:["Needs review (",y.length,")"]}),n.jsxs("button",{className:d?"on":"",onClick:()=>f(!0),children:["Review all mappings (",m.slots.length,")"]})]})}),n.jsxs("div",{className:"tm-list",children:[!_.length&&n.jsxs("div",{className:"muted small pad",children:["Every slot was mapped with high confidence. ",n.jsx("button",{className:"link",onClick:()=>f(!0),children:"Review all mappings"})]}),_.map(N=>n.jsx(b6,{s:N,model:s,expanded:u===N.slot.slot,onToggle:()=>p(C=>C===N.slot.slot?null:N.slot.slot),onChoose:C=>x(N.slot.slot,C),overridden:N.slot.slot in o},N.slot.slot))]}),n.jsxs("div",{className:"row gap end",children:[n.jsx("button",{className:"btn",title:"Reproducibility report: every mapping with its evidence, method and versions",onClick:()=>Di(`${a.id}_mapping_${s.id}.json`,JSON.stringify(_C(m,a),null,1),"application/json"),children:"Export report"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:i,children:"Cancel"}),n.jsx("button",{className:"btn primary",onClick:v,children:"Create pathway"})]})]})}function b6({s:e,model:t,expanded:i,onToggle:a,onChoose:s,overridden:o}){const l=S_[e.status],r=e.chosen&&ei(e.status)?e.chosen:void 0;return n.jsxs("div",{className:`tm-row ${i?"open":""}`,children:[n.jsxs("button",{className:"tm-row-head",onClick:a,children:[n.jsx("span",{className:"tm-status",style:{color:l.color},title:l.label,children:l.icon}),n.jsxs("span",{className:"tm-slot",children:[n.jsx("b",{children:e.entity.name}),e.slot.level!=="required"&&n.jsx("span",{className:"tag",children:e.slot.level})]}),n.jsx("span",{className:"muted small",children:e.expected.expected?dn[e.expected.expected]:"—"}),n.jsx("span",{className:"grow"}),r?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mono",children:r.metId}),n.jsx(A_,{c:r.confidence})]}):n.jsx("span",{className:"muted small",children:e.status==="absent"?"absent":e.status==="ambiguous"?"choose…":"unresolved"})]}),i&&n.jsxs("div",{className:"tm-row-body",children:[n.jsx("div",{className:"small",style:{color:l.color},children:e.reason}),e.staleProfile&&n.jsx("div",{className:"small muted",children:e.staleProfile}),n.jsx(D_,{s:e,onPick:c=>s(c)}),n.jsx(P_,{model:t,initial:e.entity.name,onPick:c=>s(c)}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:()=>s(null),title:"The model does not contain this entity; keep a placeholder",children:"Mark absent"}),o&&n.jsx("button",{className:"btn small",onClick:()=>s(void 0),children:"Back to automatic"})]})]})]})}function A_({c:e}){return n.jsx("span",{className:`tm-conf ${e}`,children:A0[e]})}function D_({s:e,onPick:t,current:i}){const[a,s]=E.useState(null),o=i??(e.chosen&&ei(e.status)?e.chosen.metId:void 0);return e.candidates.length?n.jsx("div",{className:"tm-cands",children:e.candidates.map(l=>n.jsxs("div",{className:`tm-cand ${l.metId===o?"on":""}`,children:[n.jsxs("div",{className:"row gap",children:[n.jsx("input",{type:"radio",checked:l.metId===o,onChange:()=>t(l.metId),disabled:!!l.usedBy}),n.jsxs("button",{className:"tm-cand-main",onClick:()=>!l.usedBy&&t(l.metId),disabled:!!l.usedBy,children:[n.jsx("span",{className:"mono",children:l.metId})," ",n.jsx("span",{children:l.name})," ",n.jsx("span",{className:"muted small",children:l.compartmentLabel})]}),n.jsx(A_,{c:l.confidence}),n.jsx("span",{className:"muted small",title:"Ranking score (heuristic, not a probability)",children:Math.round(l.score*100)}),n.jsx("button",{className:"link small",onClick:()=>s(r=>r===l.metId?null:l.metId),children:"why?"})]}),n.jsx("div",{className:"muted small tm-cand-sum",children:l.usedBy?`already used for slot “${l.usedBy}”`:l.summary}),a===l.metId&&n.jsx(y6,{c:l})]},l.metId))}):n.jsx("div",{className:"muted small",children:"No candidate found by identifiers, names or formula."})}function y6({c:e}){return n.jsxs("ul",{className:"tm-evidence",children:[e.evidence.map((t,i)=>n.jsxs("li",{className:t.ok===!0?"ok":t.ok===!1?"bad":"",children:[n.jsx("span",{children:t.ok===!0?"✓":t.ok===!1?"✗":"·"}),t.text]},i)),n.jsxs("li",{className:"muted",children:[n.jsx("span",{children:"Σ"}),"identity ",e.identity," × compartment ",e.compartmentFactor," × topology ",e.topologyFactor," = ",e.score]})]})}function P_({model:e,initial:t,onPick:i}){const[a,s]=E.useState(""),[o,l]=E.useState(!1),r=E.useMemo(()=>o&&a?Yc(e,a,["metabolite"],12):[],[e,a,o]);return o?n.jsxs("div",{className:"tm-search",children:[n.jsx("input",{className:"input",autoFocus:!0,value:a,onChange:c=>s(c.target.value),placeholder:"Search metabolites (name, ID, formula)…"}),n.jsxs("div",{className:"list",children:[r.map(c=>n.jsx("button",{className:"list-item",onClick:()=>{i(c.id),l(!1)},children:n.jsxs("div",{className:"li-top",children:[n.jsx("b",{className:"mono",children:c.id}),n.jsx("span",{children:c.name}),n.jsx("span",{className:"muted small",children:c.detail})]})},c.id)),a&&!r.length&&n.jsx("div",{className:"muted small pad",children:"No match."})]})]}):n.jsx("button",{className:"link small",onClick:()=>{l(!0),s(t)},children:"Search all model metabolites…"})}function x6({n:e}){var m;const t=R(h=>h.model),i=e.template,a=Rc(i.templateId),[s,o]=E.useState(0),l=Hu(a,t,void 0,s),r=a?(m=M1(a,i.slot))==null?void 0:m.slot:void 0,c=l==null?void 0:l.slots.find(h=>h.slot.slot===r),d=a?Is(a,i.entity):void 0,f=S_[i.status],u=V(),p=h=>{u.setTemplateMapping(e.id,h),o(g=>g+1)};return n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Template mapping"}),n.jsxs("div",{className:"small",children:["Expected: ",n.jsx("b",{children:(d==null?void 0:d.name)??i.entity}),i.compartment?n.jsxs(n.Fragment,{children:[" · ",dn[i.compartment]]}):null]}),n.jsxs("div",{className:"small",style:{color:f.color},children:[f.icon," ",f.label,e.metaboliteId?n.jsxs(n.Fragment,{children:[" — ",n.jsx("span",{className:"mono",children:e.metaboliteId})]}):null,i.method?n.jsxs("span",{className:"muted",children:[" · ",i.method]}):null]}),n.jsxs("div",{className:"muted small",children:[(a==null?void 0:a.name)??i.templateId," v",i.templateVersion]}),!t&&n.jsx("div",{className:"muted small",children:"Load a GEM to map this slot."}),t&&c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"small muted",children:"Suggested model metabolites:"}),n.jsx(D_,{s:c,current:e.metaboliteId,onPick:h=>p(h)}),n.jsx(P_,{model:t,initial:(d==null?void 0:d.name)??"",onPick:h=>p(h)}),n.jsxs("div",{className:"row gap wrap",children:[i.status==="provisional"&&e.metaboliteId&&n.jsx("button",{className:"btn small primary",onClick:()=>p(e.metaboliteId),children:"Confirm"}),e.metaboliteId&&n.jsx("button",{className:"btn small",onClick:()=>p(void 0),children:"Clear mapping"}),i.status!=="absent"&&n.jsx("button",{className:"btn small",onClick:()=>p(null),title:"Keep the node as a placeholder",children:"Mark absent"})]})]})]})}const Yd={},R_=(Yd==null?void 0:Yd.VITE_COBRA_API)??"/api",Yl=new Map;async function _6(e){const t=e.trim().toLowerCase();if(!Yl.has(t)){const i=fetch(`${R_}/identity/compounds?q=${encodeURIComponent(e.trim())}&limit=8`).then(async a=>{if(!a.ok)throw new Error(`backend ${a.status}`);return await a.json()});i.catch(()=>Yl.delete(t)),Yl.set(t,i)}return Yl.get(t)}const v6=e=>({name:e.name,formula:e.formula??void 0,charge:e.charge??void 0,synonyms:e.synonyms??[],identifiers:e.identifiers,sources:e.sources,score:e.structured===!1?e.score*.9:e.score,match:e.match,note:e.note}),I_=e=>x_(e);async function B_(e){const t=x_(e);try{const i=await _6(e);return{candidates:C0([t,i.candidates.map(v6)]),online:!0,sources:i.sources}}catch(i){return{candidates:t,online:!1,note:`Database search unavailable (${i.message}) — showing the GEMsMAP library only. Start GEMsMAP with the gemsmap command (development checkout: npm run backend) to search KEGG, ChEBI and MetaNetX.`}}}const j6=async e=>(await B_(e)).candidates;let N6=null;const w6=()=>N6??(N6=cl.flatMap(e=>e.biology.reactions.map(t=>({r:t,f:e}))).filter((e,t,i)=>i.findIndex(a=>a.r.name===e.r.name&&a.r.ec.join()===e.r.ec.join())===t)),Go=(e,t)=>{const i=e.biology.metabolites.find(a=>a.id===t);return i?e.biology.entities.find(a=>a.id===i.entity):void 0};function C6(e,t,i=""){const a=t.participants.filter(l=>l.main).map(l=>({p:l,e:Go(e,l.metabolite)})).filter(l=>l.e),s=$t(i),o=[];for(const{r:l,f:r}of w6()){const c=l.participants.map(m=>({p:m,e:Go(r,m.metabolite)})),d=[];let f=0;for(const{p:m,e:h}of a){const g=c.find(y=>y.e&&gl(y.e,h));g&&Math.sign(g.p.coefficient)===Math.sign(m.coefficient)?(f++,d.push({ok:!0,text:`${h.name} (${m.coefficient<0?"substrate":"product"})`})):d.push({ok:!1,text:g?`${h.name} on the other side`:`${h.name} not in this reaction`})}const u=!!s&&[l.name,l.canonicalName??"",...l.ec].some(m=>$t(m).includes(s));if(!u&&(f<2||f<a.length))continue;u&&d.push({ok:!0,text:`name / EC matches “${i}”`});const p=l.participants.filter(m=>!m.main).map(m=>{var h;return(h=Go(r,m.metabolite))==null?void 0:h.name}).filter(Boolean);o.push({name:l.name,canonicalName:l.canonicalName,ec:l.ec,identifiers:l.identifiers,reversible:l.reversible,equation:bl(r,l),sources:["GEMsMAP library"],score:a.length?f/a.length:.5,evidence:[...d,...p.length?[{ok:!0,text:`cofactors in the library equation: ${p.join(", ")}`}]:[]]})}return o.sort((l,r)=>r.score-l.score).slice(0,6)}async function k6(e,t){const i=t.participants.map(a=>{const s=e.biology.metabolites.find(l=>l.id===a.metabolite),o=Go(e,a.metabolite);return{name:o==null?void 0:o.name,identifiers:(o==null?void 0:o.identifiers)??{},coefficient:a.coefficient,main:a.main,compartment:t.compartment??(s==null?void 0:s.compartment)??void 0}});try{const a=await fetch(`${R_}/identity/reactions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({participants:i,ec:t.ec})});if(!a.ok)throw new Error(`backend ${a.status}`);const s=await a.json();return{online:!0,notes:s.notes,candidates:s.candidates.map(o=>({...o,evidence:[...o.evidence.filter(l=>l.ok!==null).map(l=>({ok:!!l.ok,text:l.text})),...o.direction?[{ok:o.direction==="as drawn",text:`Direction: ${o.direction}`}]:[]]}))}}catch(a){return{candidates:[],notes:[`Database search unavailable (${a.message}) — start the backend to search MetaNetX`],online:!1}}}function bl(e,t,i="name"){const a=l=>{const r=Go(e,l.metabolite),c=(i==="short"?r==null?void 0:r.short:void 0)??(r==null?void 0:r.name)??l.metabolite,d=Math.abs(l.coefficient);return`${d!==1?`${d} `:""}${c}`},s=t.participants.filter(l=>l.coefficient<0).map(a).join(" + ")||"∅",o=t.participants.filter(l=>l.coefficient>0).map(a).join(" + ")||"∅";return`${s} ${t.reversible?"⇌":t.reversible===!1?"→":"→?"} ${o}`}const M6={confirmed:{icon:"✓",label:"Confirmed",cls:"confirmed",help:"Chosen or reviewed by a person"},suggested:{icon:"?",label:"Suggested",cls:"suggested",help:"Proposed by a database search, Auto Identify or AI — not reviewed yet"},ambiguous:{icon:"⚠",label:"Ambiguous",cls:"ambiguous",help:"Several plausible candidates — choose one"},unresolved:{icon:"○",label:"Unresolved",cls:"unresolved",help:"Identity not defined yet"}};function yl({status:e,conflict:t,compact:i,confidence:a}){const s=M6[e],o=e==="suggested"&&a?a:void 0;return n.jsxs("span",{className:`id-badge ${s.cls}${o==="probable"?" probable":""}`,title:`${s.label}${o?` (${o} confidence)`:""}: ${s.help}${t?`
|
|
77
|
+
Potential identity conflict — review it`:""}`,children:[s.icon,!i&&n.jsxs(n.Fragment,{children:[" ",s.label,o&&n.jsxs("span",{className:"id-conf",children:[" · ",o]})]}),t&&n.jsx("b",{className:"id-conflict",children:" !"})]})}const H_=()=>n.jsx("span",{className:"tag generic",title:"Generic entity — a class of molecules (e.g. any protein with a phospho-histidine), not one exact compound",children:"generic"});function O_({p:e}){return e.length?n.jsxs("span",{className:"small muted",children:["From ",e.map((t,i)=>n.jsxs("span",{children:[i?", ":"",t.url?n.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",children:[t.source," ",t.id]}):`${t.source} ${t.id}`]},t.source+t.id))]}):null}const E6={"ai-generated":"AI-generated — needs review","ai-validated":"AI-validated","human-reviewed":"Human-reviewed"};function $_({md:e}){return e.review_status?n.jsx("span",{className:`tag review ${e.review_status}`,title:e.last_review?`Last review ${e.last_review}`:"Drafted with a language model (LLM) outside GEMsMAP; a person has not reviewed its identities and layout yet",children:E6[e.review_status]}):null}const G6=["metanetx.chemical","kegg.compound","chebi","bigg.metabolite","seed.compound","metacyc.compound","hmdb","inchikey","metanetx.reaction","kegg.reaction","rhea","bigg.reaction","seed.reaction","metacyc.reaction","vmh","lipidmaps","pubchem.compound","reactome"];function qa({ids:e,max:t=6}){const i=G6.flatMap(a=>(e[a]??[]).slice(0,a==="chebi"?2:1).map(s=>`${sa[a]} ${s}`));return i.length?n.jsxs("span",{className:"mono small id-line",title:i.join(`
|
|
78
|
+
`),children:[i.slice(0,t).join(" · "),i.length>t?` · +${i.length-t}`:""]}):n.jsx("span",{className:"muted small",children:"no database identifier"})}function L_({ns:e,values:t,onChange:i}){const[a,s]=E.useState(null),o=a??t.join(", "),l=o.split(/[,;\s]+/).map(c=>c.trim()).filter(Boolean),r=l.filter(c=>!ri(e,c));return n.jsxs("label",{className:"field id-field",children:[n.jsx("span",{children:sa[e]}),n.jsx("input",{className:`input mono ${r.length?"bad":""}`,value:o,placeholder:"—",spellCheck:!1,onChange:c=>s(c.target.value),onBlur:()=>{a!==null&&(i(l),s(null))},onKeyDown:c=>{c.key==="Enter"&&c.target.blur()},title:r.length?`Not a valid ${sa[e]} identifier: ${r.join(", ")}`:void 0})]})}function D0({c:e}){const t=(i,a,s)=>n.jsxs("div",{className:"cmp-row",children:[n.jsx("span",{children:i}),n.jsx("span",{className:"cmp-bar",children:n.jsx("i",{style:{width:`${s?a/s*100:100}%`}})}),n.jsxs("span",{className:"mono",children:[a,"/",s]})]},i);return n.jsxs("div",{className:"tpl-cmp",title:"Overall = mean of the two identity ratios (compartments are optional). Identified = at least one database identifier (or EC for reactions) and a confirmed or suggested identity.",children:[t("Metabolites identified",e.metabolitesIdentified,e.metabolites),t("Reactions identified",e.reactionsIdentified,e.reactions),n.jsxs("div",{className:"cmp-row muted",title:"Optional: a preferred compartment ranks the matcher's candidates; without one, you choose the compartment when mapping onto a GEM",children:[n.jsx("span",{children:"Preferred compartments"}),n.jsx("span",{children:"optional"}),n.jsxs("span",{className:"mono",children:[e.compartmentsDefined,"/",e.metabolites]})]}),n.jsxs("div",{className:"cmp-row total",children:[n.jsx("span",{children:"Overall"}),n.jsx("span",{}),n.jsxs("span",{className:"mono",children:[Math.round(e.overall*100),"%"]})]})]})}function S6({f:e,w:t=220,h:i=130}){const a=e.layout.nodes.filter(y=>!y.attach),s=[...a,...e.layout.ports];if(!s.length)return n.jsx("svg",{width:qe(t),height:qe(i),viewBox:`0 0 ${t} ${i}`,className:"tpl-preview",children:n.jsx("text",{x:t/2,y:i/2,textAnchor:"middle",fontSize:11,fill:"#8d90a0",children:"empty"})});const o=s.map(y=>y.x),l=s.map(y=>y.y),r=Math.min(...o),c=Math.min(...l),d=Math.max(...o)-r||1,f=Math.max(...l)-c||1,u=12,p=Math.min((t-2*u)/d,(i-2*u)/f,1.2),m=(y,b)=>[(y-r)*p+(t-d*p)/2,(b-c)*p+(i-f*p)/2],h=new Map(s.map(y=>[y.id,y])),g=new Map(e.biology.metabolites.map(y=>{var b;return[y.id,((b=e.biology.entities.find(_=>_.id===y.entity))==null?void 0:b.identity.status)??"unresolved"]}));return n.jsxs("svg",{width:qe(t),height:qe(i),viewBox:`0 0 ${t} ${i}`,className:"tpl-preview",children:[e.layout.reactions.map((y,b)=>y.sources.flatMap(_=>y.targets.map(x=>{const v=h.get(_),j=h.get(x);if(!v||!j)return null;const[N,C]=m(v.x,v.y),[w,k]=m(j.x,j.y);return n.jsx("line",{x1:N,y1:C,x2:w,y2:k,stroke:"#5d6070",strokeOpacity:.55,strokeWidth:1},`${b}-${_}-${x}`)}))),e.layout.ports.map(y=>{const b=h.get(y.from);if(!b)return null;const[_,x]=m(b.x,b.y),[v,j]=m(y.x,y.y);return n.jsx("line",{x1:_,y1:x,x2:v,y2:j,stroke:"#8d90a0",strokeDasharray:"2 2"},y.id)}),a.map(y=>{const[b,_]=m(y.x,y.y),x=g.get(y.metabolite);return n.jsx("circle",{cx:b,cy:_,r:2.6,fill:x==="confirmed"?"#262c8c":x==="unresolved"?"#fff":"#d97706",stroke:"#262c8c",strokeWidth:.8},y.id)}),e.layout.ports.map(y=>{const[b,_]=m(y.x,y.y);return n.jsx("rect",{x:b-5,y:_-3,width:10,height:6,rx:2,fill:"#fff",stroke:"#8d90a0",strokeDasharray:"1.5 1"},y.id)})]})}const yi=()=>R.setState({dialog:null});function A6({nodeId:e,entityId:t,reactionId:i,query:a}){var r,c,d;const s=R(f=>f.design),o=R(f=>e?f.doc.nodes[e]:void 0);if(!s)return null;if(i||((r=o==null?void 0:o.design)==null?void 0:r.kind)==="port")return i?n.jsx(I6,{reactionId:i}):null;const l=((c=o==null?void 0:o.design)==null?void 0:c.kind)==="metabolite"?o.design.id:(d=s.biology.metabolites.find(f=>f.entity===t))==null?void 0:d.id;return l?n.jsx(D6,{metId:l,query:a}):null}function D6({metId:e,query:t}){var j,N,C;const i=R(w=>w.design),a=i.biology.metabolites.find(w=>w.id===e),s=a&&i.biology.entities.find(w=>w.id===a.entity),o=t??(s&&s.name!=="New metabolite"?s.name:ou(a==null?void 0:a.label)?"":(a==null?void 0:a.label)??""),[l,r]=E.useState(o),[c,d]=E.useState(a!=null&&a.label&&!ou(a.label)?a.label:""),[f,u]=E.useState(null),[p,m]=E.useState(!1),[h,g]=E.useState(0),[y,b]=E.useState(!1),_=E.useMemo(()=>I_(l),[l]);if(E.useEffect(()=>{if(l.trim().length<2){u(null);return}let w=!0;const k=setTimeout(()=>{m(!0),B_(l).then(P=>{w&&u({q:l,c:P.candidates,online:P.online,note:P.note,sources:P.sources})}).finally(()=>w&&m(!1))},350);return()=>{w=!1,clearTimeout(k)}},[l]),!a||!s)return null;const x=f&&f.q===l?f.c:C0([_]),v=w=>{fe.assignIdentity(e,w,c),yi()};return n.jsxs(an,{title:"Define identity — template entity",onClose:yi,width:640,children:[n.jsx("div",{className:"muted small",children:"A template node is an abstract biological entity, not a model metabolite. Choose the compound it stands for; the matcher finds what the compound is called in each GEM later."}),n.jsxs("div",{className:"row gap",children:[n.jsxs("label",{className:"field grow",children:[n.jsx("span",{children:"Display name"}),n.jsx("input",{className:"input",value:c,placeholder:s.short||s.name,onChange:w=>d(w.target.value)})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Compartment"}),n.jsxs("select",{className:"input",value:a.compartment??"",onChange:w=>fe.updateMetabolite(a.id,{compartment:w.target.value||null}),children:[n.jsx("option",{value:"",children:"— none —"}),rl.map(w=>n.jsx("option",{value:w.id,children:w.label},w.id))]})]})]}),n.jsxs("div",{className:"row gap small",children:[n.jsx("span",{className:"muted",children:"Current identity:"}),n.jsx("b",{children:s.name}),n.jsx(yl,{status:s.identity.status,conflict:!!s.identity.conflict}),n.jsx(qa,{ids:s.identifiers,max:3})]}),s.identity.status==="ambiguous"&&!!((j=s.identity.candidates)!=null&&j.length)&&n.jsxs("div",{className:"notice small",children:[n.jsx("b",{children:"Ambiguous:"})," ",s.identity.note,n.jsx("div",{className:"id-cands",children:s.identity.candidates.map((w,k)=>n.jsxs("button",{className:"btn small",onClick:()=>{fe.chooseCandidate(s.id,k),yi()},children:[w.name," ",n.jsx("span",{className:"muted",children:n.jsx(qa,{ids:w.identifiers,max:2})})]},k))})]}),n.jsx("input",{className:"input big",autoFocus:!0,placeholder:"Search compound: name, synonym, KEGG C00031, CHEBI:17634, MNXM…",value:l,onChange:w=>{r(w.target.value),g(0)},onKeyDown:w=>{w.key==="ArrowDown"&&(g(k=>Math.min(x.length-1,k+1)),w.preventDefault()),w.key==="ArrowUp"&&(g(k=>Math.max(0,k-1)),w.preventDefault()),w.key==="Enter"&&x[h]&&v(x[h])}}),n.jsx("div",{className:"row gap small muted",children:p?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner sm"})," searching BiGG, KEGG, ChEBI and MetaNetX…"]}):f!=null&&f.online?n.jsxs(n.Fragment,{children:["GEMsMAP library",((N=f.sources)==null?void 0:N.BiGG)==="ok"?" + BiGG":""," + KEGG + ChEBI (resolved through MetaNetX)",((C=f.sources)==null?void 0:C.BiGG)==="not downloaded"?n.jsx("span",{children:" · BiGG data not downloaded (Template Library → BiGG)"}):null]}):"GEMsMAP library"}),f&&!f.online&&f.note&&n.jsx("div",{className:"tm-note small",children:f.note}),n.jsxs("div",{className:"list scroll id-results",children:[x.map((w,k)=>n.jsx(P6,{c:w,active:k===h,onHover:()=>g(k),onPick:()=>v(w)},`${w.name}-${k}`)),!x.length&&l.trim()&&!p&&n.jsx("div",{className:"muted small pad",children:"No candidate — refine the name, type an identifier, or enter the identity manually."})]}),n.jsxs("details",{open:y,onToggle:w=>b(w.target.open),className:"small",children:[n.jsx("summary",{children:"Enter the identity manually"}),n.jsx(R6,{initialName:l||s.name,onUse:w=>v(w)})]}),n.jsxs("div",{className:"row gap end",children:[s.identity.status==="suggested"&&n.jsx("button",{className:"btn",onClick:()=>{fe.confirmEntity(s.id),yi()},children:"Confirm current identity"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:yi,children:s.identity.status==="unresolved"?"Leave unresolved":"Close"})]})]})}function P6({c:e,active:t,onHover:i,onPick:a}){return n.jsxs("button",{className:`list-item id-cand ${t?"active":""}`,onMouseEnter:i,onClick:a,children:[n.jsxs("div",{className:"li-top",children:[n.jsx("b",{children:e.name}),e.formula&&n.jsx("span",{className:"mono muted",children:e.formula}),n.jsx("span",{className:"grow"}),e.sources.map(s=>n.jsx("span",{className:"tag",children:s},s))]}),n.jsx("div",{className:"small",children:n.jsx(qa,{ids:e.identifiers})}),n.jsxs("div",{className:"muted small",children:[e.match,e.note?` · ${e.note}`:"",e.synonyms.length?` · also: ${e.synonyms.slice(0,4).join(", ")}`:""]})]})}function R6({initialName:e,onUse:t}){const[i,a]=E.useState(e),[s,o]=E.useState(""),[l,r]=E.useState({}),c=Object.fromEntries(Object.entries(l).map(([d,f])=>[d,f.split(/[,;\s]+/).filter(Boolean)]).filter(([,d])=>d.length));return n.jsxs("div",{className:"manual-id",children:[n.jsxs("div",{className:"row gap",children:[n.jsxs("label",{className:"field grow",children:[n.jsx("span",{children:"Canonical name"}),n.jsx("input",{className:"input",value:i,onChange:d=>a(d.target.value)})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Formula"}),n.jsx("input",{className:"input mono",value:s,onChange:d=>o(d.target.value),placeholder:"C6H12O6"})]})]}),n.jsx("div",{className:"id-grid",children:C1.map(d=>n.jsxs("label",{className:"field",children:[n.jsx("span",{children:sa[d]}),n.jsx("input",{className:"input mono",value:l[d]??"",onChange:f=>r({...l,[d]:f.target.value}),placeholder:"—"})]},d))}),n.jsx("button",{className:"btn primary small",disabled:!i.trim(),onClick:()=>t({name:i.trim(),formula:s.trim()||void 0,synonyms:[],identifiers:c,sources:["manual entry"],score:1,match:"entered by the user"}),children:"Use this identity"})]})}function I6({reactionId:e}){const t=R(u=>u.design),i=t.biology.reactions.find(u=>u.id===e),[a,s]=E.useState(""),[o,l]=E.useState(null),[r,c]=E.useState(!1),d=E.useMemo(()=>i?C6(t,i,a):[],[t,i,a]);if(E.useEffect(()=>{if(!i)return;let u=!0;return c(!0),k6(t,i).then(p=>u&&l(p)).finally(()=>u&&c(!1)),()=>{u=!1}},[e]),!i)return null;const f=u=>{fe.setReactionIdentity(i.id,u),yi()};return n.jsxs(an,{title:"Define reaction identity — template reaction",onClose:yi,width:680,children:[n.jsx("div",{className:"muted small",children:"A reaction is defined by its participants, stoichiometry and direction — not by its name, which varies between models. Database identifiers make later matching to a GEM stronger."}),n.jsx("div",{className:"eq mono",children:bl(t,i)}),n.jsxs("div",{className:"row gap small",children:[n.jsx("span",{className:"muted",children:"Current:"}),n.jsx("b",{children:i.name}),i.canonicalName&&n.jsx("span",{children:i.canonicalName}),n.jsx(yl,{status:i.identity.status}),i.ec.length>0&&n.jsxs("span",{className:"tag",children:["EC ",i.ec.join(", ")]})]}),n.jsx("div",{className:"section-title",children:"GEMsMAP library (built-in templates)"}),n.jsx("input",{className:"input",placeholder:"Filter by name or EC (hexokinase, 2.7.1.1 …)",value:a,onChange:u=>s(u.target.value)}),n.jsxs("div",{className:"list id-results",children:[d.map((u,p)=>n.jsx(Tg,{c:u,onPick:()=>f(u)},`l${p}`)),!d.length&&n.jsxs("div",{className:"muted small pad",children:["No built-in reaction with these participants",a?" or this name":"","."]})]}),n.jsx("div",{className:"section-title",children:"BiGG + MetaNetX (from the participants' identities, stoichiometry and compartments)"}),r&&n.jsxs("div",{className:"muted small",children:[n.jsx("span",{className:"spinner sm"})," searching BiGG and MNXref…"]}),o==null?void 0:o.notes.map(u=>n.jsx("div",{className:"tm-note small",children:u},u)),o&&o.candidates.length>1&&Math.abs(o.candidates[0].score-o.candidates[1].score)<.05&&n.jsxs("div",{className:"notice small",children:["⚠ The first ",o.candidates.filter(u=>Math.abs(u.score-o.candidates[0].score)<.05).length," candidates fit equally well — compare their equations (anomers, generic vs specific forms) before choosing."]}),n.jsxs("div",{className:"list id-results",children:[o==null?void 0:o.candidates.map((u,p)=>n.jsx(Tg,{c:u,onPick:()=>f(u)},`d${p}`)),o&&!o.candidates.length&&!r&&n.jsx("div",{className:"muted small pad",children:"No BiGG or MNXref reaction found."})]}),n.jsxs("div",{className:"row gap end",children:[i.identity.status==="suggested"&&n.jsx("button",{className:"btn",onClick:()=>{fe.confirmReaction(i.id),yi()},children:"Confirm current identity"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"btn",onClick:yi,children:"Close"})]})]})}function Tg({c:e,onPick:t}){return n.jsxs("div",{className:"list-item id-cand",children:[n.jsxs("div",{className:"li-top",children:[n.jsx("b",{children:e.canonicalName??e.name}),e.canonicalName&&n.jsx("span",{className:"mono muted",children:e.name}),e.ec.length>0&&n.jsxs("span",{className:"tag",children:["EC ",e.ec.join(", ")]}),n.jsx("span",{className:"grow"}),e.sources.map(i=>n.jsx("span",{className:"tag",children:i},i)),n.jsx("span",{className:"muted small",title:"Participant coverage, coefficients, compartments, EC and transport agreement (heuristic, not a probability)",children:Math.round(e.score*100)}),n.jsx("button",{className:"btn small primary",onClick:t,children:"Use"})]}),e.equation&&n.jsx("div",{className:"mono small",children:e.equation}),n.jsx("div",{className:"small",children:n.jsx(qa,{ids:e.identifiers})}),n.jsx("ul",{className:"tm-evidence",children:e.evidence.map((i,a)=>n.jsxs("li",{className:i.ok?"ok":"bad",children:[n.jsx("span",{children:i.ok?"✓":"✗"}),i.text]},a))})]})}function an({title:e,children:t,onClose:i,width:a=480}){return E.useEffect(()=>{const s=o=>{o.key==="Escape"&&i()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i]),n.jsx("div",{className:"modal-backdrop",onPointerDown:i,children:n.jsxs("div",{className:"modal",style:{width:qe(a)},onPointerDown:s=>s.stopPropagation(),children:[n.jsxs("div",{className:"modal-head",children:[n.jsx("span",{children:e}),n.jsx("button",{className:"icon-btn",onClick:i,children:n.jsx(q,{name:"x",size:14})})]}),n.jsx("div",{className:"modal-body",children:t})]})})}const tt=()=>R.setState({dialog:null});function B6(){const e=R(t=>t.dialog);if(!e)return null;switch(e.kind){case"reaction":return n.jsx(H6,{sources:e.sources,targets:e.targets});case"metabolite":return n.jsx(O6,{at:e.at,bindNodeId:e.bindNodeId});case"export":return n.jsx($6,{});case"saveTemplate":return n.jsx(L6,{});case"templateMapping":return n.jsx(g6,{templateId:e.templateId,at:e.at,onClose:tt});case"importReport":return n.jsx(T6,{datasetId:e.datasetId});case"path":return n.jsx(F6,{});case"validation":return n.jsx(X6,{});case"help":return n.jsx(K6,{});case"identity":return n.jsx(A6,{nodeId:e.nodeId,entityId:e.entityId,reactionId:e.reactionId,query:e.query});case"routes":return n.jsx(an,{title:"Routes in the model",onClose:tt,width:760,children:n.jsx(Bu,{fromNode:e.from,toNode:e.to,replaceGlyph:e.replaceGlyph,onDone:tt})})}}function H6({sources:e,targets:t}){const i=R(m=>m.model),a=R(m=>m.doc),s=a.nodes[e[0]],o=a.nodes[t[0]],l=s==null?void 0:s.metaboliteId,r=o==null?void 0:o.metaboliteId,[c,d]=E.useState(""),f=E.useMemo(()=>l&&r?Tp(i,l,r):[],[i,l,r]),u=E.useMemo(()=>l?Xa(i,l,"down").filter(m=>!f.some(h=>h.reactionIds[0]===m.reactionId)).slice(0,8):[],[i,l,f]),p=(m,h)=>{V().addReaction(e,t,{reactionId:m[0],lumped:m.length>1?m:void 0,reversedToModel:h,label:c||void 0},!1),tt()};return n.jsxs(an,{title:"Create reaction",onClose:tt,width:560,children:[n.jsxs("div",{className:"muted small",children:[l," → ",r]}),f.length?n.jsx("div",{className:"list",children:f.map(m=>{const h=i.reactions[m.reactionIds[0]];return n.jsxs("button",{className:"list-item",onClick:()=>p(m.reactionIds,m.reversed),children:[n.jsxs("div",{className:"li-top",children:[n.jsx("b",{children:m.reactionIds.join(" + ")}),n.jsx("span",{className:"muted",children:h.name}),h.reversible&&n.jsx("span",{className:"tag",children:"reversible"}),m.reversed&&n.jsx("span",{className:"tag warn",children:"drawn against model direction"}),m.reactionIds.length>1&&n.jsx("span",{className:"tag",children:"lumped"})]}),n.jsx("div",{className:"mono small",children:zr(h,i.metabolites)}),n.jsx("div",{className:"muted small",children:[h.subsystem,h.gpr].filter(Boolean).join(" · ")})]},m.reactionIds.join("+"))})}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"notice",children:["No single reaction in ",n.jsx("b",{children:i.name})," converts ",l," into ",r,". Routes through the network:"]}),n.jsx(Bu,{fromNode:e[0],toNode:t[0],onDone:tt})]}),f.length>0&&n.jsxs("details",{className:"small",children:[n.jsx("summary",{children:"Alternative multi-step routes in the model"}),n.jsx(Bu,{fromNode:e[0],toNode:t[0],onDone:tt})]}),u.length>0&&n.jsxs("details",{className:"small",children:[n.jsxs("summary",{children:["Other reactions consuming ",l]}),n.jsx("div",{className:"list",children:u.map(m=>n.jsxs("div",{className:"muted mono",children:[m.reactionId,": ",l," → ",m.to]},m.reactionId+m.to))})]}),n.jsxs("div",{className:"row gap",children:[n.jsx("input",{className:"input",placeholder:"Label (optional)",value:c,onChange:m=>d(m.target.value)}),n.jsx("button",{className:"btn",onClick:()=>{V().addReaction(e,t,{label:c||void 0},!1),tt()},children:"Free arrow (no model reaction)"})]})]})}function O6({at:e,bindNodeId:t}){var p;const i=R(m=>m.model),a=R(m=>t?m.doc.nodes[t]:void 0),[s,o]=E.useState(((p=a==null?void 0:a.hints)==null?void 0:p[0])??(a==null?void 0:a.label)??""),[l,r]=E.useState({id:"",name:""}),[c,d]=E.useState(0),f=E.useMemo(()=>Yc(i,s,["metabolite"],40),[i,s]),u=m=>{t?V().bindNode(t,m):V().addNode(e,{metaboliteId:m}),tt()};return n.jsxs(an,{title:t?"Bind slot to metabolite":"Add metabolite",onClose:tt,width:520,children:[n.jsx("input",{className:"input big",autoFocus:!0,placeholder:"Search metabolites… (glucose, g6p, pyruvate)",value:s,onChange:m=>{o(m.target.value),d(0)},onKeyDown:m=>{m.key==="ArrowDown"&&(d(h=>Math.min(f.length-1,h+1)),m.preventDefault()),m.key==="ArrowUp"&&(d(h=>Math.max(0,h-1)),m.preventDefault()),m.key==="Enter"&&f[c]&&u(f[c].id)}}),n.jsxs("div",{className:"list scroll",children:[f.map((m,h)=>n.jsx("button",{className:`list-item ${h===c?"active":""}`,onMouseEnter:()=>d(h),onClick:()=>u(m.id),children:n.jsxs("div",{className:"li-top",children:[n.jsx("b",{className:"mono",children:m.id}),n.jsx("span",{children:m.name}),n.jsx("span",{className:"muted small",children:m.detail})]})},m.id)),!f.length&&s&&n.jsx("div",{className:"muted small pad",children:"No match in the model."})]}),!t&&n.jsxs("div",{className:"row gap",children:[n.jsx("input",{className:"input",placeholder:"Custom ID",value:l.id,onChange:m=>r({...l,id:m.target.value})}),n.jsx("input",{className:"input",placeholder:"Label",value:l.name,onChange:m=>r({...l,name:m.target.value})}),n.jsx("button",{className:"btn",onClick:()=>{V().addNode(e,{label:l.name||l.id||"M",hints:l.id?[l.id]:void 0}),tt()},children:"Add slot"})]}),t&&(a==null?void 0:a.metaboliteId)&&n.jsx("button",{className:"btn",onClick:()=>{V().unbindNode(t),tt()},children:"Unbind (keep as template slot)"})]})}function $6(){const[e,t]=E.useState(()=>{try{return{...Fg,...JSON.parse(localStorage.getItem("gemsmap.export")||"{}")}}catch{return Fg}}),[i,a]=E.useState("auto"),s=R(y=>y.selection.length>0),[o,l]=E.useState(""),r=R(y=>y.conditions),[c,d]=E.useState(()=>{const y={conditions:[],hold:1.2,tween:6,label:!0,dpi:600,loopBack:!0};try{const b=JSON.parse(localStorage.getItem("gemsmap.export.gif")||"{}");return delete b.widthPx,{...y,...b,conditions:[]}}catch{return y}}),f=c.conditions.length?r.filter(y=>c.conditions.includes(y.id)).map(y=>y.id):r.map(y=>y.id),[u,p]=E.useState(null),m=E.useMemo(()=>{if(e.format!=="gif")return null;try{const{wMm:y,hMm:b}=Ic({...e,background:"white"});return S0(y,b,c.dpi)}catch{return null}},[e,c.dpi]),h=y=>t(b=>({...b,...y})),g=async()=>{try{localStorage.setItem("gemsmap.export",JSON.stringify(e)),localStorage.setItem("gemsmap.export.gif",JSON.stringify({...c,conditions:[]}))}catch{}try{if(e.format==="gif"){p(0);const{exportGif:y}=await ra(async()=>{const{exportGif:b}=await Promise.resolve().then(()=>p6);return{exportGif:b}},void 0);l(await y(e,{...c,conditions:f},b=>p(b)))}else l(await Q1(e))}catch(y){l(String(y.message))}finally{p(null)}};return n.jsxs(an,{title:"Export figure",onClose:tt,width:440,children:[n.jsx("div",{className:"seg",children:["svg","pdf","png","gif"].map(y=>n.jsx("button",{className:e.format===y?"on":"",onClick:()=>h({format:y}),children:y.toUpperCase()},y))}),n.jsx("div",{className:"muted small",children:e.format==="svg"?"Vector, editable in Illustrator / Inkscape / Affinity. Text stays text.":e.format==="pdf"?"Vector PDF through the browser print dialog (“Save as PDF”).":e.format==="gif"?"Animation across conditions for slides and posters: arrow widths, colours and plots change from one condition to the next.":"Raster with embedded DPI metadata."}),e.format==="gif"&&n.jsxs("div",{className:"gif-opts",children:[n.jsxs("div",{className:"field",children:[n.jsx("span",{children:"Conditions (in order)"}),r.length<2?n.jsx("div",{className:"muted small",children:"Import data with at least two conditions first."}):n.jsx("div",{className:"gif-conds",children:r.map(y=>{const b=f.includes(y.id);return n.jsxs("label",{className:"check small",style:{"--c":y.color},children:[n.jsx("input",{type:"checkbox",checked:b,onChange:()=>d({...c,conditions:b?f.filter(_=>_!==y.id):[...f,y.id]})}),n.jsx("i",{className:"gif-dot"}),y.name]},y.id)})}),n.jsx("div",{className:"muted small",children:"The order follows Data → Conditions (drag to reorder there)."})]}),n.jsxs("div",{className:"row gap",children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Hold (s)"}),n.jsx("input",{className:"input",type:"number",min:.2,step:.1,value:c.hold,onChange:y=>d({...c,hold:+y.target.value})})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Transition"}),n.jsxs("select",{className:"input",value:c.tween,onChange:y=>d({...c,tween:+y.target.value}),children:[n.jsx("option",{value:0,children:"cut"}),n.jsx("option",{value:4,children:"quick"}),n.jsx("option",{value:6,children:"smooth"}),n.jsx("option",{value:10,children:"slow"})]})]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Resolution"}),n.jsx("div",{className:"seg",children:[300,600,900].map(y=>n.jsxs("button",{className:c.dpi===y?"on":"",onClick:()=>d({...c,dpi:y}),children:[y," dpi"]},y))})]}),m&&n.jsxs("div",{className:`muted small ${m.capped?"warn-text":""}`,children:["Frames: ",m.w," × ",m.h," px",m.capped?` — capped at ${E0} px / ${G0/1e6} MP (the figure is large at natural size; pick a journal width above for the full ${c.dpi} dpi)`:"",". Higher resolution = sharper but larger file and slower export."]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:c.label,onChange:y=>d({...c,label:y.target.checked})})," Show condition name"]}),n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:c.loopBack,onChange:y=>d({...c,loopBack:y.target.checked})})," Smooth loop back to the first"]})]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Area"}),n.jsx("div",{className:"seg",children:[["all","Entire figure"],["view","Current view"],["selection","Selection"]].map(([y,b])=>n.jsx("button",{className:(e.area??"all")===y?"on":"",disabled:y==="selection"&&!s,onClick:()=>h({area:y}),children:b},y))})]}),(e.area??"all")==="view"&&n.jsx("div",{className:"muted small",children:"Exports exactly what is framed on the canvas now (close this dialog and pan/zoom to adjust)."}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Size"}),n.jsxs("select",{className:"input",value:i,onChange:y=>{a(y.target.value);const b=du.find(_=>_.id===y.target.value);h({widthMm:b.w,heightMm:b.h})},children:[du.map(y=>n.jsx("option",{value:y.id,children:y.name},y.id)),n.jsx("option",{value:"custom",children:"Custom…"})]})]}),i==="custom"&&n.jsxs("div",{className:"row gap",children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Width (mm)"}),n.jsx("input",{className:"input",type:"number",value:e.widthMm,onChange:y=>h({widthMm:+y.target.value})})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Max height (mm)"}),n.jsx("input",{className:"input",type:"number",value:e.heightMm,onChange:y=>h({heightMm:+y.target.value})})]})]}),e.format==="png"&&n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Resolution"}),n.jsx("div",{className:"seg",children:[150,300,600].map(y=>n.jsxs("button",{className:e.dpi===y?"on":"",onClick:()=>h({dpi:y}),children:[y," dpi"]},y))})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Background"}),n.jsx("div",{className:"seg",children:["white","transparent"].map(y=>n.jsx("button",{className:e.background===y?"on":"",onClick:()=>h({background:y}),children:y},y))})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Margin"}),n.jsx("input",{className:"input",type:"number",value:e.margin,onChange:y=>h({margin:+y.target.value})})]}),n.jsx("div",{className:"muted small",children:"The grid, selection and handles are never exported."}),n.jsxs("div",{className:"row gap end",children:[u!=null&&n.jsxs("span",{className:"small muted",children:["Rendering frames… ",Math.round(u*100),"%"]}),u==null&&o&&n.jsx("span",{className:"small ok",children:o}),n.jsxs("button",{className:"btn primary",onClick:g,disabled:u!=null||e.format==="gif"&&f.length<2,children:[n.jsx(q,{name:"export",size:14})," Export ",e.format.toUpperCase()]})]})]})}const Fg={format:"svg",background:"white",widthMm:0,heightMm:0,dpi:300,margin:16};function L6(){const[e,t]=E.useState("My pathway");return n.jsxs(an,{title:"Save selection as template",onClose:tt,width:420,children:[n.jsxs("p",{className:"small muted",children:["Bound metabolites and reactions are stored as compartment-free hints (e.g. ",n.jsx("span",{className:"mono",children:"g6p"}),", ",n.jsx("span",{className:"mono",children:"PFK"}),"), so the template re-binds automatically to other GEMs."]}),n.jsx("input",{className:"input",autoFocus:!0,value:e,onChange:i=>t(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(V().saveSelectionAsTemplate(e),tt())}}),n.jsx("div",{className:"row end",children:n.jsx("button",{className:"btn primary",onClick:()=>{V().saveSelectionAsTemplate(e),tt()},children:"Save template"})})]})}function T6({datasetId:e}){const t=R(r=>r.datasets.find(c=>c.id===e)),i=R(r=>r.model),[a,s]=E.useState({});if(!t)return null;const o=Math.round((t.matchedFraction??1)*100),l=t.target==="reaction"?i==null?void 0:i.reactions:i==null?void 0:i.metabolites;return n.jsxs(an,{title:`ID matching — ${t.name}`,onClose:tt,width:560,children:[n.jsx("div",{className:"match-bar",children:n.jsx("div",{style:{width:`${o}%`}})}),n.jsxs("div",{className:"row between",children:[n.jsxs("b",{children:[o,"% ",t.target,"s matched"]}),n.jsxs("span",{className:"muted",children:[t.unmatched.length," unmatched"]})]}),i&&o<30&&n.jsxs("div",{className:"notice",children:[n.jsx("b",{children:"This file looks like it was made for a different model."})," Almost none of its IDs (e.g. ",n.jsx("span",{className:"mono",children:t.unmatched.slice(0,3).join(", ")}),") exist in ",n.jsx("b",{children:i.name})," ","(which uses IDs like ",n.jsx("span",{className:"mono",children:Object.keys(t.target==="reaction"?i.reactions:i.metabolites).slice(0,3).join(", ")}),"). Mapping them one by one is rarely worth it — remove this dataset and import the flux table simulated with this model.",n.jsx("div",{className:"row gap",style:{marginTop:8},children:n.jsx("button",{className:"btn small",onClick:()=>{V().removeDataset(t.id),tt()},children:"Remove this dataset"})})]}),t.unmatched.length>0&&i&&n.jsxs("div",{className:"list scroll",children:[t.unmatched.slice(0,200).map(r=>n.jsxs("div",{className:"row gap",children:[n.jsx("span",{className:"mono grow",children:r}),n.jsx("input",{className:"input",list:"model-ids",placeholder:"map to model id…",value:a[r]??"",onChange:c=>s({...a,[r]:c.target.value})}),n.jsx("button",{className:"btn",disabled:!(l!=null&&l[a[r]??""]),onClick:()=>V().remapDatasetId(t.id,r,a[r]),children:"Map"})]},r)),n.jsx("datalist",{id:"model-ids",children:Object.keys(l??{}).slice(0,5e3).map(r=>n.jsx("option",{value:r},r))})]}),!i&&n.jsx("div",{className:"notice",children:"No model loaded — IDs are kept as-is and matched against glyph bindings."}),n.jsx("div",{className:"row end",children:n.jsx("button",{className:"btn primary",onClick:tt,children:"Done"})})]})}function F6(){const e=R(c=>c.model),[t,i]=E.useState(""),[a,s]=E.useState(""),[o,l]=E.useState(!1),r=E.useMemo(()=>Object.keys((e==null?void 0:e.metabolites)??{}),[e]);return n.jsxs(an,{title:"Find metabolic path",onClose:tt,width:440,children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Start"}),n.jsx("input",{className:"input",list:"met-ids",value:t,onChange:c=>i(c.target.value),placeholder:"e.g. glc__D_c"})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"End"}),n.jsx("input",{className:"input",list:"met-ids",value:a,onChange:c=>s(c.target.value),placeholder:"e.g. succ_c"})]}),n.jsx("datalist",{id:"met-ids",children:r.slice(0,5e3).map(c=>n.jsx("option",{value:c},c))}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:c=>l(c.target.checked)})," Allow currency metabolites (ATP, NADH, H₂O…) as links"]}),n.jsx("div",{className:"row end",children:n.jsx("button",{className:"btn primary",disabled:!(e!=null&&e.metabolites[t])||!(e!=null&&e.metabolites[a]),onClick:()=>{V().findPath(t,a,o),tt()},children:"Find fewest-reaction route"})})]})}function X6(){const e=R(i=>i.validation),t=R(i=>i.model);return n.jsxs(an,{title:`Model validation — ${(t==null?void 0:t.name)??""}`,onClose:tt,width:520,children:[!e.length&&n.jsx("div",{className:"ok",children:"No issues found."}),e.map((i,a)=>n.jsxs("details",{className:`issue ${i.level}`,children:[n.jsxs("summary",{children:[n.jsx("span",{className:`tag ${i.level==="error"?"warn":""}`,children:i.level})," ",i.message]}),n.jsxs("div",{className:"mono small muted",children:[i.ids.slice(0,60).join(", "),i.ids.length>60?" …":""]})]},a))]})}function K6(){const e=[["V","Select"],["M","Metabolite (from model)"],["S","Empty slot (template)"],["R","Reaction tool"],["T","Text"],["Space (hold) + drag · right-drag · C","Pan the map"],["P","Add plot to selected reaction(s)"],["Ctrl K","Command palette"],["Ctrl Z / Ctrl Shift Z","Undo / redo"],["Ctrl C / V / D","Copy / paste / duplicate"],["Ctrl G","Group as pathway"],["Ctrl A","Select all"],["Del","Delete"],["L","Lock selection (skipped by clicks; hold 3 s to unlock)"],["Arrows (+Shift)","Nudge 1 (10) units"],["Shift + drag","Constrain to 0° / 45° / 90°"],["Alt + drag","Ignore smart guides"],["F / Shift F","Fit all / fit selection"],["[ / ]","Previous / next condition"],["Double-click canvas","Add metabolite"],["Drag outer ring of a node","Draw reaction (drop on empty = new slot)"],["Double-click label","Edit text"],["Ctrl Alt + / − / 0","Interface size: larger / smaller / 100 %"]];return n.jsx(an,{title:"Keyboard shortcuts",onClose:tt,width:520,children:n.jsx("div",{className:"kbd-grid",children:e.map(([t,i])=>n.jsxs("div",{className:"kbd-row",children:[n.jsx("kbd",{children:t}),n.jsx("span",{children:i})]},t))})})}class Rn extends E.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error(`[GEMsMAP] ${this.props.name} crashed:`,t)}render(){return this.state.error?n.jsxs("div",{className:"panel-error",children:[n.jsxs("b",{children:[this.props.name," hit an error"]}),n.jsx("div",{className:"mono small",children:this.state.error.message}),n.jsx("button",{className:"btn small",onClick:()=>this.setState({error:null}),children:"Try again"}),n.jsx("div",{className:"muted small",children:"Your work is safe (autosaved). Please send this message so it can be fixed."})]}):this.props.children}}function Xg({value:e,options:t,onChange:i,labels:a}){return n.jsx("div",{className:"seg",children:t.map(s=>n.jsx("button",{className:e===s?"on":"",onClick:()=>i(s),children:(a==null?void 0:a[s])??s},s))})}function z6({values:e,unit:t}){const i=R(l=>l.view.activeCondition),a=R(l=>l.conditions),s=l=>{var r;return((r=a.find(c=>c.id===l))==null?void 0:r.name)??l},o=Math.max(1e-9,...e.map(l=>Math.abs(l.v??0)));return n.jsxs("div",{className:"cvals",children:[e.map(l=>n.jsxs("button",{className:`cval ${l.cond===i?"on":""}`,onClick:()=>V().setView({activeCondition:l.cond}),children:[n.jsx("span",{className:"sw",style:{background:l.color}}),n.jsx("span",{className:"cname ellipsis",title:s(l.cond),children:s(l.cond)}),n.jsx("span",{className:"cbar",children:n.jsx("span",{style:{width:`${Math.abs(l.v??0)/o*100}%`,background:l.color}})}),n.jsx("span",{className:"mono",children:jt(l.v)})]},l.cond)),t&&n.jsx("div",{className:"muted small right",children:t})]})}function U6({g:e}){const t=R(p=>p.model),i=R(p=>p.doc),a=t.reactions[e.reactionId],s=new Set([...e.sources,...e.targets].map(p=>{var m;return(m=i.nodes[p])==null?void 0:m.metaboliteId}).filter(Boolean)),o=Object.entries(a.stoichiometry),l=p=>e.reversedToModel?p>0:p<0,r=o.filter(([p])=>!Fa(t.metabolites[p])),c=o.filter(([p])=>Fa(t.metabolites[p])),d=r.filter(([p])=>!s.has(p)).length;if(r.length<=2&&!d&&!c.length)return null;const f=([p,m])=>{var h,g;return n.jsxs("label",{className:"check part-row",title:(h=t.metabolites[p])==null?void 0:h.name,children:[n.jsx("input",{type:"checkbox",checked:s.has(p),onChange:y=>V().setParticipant(e.id,p,y.target.checked)}),n.jsxs("span",{className:"part-text",children:[n.jsxs("span",{className:"mono ellipsis",children:[Math.abs(m)!==1?`${+Math.abs(m).toFixed(3)} `:"",p]}),n.jsx("span",{className:"muted small ellipsis",children:(g=t.metabolites[p])==null?void 0:g.name})]})]},p)},u=(p,m)=>m.filter(([,h])=>l(h)===p);return n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"row between",children:[n.jsx("div",{className:"section-title",children:"Participants shown"}),n.jsxs("span",{className:"muted small",children:[r.length-d,"/",r.length,d?` · ${d} hidden`:""]})]}),n.jsxs("div",{className:"part-cols",children:[n.jsxs("div",{children:[n.jsx("div",{className:"muted small",children:"Substrates"}),u(!0,r).map(f)]}),n.jsxs("div",{children:[n.jsx("div",{className:"muted small",children:"Products"}),u(!1,r).map(f)]})]}),c.length>0&&n.jsxs("details",{className:"adv",children:[n.jsxs("summary",{children:["Cofactors / currency (",c.length,")"]}),n.jsxs("div",{className:"part-cols",children:[n.jsx("div",{children:u(!0,c).map(f)}),n.jsx("div",{children:u(!1,c).map(f)})]})]}),n.jsx("div",{className:"muted small",children:"Unticking hides the metabolite from this arrow only; the model reaction is unchanged."})]})}const q6={entry:"Net flux leaving the start metabolite into the hidden segment. Equals the sum for parallel reactions and the through-flux of a chain.",sum:"Sum of all hidden reactions. Right for parallel/alternative reactions; double-counts along a chain.",mean:"Mean of the hidden reactions.",min:"Smallest |flux|: the bottleneck of a chain.",max:"Largest |flux|."};function V6({g:e,plots:t}){const i=e.collapsed,a=R(u=>u.model),s=R(u=>u.datasets),o=R(u=>u.conditions),l=R(u=>u.view),r=R(u=>u.doc),c=V(),d=s.find(u=>u.target==="reaction"&&u.kind==="flux"&&u.visible)??s.find(u=>u.target==="reaction"),f=u=>{const p=r.nodes[u];return(p==null?void 0:p.label)??(p!=null&&p.metaboliteId?bt(p.metaboliteId):"?")};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsxs("div",{className:"insp-kind",children:["Collapsed arrow · ",i.topology]}),n.jsx("div",{className:"insp-title",children:e.label??`${i.members.length} reactions`}),n.jsxs("div",{className:"muted small",children:[e.sources.map(f).join(" + ")," → ",e.targets.map(f).join(" + ")," · ",i.hidden.nodes.length," hidden metabolites"]}),n.jsxs("button",{className:"btn primary small insp-action",onClick:()=>c.expandGlyph(e.id),children:[n.jsx(q,{name:"expandDown",size:13})," Expand back"]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Flux of the arrow"}),n.jsx(Xg,{value:i.aggregate,options:["entry","sum","mean","min","max"],onChange:u=>c.updateReaction(e.id,{collapsed:{...i,aggregate:u}}),labels:{entry:"net in"}}),n.jsx("div",{className:"muted small",children:q6[i.aggregate]}),d&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"bignum",children:[jt(ca(d,e,l.activeCondition))," ",n.jsx("span",{className:"muted small",children:d.unit})]}),n.jsx(z6,{values:Wc(d,o).map(u=>{var p;return{cond:u,color:((p=o.find(m=>m.id===u))==null?void 0:p.color)??"#888",v:ca(d,e,u)}})})]})]}),n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Hidden reactions (",i.members.length,")"]}),n.jsx("div",{className:"members",children:i.members.map((u,p)=>{var h;const m=d?Hs(d,u.reactionId,l.activeCondition):null;return n.jsxs("div",{className:"member",title:(h=a==null?void 0:a.reactions[u.reactionId])==null?void 0:h.name,children:[n.jsx("span",{className:"mono",children:u.reactionId}),u.entry&&n.jsx("span",{className:"tag",children:"entry"}),u.sign<0&&n.jsx("span",{className:"tag warn",children:"reversed"}),n.jsx("span",{className:"mono grow right",children:jt(m==null?null:m*u.sign)})]},u.reactionId+p)})})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Label"}),n.jsx("input",{className:"input",placeholder:`${i.members.length} reactions`,value:e.label??"",onChange:u=>c.updateReaction(e.id,{label:u.target.value||void 0})})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{children:"Routing"}),n.jsx(Xg,{value:e.routing,options:["straight","curved","orthogonal"],onChange:u=>c.updateReaction(e.id,{routing:u,bend:void 0})})]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:i.showBadge,onChange:u=>c.updateReaction(e.id,{collapsed:{...i,showBadge:u.target.checked}})})," Show the reaction-count badge (exported)"]}),n.jsxs("div",{className:"row gap wrap",children:[["density","bar","line","heatmap"].map(u=>n.jsxs("button",{className:"btn small",onClick:()=>c.addPlot({kind:"reaction",id:e.id},u),children:["+ ",u]},u)),n.jsxs("span",{className:"muted small",children:[t," linked"]})]})]})]})}function W6({rid:e,model:t,metId:i,onCanvas:a,open:s,onToggle:o,onAction:l}){var m;const r=E.useRef(null),[c,d]=E.useState(null),f=t.reactions[e];if(E.useEffect(()=>{var b;if(!s||!r.current){d(null);return}const h=r.current.getBoundingClientRect(),g=(b=r.current.closest(".panel"))==null?void 0:b.getBoundingClientRect();d({right:window.innerWidth-((g==null?void 0:g.left)??h.left)+10,top:Math.max(8,Math.min(h.top-12,window.innerHeight-Zr(260)))});const y=_=>{_.key==="Escape"&&o()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s,o]),!f)return null;const u=i?f.stoichiometry[i]:void 0,p=u==null?"":u<0?f.reversible?"consumes (reversible)":"consumes":f.reversible?"produces (reversible)":"produces";return n.jsxs(n.Fragment,{children:[n.jsxs("button",{ref:r,className:`chip btn-chip ${a?"on":""} ${s?"open":""} ${u!=null&&u<0?"out":"in"}`,title:f.name,onClick:o,children:[n.jsx("span",{className:"chip-dir",children:u==null?"":u<0?"↓":"↑"}),e]}),s&&c&&Pp.createPortal(n.jsxs("div",{className:"rx-tip",style:{right:c.right,top:c.top},onPointerDown:h=>h.stopPropagation(),children:[n.jsxs("div",{className:"rx-tip-head",children:[n.jsx("b",{className:"mono",children:e}),f.reversible&&n.jsx("span",{className:"tag",children:"reversible"}),a&&n.jsx("span",{className:"tag on",children:"on map"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"icon-btn tiny",onClick:o,title:"Close (Esc)",children:"×"})]}),n.jsx("div",{className:"rx-tip-name",children:f.name}),n.jsx("div",{className:"rx-tip-eq",children:zr(f,t.metabolites,!0)}),n.jsx("div",{className:"rx-tip-eq mono muted",children:zr(f,t.metabolites)}),p&&n.jsxs("div",{className:"small",children:["This metabolite: ",n.jsx("b",{children:p})]}),f.subsystem&&n.jsxs("div",{className:"small muted",children:["Subsystem: ",f.subsystem]}),f.gpr&&n.jsxs("div",{className:"small muted mono",children:["GPR: ",f.gpr]}),n.jsxs("div",{className:"small muted",children:["Bounds: ",f.lowerBound," → ",f.upperBound,(m=f.ec)!=null&&m.length?` · EC ${f.ec.join(", ")}`:""]}),n.jsx("button",{className:"btn primary small",onClick:()=>{o(),l()},children:a?"Select on the map":"Add to the map"})]}),document.body)]})}function Y6(){const e=Kn("map-right",288,220,640),t=pl("map-inspector"),i=R(l=>l.rightOpen),a=R(l=>l.selection),s=R(l=>l.doc);if(!i)return null;let o;if(a.length===1){const[l,r]=Oe(a[0]);l==="node"&&s.nodes[r]?o=n.jsx(Z6,{n:s.nodes[r]}):l==="reaction"&&s.reactions[r]?o=n.jsx(Q6,{g:s.reactions[r]}):l==="plot"&&s.plots[r]?o=n.jsx(J6,{p:s.plots[r]}):l==="text"&&s.texts[r]?o=n.jsx(F_,{t:s.texts[r]}):l==="group"&&s.groups[r]?o=n.jsx(X_,{g:s.groups[r]}):l==="legend"?o=n.jsx(eE,{}):o=n.jsx(Kg,{})}else a.length>1?o=n.jsx(K_,{}):o=n.jsx(Kg,{});return n.jsxs("aside",{className:"panel right",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"left"}),n.jsx(Fc,{api:t}),n.jsx("div",{className:"panel-scroll",ref:t.ref,children:o})]})}function Ee({label:e,children:t}){return n.jsxs("label",{className:"field",children:[n.jsx("span",{children:e}),t]})}function li({value:e,options:t,onChange:i,labels:a}){return n.jsx("div",{className:"seg",children:t.map(s=>n.jsx("button",{className:e===s?"on":"",onClick:()=>i(s),children:(a==null?void 0:a[s])??s},s))})}function Da({k:e,v:t,mono:i}){return n.jsxs("div",{className:"kv",children:[n.jsx("span",{children:e}),n.jsx("span",{className:i?"mono":"",children:t??"—"})]})}function T_({values:e,unit:t}){const i=R(l=>l.view.activeCondition),a=R(l=>l.conditions),s=l=>{var r;return((r=a.find(c=>c.id===l))==null?void 0:r.name)??l},o=Math.max(1e-9,...e.map(l=>Math.abs(l.v??0)));return n.jsxs("div",{className:"cvals",children:[e.map(l=>n.jsxs("button",{className:`cval ${l.cond===i?"on":""}`,onClick:()=>V().setView({activeCondition:l.cond}),children:[n.jsx("span",{className:"sw",style:{background:l.color}}),n.jsx("span",{className:"cname ellipsis",title:s(l.cond),children:s(l.cond)}),n.jsx("span",{className:"cbar",children:n.jsx("span",{style:{width:`${Math.abs(l.v??0)/o*100}%`,background:l.color}})}),n.jsx("span",{className:"mono",children:jt(l.v)})]},l.cond)),t&&n.jsx("div",{className:"muted small right",children:t})]})}function Z6({n:e}){var _,x;const t=R(v=>v.model),i=R(v=>v.datasets),a=R(v=>v.conditions),s=R(v=>v.doc),o=R(v=>v.style),l=V(),r=e.metaboliteId?t==null?void 0:t.metabolites[e.metaboliteId]:void 0,c=r&&t?Gc(t).get(r.id)??[]:[],[d,f]=E.useState(!1),[u,p]=E.useState(null),m=R(v=>v.hideZeroReactions),h=i.find(v=>v.visible&&v.target==="reaction"&&(v.kind==="flux"||v.kind==="samples")),g=v=>!h||h.columns.every((j,N)=>Math.abs(Ec(h,v,N)??0)<1e-9),y=h&&m?c.filter(v=>!g(v)):c,b=new Map;for(const v of Object.values(s.reactions))for(const j of[v.reactionId,...v.lumped??[],...((_=v.collapsed)==null?void 0:_.members.map(N=>N.reactionId))??[]])j&&b.set(j,v.id);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:r?"Metabolite":"Template slot"}),n.jsx("div",{className:"insp-title",children:(r==null?void 0:r.name)??e.label??"Unbound slot"}),r&&n.jsx(m_,{r:{kind:"metabolite",id:r.id}}),r&&n.jsx("div",{className:"mono muted",children:r.id})]}),e.template&&n.jsx(x6,{n:e}),!r&&!e.template&&n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"muted small",children:["This slot isn't bound to a model metabolite. ",(x=e.hints)!=null&&x.length?n.jsxs(n.Fragment,{children:["Hints: ",n.jsx("span",{className:"mono",children:e.hints.slice(0,4).join(", ")})]}):null]}),t&&n.jsxs("button",{className:"btn primary small",onClick:()=>R.setState({dialog:{kind:"metabolite",at:e,bindNodeId:e.id}}),children:[n.jsx(q,{name:"link",size:13})," Bind to metabolite…"]})]}),r&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Details"}),n.jsx(Da,{k:"Formula",v:r.formula,mono:!0}),n.jsx(Da,{k:"Charge",v:r.charge}),n.jsx(Da,{k:"Compartment",v:(t==null?void 0:t.compartments[r.compartment])??r.compartment}),Fa(r)&&n.jsx("div",{className:"tag",children:"currency metabolite"})]}),r&&i.filter(v=>v.target==="metabolite").map(v=>n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:v.name}),n.jsx(T_,{unit:v.unit,values:Wc(v,a).map(j=>{var N;return{cond:j,color:((N=a.find(C=>C.id===j))==null?void 0:N.color)??"#888",v:Hs(v,r.id,j)}})})]},v.id)),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),n.jsx(z_,{mode:e.labelMode,custom:e.label,idText:e.metaboliteId??e.label??"—",nameText:(r==null?void 0:r.name)??"—",globalText:o.metaboliteLabel,onMode:v=>l.updateNode(e.id,{labelMode:v,label:v==="custom"&&!e.label?(r==null?void 0:r.name)??e.metaboliteId:e.label}),onCustom:v=>l.updateNode(e.id,{label:v||void 0,labelMode:"custom"})}),n.jsx(Ee,{label:"Label position",children:n.jsx(li,{value:e.labelPos??"right",options:["left","top","right","bottom","none"],onChange:v=>l.updateNode(e.id,{labelPos:v}),labels:{left:"←",top:"↑",right:"→",bottom:"↓",none:"∅"}})}),n.jsx(Ee,{label:"Radius",children:n.jsx("input",{className:"input",type:"number",min:1,value:e.r??o.nodeRadius,onChange:v=>l.updateNode(e.id,{r:+v.target.value})})}),n.jsx(Ee,{label:"Style",children:n.jsx(li,{value:e.shape==="label"?"text":e.role??"normal",options:["normal","exchange","text"],onChange:v=>l.updateNode(e.id,v==="text"?{shape:"label",role:"normal"}:{shape:"circle",role:v}),labels:{text:"text only"}})}),n.jsxs(Ee,{label:"Fill",children:[n.jsx("input",{type:"color",value:e.fill??"#111111",onChange:v=>l.updateNode(e.id,{fill:v.target.value})})," ",e.fill&&n.jsx("button",{className:"link",onClick:()=>l.updateNode(e.id,{fill:void 0}),children:"reset"})]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:!!e.locked,onChange:v=>l.updateNode(e.id,{locked:v.target.checked})})," Locked"]})]}),r&&n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Connected reactions (",y.length===c.length?c.length:`${y.length} of ${c.length}`,")"]}),n.jsx("div",{className:"muted small",children:"↓ consumes · ↑ produces · click a reaction for details"}),h&&n.jsxs("label",{className:"check small",title:`Hide reactions whose flux is zero (or missing) in every condition of “${h.name}”`,children:[n.jsx("input",{type:"checkbox",checked:m,onChange:v=>R.setState({hideZeroReactions:v.target.checked})})," Hide zero-flux reactions"]}),n.jsxs("div",{className:"chips",children:[y.slice(0,d?void 0:48).map(v=>n.jsx(W6,{rid:v,model:t,metId:r.id,onCanvas:b.has(v),open:u===v,onToggle:()=>p(j=>j===v?null:v),onAction:()=>b.has(v)?R.setState({selection:[`reaction:${b.get(v)}`]}):l.addConnectedReaction(e.id,v)},v)),!d&&y.length>48&&n.jsxs("button",{className:"link small",onClick:()=>f(!0),children:["+",y.length-48," more"]}),!y.length&&c.length>0&&n.jsxs("div",{className:"muted small",children:["All ",c.length," reactions carry zero flux."]})]}),n.jsxs("div",{className:"row gap",children:[n.jsxs("button",{className:"btn small",onClick:()=>l.expandNode(e.id,"up",1),children:[n.jsx(q,{name:"expandUp",size:13})," Upstream"]}),n.jsxs("button",{className:"btn small",onClick:()=>l.expandNode(e.id,"down",1),children:[n.jsx(q,{name:"expandDown",size:13})," Downstream"]})]})]})]})}function Q6({g:e}){var y,b,_,x,v;const t=R(j=>j.model),i=R(j=>j.datasets),a=R(j=>j.conditions),s=R(j=>j.view),o=R(j=>j.doc),l=V(),r=e.reactionId?t==null?void 0:t.reactions[e.reactionId]:void 0,c=i.find(j=>j.target==="reaction"&&j.kind==="flux"&&j.visible)??i.find(j=>j.target==="reaction"),d=c?ca(c,e,s.activeCondition):null,f=Object.values(o.plots).filter(j=>j.anchor.id===e.id),u=(y=o.nodes[e.sources[0]])==null?void 0:y.metaboliteId,p=(b=o.nodes[e.targets[0]])==null?void 0:b.metaboliteId,m=!!t&&!!u&&!!p&&!!t.metabolites[u]&&!!t.metabolites[p],h=()=>R.setState({dialog:{kind:"routes",from:e.sources[0],to:e.targets[0],replaceGlyph:e.id}}),g=e.reactionId?Object.values(o.reactions).filter(j=>j.id!==e.id&&j.reactionId===e.reactionId&&!j.collapsed).length:0;return e.collapsed?n.jsx(V6,{g:e,plots:f.length}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsxs("div",{className:"insp-kind",children:["Reaction",e.lumped?" (lumped)":""]}),n.jsx("div",{className:"insp-title",children:e.lumped?e.lumped.join(" + "):e.reactionId??e.label??"Free arrow"}),r&&n.jsx("div",{className:"muted",children:r.name}),r&&n.jsx(m_,{r:{kind:"reaction",id:r.id}})]}),r&&t&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Equation"}),n.jsx("div",{className:"eq mono",children:zr(r,t.metabolites)}),e.reversedToModel&&n.jsx("div",{className:"tag warn",children:"drawn opposite to model direction — flux sign flipped for display"})]}),!r&&n.jsxs("div",{className:"section small",children:[n.jsxs("div",{className:"muted",children:["Not bound to a model reaction.",(_=e.hints)!=null&&_.length?n.jsxs(n.Fragment,{children:[" Hints: ",n.jsx("span",{className:"mono",children:e.hints.join(", ")})]}):null]}),m?n.jsxs("button",{className:"btn primary small",onClick:h,children:[n.jsx(q,{name:"path",size:13})," Find routes ",u," → ",p," in the model…"]}):t&&n.jsx("div",{className:"muted",children:"Bind both endpoints to metabolites to search routes or auto-bind."})]}),g>0&&n.jsxs("div",{className:"section callout small",children:[n.jsxs("div",{children:[n.jsx("b",{children:g+1})," arrows draw ",e.reactionId,"."]}),n.jsx("button",{className:"btn small",onClick:()=>l.mergeDuplicates(e.reactionId),children:"Merge into one arrow"})]}),r&&t&&!e.lumped&&n.jsx(U6,{g:e}),c&&r&&n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Flux · ",((x=a.find(j=>j.id===s.activeCondition))==null?void 0:x.name)??s.activeCondition]}),n.jsxs("div",{className:"bignum",children:[jt(d)," ",n.jsx("span",{className:"muted small",children:c.unit})]}),n.jsx(T_,{values:Wc(c,a).map(j=>{var N;return{cond:j,color:((N=a.find(C=>C.id===j))==null?void 0:N.color)??"#888",v:ca(c,e,j)}})}),i.filter(j=>j.kind==="fva"&&j.columns.some((N,C)=>Wm(j,r.id,C))).map(j=>n.jsxs("div",{className:"small",children:["FVA (",j.name,"): ",w0(j,a).map(N=>{const C=j.columns[N],w=Wm(j,r.id,N);return w?`${C} [${jt(w[0])}, ${jt(w[1])}]`:null}).filter(Boolean).join(" · ")]},j.id))]}),r&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Details"}),n.jsx(Da,{k:"Bounds",v:`${r.lowerBound} → ${r.upperBound}`,mono:!0}),n.jsx(Da,{k:"Genes",v:r.gpr,mono:!0}),n.jsx(Da,{k:"Subsystem",v:r.subsystem}),r.ec&&n.jsx(Da,{k:"EC",v:r.ec.join(", "),mono:!0})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),n.jsx(z_,{mode:e.labelMode,custom:e.label,idText:((v=e.lumped)==null?void 0:v.join(" + "))??e.reactionId??"—",nameText:(r==null?void 0:r.name)??"—",globalText:R.getState().style.reactionLabel,onMode:j=>l.updateReaction(e.id,{labelMode:j,label:j==="custom"&&!e.label?(r==null?void 0:r.name)??e.reactionId:e.label}),onCustom:j=>l.updateReaction(e.id,{label:j||void 0,labelMode:"custom"})}),n.jsx(Ee,{label:"Routing",children:n.jsx(li,{value:e.routing,options:["straight","curved","orthogonal"],onChange:j=>l.updateReaction(e.id,{routing:j,bend:void 0})})}),e.routing==="curved"&&n.jsx(Ee,{label:"Curvature",children:n.jsx("input",{type:"range",min:-80,max:80,value:e.bend??0,onChange:j=>l.updateReaction(e.id,{bend:+j.target.value})})}),n.jsx(Ee,{label:"Line",children:n.jsx(li,{value:e.role??"normal",options:["normal","exchange"],onChange:j=>l.updateReaction(e.id,{role:j}),labels:{normal:"solid",exchange:"dashed"}})}),n.jsxs("div",{className:"row gap",children:[n.jsxs("button",{className:"btn small",onClick:()=>l.reverseReaction(e.id),children:[n.jsx(q,{name:"swap",size:13})," Reverse"]}),n.jsx("button",{className:"btn small",onClick:()=>l.updateReaction(e.id,{labelFlip:!e.labelFlip,labelOffset:void 0,labelAngle:void 0}),children:"Flip label"}),(e.labelOffset||e.labelAngle)&&n.jsx("button",{className:"btn small",onClick:()=>l.updateReaction(e.id,{labelOffset:void 0,labelAngle:void 0}),children:"Auto label position"})]})]}),r&&m&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Routes"}),n.jsxs("button",{className:"btn small",onClick:h,children:[n.jsx(q,{name:"path",size:13})," Alternative routes ",u," → ",p,"…"]})]}),n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Linked plots (",f.length,")"]}),n.jsx("div",{className:"row gap wrap",children:["density","bar","line","heatmap","box","range"].map(j=>n.jsxs("button",{className:"btn small",onClick:()=>l.addPlot({kind:"reaction",id:e.id},j),children:["+ ",j]},j))})]})]})}function J6({p:e}){const t=R(a=>a.datasets),i=V();return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Mini-plot"}),n.jsx("div",{className:"insp-title",children:e.type}),n.jsxs("div",{className:"muted small",children:["linked to ",e.anchor.kind," — moves with it"]})]}),n.jsxs("div",{className:"section",children:[n.jsx(Ee,{label:"Type",children:n.jsx("select",{className:"input",value:e.type,onChange:a=>i.updatePlot(e.id,{type:a.target.value}),children:["density","bar","line","heatmap","box","range"].map(a=>n.jsx("option",{children:a},a))})}),n.jsx(Ee,{label:"Dataset",children:n.jsxs("select",{className:"input",value:e.datasetId??"",onChange:a=>i.updatePlot(e.id,{datasetId:a.target.value||void 0}),children:[n.jsx("option",{value:"",children:"auto (best match)"}),t.map(a=>n.jsxs("option",{value:a.id,children:[a.name," (",a.kind,")"]},a.id))]})}),n.jsx(Ee,{label:"Title",children:n.jsx("input",{className:"input",placeholder:"auto: substrate → product",value:e.title??"",onChange:a=>i.updatePlot(e.id,{title:a.target.value||void 0})})}),n.jsxs(Ee,{label:"Font size",children:[n.jsx("input",{type:"range",min:4,max:16,step:.5,value:e.fontSize??7,onChange:a=>i.updatePlot(e.id,{fontSize:+a.target.value})}),n.jsx("span",{className:"mono small",children:e.fontSize??7})]}),n.jsx("div",{className:"muted small",children:"Drag the handles on the selected plot to resize it (Shift on a corner keeps the proportions)."}),n.jsxs("div",{className:"row gap",children:[n.jsx(Ee,{label:"W",children:n.jsx("input",{className:"input",type:"number",value:e.w,onChange:a=>i.updatePlot(e.id,{w:Math.max(40,+a.target.value)})})}),n.jsx(Ee,{label:"H",children:n.jsx("input",{className:"input",type:"number",value:e.h,onChange:a=>i.updatePlot(e.id,{h:Math.max(30,+a.target.value)})})})]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:e.showConnector,onChange:a=>i.updatePlot(e.id,{showConnector:a.target.checked})})," Connector line"]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:e.showAxis,onChange:a=>i.updatePlot(e.id,{showAxis:a.target.checked})})," Axis"]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:!!e.locked,onChange:a=>i.updatePlot(e.id,{locked:a.target.checked})})," Locked"]})]})]})}function F_({t:e}){const t=V();return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"insp-head",children:n.jsx("div",{className:"insp-kind",children:e.kind==="panel"?"Panel label":"Text"})}),n.jsxs("div",{className:"section",children:[n.jsx(Ee,{label:"Text",children:n.jsx("textarea",{className:"input",value:e.text,onChange:i=>t.updateText(e.id,{text:i.target.value})})}),n.jsxs("div",{className:"row gap",children:[n.jsx(Ee,{label:"Size",children:n.jsx("input",{className:"input",type:"number",value:e.size,onChange:i=>t.updateText(e.id,{size:+i.target.value})})}),n.jsx(Ee,{label:"Weight",children:n.jsx("select",{className:"input",value:e.weight,onChange:i=>t.updateText(e.id,{weight:+i.target.value}),children:[400,500,600,700].map(i=>n.jsx("option",{children:i},i))})})]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:!!e.italic,onChange:i=>t.updateText(e.id,{italic:i.target.checked})})," Italic"]}),n.jsx(Ee,{label:"Colour",children:n.jsx("input",{type:"color",value:e.color??"#111111",onChange:i=>t.updateText(e.id,{color:i.target.value})})}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:!!e.locked,onChange:i=>t.updateText(e.id,{locked:i.target.checked})})," Locked"]})]})]})}function X_({g:e}){const t=V();return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:e.kind==="compartment"?"Compartment":"Pathway group"}),n.jsx("div",{className:"insp-title",children:e.title}),n.jsxs("div",{className:"muted small",children:[e.nodeIds.length," metabolites"]})]}),n.jsxs("div",{className:"section",children:[n.jsx(Ee,{label:"Title",children:n.jsx("input",{className:"input",value:e.title,onChange:i=>t.updateGroup(e.id,{title:i.target.value})})}),n.jsx(Ee,{label:"Subtitle",children:n.jsx("input",{className:"input",value:e.subtitle??"",onChange:i=>t.updateGroup(e.id,{subtitle:i.target.value||void 0})})}),n.jsx(Ee,{label:"Kind",children:n.jsx(li,{value:e.kind,options:["pathway","compartment"],onChange:i=>t.updateGroup(e.id,{kind:i})})}),n.jsxs(Ee,{label:"Background",children:[n.jsx("input",{type:"color",value:e.fill==="none"?"#ffffff":e.fill,onChange:i=>t.updateGroup(e.id,{fill:i.target.value})})," ",n.jsx("button",{className:"link",onClick:()=>t.updateGroup(e.id,{fill:"none"}),children:"none"})]}),n.jsxs(Ee,{label:"Border",children:[n.jsx("input",{type:"color",value:e.stroke==="none"?"#cccccc":e.stroke,onChange:i=>t.updateGroup(e.id,{stroke:i.target.value})})," ",n.jsx("button",{className:"link",onClick:()=>t.updateGroup(e.id,{stroke:"none"}),children:"none"})]}),n.jsx(Ee,{label:"Padding",children:n.jsx("input",{className:"input",type:"number",value:e.padding,onChange:i=>t.updateGroup(e.id,{padding:+i.target.value})})}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:e.dashed,onChange:i=>t.updateGroup(e.id,{dashed:i.target.checked})})," Dashed boundary"]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:!!e.hidden,onChange:i=>t.updateGroup(e.id,{hidden:i.target.checked})})," Hidden"]}),n.jsxs("label",{className:"check",title:"Clicks and box selection go through to the reactions inside. Hold 3 s or right-click to unlock.",children:[n.jsx("input",{type:"checkbox",checked:!!e.locked,onChange:i=>t.updateGroup(e.id,{locked:i.target.checked})})," Locked (select what is inside)"]}),n.jsx("button",{className:"btn small",onClick:()=>t.ungroup(),children:"Ungroup"})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Frame"}),e.box?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"muted small",children:["Free frame — drag its handles to resize it; the ",e.nodeIds.length," metabolites inside belong to it, and moving the frame moves them too."]}),n.jsx("button",{className:"btn small",onClick:()=>t.fitGroupToMembers(e.id),title:"Let the frame follow its metabolites again",children:"Fit frame to its metabolites"})]}):n.jsx("div",{className:"muted small",children:"The frame follows its metabolites. Drag a handle of the selected frame to size it freely."})]})]})}function eE(){const e=R(t=>t.doc.legend);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Legend"}),n.jsx("div",{className:"muted small",children:"Generated from the active mappings."})]}),n.jsxs("div",{className:"section",children:[n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:e.visible,onChange:t=>V().commit(i=>({doc:{...i.doc,legend:{...i.doc.legend,visible:t.target.checked}}}))})," Show legend"]}),n.jsx(Ee,{label:`Size ${Math.round((e.scale??1)*100)}%`,children:n.jsx("input",{type:"range",min:40,max:300,step:5,value:Math.round((e.scale??1)*100),onChange:t=>V().commit(i=>({doc:{...i.doc,legend:{...i.doc.legend,scale:+t.target.value/100}}}))})}),n.jsx("div",{className:"muted small",children:"Or drag a corner of the selected legend."})]})]})}function K_(){const e=R(o=>o.selection),t=R(o=>o.layoutSpacing),i=V(),a=i.selectedNodeIds(),s=i.selectedIds("reaction");return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Selection"}),n.jsxs("div",{className:"insp-title",children:[e.length," items"]}),n.jsxs("div",{className:"muted small",children:[a.length," metabolites · ",s.length," reactions"]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Layout"}),n.jsxs(Ee,{label:"Spacing",children:[n.jsx("input",{type:"range",min:30,max:160,step:10,value:t,onChange:o=>R.setState({layoutSpacing:+o.target.value})}),n.jsx("span",{className:"mono small",children:t})]}),n.jsx("div",{className:"layout-grid",children:[["vertical","Vertical"],["horizontal","Horizontal"],["circle","Circle"],["hierarchical","Hierarchy"],["grid","Grid"],["organic","Organic"]].map(([o,l])=>n.jsxs("button",{className:"btn small",onClick:()=>i.layoutSelection(o),children:[n.jsx(q,{name:o==="hierarchical"?"hier":o==="grid"?"gridLayout":o,size:14})," ",l]},o))}),n.jsxs("details",{className:"adv",children:[n.jsx("summary",{children:"Circle options"}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small",onClick:()=>i.layoutSelection("circle",{clockwise:!0}),children:"Clockwise"}),n.jsx("button",{className:"btn small",onClick:()=>i.layoutSelection("circle",{clockwise:!1}),children:"Counter-clockwise"}),n.jsx("button",{className:"btn small",onClick:()=>i.layoutSelection("circle",{startAngle:0}),children:"Start east"}),n.jsx("button",{className:"btn small",onClick:()=>i.layoutSelection("circle",{radius:120}),children:"Ø 240"})]})]}),n.jsxs("button",{className:"btn small block",onClick:()=>i.tidySelection(),children:[n.jsx(q,{name:"tidy",size:14})," Tidy selection"]}),n.jsxs("button",{className:"btn small block",title:"Hide the selected arrows (or everything drawn between 2 selected metabolites) inside one summary arrow",onClick:()=>i.collapseSelection(),children:[n.jsx(q,{name:"group",size:14})," Collapse into one arrow"]})]}),a.length>0&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Metabolite labels"}),n.jsx("div",{className:"seg",children:["global","id","name"].map(o=>n.jsx("button",{onClick:()=>i.updateNodes(a,{labelMode:o==="global"?void 0:o}),children:o==="global"?"global":o==="id"?"ID":"name"},o))}),n.jsx(li,{value:"right",options:["left","top","right","bottom","none"],onChange:o=>i.updateNodes(a,{labelPos:o}),labels:{left:"←",top:"↑",right:"→",bottom:"↓",none:"∅"}})]}),s.length>0&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Reactions"}),n.jsx(li,{value:"straight",options:["straight","curved","orthogonal"],onChange:o=>i.updateReactions(s,{routing:o,bend:void 0})}),n.jsx("button",{className:"btn small",onClick:()=>i.addPlotsForSelection("density"),children:"+ density plot for each"})]})]})}function Kg(){const e=R(l=>l.style),t=R(l=>l.canvas),i=R(l=>l.name),a=R(l=>l.layoutSpacing),s=R(l=>l.doc.legend),o=V();return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Figure"}),n.jsx("input",{className:"input title-input",value:i,onChange:l=>R.setState({name:l.target.value})})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Style preset"}),n.jsx("div",{className:"preset-grid",children:Object.keys(Ot).map(l=>n.jsxs("button",{className:`preset ${e.preset===l?"on":""}`,onClick:()=>o.setStyle({preset:l}),children:[n.jsxs("span",{className:"preset-sw",style:{background:Ot[l].background,borderColor:Ot[l].groupStroke},children:[n.jsx("i",{style:{background:Ot[l].nodeFill,boxShadow:Ot[l].nodeStrokeWidth?`0 0 0 1.5px ${Ot[l].nodeStroke}`:void 0}}),n.jsx("b",{style:{background:Ot[l].edge}}),n.jsx("i",{style:{background:Ot[l].nodeFill}})]}),Ot[l].name]},l))}),n.jsx("div",{className:"muted small",children:"Presets change appearance only — never the data."})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Labels"}),n.jsx(Ee,{label:"Metabolites",children:n.jsx(li,{value:e.metaboliteLabel,options:["id","name","none"],onChange:l=>o.setStyle({metaboliteLabel:l})})}),n.jsx(Ee,{label:"Reactions",children:n.jsx(li,{value:e.reactionLabel,options:["id","name","none"],onChange:l=>o.setStyle({reactionLabel:l})})}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:e.showFluxValues,onChange:l=>o.setStyle({showFluxValues:l.target.checked})})," Show flux values"]}),n.jsx(Ee,{label:"Cofactors",children:n.jsx(li,{value:e.currency,options:["hide","inline"],onChange:l=>o.setStyle({currency:l}),labels:{hide:"hidden",inline:"inline text"}})}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:s.visible,onChange:l=>o.commit(r=>({doc:{...r.doc,legend:{...r.doc.legend,visible:l.target.checked}}}))})," Legend"]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Sizes"}),n.jsxs(Ee,{label:"Node radius",children:[n.jsx("input",{type:"range",min:2,max:16,step:.5,value:e.nodeRadius,onChange:l=>o.setStyle({nodeRadius:+l.target.value})}),n.jsx("span",{className:"mono small",children:e.nodeRadius})]}),n.jsxs(Ee,{label:"Edge width",children:[n.jsx("input",{type:"range",min:.4,max:4,step:.1,value:e.baseEdgeWidth,onChange:l=>o.setStyle({baseEdgeWidth:+l.target.value})}),n.jsx("span",{className:"mono small",children:e.baseEdgeWidth})]}),n.jsxs(Ee,{label:"Font size",children:[n.jsx("input",{type:"range",min:6,max:18,step:.5,value:e.fontSize,onChange:l=>o.setStyle({fontSize:+l.target.value})}),n.jsx("span",{className:"mono small",children:e.fontSize})]}),n.jsxs(Ee,{label:"Reaction labels",children:[n.jsx("input",{type:"range",min:5,max:16,step:.5,value:e.reactionLabelSize??e.fontSize-1,onChange:l=>o.setStyle({reactionLabelSize:+l.target.value})}),n.jsx("span",{className:"mono small",children:e.reactionLabelSize??e.fontSize-1})]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Canvas"}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:t.showGrid,onChange:l=>o.setCanvas({showGrid:l.target.checked})})," Show grid"]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:t.snap,onChange:l=>o.setCanvas({snap:l.target.checked})})," Snap to grid"]}),n.jsxs("label",{className:"check",children:[n.jsx("input",{type:"checkbox",checked:t.smartGuides,onChange:l=>o.setCanvas({smartGuides:l.target.checked})})," Smart alignment guides"]}),n.jsx(Ee,{label:"Grid size",children:n.jsx("input",{className:"input",type:"number",min:2,value:t.gridSize,onChange:l=>o.setCanvas({gridSize:Math.max(2,+l.target.value)})})}),n.jsxs(Ee,{label:"Layout spacing",children:[n.jsx("input",{type:"range",min:30,max:160,step:10,value:a,onChange:l=>R.setState({layoutSpacing:+l.target.value})}),n.jsx("span",{className:"mono small",children:a})]})]})]})}function z_({mode:e,custom:t,idText:i,nameText:a,globalText:s,onMode:o,onCustom:l}){const r=e??"global";return n.jsxs(n.Fragment,{children:[n.jsx(Ee,{label:"Label shows",children:n.jsx("div",{className:"seg",children:["global","id","name","custom"].map(c=>n.jsx("button",{className:r===c?"on":"",title:c==="global"?`Follow the global Labels setting (${s})`:c==="id"?i:c==="name"?a:"Your own text",onClick:()=>o(c==="global"?void 0:c),children:c==="global"?"global":c==="id"?"ID":c==="name"?"name":"mine"},c))})}),r==="custom"?n.jsx(Ee,{label:"My label",children:n.jsx("input",{className:"input",autoFocus:!0,value:t??"",placeholder:"type a label",onChange:c=>l(c.target.value)})}):n.jsx("div",{className:"muted small label-preview",children:r==="id"?i:r==="name"?a:`follows global (${s})`})]})}const tE={glc__D:["D-Glucose","C6H12O6",0],g6p:["D-Glucose 6-phosphate","C6H11O9P",-2],f6p:["D-Fructose 6-phosphate","C6H11O9P",-2],fdp:["D-Fructose 1,6-bisphosphate","C6H10O12P2",-4],dhap:["Dihydroxyacetone phosphate","C3H5O6P",-2],g3p:["Glyceraldehyde 3-phosphate","C3H5O6P",-2],"13dpg":["3-Phospho-D-glyceroyl phosphate","C3H4O10P2",-4],"3pg":["3-Phospho-D-glycerate","C3H4O7P",-3],"2pg":["D-Glycerate 2-phosphate","C3H4O7P",-3],pep:["Phosphoenolpyruvate","C3H2O6P",-3],pyr:["Pyruvate","C3H3O3",-1],lac__L:["L-Lactate","C3H5O3",-1],accoa:["Acetyl-CoA","C23H34N7O17P3S",-4],"6pgl":["6-Phospho-D-glucono-1,5-lactone","C6H9O9P",-2],"6pgc":["6-Phospho-D-gluconate","C6H10O10P",-3],ru5p__D:["D-Ribulose 5-phosphate","C5H9O8P",-2],r5p:["Alpha-D-Ribose 5-phosphate","C5H9O8P",-2],xu5p__D:["D-Xylulose 5-phosphate","C5H9O8P",-2],cit:["Citrate","C6H5O7",-3],acon_C:["cis-Aconitate","C6H3O6",-3],icit:["Isocitrate","C6H5O7",-3],akg:["2-Oxoglutarate","C5H4O5",-2],succoa:["Succinyl-CoA","C25H35N7O19P3S",-5],succ:["Succinate","C4H4O4",-2],fum:["Fumarate","C4H2O4",-2],mal__L:["L-Malate","C4H4O5",-2],oaa:["Oxaloacetate","C4H2O5",-2],atp:["ATP","C10H12N5O13P3",-4],adp:["ADP","C10H12N5O10P2",-3],h:["H+","H",1],h2o:["H2O","H2O",0],pi:["Phosphate","HO4P",-2],nad:["NAD+","C21H26N7O14P2",-1],nadh:["NADH","C21H27N7O14P2",-2],nadp:["NADP+","C21H25N7O17P3",-3],nadph:["NADPH","C21H26N7O17P3",-4],coa:["Coenzyme A","C21H32N7O16P3S",-4],co2:["CO2","CO2",0],q8:["Ubiquinone-8","C49H74O4",0],q8h2:["Ubiquinol-8","C49H76O4",0]},nE=[["GLCt","Glucose transport","glc__D_e -> glc__D_c",!1,"Transport","GLUT1"],["HEX1","Hexokinase","glc__D + atp -> g6p + adp + h",!1,"Glycolysis","HK1 or HK2"],["PGI","Glucose-6-phosphate isomerase","g6p <-> f6p",!0,"Glycolysis","GPI"],["PFK","Phosphofructokinase","f6p + atp -> fdp + adp + h",!1,"Glycolysis","PFKL and PFKM"],["FBA","Fructose-bisphosphate aldolase","fdp <-> dhap + g3p",!0,"Glycolysis","ALDOA"],["TPI","Triose-phosphate isomerase","dhap <-> g3p",!0,"Glycolysis","TPI1"],["GAPD","Glyceraldehyde-3-phosphate dehydrogenase","g3p + nad + pi <-> 13dpg + h + nadh",!0,"Glycolysis","GAPDH"],["PGK","Phosphoglycerate kinase","3pg + atp <-> 13dpg + adp",!0,"Glycolysis","PGK1"],["PGM","Phosphoglycerate mutase","2pg <-> 3pg",!0,"Glycolysis","PGAM1"],["ENO","Enolase","2pg <-> h2o + pep",!0,"Glycolysis","ENO1"],["PYK","Pyruvate kinase","adp + h + pep -> atp + pyr",!1,"Glycolysis","PKM"],["LDH_L","L-lactate dehydrogenase","lac__L + nad <-> h + nadh + pyr",!0,"Pyruvate metabolism","LDHA or LDHB"],["PDH","Pyruvate dehydrogenase","coa + nad + pyr -> accoa + co2 + nadh",!1,"Pyruvate metabolism","PDHA1 and DLAT and DLD"],["G6PDH2r","Glucose 6-phosphate dehydrogenase","g6p + nadp <-> 6pgl + h + nadph",!0,"Pentose phosphate pathway","G6PD"],["PGL","6-Phosphogluconolactonase","6pgl + h2o -> 6pgc + h",!1,"Pentose phosphate pathway","PGLS"],["GND","Phosphogluconate dehydrogenase","6pgc + nadp -> co2 + nadph + ru5p__D",!1,"Pentose phosphate pathway","PGD"],["RPI","Ribose-5-phosphate isomerase","r5p <-> ru5p__D",!0,"Pentose phosphate pathway","RPIA"],["RPE","Ribulose 5-phosphate 3-epimerase","ru5p__D <-> xu5p__D",!0,"Pentose phosphate pathway","RPE"],["CS","Citrate synthase","accoa + h2o + oaa -> cit + coa + h",!1,"TCA cycle","CS"],["ACONTa","Aconitase (half-reaction A)","cit <-> acon_C + h2o",!0,"TCA cycle","ACO2"],["ACONTb","Aconitase (half-reaction B)","acon_C + h2o <-> icit",!0,"TCA cycle","ACO2"],["ICDHyr","Isocitrate dehydrogenase (NADP)","icit + nadp <-> akg + co2 + nadph",!0,"TCA cycle","IDH2"],["AKGDH","2-Oxoglutarate dehydrogenase","akg + coa + nad -> co2 + nadh + succoa",!1,"TCA cycle","OGDH and DLST and DLD"],["SUCOAS","Succinyl-CoA synthetase","atp + coa + succ <-> adp + pi + succoa",!0,"TCA cycle","SUCLG1 and SUCLA2"],["SUCDi","Succinate dehydrogenase","succ + q8 -> fum + q8h2",!1,"TCA cycle","SDHA and SDHB and SDHC and SDHD"],["FUM","Fumarase","fum + h2o <-> mal__L",!0,"TCA cycle","FH"],["MDH","Malate dehydrogenase","mal__L + nad <-> h + nadh + oaa",!0,"TCA cycle","MDH2"],["PYRt2","Pyruvate transport (H+ symport)","pyr_e + h_e <-> pyr_c + h_c",!0,"Transport","MPC1"],["L_LACt2r","L-lactate transport","lac__L_c + h_c <-> lac__L_e + h_e",!0,"Transport","SLC16A1"],["EX_glc__D_e","Glucose exchange","glc__D_e <->",!0,"Exchange",""],["EX_pyr_e","Pyruvate exchange","pyr_e <->",!0,"Exchange",""],["EX_lac__L_e","L-Lactate exchange","lac__L_e <->",!0,"Exchange",""]];function iE(e){const[t,i]=e.split(/<->|->/).map(o=>o.trim()),a={},s=(o,l)=>o.split("+").map(r=>r.trim()).filter(Boolean).forEach(r=>{const c=r.match(/^([\d.]+)\s+(.+)$/),d=c?Number(c[1]):1;let f=c?c[2]:r;/_[ce]$/.test(f)||(f+="_c"),a[f]=(a[f]??0)+l*d});return s(t,-1),s(i??"",1),a}function P0(){const e={},t={};for(const[a,s,o,l,r,c]of nE){const d=iE(o);for(const f of Object.keys(d)){if(e[f])continue;const u=f.replace(/_[ce]$/,""),[p,m,h]=tE[u]??[u,void 0,void 0];e[f]={id:f,name:p,formula:m,charge:h,compartment:f.endsWith("_e")?"e":"c"}}t[a]={id:a,name:s,stoichiometry:d,reversible:l,lowerBound:l?-1e3:0,upperBound:1e3,subsystem:r,gpr:c||void 0,genes:c?c.replace(/[()]/g,"").split(/\s+(?:and|or)\s+/):[]}}const i=Object.fromEntries(Object.values(t).flatMap(a=>a.genes).map(a=>[a,{id:a,name:a}]));return{id:"demo_ccm",name:"Central carbon demo",metabolites:e,reactions:t,genes:i,compartments:{c:"cytosol",e:"extracellular"},source:"demo"}}const lc={GLCt:[4.2,4,3.1,3],HEX1:[4.2,4,3.1,3],PGI:[3.35,3.15,2.62,2.52],PFK:[3.35,3.2,2.6,2.5],FBA:[3.35,3.2,2.6,2.5],TPI:[3.3,3.12,2.52,2.42],GAPD:[6.62,6.38,5.1,4.96],PGK:[-6.62,-6.38,-5.1,-4.96],PGM:[-6.3,-6.1,-4.85,-4.75],ENO:[6.3,6.1,4.85,4.75],PYK:[5.02,4.82,3.62,3.5],LDH_L:[-4.08,-3.78,-1.22,-.92],PDH:[1.02,1.18,2.56,2.82],G6PDH2r:[.82,.8,.46,.45],PGL:[.82,.8,.46,.45],GND:[.82,.8,.46,.45],RPI:[-.31,-.3,-.19,-.18],RPE:[.51,.5,.27,.27],CS:[.92,1.12,2.42,2.64],ACONTa:[.92,1.12,2.42,2.64],ACONTb:[.92,1.12,2.42,2.64],ICDHyr:[.88,1.06,2.33,2.52],AKGDH:[.72,.9,2.02,2.21],SUCOAS:[-.72,-.9,-2.02,-2.21],SUCDi:[.76,.95,2.1,2.31],FUM:[.76,.95,2.1,2.31],MDH:[.7,.88,1.98,2.2],PYRt2:[.12,.05,-.18,-.24],L_LACt2r:[4.08,3.78,1.22,.92],EX_glc__D_e:[-4.2,-4,-3.1,-3],EX_pyr_e:[-.12,-.05,.18,.24],EX_lac__L_e:[4.08,3.78,1.22,.92]},R0=[{id:"P10",name:"P10",color:"#e8505b",time:10},{id:"P12",name:"P12",color:"#a0524f",time:12},{id:"P26",name:"P26",color:"#5b6ee1",time:26},{id:"P28",name:"P28",color:"#262c8c",time:28}];function aE(){return["reaction,P10,P12,P26,P28",...Object.entries(lc).map(([e,t])=>`${e},${t.join(",")}`)].join(`
|
|
79
|
+
`)}function sE(){const e=R0.map(c=>c.id),t={id:"ds_pfba",name:"pFBA (simulated)",kind:"flux",target:"reaction",unit:"mmol gDW⁻¹ h⁻¹",visible:!0,columns:e,values:Object.fromEntries(Object.entries(lc).map(([c,d])=>[c,[...d]])),unmatched:[],idMap:{},matchedFraction:1},i=y5(42),a={},s={};for(const[c,d]of Object.entries(lc))a[c]=d.map((f,u)=>{const p=Math.abs(f)*(.035+.02*u)+.03,m=["PDH","LDH_L","PYRt2","CS"].includes(c)&&u%2===0;return Array.from({length:300},()=>{const h=m&&i.next()<.3?p*3.2:0;return+(f+h+i.normal()*p).toFixed(4)})}),s[c]=a[c].map(f=>+(f.reduce((u,p)=>u+p,0)/f.length).toFixed(4));return[t,{id:"ds_samples",name:"Flux sampling (n=300)",kind:"samples",target:"reaction",unit:"mmol gDW⁻¹ h⁻¹",visible:!0,columns:e,values:s,samples:a,unmatched:[],idMap:{},matchedFraction:1},{id:"ds_conc",name:"Metabolite pools (simulated)",kind:"metabolite",target:"metabolite",unit:"mM",visible:!0,columns:e,values:{g6p_c:[1.6,1.5,.9,.85],f6p_c:[.5,.48,.3,.28],fdp_c:[2.4,2.1,1.1,1],pep_c:[.35,.32,.22,.2],pyr_c:[.9,.85,.5,.45],lac__L_c:[6.5,6,2.2,1.8],accoa_c:[.12,.13,.25,.27],cit_c:[.8,.9,1.8,1.9],akg_c:[.4,.45,.9,1],succ_c:[.6,.62,1.1,1.2],fum_c:[.2,.22,.4,.42],mal__L_c:[.9,.95,1.6,1.7],oaa_c:[.05,.05,.08,.09]},unmatched:[],idMap:{},matchedFraction:1}]}function oE(){const e=P0(),t=Yo(),i=zp.find(p=>p.id==="central-carbon"),a={...t.doc,nodes:{},reactions:{},groups:{},texts:{},plots:{}},s=new Map,o=120,l=120,r=p=>{var m,h,g;return((g=(h=(m=i.spec)==null?void 0:m.biology.slots.find(y=>y.slot===p))==null?void 0:h.aliases)==null?void 0:g[0])??p};for(const p of i.nodes){const m="n_"+r(p.key);s.set(p.key,m),a.nodes[m]={id:m,x:o+p.x+280,y:l+p.y,label:p.label,hints:p.hints,labelPos:p.labelPos}}for(const p of i.reactions){const m="r_"+p.label;a.reactions[m]={id:m,sources:p.sources.map(h=>s.get(h)),targets:p.targets.map(h=>s.get(h)),label:p.label,hints:p.hints,routing:p.routing??"straight",bend:p.bend}}const c=a.nodes.n_pyr,d=a.nodes.n_lac;a.nodes.n_pyr_e={id:"n_pyr_e",x:c.x-90,y:c.y,metaboliteId:"pyr_e",label:"pyr[e]",labelPos:"left",role:"exchange"},a.nodes.n_lac_e={id:"n_lac_e",x:d.x-90,y:d.y,metaboliteId:"lac__L_e",label:"lac[e]",labelPos:"left",role:"exchange"},a.reactions.r_PYRt={id:"r_PYRt",sources:["n_pyr_e"],targets:["n_pyr"],label:"MPC",routing:"straight",role:"exchange"},a.reactions.r_LACt={id:"r_LACt",sources:["n_lac"],targets:["n_lac_e"],label:"MCT",routing:"straight",role:"exchange"},a.nodes.n_lac.labelPos="right",a.reactions.r_ACONT.labelFlip=!0;for(const p of["r_CS","r_ICDH","r_AKGDH","r_SUCOAS","r_SDH","r_FUM","r_MDH"])a.reactions[p].labelFlip=!0;for(const p of i.groups??[]){const m="g_"+p.title.replace(/\W+/g,"");a.groups[m]={id:m,kind:p.kind,title:p.title,nodeIds:p.keys.map(h=>s.get(h)),padding:26,fill:"none",stroke:"none",dashed:!1}}a.groups.g_Glycolysis.hidden=!0,a.groups.g_Pentosephosphatepathway.hidden=!0;const f=tu(a,e).doc;f.reactions.r_PYRt={...f.reactions.r_PYRt,reactionId:"PYRt2",reversedToModel:!1},f.reactions.r_LACt={...f.reactions.r_LACt,reactionId:"L_LACt2r",reversedToModel:!1},f.texts={t_a:{id:"t_a",x:40,y:60,text:"a",size:22,weight:700,kind:"panel"},t_title:{id:"t_title",x:70,y:60,text:"Central carbon metabolism",size:17,weight:700,kind:"title"},t_glyc:{id:"t_glyc",x:372,y:100,text:"Glycolysis",size:11,weight:600,italic:!0,kind:"text"},t_ppp:{id:"t_ppp",x:120,y:150,text:"Pentose phosphate pathway",size:11,weight:600,italic:!0,kind:"text"}};const u=(p,m,h)=>{const g=ke("p");f.plots[g]={id:g,anchor:{kind:"reaction",id:p},type:"density",dx:m,dy:h,w:130,h:78,datasetId:"ds_samples",showConnector:!0,showAxis:!0}};return u("r_HEX",80,-50),u("r_PFK",80,-70),u("r_GAPD",80,-90),u("r_ENO",80,-110),u("r_PYK",80,-130),u("r_LDH",-290,-20),u("r_PDH",-345,-110),u("r_CS",207,-118),u("r_ICDH",122,-44),u("r_AKGDH",74,-38),u("r_SUCOAS",122,4),u("r_SDH",-106,64),u("r_FUM",-299,20),f.legend={x:890,y:80,visible:!0,title:"Legend"},{...t,name:"Central Carbon Metabolism Demo",model:e,datasets:sE(),conditions:R0,doc:f,mappings:[{id:"m_w",datasetId:"ds_pfba",target:"reaction",property:"width",scale:"linear",magnitude:!0,enabled:!0},{id:"m_c",datasetId:"ds_pfba",target:"reaction",property:"color",scale:"linear",magnitude:!0,enabled:!0,palette:"viridis"},{id:"m_r",datasetId:"ds_conc",target:"metabolite",property:"radius",scale:"sqrt",magnitude:!0,enabled:!1}],view:{activeCondition:"P10",compare:"absolute",reference:"P10"},savedViews:[]}}const I0=Object.freeze(Object.defineProperty({__proto__:null,DEMO_CONDITIONS:R0,DEMO_FLUX:lc,demoFluxCsv:aE,demoModel:P0,demoProject:oE},Symbol.toStringTag,{value:"Module"})),lE=[{id:"select",icon:"select",label:"Select",key:"V"},{id:"pan",icon:"pan",label:"Pan",key:"C"},{id:"metabolite",icon:"metabolite",label:"Metabolite",key:"M"},{id:"slot",icon:"slot",label:"Slot",key:"S"},{id:"reaction",icon:"reaction",label:"Reaction",key:"R"},{id:"text",icon:"text",label:"Text",key:"T"}];function rE(){const e=Kn("map-left",272,200,640),t=R(o=>o.leftTab),i=R(o=>o.leftOpen),a=E.useRef(null),s=pl("map-left");return E.useEffect(()=>{if(!i)return;const o=l=>{if(!(l.button!==0||!a.current))for(const r of Array.from(a.current.querySelectorAll("[data-tab]"))){const c=r.getBoundingClientRect();if(l.clientX>=c.left&&l.clientX<=c.right&&l.clientY>=c.top&&l.clientY<=c.bottom){R.setState({leftTab:r.dataset.tab});return}}};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[i]),i?n.jsxs("aside",{className:"panel left",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"right"}),n.jsx("div",{className:"tabs",role:"tablist",ref:a,children:["elements","model","data"].map((o,l)=>n.jsx("button",{type:"button",role:"tab","data-tab":o,"aria-selected":t===o,className:t===o?"on":"",title:`Alt+${l+1}`,onClick:()=>R.setState({leftTab:o}),children:o==="elements"?"Elements":o==="model"?"Model":"Data"},o))}),n.jsxs("div",{className:"panel-scroll",ref:s.ref,children:[t==="elements"&&n.jsx(cE,{}),t==="model"&&n.jsx(dE,{}),t==="data"&&n.jsx(hE,{})]})]}):null}function zg({t:e}){const t=e.nodes.map(f=>f.x),i=e.nodes.map(f=>f.y),a=Math.min(...t),s=Math.min(...i),o=Math.max(...t)-a||1,l=Math.max(...i)-s||1,r=Math.min(52/o,36/l),c=(f,u)=>[(f-a)*r+4+(52-o*r)/2,(u-s)*r+4+(36-l*r)/2],d=new Map(e.nodes.map(f=>[f.key,f]));return n.jsxs("svg",{width:qe(60),height:qe(44),viewBox:"0 0 60 44",className:"tpl-mini",children:[e.reactions.map((f,u)=>{const p=d.get(f.sources[0]),m=d.get(f.targets[0]);if(!p||!m)return null;const[h,g]=c(p.x,p.y),[y,b]=c(m.x,m.y);return n.jsx("line",{x1:h,y1:g,x2:y,y2:b,stroke:"currentColor",strokeOpacity:.45,strokeWidth:.8},u)}),e.nodes.map(f=>{const[u,p]=c(f.x,f.y);return n.jsx("circle",{cx:u,cy:p,r:1.8,fill:"currentColor"},f.key)})]})}function cE(){const e=R(d=>d.tool),t=R(d=>d.userTemplates),i=R(d=>d.model),a=R(d=>Object.values(d.doc.nodes).filter(f=>{var u,p;return!f.attach&&(!f.metaboliteId||!((u=d.model)!=null&&u.metabolites[f.metaboliteId]))&&((p=f.template)==null?void 0:p.status)!=="absent"}).length),s=R(d=>Object.values(d.doc.nodes).filter(f=>{var u;return((u=f.template)==null?void 0:u.status)==="provisional"}).length),o=V(),l=Ft(d=>d.user),c=[["Pathway templates",E.useMemo(()=>Dc(l).map(d=>Kp(Sc(d.file))),[l])],["Shapes",zp.filter(d=>d.category==="shape")]];return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"section",children:n.jsx("div",{className:"tool-grid",children:lE.map(d=>n.jsxs("button",{className:`tool ${e===d.id?"on":""}`,title:`${d.label} (${d.key})`,onClick:()=>R.setState({tool:d.id}),children:[n.jsx(q,{name:d.icon,size:17}),n.jsx("span",{children:d.label}),n.jsx("kbd",{children:d.key})]},d.id))})}),a>0&&n.jsxs("div",{className:"section callout",children:[n.jsxs("div",{children:[n.jsx("b",{children:a})," unbound slot",a>1?"s":""," on the canvas."]}),i?n.jsxs("button",{className:"btn primary small",onClick:()=>o.autoBindAll(),children:[n.jsx(q,{name:"link",size:13})," Auto-bind to ",i.name]}):n.jsx("button",{className:"btn small",onClick:()=>$n("model"),children:"Load a GEM to bind"})]}),s>0&&i&&n.jsxs("div",{className:"section callout",children:[n.jsxs("div",{children:[n.jsx("b",{children:s})," provisional template mapping",s>1?"s":""," (yellow ",n.jsx("b",{children:"?"}),"). Click a node to review its candidates."]}),n.jsx("button",{className:"btn small",onClick:()=>o.confirmProvisional(),children:"Confirm all provisional"})]}),c.map(([d,f])=>n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"row between",children:[n.jsx("div",{className:"section-title",children:d}),d==="Pathway templates"&&n.jsx("button",{className:"link small",onClick:()=>B.setWorkspace("templates"),title:"Create, edit, review, import and export templates",children:"Template Builder →"})]}),n.jsx("div",{className:"tpl-list",children:f.map(u=>n.jsxs("button",{className:"tpl",onClick:()=>o.openTemplate(u),title:u.description,children:[n.jsx(zg,{t:u}),n.jsxs("div",{className:"grow",children:[n.jsx("div",{className:"tpl-name",children:u.name}),n.jsx("div",{className:"tpl-desc",children:u.spec?`${u.spec.biology.slots.filter(p=>p.level==="required").length} core nodes · ${u.spec.compartmentSummary}`:u.description})]}),u.spec&&i&&n.jsx(f6,{spec:u.spec,model:i})]},u.id))})]},d)),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"My templates"}),!t.length&&n.jsxs("div",{className:"muted small",children:["Select part of a map → ",n.jsx(q,{name:"template",size:12})," “Save as template”. Templates keep compartment-free hints and re-bind to any GEM."]}),n.jsx("div",{className:"tpl-list",children:t.map(d=>n.jsxs("div",{className:"tpl",children:[n.jsxs("button",{className:"tpl-hit",onClick:()=>o.instantiateTemplate(d),children:[n.jsx(zg,{t:d}),n.jsxs("div",{children:[n.jsx("div",{className:"tpl-name",children:d.name}),n.jsx("div",{className:"tpl-desc",children:d.description})]})]}),n.jsx("button",{className:"icon-btn",title:"Delete template",onClick:()=>o.deleteUserTemplate(d.id),children:n.jsx(q,{name:"trash",size:13})})]},d.id))})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Annotations"}),n.jsxs("div",{className:"row wrap gap",children:[n.jsx("button",{className:"btn small",onClick:()=>o.addText(Zd(),{text:"a",size:22,weight:700,kind:"panel"}),children:"Panel label"}),n.jsx("button",{className:"btn small",onClick:()=>o.addText(Zd(),{text:"Figure title",size:16,weight:700,kind:"title"}),children:"Title"}),n.jsx("button",{className:"btn small",onClick:()=>o.addText(Zd(),{text:"Pathway",size:11,weight:600,italic:!0}),children:"Pathway label"}),n.jsx("button",{className:"btn small",onClick:()=>o.groupSelection("compartment","Mitochondrion"),children:"Compartment box"})]})]})]})}const Zd=()=>{const e=R.getState();return{x:(e.viewport.w/2-e.camera.x)/e.camera.k,y:(e.viewport.h/3-e.camera.y)/e.camera.k}};function dE(){const e=R(f=>f.model),t=R(f=>f.validation),[i,a]=E.useState(""),s=E.useMemo(()=>Yc(e,i,void 0,40),[e,i]),o=s.filter(f=>f.kind==="metabolite").map(f=>f.id).join("|"),l=R(f=>{if(!o)return"";const u=new Set(o.split("|")),p=[];for(const m of Object.values(f.doc.nodes))m.metaboliteId&&u.has(m.metaboliteId)&&p.push(`${m.metaboliteId}=${m.id}`);return p.join("|")}),r=E.useMemo(()=>new Map(l?l.split("|").map(f=>f.split("=")):[]),[l]),c=V();if(!e)return n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Genome-scale model"}),n.jsx("p",{className:"small muted",children:"Import a COBRApy / BiGG JSON or an SBML file (fbc supported). Templates and data bind to it automatically."}),n.jsxs("button",{className:"btn primary block",onClick:()=>$n("model"),children:[n.jsx(q,{name:"import",size:14})," Import GEM (JSON / SBML)"]}),n.jsx("button",{className:"btn block",onClick:()=>c.importModel(P0()),children:"Use the built-in central carbon model"}),n.jsxs("p",{className:"small muted",children:["Tip: ",n.jsx("span",{className:"mono",children:"e_coli_core.json"})," from BiGG works out of the box with the “Central carbon” template."]})]});const d=t.filter(f=>f.level==="error").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"row between",children:[n.jsx("div",{className:"section-title",children:e.name}),n.jsx("button",{className:"icon-btn",title:"Replace model",onClick:()=>$n("model"),children:n.jsx(q,{name:"import",size:14})})]}),n.jsxs("div",{className:"stats",children:[n.jsxs("div",{children:[n.jsx("b",{children:Object.keys(e.metabolites).length}),n.jsx("span",{children:"metabolites"})]}),n.jsxs("div",{children:[n.jsx("b",{children:Object.keys(e.reactions).length}),n.jsx("span",{children:"reactions"})]}),n.jsxs("div",{children:[n.jsx("b",{children:Object.keys(e.genes).length}),n.jsx("span",{children:"genes"})]})]}),n.jsx("button",{className:`btn small block ${d?"warn":""}`,onClick:()=>R.setState({dialog:{kind:"validation"}}),children:d?`${d} validation errors`:`Validation: ${t.length} notes`})]}),n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"search-box",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:"Search IDs, names, genes, EC, pathways…",value:i,onChange:f=>a(f.target.value)})]}),n.jsxs("div",{className:"hits",children:[s.map(f=>{const u=f.kind==="metabolite"?r.get(f.id):void 0;return n.jsxs("div",{className:"hit",children:[n.jsx("span",{className:`kind k-${f.kind}`,children:f.kind[0].toUpperCase()}),n.jsxs("div",{className:"hit-main",children:[n.jsx("div",{className:"mono",children:f.id}),n.jsxs("div",{className:"muted small ellipsis",children:[f.name,f.detail?` · ${f.detail}`:""]})]}),n.jsxs("div",{className:"hit-actions",children:[f.kind==="metabolite"&&!u&&n.jsx("button",{className:"icon-btn",title:"Add to canvas",onClick:()=>c.addMetaboliteFromModel(f.id),children:n.jsx(q,{name:"plus",size:13})}),f.kind==="metabolite"&&u&&n.jsx("button",{className:"icon-btn",title:"Focus on canvas",onClick:()=>c.focusNode(u),children:n.jsx(q,{name:"fit",size:13})}),f.kind==="metabolite"&&u&&n.jsx("button",{className:"icon-btn",title:"Expand downstream",onClick:()=>c.expandNode(u,"down",1),children:n.jsx(q,{name:"expandDown",size:13})}),f.kind==="reaction"&&n.jsx("button",{className:"icon-btn",title:"Add reaction with its metabolites",onClick:()=>c.addModelReaction(f.id),children:n.jsx(q,{name:"plus",size:13})})]})]},f.kind+f.id)}),i&&!s.length&&n.jsx("div",{className:"muted small",children:"No match."})]})]}),n.jsxs("div",{className:"section",children:[n.jsxs("button",{className:"btn block",onClick:()=>R.setState({dialog:{kind:"path"}}),children:[n.jsx(q,{name:"path",size:14})," Find metabolic path…"]}),n.jsx("div",{className:"muted small",children:"Currency metabolites (ATP, NAD(P)H, H₂O, H⁺, Pi, CoA…) are skipped when expanding and path-finding."})]})]})}function mE(){const e=R(o=>o.model),t=V();if(!e)return null;const a=e.source==="demo"||!!e.reactions.HEX1?"examples/pfba_4conditions.csv":null;if(!a)return null;const s=async()=>{try{t.importDataset(a.split("/").pop(),await(await lk(a)).text())}catch(o){t.toast(`Could not load example: ${o.message}`)}};return n.jsx("button",{className:"link",onClick:s,title:"Import an example flux table made for this model",children:"Load example fluxes for this model"})}const uE=["width","color","opacity","label"],pE=["radius","fill","opacity"];function hE(){const e=R(d=>d.datasets),t=R(d=>d.conditions),i=R(d=>d.mappings),a=R(d=>d.savedViews),[s,o]=E.useState(null),[l,r]=E.useState(null),c=V();return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"section",children:[n.jsxs("button",{className:"btn primary block",onClick:()=>$n("data"),children:[n.jsx(q,{name:"import",size:14})," Import fluxes / data (CSV, TSV, JSON)"]}),n.jsxs("div",{className:"muted small",children:["Wide tables (",n.jsx("span",{className:"mono",children:"reaction,WT,KO…"}),"), time courses, FVA (",n.jsx("span",{className:"mono",children:"_min/_max"}),") and long-format samples (",n.jsx("span",{className:"mono",children:"reaction,condition,value"}),") are detected automatically. Result JSON files exported by COBRAGUI (or the legacy GEM Explorer) are added as conditions. ",n.jsx(mE,{})]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Datasets"}),!e.length&&n.jsx("div",{className:"muted small",children:"No data yet."}),e.map(d=>n.jsxs("div",{className:"ds",children:[n.jsx("button",{className:"icon-btn",title:d.visible?"Hide":"Show",onClick:()=>c.updateDataset(d.id,{visible:!d.visible}),children:n.jsx(q,{name:d.visible?"eye":"eyeOff",size:13})}),n.jsxs("div",{className:"ds-main",children:[s===d.id?n.jsx("input",{className:"input tiny",autoFocus:!0,defaultValue:d.name,onBlur:f=>{c.updateDataset(d.id,{name:f.target.value}),o(null)},onKeyDown:f=>{f.key==="Enter"&&f.target.blur()}}):n.jsx("div",{className:"ds-name",onDoubleClick:()=>o(d.id),title:"Double-click to rename",children:d.name}),n.jsxs("div",{className:"muted small",children:[n.jsx("span",{className:"tag",children:d.kind})," ",d.columns.length," cond · ",Object.keys(d.values).length," ",d.target,"s · ",n.jsxs("button",{className:"link",onClick:()=>R.setState({dialog:{kind:"importReport",datasetId:d.id}}),children:[Math.round((d.matchedFraction??1)*100),"% matched"]})]})]}),n.jsx("button",{className:"icon-btn",title:"Remove",onClick:()=>c.removeDataset(d.id),children:n.jsx(q,{name:"trash",size:13})})]},d.id))]}),t.length>0&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Conditions"}),n.jsx("div",{className:"muted small",children:"Drag ⋮⋮ (or use ↑ ↓) to reorder — plots, the legend and the condition bar follow this order."}),t.map((d,f)=>n.jsxs("div",{className:`row gap cond-row ${(l==null?void 0:l.id)===d.id?"dragging":""} ${l&&l.id!==d.id&&l.over===f?"drop-here":""}`,onDragOver:u=>{l&&(u.preventDefault(),l.over!==f&&r({...l,over:f}))},onDrop:u=>{if(u.preventDefault(),l){const p=t.findIndex(m=>m.id===l.id);c.moveCondition(l.id,p<f?f-1:f)}r(null)},children:[n.jsx("span",{className:"cond-grip",draggable:!0,title:"Drag to reorder",onDragStart:u=>{u.dataTransfer.effectAllowed="move",u.dataTransfer.setData("text/plain",d.id),r({id:d.id,over:f})},onDragEnd:()=>r(null),children:"⋮⋮"}),n.jsx("input",{type:"color",value:d.color,onChange:u=>c.updateCondition(d.id,{color:u.target.value})}),n.jsx("input",{className:"input tiny grow",value:d.name,onChange:u=>c.updateCondition(d.id,{name:u.target.value})}),n.jsx("input",{className:"input tiny num",type:"number",placeholder:"t",value:d.time??"",title:"Time / order (for time-course plots)",onChange:u=>c.updateCondition(d.id,{time:u.target.value===""?void 0:+u.target.value})}),n.jsxs("span",{className:"cond-move",children:[n.jsx("button",{className:"icon-btn",title:"Move up",disabled:f===0,onClick:()=>c.moveCondition(d.id,f-1),children:"↑"}),n.jsx("button",{className:"icon-btn",title:"Move down",disabled:f===t.length-1,onClick:()=>c.moveCondition(d.id,f+1),children:"↓"})]})]},d.id))]}),e.length>0&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Map data → visual"}),i.map(d=>{var p,m;const f=e.find(h=>h.id===d.datasetId),u=d.target==="reaction"?uE:pE;return n.jsxs("div",{className:`mapping ${d.enabled?"":"off"}`,children:[n.jsxs("div",{className:"row gap",children:[n.jsx("input",{type:"checkbox",checked:d.enabled,onChange:h=>c.updateMapping(d.id,{enabled:h.target.checked})}),n.jsx("select",{className:"input tiny grow",value:d.datasetId,onChange:h=>{const g=e.find(y=>y.id===h.target.value);c.updateMapping(d.id,{datasetId:g.id,target:g.target,property:g.target===d.target?d.property:g.target==="reaction"?"width":"radius"})},children:e.map(h=>n.jsx("option",{value:h.id,children:h.name},h.id))}),n.jsx("span",{className:"muted",children:"→"}),n.jsx("select",{className:"input tiny",value:d.property,onChange:h=>c.updateMapping(d.id,{property:h.target.value}),children:u.map(h=>n.jsxs("option",{value:h,children:[d.target==="reaction"?"edge ":"node ",h]},h))}),n.jsx("button",{className:"icon-btn",onClick:()=>c.removeMapping(d.id),children:n.jsx(q,{name:"x",size:12})})]}),n.jsxs("details",{className:"adv",children:[n.jsxs("summary",{children:["Scale: ",d.scale,d.palette?` · ${d.palette}`:"",d.domain?` · [${jt(d.domain[0])}, ${jt(d.domain[1])}]`:""]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("select",{className:"input tiny",value:d.scale,onChange:h=>c.updateMapping(d.id,{scale:h.target.value}),children:["linear","sqrt","log","percentile"].map(h=>n.jsx("option",{children:h},h))}),d.property==="color"&&n.jsxs("label",{className:"check small",title:"Colour by signed value (diverging) instead of magnitude; arrows already show direction",children:[n.jsx("input",{type:"checkbox",checked:!d.magnitude,onChange:h=>c.updateMapping(d.id,{magnitude:!h.target.checked})})," signed"]}),(d.property==="color"||d.property==="fill")&&n.jsxs("select",{className:"input tiny",value:d.palette??"",onChange:h=>c.updateMapping(d.id,{palette:h.target.value||void 0}),children:[n.jsx("option",{value:"",children:"auto"}),Qo.map(h=>n.jsxs("option",{value:h.id,children:[h.name,h.kind==="diverging"?" (div)":""]},h.id))]}),n.jsxs("label",{className:"small",children:["min ",n.jsx("input",{className:"input tiny num",type:"number",value:((p=d.domain)==null?void 0:p[0])??"",onChange:h=>{var g;return c.updateMapping(d.id,{domain:h.target.value===""?void 0:[+h.target.value,((g=d.domain)==null?void 0:g[1])??10]})}})]}),n.jsxs("label",{className:"small",children:["max ",n.jsx("input",{className:"input tiny num",type:"number",value:((m=d.domain)==null?void 0:m[1])??"",onChange:h=>{var g;return c.updateMapping(d.id,{domain:h.target.value===""?void 0:[((g=d.domain)==null?void 0:g[0])??0,+h.target.value]})}})]})]}),f&&n.jsx("div",{className:"muted small",children:"Domain is computed over all conditions so switching condition never rescales."})]})]},d.id)}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("button",{className:"btn small",onClick:()=>{const d=e.find(f=>f.target==="reaction");d&&c.addMapping({datasetId:d.id,target:"reaction",property:"color",scale:"linear",magnitude:!1,enabled:!0})},children:[n.jsx(q,{name:"plus",size:12})," Reaction mapping"]}),n.jsxs("button",{className:"btn small",onClick:()=>{const d=e.find(f=>f.target==="metabolite");d?c.addMapping({datasetId:d.id,target:"metabolite",property:"radius",scale:"sqrt",magnitude:!0,enabled:!0}):c.toast("Import a metabolite dataset first")},children:[n.jsx(q,{name:"plus",size:12})," Metabolite mapping"]})]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Saved views"}),a.map(d=>n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small grow",onClick:()=>c.applySavedView(d),children:d.name}),n.jsx("button",{className:"icon-btn",onClick:()=>c.deleteSavedView(d.id),children:n.jsx(q,{name:"x",size:12})})]},d.id)),n.jsxs("button",{className:"btn small",onClick:()=>{const d=R.getState();c.saveView(`${d.view.activeCondition}${d.view.compare!=="absolute"?` ${d.view.compare} vs ${d.view.reference}`:""}`)},children:[n.jsx(q,{name:"plus",size:12})," Save current view"]})]})]})}const Qd={},U_=(Qd==null?void 0:Qd.VITE_COBRA_API)??"/api",rc=Ts(()=>({status:null,offline:!1}));async function q_(){try{const e=await fetch(`${U_}/bigg/status`);if(!e.ok)throw new Error(String(e.status));rc.setState({status:await e.json(),offline:!1})}catch{rc.setState({offline:!0})}}async function fE(e){const t=new Map(e.biology.metabolites.map(o=>[o.id,o])),i=new Map(e.biology.entities.map(o=>[o.id,o])),a={entities:e.biology.entities.map(o=>({id:o.id,identifiers:o.identifiers})),reactions:e.biology.reactions.map(o=>({id:o.id,ec:o.ec,identifiers:o.identifiers,participants:o.participants.map(l=>{const r=t.get(l.metabolite),c=r&&i.get(r.entity);return{name:c==null?void 0:c.name,identifiers:(c==null?void 0:c.identifiers)??{},coefficient:l.coefficient,main:l.main,compartment:o.compartment??(r==null?void 0:r.compartment)??void 0}})}))},s=await fetch(`${U_}/identity/bigg-ids`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!s.ok)throw new Error(`backend ${s.status}`);return await s.json()}function Ae({label:e,children:t}){return n.jsxs("label",{className:"field",children:[n.jsx("span",{children:e}),t]})}function Ii({value:e,options:t,onChange:i,labels:a}){return n.jsx("div",{className:"seg",children:t.map(s=>n.jsx("button",{className:e===s?"on":"",onClick:()=>i(s),children:(a==null?void 0:a[s])??s},s))})}function vt({value:e,onCommit:t,placeholder:i,mono:a,list:s}){const[o,l]=E.useState(null),r=()=>{o!==null&&o!==e&&t(o),l(null)};return n.jsx("input",{className:`input ${a?"mono":""}`,value:o??e,placeholder:i,onChange:c=>l(c.target.value),onBlur:r,onKeyDown:c=>{c.key==="Enter"&&c.target.blur()},title:s?"Comma separated":void 0})}const So=e=>e.split(/[,;]+/).map(t=>t.trim()).filter(Boolean),V_=["required","recommended","optional"];function gE(){var r,c,d,f;const e=Kn("tpl-right",312,240,640),t=R(u=>u.selection),i=R(u=>u.doc),a=R(u=>u.design),s=R(u=>u.rightOpen),o=pl("template-inspector");if(!a||!s)return null;let l;if(t.length===1){const[u,p]=Oe(t[0]),m=u==="node"?i.nodes[p]:void 0,h=u==="reaction"?i.reactions[p]:void 0;((r=m==null?void 0:m.design)==null?void 0:r.kind)==="metabolite"?l=n.jsx(bE,{f:a,n:m}):((c=m==null?void 0:m.design)==null?void 0:c.kind)==="port"?l=n.jsx(Ug,{f:a,connectorId:m.design.id}):((d=h==null?void 0:h.design)==null?void 0:d.kind)==="reaction"?l=n.jsx(vE,{f:a,g:h}):((f=h==null?void 0:h.design)==null?void 0:f.kind)==="link"?l=n.jsx(Ug,{f:a,connectorId:h.design.id}):u==="text"&&i.texts[p]?l=n.jsx(F_,{t:i.texts[p]}):u==="group"&&i.groups[p]?l=n.jsx(X_,{g:i.groups[p]}):l=n.jsx(qg,{f:a})}else t.length>1?l=n.jsx(K_,{}):l=n.jsx(qg,{f:a});return n.jsxs("aside",{className:"panel right tpl-insp",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"left"}),n.jsx(Fc,{api:o}),n.jsx("div",{className:"panel-scroll",ref:o.ref,children:l})]})}function bE({f:e,n:t}){var d;const i=e.biology.metabolites.find(f=>f.id===t.design.id),a=i&&e.biology.entities.find(f=>f.id===i.entity),s=R(f=>f.doc);if(!i||!a)return n.jsx("div",{className:"section muted small",children:"Unknown template element."});const o=Object.values(s.nodes).filter(f=>{var u;return((u=f.design)==null?void 0:u.kind)==="metabolite"&&f.design.id===i.id}).length,l=e.biology.metabolites.filter(f=>f.entity===a.id&&f.id!==i.id),r=e.biology.reactions.filter(f=>f.participants.some(u=>u.metabolite===i.id)),c=()=>R.setState({dialog:{kind:"identity",nodeId:t.id}});return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Template metabolite · template entity"}),n.jsx("div",{className:"insp-title",children:i.label||a.short||a.name}),n.jsxs("div",{className:"muted small",children:["Abstract biological entity — the matcher finds it in each GEM. ",n.jsx("span",{className:"mono",children:i.id})]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Identity"}),n.jsx(Ae,{label:"Display name",children:n.jsx(vt,{value:i.label??"",placeholder:a.short||a.name,onCommit:f=>fe.updateMetabolite(i.id,{label:f.trim()||void 0})})}),n.jsx(Ae,{label:"Canonical identity",children:n.jsxs("span",{className:"row gap wrap",children:[n.jsx("b",{children:a.name}),n.jsx(yl,{status:a.identity.status,conflict:!!a.identity.conflict,confidence:a.identity.confidence}),a.generic&&n.jsx(H_,{})]})}),a.identity.note&&n.jsxs("div",{className:"muted small",children:[a.identity.source?`${a.identity.source}: `:"",a.identity.note]}),a.provenance&&n.jsx(O_,{p:[a.provenance]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small primary",onClick:c,children:a.identity.status==="unresolved"?"Define identity…":"Change identity…"}),a.identity.status==="suggested"&&n.jsx("button",{className:"btn small",onClick:()=>fe.confirmEntity(a.id),children:"✓ Confirm"}),a.identity.status!=="unresolved"&&n.jsx("button",{className:"btn small",onClick:()=>fe.clearIdentity(a.id),title:"Back to unresolved",children:"Clear"})]}),a.identity.conflict&&n.jsxs("div",{className:"notice small",children:[n.jsx("b",{children:"Potential identity conflict."})," A ",a.identity.conflict.source," suggestion says ",n.jsx("b",{children:a.identity.conflict.name})," (",n.jsx(qa,{ids:a.identity.conflict.identifiers,max:3}),"). Your confirmed identity was kept.",n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"btn small",onClick:()=>fe.resolveConflict(a.id,!1),children:"Keep mine"}),n.jsx("button",{className:"btn small",onClick:()=>fe.resolveConflict(a.id,!0),children:"Use the suggestion"})]})]}),n.jsx(Ae,{label:"Preferred compartment",children:n.jsxs("select",{className:"input",value:i.compartment??"",title:"Optional. Without one, the matcher proposes candidates in every compartment and you choose when mapping onto a GEM",onChange:f=>fe.updateMetabolite(i.id,{compartment:f.target.value||null}),children:[n.jsx("option",{value:"",children:"— chosen when mapping —"}),rl.map(f=>n.jsx("option",{value:f.id,children:f.label},f.id))]})}),n.jsx(Ae,{label:"Requirement",children:n.jsx(Ii,{value:i.level,options:V_,onChange:f=>fe.updateMetabolite(i.id,{level:f})})}),n.jsx(Ae,{label:"Role",children:n.jsx(Ii,{value:i.role??"normal",options:["normal","exchange"],onChange:f=>fe.updateMetabolite(i.id,{role:f==="normal"?void 0:f})})})]}),n.jsx(yE,{n:t}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Databases"}),C1.map(f=>n.jsx(L_,{ns:f,values:a.identifiers[f]??[],onChange:u=>fe.updateEntity(a.id,{identifiers:{...a.identifiers,[f]:u}})},f)),n.jsx(Ae,{label:"Formula",children:n.jsx(vt,{mono:!0,value:a.formula??"",placeholder:"neutral formula",onCommit:f=>fe.updateEntity(a.id,{formula:f.trim()||void 0})})}),n.jsx(Ae,{label:"Synonyms",children:n.jsx(vt,{list:!0,value:a.synonyms.join(", "),onCommit:f=>fe.updateEntity(a.id,{synonyms:So(f)})})}),n.jsx(Ae,{label:"Short label",children:n.jsx(vt,{mono:!0,value:a.short??"",placeholder:"glc_D",onCommit:f=>fe.updateEntity(a.id,{short:f.trim()||void 0})})}),!!((d=a.related)!=null&&d.length)&&n.jsxs("div",{className:"muted small",children:["Related forms (scored lower when matching): ",a.related.map(f=>f.note).join("; ")]}),n.jsxs("div",{className:"muted small",children:["Editing identifiers by hand keeps the status; review it with ",n.jsx("b",{children:"Confirm"})," when done."]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Drawing"}),n.jsxs("div",{className:"small",children:[o," visual instance",o>1?"s":""," of this metabolite",l.length?` · same compound also as ${l.map(f=>wi(f.compartment).toLowerCase()).join(", ")}`:""]}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small",onClick:()=>fe.addInstance(t.id),title:"Draw the same metabolite once more (global maps)",children:"+ Instance"}),o>1&&n.jsx("button",{className:"btn small",onClick:()=>fe.makeIndependent(t.id),title:"This node becomes its own metabolite (same identity), e.g. for another compartment",children:"Make independent"}),n.jsx(_E,{nodeId:t.id})]})]}),n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Reactions (",r.length,")"]}),r.map(f=>n.jsxs("div",{className:"small",children:[n.jsx("b",{children:f.name})," ",n.jsx("span",{className:"mono muted",children:bl(e,f,"short")})]},f.id)),!r.length&&n.jsx("div",{className:"muted small",children:"Drag from the node's outer ring to another node to draw a reaction."})]})]})}function yE({n:e}){const t=R(s=>s.style),i=V();if(e.attach)return n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),n.jsx("div",{className:"muted small",children:"A cofactor drawn beside its arrow: it follows the arrow when the arrow moves. Drag it to place it."})]});const a=e.shape==="label";return n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),!a&&n.jsx(Ae,{label:"Label position",children:n.jsx(Ii,{value:e.labelPos??"right",options:["left","top","right","bottom","none"],onChange:s=>i.updateNode(e.id,{labelPos:s}),labels:{left:"←",top:"↑",right:"→",bottom:"↓",none:"∅"}})}),n.jsx(Ae,{label:"Style",children:n.jsx(Ii,{value:a?"text":"circle",options:["circle","text"],onChange:s=>i.updateNode(e.id,s==="text"?{shape:"label",labelPos:void 0}:{shape:"circle"}),labels:{circle:"circle + label",text:"text only"}})}),!a&&n.jsx(Ae,{label:"Radius",children:n.jsx("input",{className:"input",type:"number",min:1,max:40,value:e.r??t.nodeRadius,onChange:s=>i.updateNode(e.id,{r:+s.target.value||void 0})})}),!a&&n.jsxs(Ae,{label:"Fill",children:[n.jsx("input",{type:"color",value:e.fill??"#111111",onChange:s=>i.updateNode(e.id,{fill:s.target.value})}),e.fill&&n.jsx("button",{className:"link",onClick:()=>i.updateNode(e.id,{fill:void 0}),children:"reset"})]}),n.jsxs("div",{className:"muted small",children:["The name shown is the ",n.jsx("b",{children:"Display name"})," above (or the entity's short label)."]})]})}function xE({g:e}){const t=V(),i=e.sources.length===1&&e.targets.length===1;return n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Appearance"}),n.jsx(Ae,{label:"Routing",children:n.jsx(Ii,{value:e.routing,options:i?["straight","curved","orthogonal"]:["straight"],onChange:a=>t.updateReaction(e.id,{routing:a,bend:void 0})})}),(e.routing==="curved"||!i)&&n.jsx(Ae,{label:i?"Curvature":"Hub offset",children:n.jsx("input",{type:"range",min:-120,max:120,value:e.bend??0,onChange:a=>t.updateReaction(e.id,{bend:+a.target.value})})}),n.jsxs("div",{className:"row gap wrap",children:[n.jsxs("button",{className:"btn small",onClick:()=>t.reverseReaction(e.id),title:"Swap substrates and products (cofactors follow)",children:[n.jsx(q,{name:"swap",size:13})," Reverse"]}),n.jsx("button",{className:"btn small",onClick:()=>t.updateReaction(e.id,{labelFlip:!e.labelFlip,labelOffset:void 0,labelAngle:void 0}),children:"Flip label"}),(e.labelOffset||e.labelAngle)&&n.jsx("button",{className:"btn small",onClick:()=>t.updateReaction(e.id,{labelOffset:void 0,labelAngle:void 0}),children:"Auto label position"})]}),n.jsxs("div",{className:"muted small",children:["The label is the ",n.jsx("b",{children:"Display name"})," above; drag the label on the canvas to move it."]})]})}function _E({nodeId:e}){const[t,i]=E.useState(!1),[a,s]=E.useState(""),[o,l]=E.useState("out"),r=Ft(f=>f.user),c=E.useMemo(()=>Dc(r),[r]);if(!t)return n.jsx("button",{className:"btn small",onClick:()=>i(!0),title:"A link to another pathway (not a reaction), e.g. pyruvate → amino acid metabolism",children:"+ Pathway link"});const d=c.find(f=>f.file.metadata.name===a);return n.jsxs("div",{className:"port-form",children:[n.jsx("input",{className:"input",autoFocus:!0,list:"tpl-names",placeholder:"Pathway (e.g. Amino acid metabolism)",value:a,onChange:f=>s(f.target.value)}),n.jsx("datalist",{id:"tpl-names",children:c.map(f=>n.jsx("option",{value:f.file.metadata.name},f.file.metadata.id))}),n.jsx(Ii,{value:o,options:["out","in"],onChange:l,labels:{out:"→ to",in:"← from"}}),n.jsx("button",{className:"btn small primary",disabled:!a.trim(),onClick:()=>{fe.addPort(e,a.trim(),o,d==null?void 0:d.file.metadata.id),i(!1),s("")},children:"Add"})]})}function vE({f:e,g:t}){var c,d,f;const i=e.biology.reactions.find(u=>u.id===t.design.id),[a,s]=E.useState(null);if(!i)return n.jsx("div",{className:"section muted small",children:"Unknown template reaction."});const o=__(e,i),l=u=>{const p=e.biology.metabolites.find(h=>h.id===u);return{e:p&&e.biology.entities.find(h=>h.id===p.entity),m:p}},r=u=>i.participants.filter(p=>Math.sign(p.coefficient)===u);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:i.summary?"Pathway summary (several steps drawn as one arrow)":"Template reaction"}),n.jsx("div",{className:"insp-title",children:i.name}),n.jsxs("div",{className:"muted small",children:["Defined by participants, stoichiometry and direction — not by its name. ",n.jsx("span",{className:"mono",children:i.id})]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Identity"}),n.jsx(Ae,{label:"Display name",children:n.jsx(vt,{value:i.name,onCommit:u=>fe.updateReaction(i.id,{name:u.trim()||i.name})})}),n.jsx(Ae,{label:"Canonical reaction",children:n.jsx(vt,{value:i.canonicalName??"",placeholder:"e.g. hexokinase",onCommit:u=>fe.updateReaction(i.id,{canonicalName:u.trim()||void 0})})}),n.jsx("div",{className:"eq mono",children:bl(e,i)}),n.jsxs("span",{className:"row gap wrap",children:[n.jsx(yl,{status:i.identity.status,confidence:i.identity.confidence}),i.identity.note&&n.jsx("span",{className:"muted small",children:i.identity.note})]}),!!((c=i.provenance)!=null&&c.length)&&n.jsx(O_,{p:i.provenance}),n.jsxs("div",{className:"row gap wrap",children:[n.jsx("button",{className:"btn small primary",onClick:()=>R.setState({dialog:{kind:"identity",reactionId:i.id}}),children:i.identity.status==="unresolved"?"Define identity…":"Find identity…"}),i.identity.status==="suggested"&&n.jsx("button",{className:"btn small",onClick:()=>fe.confirmReaction(i.id),children:"✓ Confirm"})]}),n.jsx(Ae,{label:"Direction",children:n.jsx(Ii,{value:i.reversible===null?"unknown":i.reversible?"reversible":"forward",options:["forward","reversible","unknown"],onChange:u=>fe.updateReaction(i.id,{reversible:u==="unknown"?null:u==="reversible"}),labels:{forward:"→ forward",reversible:"⇌ reversible",unknown:"?"}})}),n.jsx(Ae,{label:"Compartment",children:n.jsxs("select",{className:"input",value:i.compartment??"",onChange:u=>fe.updateReaction(i.id,{compartment:u.target.value||void 0}),children:[n.jsx("option",{value:"",children:`from participants (${o==="transport"?"transport":wi(o).toLowerCase()})`}),rl.map(u=>n.jsx("option",{value:u.id,children:u.label},u.id))]})}),n.jsx(Ae,{label:"Requirement",children:n.jsx(Ii,{value:i.level,options:V_,onChange:u=>fe.updateReaction(i.id,{level:u})})})]}),n.jsx(xE,{g:t}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Stoichiometry"}),[-1,1].map(u=>n.jsxs("div",{className:"stoich",children:[n.jsx("div",{className:"muted small",children:u<0?"Substrates":"Products"}),r(u).map(p=>{const{e:m,m:h}=l(p.metabolite);return n.jsxs("div",{className:"row gap stoich-row",children:[n.jsx("input",{className:"input tiny num",type:"number",min:.001,step:"any",value:Math.abs(p.coefficient),onChange:g=>fe.setCoefficient(i.id,p.metabolite,u,+g.target.value)}),n.jsxs("span",{className:"grow",children:[(m==null?void 0:m.name)??p.metabolite,h!=null&&h.compartment?n.jsxs("span",{className:"muted",children:[" [",wi(h.compartment).toLowerCase(),"]"]}):null]}),p.main?n.jsx("span",{className:"tag",title:"Drawn on the map; change it by redrawing the arrow",children:"drawn"}):n.jsx("button",{className:"icon-btn",title:"Remove this side compound",onClick:()=>fe.removeParticipant(i.id,p.metabolite,u),children:"✕"})]},p.metabolite+u)}),(a==null?void 0:a.sign)===u?n.jsx(jE,{q:a.q,setQ:p=>s({sign:u,q:p}),onPick:p=>{fe.addSideParticipant(i.id,p,u),s(null)},onClose:()=>s(null)}):n.jsx("button",{className:"link small",onClick:()=>s({sign:u,q:""}),children:"+ side compound (cofactor)"})]},u)),n.jsx("div",{className:"muted small",children:"Side compounds (ATP, NAD⁺ …) complete the equation without being drawn; the validator checks the atom balance when every formula is known."})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Databases"}),n.jsx(Ae,{label:"EC",children:n.jsx(vt,{list:!0,mono:!0,value:i.ec.join(", "),onCommit:u=>fe.updateReaction(i.id,{ec:So(u)})})}),Sw.map(u=>n.jsx(L_,{ns:u,values:i.identifiers[u]??[],onChange:p=>fe.updateReaction(i.id,{identifiers:{...i.identifiers,[u]:p}})},u)),!!((d=i.hints)!=null&&d.length)&&n.jsxs("div",{className:"muted small",title:"Only used to break ties between model reactions that connect the same metabolites equally well",children:["Tie-break hints: ",n.jsx("span",{className:"mono",children:i.hints.join(", ")})]})]}),!!((f=i.variants)!=null&&f.length)&&n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"section-title",children:["Variants (",i.variants.length,")"]}),n.jsx("div",{className:"muted small",children:"The same step with another cofactor or donor. Not drawn; their EC numbers and identifiers also count when the matcher looks for this step in a model."}),i.variants.map(u=>{var p;return n.jsxs("div",{className:"variant small",children:[n.jsx("b",{children:u.name})," ",n.jsx("span",{className:"mono muted",children:[...u.identifiers["kegg.reaction"]??[],...u.ec.map(m=>`EC ${m}`)].join(" · ")}),u.equation&&n.jsx("div",{className:"mono muted",children:u.equation}),u.note&&n.jsx("div",{className:"muted",children:u.note})]},u.name+(((p=u.identifiers["kegg.reaction"])==null?void 0:p[0])??""))})]})]})}function jE({q:e,setQ:t,onPick:i,onClose:a}){const s=E.useMemo(()=>I_(e).slice(0,6),[e]);return n.jsxs("div",{className:"cof-pick",children:[n.jsxs("div",{className:"row gap",children:[n.jsx("input",{className:"input",autoFocus:!0,placeholder:"ATP, NAD+, CoA, H2O …",value:e,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Escape"&&a(),o.key==="Enter"&&s[0]&&i(s[0])}}),n.jsx("button",{className:"icon-btn",onClick:a,children:"✕"})]}),s.map(o=>n.jsxs("button",{className:"list-item",onClick:()=>i(o),children:[n.jsx("b",{children:o.name})," ",n.jsx("span",{className:"muted small",children:n.jsx(qa,{ids:o.identifiers,max:2})})]},o.library??o.name)),e&&!s.length&&n.jsx("div",{className:"muted small",children:"Not in the GEMsMAP library — draw it as a node and define its identity, then it can be a side compound."})]})}function Ug({f:e,connectorId:t}){const i=e.biology.connectors.find(r=>r.id===t),a=Ft(r=>r.user),s=E.useMemo(()=>Dc(a),[a]);if(!i)return n.jsx("div",{className:"section muted small",children:"Unknown pathway link."});const o=e.biology.metabolites.find(r=>r.id===i.metabolite),l=o&&e.biology.entities.find(r=>r.id===o.entity);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Pathway link (port)"}),n.jsxs("div",{className:"insp-title",children:[i.direction==="in"?"← from":"→"," ",i.target.pathway||"pathway"]}),n.jsx("div",{className:"muted small",children:"A connection to another pathway — not a biological reaction. It is never matched to model reactions."})]}),n.jsxs("div",{className:"section",children:[n.jsx(Ae,{label:"Metabolite",children:n.jsx("b",{children:(l==null?void 0:l.name)??"—"})}),n.jsx(Ae,{label:"Direction",children:n.jsx(Ii,{value:i.direction,options:["out","in"],onChange:r=>fe.updateConnector(i.id,{direction:r}),labels:{out:"→ to",in:"← from"}})}),n.jsx(Ae,{label:"Pathway",children:n.jsx(vt,{value:i.target.pathway,onCommit:r=>fe.updateConnector(i.id,{target:{...i.target,pathway:r.trim()}})})}),n.jsx(Ae,{label:"Template",children:n.jsxs("select",{className:"input",value:i.target.template??"",onChange:r=>{const c=s.find(d=>d.file.metadata.id===r.target.value);fe.updateConnector(i.id,{target:{pathway:(c==null?void 0:c.file.metadata.name)??i.target.pathway,...c?{template:c.file.metadata.id}:{}}})},children:[n.jsx("option",{value:"",children:"— none —"}),s.map(r=>n.jsx("option",{value:r.file.metadata.id,children:r.file.metadata.name},r.file.metadata.id))]})})]})]})}function qg({f:e}){const t=e.metadata,i=E.useMemo(()=>hl(e),[e]),a=new Set(e.biology.metabolites.map(l=>l.compartment).filter(Boolean)),s=[...new Set([...e.biology.compartments.map(l=>l.id),...a])],o=(l,r)=>{const c=e.biology.compartments.some(d=>d.id===l)?e.biology.compartments.map(d=>d.id===l?{...d,fallback:r}:d):[...e.biology.compartments,{id:l,fallback:r}];fe.setCompartments(c)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"insp-head",children:[n.jsx("div",{className:"insp-kind",children:"Template"}),n.jsx("div",{className:"insp-title",children:t.name}),n.jsxs("div",{className:"muted small",children:["v",t.template_version," · schema ",e.schema_version," · ",n.jsx("span",{className:"mono",children:t.id})]})]}),(t.review_status||t.source)&&n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Origin and review"}),t.review_status&&n.jsx(Ae,{label:"Review",children:n.jsxs("span",{className:"row gap wrap",children:[n.jsx($_,{md:t}),t.last_review&&n.jsx("span",{className:"muted small",children:t.last_review})]})}),t.source&&n.jsxs("div",{className:"small",children:[t.source.url?n.jsxs("a",{href:t.source.url,target:"_blank",rel:"noreferrer",children:[t.source.reference," ",t.source.pathway_id," — ",t.source.pathway_name]}):n.jsxs(n.Fragment,{children:[t.source.reference," ",t.source.pathway_id]}),t.source.generated_by&&n.jsxs("div",{className:"muted",children:["Generated by ",t.source.generated_by,t.source.retrieved?` · data retrieved ${t.source.retrieved}`:""]}),t.source.generation_method&&n.jsx("div",{className:"muted",children:t.source.generation_method}),n.jsxs("div",{className:"muted",children:["GEMsMAP's own drawing of the pathway's biology — not an official ",t.source.reference," map."]})]}),t.review_status&&t.review_status!=="human-reviewed"&&n.jsx("button",{className:"btn small",onClick:()=>fe.updateMetadata({review_status:"human-reviewed",last_review:new Date().toISOString().slice(0,10)}),title:"Record that a person has reviewed this template (identities still keep their own statuses)",children:"Mark as reviewed by me"})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Completeness"}),n.jsx(D0,{c:i})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Metadata"}),n.jsx(Ae,{label:"Name",children:n.jsx(vt,{value:t.name,onCommit:l=>fe.updateMetadata({name:l.trim()||t.name})})}),n.jsx(Ae,{label:"Pathway",children:n.jsx(vt,{value:t.pathway,onCommit:l=>fe.updateMetadata({pathway:l})})}),n.jsxs("label",{className:"field col",children:[n.jsx("span",{children:"Description"}),n.jsx("textarea",{className:"input",rows:3,defaultValue:t.description,onBlur:l=>l.target.value!==t.description&&fe.updateMetadata({description:l.target.value})},t.id)]}),n.jsx(Ae,{label:"Version",children:n.jsx(vt,{mono:!0,value:t.template_version,onCommit:l=>fe.updateMetadata({template_version:l.trim()})})}),n.jsx(Ae,{label:"Scope",children:n.jsx("select",{className:"input",value:t.scope.level,onChange:l=>fe.updateMetadata({scope:{...t.scope,level:l.target.value}}),children:Object.keys(eu).map(l=>n.jsx("option",{value:l,children:eu[l]},l))})}),n.jsx(Ae,{label:"Taxa",children:n.jsx(vt,{list:!0,value:t.scope.taxa.join(", "),placeholder:"e.g. Aspergillus oryzae",onCommit:l=>fe.updateMetadata({scope:{...t.scope,taxa:So(l)}})})}),n.jsx(Ae,{label:"Scope note",children:n.jsx(vt,{value:t.scope.note??"",onCommit:l=>fe.updateMetadata({scope:{...t.scope,note:l.trim()||void 0}})})}),n.jsx(Ae,{label:"Authors",children:n.jsx(vt,{list:!0,value:t.authors.join(", "),onCommit:l=>fe.updateMetadata({authors:So(l)})})}),n.jsx(Ae,{label:"License",children:n.jsx(vt,{value:t.license,onCommit:l=>fe.updateMetadata({license:l.trim()})})}),n.jsx(Ae,{label:"Tags",children:n.jsx(vt,{list:!0,value:t.tags.join(", "),onCommit:l=>fe.updateMetadata({tags:So(l)})})}),n.jsx(Ae,{label:"Citations",children:n.jsx(vt,{list:!0,value:t.citations.map(l=>l.doi??l.text).join("; "),placeholder:"DOI or reference; …",onCommit:l=>fe.updateMetadata({citations:l.split(";").map(r=>r.trim()).filter(Boolean).map(r=>/^10\.\d+\//.test(r)?{text:r,doi:r}:{text:r})})})}),t.derived_from&&n.jsxs("div",{className:"muted small",children:["Derived from ",t.derived_from.name," v",t.derived_from.template_version]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Compartments"}),n.jsx("div",{className:"muted small",children:"Conceptual names, never model IDs. The fallback is where the matcher looks in a model without that compartment (e.g. prokaryotes have no mitochondria)."}),s.map(l=>{const r=e.biology.compartments.find(d=>d.id===l),c=(r==null?void 0:r.fallback)??[];return n.jsxs("div",{className:"row gap comp-row",children:[n.jsxs("span",{className:"grow",children:[wi(l),a.has(l)?"":n.jsx("span",{className:"muted",children:" (unused)"})]}),n.jsxs("select",{className:"input tiny",value:c.filter(d=>d!=="intracellular")[0]??"",title:"Fallback compartment",onChange:d=>o(l,[...d.target.value?[d.target.value]:[],"intracellular"]),children:[n.jsx("option",{value:"",children:"fallback: any intracellular"}),rl.filter(d=>d.id!==l).map(d=>n.jsxs("option",{value:d.id,children:["fallback: ",d.label.toLowerCase()]},d.id))]})]},l)})]})]})}function NE(){var i,a,s;const{status:e,offline:t}=rc();return E.useEffect(()=>{q_()},[]),t||!e?null:n.jsxs("div",{className:"bigg-panel small",children:[n.jsx("b",{children:"BiGG data"}),e.available?n.jsxs("span",{className:"muted",children:[(i=e.metabolites)==null?void 0:i.toLocaleString()," universal metabolites · ",(a=e.reactions)==null?void 0:a.toLocaleString()," universal reactions (installed ",(s=e.installed)==null?void 0:s.slice(0,10),") — used offline for identities, reaction stoichiometry and BiGG IDs, so templates match models downloaded from BiGG."]}):n.jsxs("span",{className:"muted",children:["Not installed. Run ",n.jsx("span",{className:"mono",children:"gemsmap bigg-data"})," once in a terminal (or ",n.jsx("span",{className:"mono",children:"gemsmap bigg-data --from <folder>"})," with the metabolite and reaction downloads of bigg.bio/data_access; in a development checkout ",n.jsx("span",{className:"mono",children:"npm run bigg:data"}),") to use the BiGG universal metabolites and reactions when building templates."]})]})}function wE(){const e=Ft(f=>f.user),t=Ft(f=>f.loaded),i=$e(f=>f.recovered),a=R(f=>f.model),[s,o]=E.useState("");E.useEffect(()=>{S1(),s5()},[]);const l=E.useMemo(()=>Dc(e),[e]),r=s.trim().toLowerCase(),c=l.filter(f=>!r||[f.file.metadata.name,f.file.metadata.pathway,...f.file.metadata.tags,f.file.metadata.scope.taxa.join(" ")].join(" ").toLowerCase().includes(r)),d=()=>Ri(k1("New template"),"new");return n.jsxs("div",{className:"tpl-library",children:[n.jsxs("div",{className:"lib-head",children:[n.jsxs("div",{children:[n.jsx("h2",{children:"Template Library"}),n.jsxs("div",{className:"muted",children:["Model-independent pathway templates. A template knows ",n.jsx("b",{children:"what"})," each molecule is; the matcher finds what it is called in a GEM. No model needed to design one."]})]}),n.jsx("span",{className:"grow"}),n.jsxs("div",{className:"search-box lib-search",children:[n.jsx(q,{name:"search",size:14}),n.jsx("input",{placeholder:"Filter templates…",value:s,onChange:f=>o(f.target.value)})]}),n.jsxs("button",{className:"btn",onClick:v0,children:[n.jsx(q,{name:"import",size:14})," Import template"]}),n.jsxs("button",{className:"btn primary",onClick:d,children:[n.jsx(q,{name:"plus",size:14})," New template"]})]}),i&&n.jsxs("div",{className:"notice lib-recover",children:["Unsaved changes to ",n.jsx("b",{children:i.file.metadata.name})," from your last session.",n.jsx("button",{className:"btn small primary",onClick:()=>{Ri(i.file,i.kind,{savedJson:null}),$e.setState({openId:i.openId,recovered:null})},children:"Resume"}),n.jsx("button",{className:"btn small",onClick:o5,children:"Discard"})]}),n.jsx(NE,{}),n.jsx("div",{className:"lib-model muted small",children:a?n.jsxs(n.Fragment,{children:["GEM in the Map Builder: ",n.jsx("b",{children:a.name})," — “Apply” maps a template onto it with the review dialog."]}):"No GEM loaded in the Map Builder — templates can still be designed, validated and exported."}),!t&&n.jsx("div",{className:"muted small pad",children:"Loading your templates…"}),CE(c).map(([f,u])=>n.jsxs("section",{className:"lib-section",children:[n.jsxs("h3",{children:[f," ",n.jsx("span",{className:"muted",children:u.length})]}),n.jsx("div",{className:"lib-grid",children:u.map(p=>n.jsx(kE,{item:p,canApply:!!a},p.file.metadata.id))})]},f))]})}function CE(e){const t=new Map;for(const i of e){const a=i.file.metadata.section||(i.kind==="builtin"?"Built-in":"My templates");t.set(a,[...t.get(a)??[],i])}return[...t].sort((i,a)=>+(i[0]==="My templates")-+(a[0]==="My templates"))}function kE({item:e,canApply:t}){const i=e.file,a=i.metadata,s=E.useMemo(()=>hl(i),[i]),o=new Set(i.layout.nodes.filter(f=>!f.attach).map(f=>f.metabolite)),l=i.biology.metabolites.filter(f=>o.has(f.id)).length,[r,c]=E.useState(!1),d=()=>Ri(i,e.kind);return n.jsxs("div",{className:"lib-card",children:[n.jsx("button",{className:"lib-preview",onClick:d,title:"Open in Template Design Mode",children:n.jsx(S6,{f:i})}),n.jsxs("div",{className:"lib-body",children:[n.jsxs("div",{className:"row gap",children:[n.jsx("b",{className:"lib-name",children:a.name}),n.jsx("span",{className:`tag ${e.kind==="builtin"?"":"on"}`,children:e.kind==="builtin"?"Built-in":"User"})]}),n.jsx("div",{className:"muted small",children:a.pathway}),(a.review_status||a.source)&&n.jsxs("div",{className:"row gap wrap small",children:[n.jsx($_,{md:a}),a.source&&n.jsxs("span",{className:"muted",children:[a.source.url?n.jsxs("a",{href:a.source.url,target:"_blank",rel:"noreferrer",children:[a.source.reference,a.source.pathway_id?` ${a.source.pathway_id}`:""]}):a.source.reference," · own drawing, not an official ",a.source.reference," map"]})]}),n.jsxs("div",{className:"lib-stats small",children:[n.jsxs("span",{title:"Drawn metabolites (side compounds not counted)",children:[l," metabolites"]}),n.jsxs("span",{children:[i.biology.reactions.length," reactions"]}),n.jsxs("span",{title:a.scope.note,children:[eu[a.scope.level],a.scope.taxa.length?` · ${a.scope.taxa.join(", ")}`:""]}),n.jsxs("span",{title:`Metabolites identified ${s.metabolitesIdentified}/${s.metabolites} · reactions ${s.reactionsIdentified}/${s.reactions} · preferred compartments ${s.compartmentsDefined}/${s.metabolites} (optional)`,children:[Math.round(s.overall*100),"% complete"]})]}),n.jsxs("div",{className:"muted small",children:[a.authors.join(", ")||"unknown author"," · v",a.template_version,a.derived_from?` · from ${a.derived_from.name}`:""]}),n.jsxs("div",{className:"row gap wrap lib-actions",children:[n.jsx("button",{className:"btn small primary",onClick:d,children:"Open"}),n.jsx("button",{className:"btn small",onClick:()=>d5(i,`${a.name} — copy`),title:"Make your own editable copy",children:"Duplicate"}),n.jsx("button",{className:"btn small",onClick:()=>_0(i),children:"Export"}),n.jsx("button",{className:"btn small",onClick:()=>h_(a.id),title:t?"Map onto the GEM loaded in the Map Builder (with review)":"Insert into the Map Builder (load a GEM to map it)",children:"Apply to GEM"}),e.kind==="user"&&(r?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn small warn",onClick:()=>qw(a.id),children:"Delete for good"}),n.jsx("button",{className:"btn small",onClick:()=>c(!1),children:"Keep"})]}):n.jsx("button",{className:"icon-btn",title:"Delete template",onClick:()=>c(!0),children:n.jsx(q,{name:"trash",size:13})}))]})]})]})}function ME(e){var s,o;const t=new Map(e.biology.entities.map(l=>[l.id,l])),i=new Set(e.layout.nodes.map(l=>l.metabolite)),a=[];for(const l of e.biology.metabolites){const r=t.get(l.entity);r&&a.push({id:l.id,kind:"metabolite",element:l.label||r.short||r.name,detail:`${wi(l.compartment).toLowerCase()}${i.has(l.id)?"":" · side compound"}`,identity:r.identity.status==="ambiguous"?`${((s=r.identity.candidates)==null?void 0:s.length)??"?"} candidates`:r.identity.status==="unresolved"?"—":r.name,status:r.identity.status,confidence:r.identity.confidence,generic:r.generic,source:r.identity.source,conflict:!!r.identity.conflict,ids:r.identifiers,entityId:r.id})}for(const l of e.biology.reactions)a.push({id:l.id,kind:"reaction",element:l.name,detail:bl(e,l,"short"),identity:l.canonicalName??((o=l.identifiers["kegg.reaction"])==null?void 0:o[0])??(l.ec[0]?`EC ${l.ec[0]}`:"—"),status:l.identity.status,confidence:l.identity.confidence,source:l.identity.source,ids:l.identifiers});return a}const EE={ambiguous:0,unresolved:1,suggested:2,confirmed:3},Vg=e=>EE[e.status]*2+(e.status==="suggested"&&e.confidence==="high"?1:0);function Ao(e,t){const i=R.getState();if(e==="metabolite"){const a=Object.values(i.doc.nodes).find(s=>{var o;return((o=s.design)==null?void 0:o.kind)==="metabolite"&&s.design.id===t});if(a)return i.actions.focusNode(a.id),a.id}else{const a=Object.values(i.doc.reactions).find(s=>{var o;return((o=s.design)==null?void 0:o.kind)==="reaction"&&s.design.id===t});a&&(i.actions.focusNode(a.sources[0]),R.setState({selection:[Ne("reaction",a.id)]}))}}function GE(){const e=R(r=>r.design),[t,i]=E.useState("review"),a=E.useMemo(()=>e?ME(e):[],[e]);if(!e)return null;const s=a.filter(r=>t==="review"?r.status!=="confirmed"||r.conflict:t==="all"?!0:r.kind===t).sort((r,c)=>Vg(r)-Vg(c)||(r.kind<c.kind?-1:1)),o=r=>a.filter(c=>c.status===r).length,l=r=>{const c=Ao(r.kind,r.id);R.setState({dialog:r.kind==="metabolite"?{kind:"identity",nodeId:c,entityId:r.entityId}:{kind:"identity",reactionId:r.id}})};return n.jsxs("aside",{className:"panel right tpl-side",children:[n.jsxs("div",{className:"side-head",children:[n.jsx("b",{children:"Template review"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"icon-btn",onClick:()=>$e.setState({panel:"none"}),title:"Close",children:"✕"})]}),n.jsxs("div",{className:"tm-summary small",children:[n.jsxs("span",{className:"tm-pill ok",children:["✓ ",o("confirmed")]}),n.jsxs("span",{className:"tm-pill warn",children:["? ",o("suggested")]}),n.jsxs("span",{className:"tm-pill warn",children:["⚠ ",o("ambiguous")]}),n.jsxs("span",{className:"tm-pill",children:["○ ",o("unresolved")]})]}),n.jsx("div",{className:"seg small",children:["review","all","metabolite","reaction"].map(r=>n.jsx("button",{className:t===r?"on":"",onClick:()=>i(r),children:r==="review"?"Needs review":r==="all"?"All":r==="metabolite"?"Metabolites":"Reactions"},r))}),n.jsxs("div",{className:"panel-scroll",children:[n.jsxs("table",{className:"rv-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Element"}),n.jsx("th",{children:"Identity"}),n.jsx("th",{children:"Status"})]})}),n.jsx("tbody",{children:s.map(r=>n.jsxs("tr",{onClick:()=>Ao(r.kind,r.id),onDoubleClick:()=>l(r),children:[n.jsxs("td",{children:[n.jsx("b",{children:r.element}),n.jsxs("div",{className:"muted small ellipsis",title:r.detail,children:[r.kind==="reaction"?"Reaction · ":"",r.detail]})]}),n.jsxs("td",{children:[n.jsx("div",{className:"small",children:r.identity}),n.jsx(qa,{ids:r.ids,max:2})]}),n.jsxs("td",{children:[n.jsx(yl,{status:r.status,conflict:r.conflict,confidence:r.confidence,compact:!0}),r.generic&&n.jsxs(n.Fragment,{children:[" ",n.jsx(H_,{})]}),r.status==="suggested"&&r.confidence&&n.jsx("div",{className:"muted small",children:r.confidence}),n.jsx("div",{className:"muted small",children:r.source??""}),n.jsxs("div",{className:"row gap",children:[n.jsx("button",{className:"link small",onClick:c=>{c.stopPropagation(),l(r)},children:"review"}),r.status==="suggested"&&n.jsx("button",{className:"link small",onClick:c=>{c.stopPropagation(),r.kind==="metabolite"?fe.confirmEntity(r.entityId):fe.confirmReaction(r.id)},children:"confirm"})]})]})]},r.kind+r.id))})]}),!s.length&&n.jsx("div",{className:"muted small pad",children:"Nothing to review — every identity is confirmed."})]})]})}const SE={error:"✕",warning:"⚠",info:"i"};function AE(){const e=R(c=>c.design),t=R(c=>c.doc),[i,a]=E.useState(!1),s=E.useMemo(()=>e?qc(Jp(e,t)):[],[e,t]);if(!e)return null;const o=Vc(s),l=s.filter(c=>i||c.severity!=="info"),r=c=>{const d=c.element;if(d){if(d.kind==="reaction")Ao("reaction",d.id);else if(d.kind==="metabolite")Ao("metabolite",d.id);else if(d.kind==="entity"){const f=e.biology.metabolites.find(u=>u.entity===d.id);f&&Ao("metabolite",f.id)}else if(d.kind==="connector"){const f=Object.values(R.getState().doc.nodes).find(u=>{var p;return((p=u.design)==null?void 0:p.kind)==="port"&&u.design.id===d.id});f&&R.getState().actions.focusNode(f.id)}}};return n.jsxs("aside",{className:"panel right tpl-side",children:[n.jsxs("div",{className:"side-head",children:[n.jsx("b",{children:"Validation"}),n.jsx("span",{className:"grow"}),n.jsx("button",{className:"icon-btn",onClick:()=>$e.setState({panel:"none"}),title:"Close",children:"✕"})]}),n.jsxs("div",{className:"tm-summary small",children:[n.jsxs("span",{className:`tm-pill ${o.errors?"bad":"ok"}`,children:[o.errors," errors"]}),n.jsxs("span",{className:"tm-pill warn",children:[o.warnings," warnings"]}),n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:c=>a(c.target.checked)})," ",o.infos," notes"]})]}),n.jsxs("div",{className:"panel-scroll",children:[!l.length&&n.jsx("div",{className:"muted small pad",children:o.errors+o.warnings?"":"No problems found."}),l.map((c,d)=>n.jsxs("button",{className:`issue-row ${c.severity}`,onClick:()=>r(c),title:c.code,children:[n.jsx("span",{className:"sev",children:SE[c.severity]}),n.jsx("span",{children:c.message})]},d))]})]})}function DE(){const e=$e(i=>i.view),t=R(i=>!!i.design);return n.jsxs(n.Fragment,{children:[e==="designer"&&t?n.jsx(RE,{}):n.jsx("div",{className:"main",children:n.jsx(wE,{})}),n.jsx(BE,{})]})}const PE=[{id:"select",icon:"select",label:"Select",key:"V"},{id:"pan",icon:"pan",label:"Pan",key:"C"},{id:"metabolite",icon:"metabolite",label:"Metabolite",key:"M"},{id:"reaction",icon:"reaction",label:"Reaction",key:"R"},{id:"text",icon:"text",label:"Label",key:"T"}];function RE(){const e=$e(t=>t.panel);return n.jsxs("div",{className:"main tpl-design",children:[n.jsx(Rn,{name:"Template palette",children:n.jsx(IE,{})}),n.jsxs("div",{className:"center",children:[n.jsxs("div",{className:"design-banner ui-only",children:[n.jsx("b",{children:"Template Design Mode"})," · nodes are ",n.jsx("b",{children:"template entities"})," (biological identities), not model metabolites · double-click a node to define what it is"]}),n.jsx(Rn,{name:"Canvas",children:n.jsx(j_,{})}),n.jsx(N_,{})]}),e==="review"&&n.jsx(Rn,{name:"Review",children:n.jsx(GE,{})}),e==="issues"&&n.jsx(Rn,{name:"Validation",children:n.jsx(AE,{})}),n.jsx(Rn,{name:"Inspector",children:n.jsx(gE,{})})]})}const Wg=()=>{const e=R.getState();return{x:(e.viewport.w/2-e.camera.x)/e.camera.k,y:(e.viewport.h/3-e.camera.y)/e.camera.k}};function IE(){var H;const e=Kn("tpl-left",264,210,520),t=pl("template-left"),i=R(G=>G.tool),a=R(G=>G.design),s=R(G=>G.doc),o=R(G=>G.selection),l=$e(G=>G.kind),r=$e(G=>G.openId),c=$e(G=>G.savedJson),[d,f]=E.useState(null),[u,p]=E.useState(!1),[m,h]=E.useState(null),g=rc(G=>G.status);E.useEffect(()=>{q_()},[]);const y=async()=>{h("running");try{const G=await fE(Ln());if(!G.available){h("BiGG data not installed — run gemsmap bigg-data once");return}h(fe.applyBiggIds(G))}catch(G){h(`BiGG IDs unavailable: ${G.message} (start the backend)`)}},b=E.useMemo(()=>Jp(a,s),[a,s]),_=E.useMemo(()=>Vc(qc(b)),[b]),x=E.useMemo(()=>hl(b),[b]),v=E.useMemo(()=>fr(),[a,s,c]),j=a.biology.entities.filter(G=>G.identity.status!=="confirmed"||G.identity.conflict).length+a.biology.reactions.filter(G=>G.identity.status!=="confirmed").length,N=o.length===1&&o[0].startsWith("node:")?s.nodes[o[0].slice(5)]:void 0;Ft(G=>G.user);const C=R(G=>G.leftOpen),w=async()=>{f("running");const G=await fe.autoIdentify(j6);f(G),G&&($e.setState({panel:"review"}),V().toast(`Auto Identify: ${G.resolved} suggested · ${G.review} need review · ${G.unresolved} unresolved${G.conflicts?` · ${G.conflicts} potential conflicts`:""}`))},k=()=>fr()?p(!0):Kd(),P=()=>{(fr()||!r)&&!Co()||h_($e.getState().openId??a.metadata.id)};return C?n.jsxs("aside",{className:"panel left tpl-left",style:{width:e.css},children:[n.jsx(zn,{panel:e,edge:"right"}),n.jsx(Fc,{api:t}),n.jsxs("div",{className:"panel-scroll",ref:t.ref,children:[n.jsxs("div",{className:"section",children:[n.jsxs("div",{className:"row gap",children:[n.jsx("b",{className:"grow ellipsis",title:a.metadata.name,children:a.metadata.name}),n.jsx("span",{className:"tag",children:l==="builtin"?"Built-in · read-only":l==="imported"?"Imported · not saved":l==="new"?"New · not saved":"My template"})]}),n.jsxs("div",{className:"muted small",children:["v",a.metadata.template_version,v?" · unsaved changes":" · saved"]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Tools"}),n.jsx("div",{className:"tool-grid",children:PE.map(G=>n.jsxs("button",{className:`tool ${i===G.id?"on":""}`,title:`${G.label} (${G.key})`,onClick:()=>R.setState({tool:G.id}),children:[n.jsx(q,{name:G.icon,size:17}),n.jsx("span",{children:G.label}),n.jsx("kbd",{children:G.key})]},G.id))}),n.jsx("div",{className:"muted small",children:"Double-click empty space: new metabolite · drag from a node's ring: new reaction · drop on empty space: extend the chain"})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Add"}),n.jsxs("div",{className:"row wrap gap",children:[n.jsx("button",{className:"btn small",onClick:()=>fe.addMetaboliteAt(Wg()),children:"+ Metabolite"}),n.jsx("button",{className:"btn small",onClick:()=>V().addText(Wg(),{text:"Label",size:11,weight:600,italic:!0}),children:"+ Label"}),n.jsx("button",{className:"btn small",onClick:()=>V().groupSelection("pathway","Pathway module"),children:"Group as module"}),n.jsx("button",{className:"btn small",onClick:()=>V().groupSelection("compartment","Mitochondria"),children:"Compartment box"})]}),n.jsx("div",{className:"muted small",children:((H=N==null?void 0:N.design)==null?void 0:H.kind)==="metabolite"?"Pathway link: see the Inspector → “+ Pathway link”.":"Pathway links (ports to other pathways) start from a selected metabolite."})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Identity"}),n.jsx("button",{className:"btn block",onClick:w,disabled:d==="running",title:"Search the GEMsMAP library (and KEGG / ChEBI / MetaNetX when the backend runs) for every entity that is not confirmed. Confirmed identities are never changed.",children:d==="running"?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner sm"})," Identifying…"]}):n.jsxs(n.Fragment,{children:[n.jsx(q,{name:"sparkle",size:14})," Auto Identify"]})}),d&&d!=="running"&&n.jsxs("div",{className:"small auto-sum",children:[n.jsxs("div",{children:["Automatically resolved (suggested): ",n.jsx("b",{children:d.resolved})]}),n.jsxs("div",{children:["Needs review: ",n.jsx("b",{children:d.review+d.conflicts})]}),n.jsxs("div",{children:["Unresolved: ",n.jsx("b",{children:d.unresolved})]}),n.jsxs("div",{className:"muted",children:["Confirmed and kept: ",d.keptConfirmed]})]}),n.jsx("button",{className:"btn block",onClick:y,disabled:m==="running"||(g==null?void 0:g.available)===!1,title:(g==null?void 0:g.available)===!1?"Install the BiGG data first: gemsmap bigg-data":"Add BiGG universal IDs (and BiGG cross-references) where exactly one BiGG metabolite / reaction fits — templates then match models downloaded from BiGG by their own IDs",children:m==="running"?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"spinner sm"})," Looking up BiGG…"]}):"Add BiGG IDs"}),typeof m=="string"&&m!=="running"&&n.jsx("div",{className:"tm-note small",children:m}),m&&typeof m=="object"&&n.jsxs("div",{className:"small auto-sum",children:[n.jsxs("div",{children:["Metabolites: ",n.jsx("b",{children:m.entities.added})," added · ",m.entities.known," already had it · ",m.entities.none," not in BiGG"]}),n.jsxs("div",{children:["Reactions: ",n.jsx("b",{children:m.reactions.added})," added · ",m.reactions.known," already had it · ",m.reactions.none," no clear match"]}),[...m.entities.review,...m.reactions.review].length>0&&n.jsxs("div",{className:"muted",children:["Several BiGG candidates (choose in the identity search): ",[...m.entities.review,...m.reactions.review].join("; ")]})]}),n.jsxs("button",{className:"btn block",onClick:()=>$e.setState({panel:"review"}),children:["Review queue ",j?n.jsx("span",{className:"tag warn",children:j}):n.jsx("span",{className:"tag on",children:"all confirmed"})]}),n.jsxs("button",{className:"btn block",onClick:()=>$e.setState({panel:"issues"}),children:["Validate template ",_.errors?n.jsxs("span",{className:"tag warn",children:[_.errors," errors"]}):null,_.warnings?n.jsxs("span",{className:"tag",children:[_.warnings," warnings"]}):null,!_.errors&&!_.warnings?n.jsx("span",{className:"tag on",children:"no problems"}):null]})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Completeness"}),n.jsx(D0,{c:x})]}),n.jsxs("div",{className:"section",children:[n.jsx("div",{className:"section-title",children:"Template"}),n.jsx("button",{className:"btn primary block",onClick:Co,title:"Ctrl S",children:l==="builtin"?"Save as my version":"Save"}),n.jsx("button",{className:"btn block",onClick:()=>{const G=dl(Vp(Ln()));Ri(G,"user"),V().toast(`Duplicated as “${G.metadata.name}”`)},children:"Duplicate"}),n.jsxs("button",{className:"btn block",onClick:()=>_0(Ln()),children:[n.jsx(q,{name:"export",size:13})," Export (.gemsmap-template.json)"]}),n.jsx("button",{className:"btn block",onClick:P,title:"Save, then map onto the GEM loaded in the Map Builder (review dialog)",children:"Apply to GEM…"}),n.jsx("button",{className:"btn block",onClick:k,children:"Close"})]})]}),u&&n.jsxs(an,{title:"Unsaved changes",onClose:()=>p(!1),width:420,children:[n.jsxs("div",{children:["Save the changes to “",a.metadata.name,"” before closing?"]}),n.jsxs("div",{className:"row gap end",children:[n.jsx("button",{className:"btn",onClick:()=>{p(!1),Kd()},children:"Discard"}),n.jsx("button",{className:"btn",onClick:()=>p(!1),children:"Cancel"}),n.jsx("button",{className:"btn primary",onClick:()=>{Co()&&(p(!1),Kd())},children:l==="builtin"?"Save as my version":"Save"})]})]})]}):null}function BE(){const e=$e(p=>p.importing),t=Ft(p=>p.user),[i,a]=E.useState(!1),s=E.useMemo(()=>e?qc(e.file):[],[e]);if(!e)return null;const o=e.file,l=Vc(s),r=hl(o),c=t.find(p=>p.metadata.id===o.metadata.id),d=new Map;for(const p of o.biology.entities)p.identity.status==="confirmed"&&d.set(p.identity.source??"unknown",(d.get(p.identity.source??"unknown")??0)+1);const f=()=>{$e.setState({importing:null}),a(!1)},u=()=>i?HE(o):o;return n.jsxs(an,{title:`Import template — ${e.fileName}`,onClose:f,width:600,children:[n.jsxs("div",{children:[n.jsx("b",{children:o.metadata.name})," v",o.metadata.template_version," · ",o.metadata.authors.join(", ")||"unknown author"," · schema ",o.schema_version]}),n.jsx("div",{className:"muted small",children:o.metadata.description}),n.jsxs("div",{className:"tm-summary small",children:[n.jsxs("span",{className:`tm-pill ${l.errors?"bad":"ok"}`,children:[l.errors," errors"]}),n.jsxs("span",{className:"tm-pill warn",children:[l.warnings," warnings"]}),n.jsxs("span",{className:"tm-pill",children:[o.layout.nodes.length," nodes · ",o.biology.reactions.length," reactions"]})]}),n.jsx(D0,{c:r}),e.warnings.map(p=>n.jsx("div",{className:"tm-note small",children:p},p)),s.filter(p=>p.severity!=="info").slice(0,8).map((p,m)=>n.jsxs("div",{className:`issue-row ${p.severity}`,children:[n.jsx("span",{className:"sev",children:p.severity==="error"?"✕":"⚠"}),n.jsx("span",{children:p.message})]},m)),s.filter(p=>p.severity!=="info").length>8&&n.jsx("div",{className:"muted small",children:"… and more in the validation panel after opening."}),n.jsxs("div",{className:"small",children:["Confirmed identities in this file: ",[...d.entries()].map(([p,m])=>`${m} by ${p}`).join(", ")||"none",". They were confirmed by the file's author, not by you."]}),n.jsxs("label",{className:"check small",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:p=>a(p.target.checked)})," Treat every identity as a suggestion and review it myself"]}),n.jsxs("div",{className:"row gap end",children:[n.jsx("button",{className:"btn",onClick:f,children:"Cancel"}),c&&n.jsxs("button",{className:"btn",onClick:()=>{Ng(u()),f()},title:"Overwrite your template with the same id",children:["Replace “",c.metadata.name,"”"]}),n.jsx("button",{className:"btn",onClick:()=>{Ng(c?jg(u()):u()),f()},children:c?"Save as a new template":"Save to library"}),n.jsx("button",{className:"btn primary",onClick:()=>{const p=c?jg(u()):u();f(),Ri(p,"imported"),(l.errors||l.warnings)&&$e.setState({panel:"issues"})},children:"Open and review"})]})]})}const HE=e=>({...e,biology:{...e.biology,entities:e.biology.entities.map(t=>t.identity.status==="confirmed"?{...t,identity:{...t.identity,status:"suggested",source:"imported"}}:t),reactions:e.biology.reactions.map(t=>t.identity.status==="confirmed"?{...t,identity:{...t.identity,status:"suggested",source:"imported"}}:t)}});function OE(){const e=R(a=>a.toast),[t,i]=E.useState(!1);return E.useEffect(()=>{if(!e)return;i(!0);const a=setTimeout(()=>i(!1),4200);return()=>clearTimeout(a)},[e]),!e||!t?null:n.jsx("div",{className:"toast",children:e.text},e.id)}const $E=/\.(xml|sbml|mat)$/i;async function LE(e){const t=e.name.toLowerCase();if($E.test(t))return B.importFile(e);if(/\.(csv|tsv|txt)$/.test(t))return B.importResults([e]);if(t.endsWith(".json")){const i=await e.slice(0,4e3).text();if(pu(i))return B.importResults([e]);if(!d1(i))return B.importFile(e)}c0(e)}const Yg=e=>{var t;return Array.from(((t=e.dataTransfer)==null?void 0:t.types)??[]).includes("Files")};function TE(){const[e,t]=E.useState(!1),i=E.useRef(void 0);E.useEffect(()=>{if(!e)return;const l=()=>{window.clearTimeout(i.current),t(!1)},r=d=>{d.key==="Escape"&&l()},c=["dragend","drop","blur","pointerdown","mousemove"];return c.forEach(d=>window.addEventListener(d,l)),window.addEventListener("keydown",r),()=>{c.forEach(d=>window.removeEventListener(d,l)),window.removeEventListener("keydown",r)}},[e]);const a=S(l=>l.workspace),s=a==="lab",o=a==="templates";return n.jsxs("div",{className:"app",onDragOver:l=>{Yg(l)&&(l.preventDefault(),t(!0),window.clearTimeout(i.current),i.current=window.setTimeout(()=>t(!1),400))},onDragLeave:l=>{(!l.relatedTarget||l.currentTarget===l.target)&&t(!1)},onDrop:l=>{if(Yg(l)){l.preventDefault(),t(!1);for(const r of Array.from(l.dataTransfer.files))s?LE(r):o?r.text().then(c=>p_(r.name,c)):c0(r)}},children:[n.jsx(m5,{}),s?n.jsx(Rn,{name:"COBRAGUI",children:n.jsx(X4,{})}):o?n.jsx(Rn,{name:"Template Builder",children:n.jsx(DE,{})}):n.jsxs("div",{className:"main",children:[n.jsx(Rn,{name:"Left panel",children:n.jsx(rE,{})}),n.jsxs("div",{className:"center",children:[n.jsx(Rn,{name:"Canvas",children:n.jsx(j_,{})}),n.jsx(N_,{})]}),n.jsx(Rn,{name:"Inspector",children:n.jsx(Y6,{})})]}),s?n.jsx(V4,{}):o?null:n.jsx(u5,{}),n.jsx(Rn,{name:"Dialog",children:n.jsx(B6,{})}),n.jsx(U5,{}),n.jsx(OE,{}),n.jsx(X3,{}),e&&n.jsx("div",{className:"drop-overlay",children:s?"Drop a model (SBML · COBRA JSON · MAT) — or result files (JSON · CSV · TSV) to add them to Results":o?"Drop a template (.gemsmap-template.json) to import it":"Drop a GEM (.json/.xml), a data table (.csv/.tsv) or a project (.gemsmap)"})]})}const FE=["overview","explore","medium","simulate","results","compare"];function XE(e){const t=S.getState(),i=e.ctrlKey||e.metaKey,a=e.key.toLowerCase();if(e.altKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight")){e.preventDefault(),e.key==="ArrowLeft"?B.back():B.forward();return}if(e.altKey&&/^Digit[1-6]$/.test(e.code)){e.preventDefault(),B.setSection(FE[+e.code.slice(5)-1]);return}if(i){a==="z"&&e.shiftKey?(e.preventDefault(),B.redo()):a==="z"||a==="y"?(e.preventDefault(),a==="y"?B.redo():B.undo()):a==="enter"?(e.preventDefault(),B.simulate(t.method)):a==="s"&&(e.preventDefault(),V().toast("COBRAGUI sessions (states, results, favorites) are saved automatically"));return}if(t.model){switch(e.key){case"/":e.preventDefault(),R.setState({paletteOpen:!0});return;case"Escape":S.setState({contextMenu:null}),B.clearSelection();return}switch(a){case"f":e.preventDefault(),t.section!=="explore"&&B.setSection("explore"),setTimeout(()=>{var s;return(s=document.getElementById("lab-explorer-search"))==null?void 0:s.focus()},20);break;case"r":B.setTab("reactions");break;case"m":B.setTab("metabolites");break;case"g":B.setTab("genes");break;case"i":S.setState({inspectorOpen:!t.inspectorOpen});break}}}const KE={Equal:1,NumpadAdd:1,Minus:-1,NumpadSubtract:-1,Digit0:0,Numpad0:0},zE={"=":1,"+":1,"-":-1,0:0};function UE(){window.addEventListener("keydown",e=>{const t=e.target;if(t instanceof Element&&t.closest("input, textarea, select, [contenteditable]")||e.code==="Space")return;const i=R.getState(),a=i.actions,s=e.ctrlKey||e.metaKey,o=e.key.toLowerCase();if(s&&o==="k"){e.preventDefault(),R.setState({paletteOpen:!i.paletteOpen});return}const l=s&&e.altKey?KE[e.code]??zE[e.key]:void 0;if(l!==void 0){e.preventDefault(),l===0?$c(1):tl(l);return}if(i.dialog||i.paletteOpen)return;if(S.getState().workspace==="lab"){XE(e);return}if(S.getState().workspace==="templates"){if(!i.design)return;if(s&&(o==="s"||o==="o"||o==="e")){e.preventDefault(),o==="s"?Co():o==="o"?v0():f_();return}if(e.altKey&&!s)return}if(e.altKey&&!s&&/^Digit[123]$/.test(e.code)){e.preventDefault(),R.setState({leftOpen:!0,leftTab:["elements","model","data"][+e.code.slice(5)-1]});return}if(s){o==="z"&&e.shiftKey?(e.preventDefault(),a.redo()):o==="z"?(e.preventDefault(),a.undo()):o==="y"?(e.preventDefault(),a.redo()):o==="c"?a.copy():o==="v"?a.paste():o==="d"?(e.preventDefault(),a.duplicate()):o==="a"?(e.preventDefault(),a.selectAll()):o==="g"&&e.shiftKey?(e.preventDefault(),a.ungroup()):o==="g"?(e.preventDefault(),a.groupSelection("pathway")):o==="s"?(e.preventDefault(),Bc(),a.toast("Project saved")):o==="o"?(e.preventDefault(),$n("project")):o==="e"&&(e.preventDefault(),R.setState({dialog:{kind:"export"}}));return}const r=e.shiftKey?10:1;switch(e.key){case"Delete":case"Backspace":a.deleteSelection();break;case"Escape":if(R.getState().placing){a.cancelPlacing();break}R.setState({selection:[],tool:"select",contextMenu:null});break;case"ArrowLeft":e.preventDefault(),a.nudge(-r,0);break;case"ArrowRight":e.preventDefault(),a.nudge(r,0);break;case"ArrowUp":e.preventDefault(),a.nudge(0,-r);break;case"ArrowDown":e.preventDefault(),a.nudge(0,r);break;case"[":a.stepCondition(-1);break;case"]":a.stepCondition(1);break;case"?":R.setState({dialog:{kind:"help"}});break;default:switch(o){case"v":R.setState({tool:"select"});break;case"m":R.setState({tool:"metabolite"});break;case"s":R.setState({tool:"slot"});break;case"r":R.setState({tool:"reaction"});break;case"t":R.setState({tool:"text"});break;case"c":R.setState({tool:"pan"});break;case"p":i.design||a.addPlotsForSelection("density");break;case"l":a.toggleLock();break;case"f":e.shiftKey?a.fitSelection():a.fitAll();break;case"=":case"+":a.zoomBy(1.2);break;case"-":a.zoomBy(1/1.2);break}}})}const Jd=[{below:1e3,isOpen:()=>R.getState().rightOpen,setOpen:e=>R.setState({rightOpen:e})},{below:760,isOpen:()=>R.getState().leftOpen,setOpen:e=>R.setState({leftOpen:e})},{below:1150,isOpen:()=>S.getState().inspectorOpen,setOpen:e=>S.setState({inspectorOpen:e})}];function qE(){const e=Jd.map(()=>!1),t=Jd.map(()=>!1);let i=!1;const a=s=>{let o=!1;Jd.forEach((l,r)=>{const c=s<l.below;c&&!e[r]&&l.isOpen()&&(l.setOpen(!1),t[r]=!0,o=!0),!c&&e[r]&&(t[r]&&!l.isOpen()&&l.setOpen(!0),t[r]=!1),e[r]=c}),o&&!i&&(i=!0,R.getState().actions.toast("Small window: side panels hidden to make room — reopen them with the panel buttons, or make the interface smaller (File → Interface size)"))};a(Fn.getState().vw),Fn.subscribe((s,o)=>{s.vw!==o.vw&&a(s.vw)})}U3();async function VE(){await Fu,await S1(),R.getState().actions.loadProject(Yo()),nx(),UE(),B.boot(),qE(),Rp(document.getElementById("root")).render(n.jsx(TE,{}))}VE().catch(e=>{console.error("GEMsMAP failed to start",e)});
|